public override void LoadContent() { _content = BlackBoard.GetEntry <ContentManager>("ContentManager"); _graphicsDevice = BlackBoard.GetEntry <GraphicsDevice>("GraphicsDevice"); _camera = BlackBoard.GetEntry <CameraComponent>("Camera"); _map = BlackBoard.GetEntry <Map>("Map"); _texture = _content.Load <Texture2D>("Images/OryxEnv"); _effect = new BasicEffect(_graphicsDevice); _effect.TextureEnabled = true; _effect.Texture = _texture; _quads = new List <QuadShape>(); for (int z = 0; z < _map.Height; z++) { for (int x = 0; x < _map.Width; x++) { Vector3 quadOrigin = new Vector3(x, 0, z); TextureFrame textureFrame = new TextureFrame(0.375f, 0, 0.0625f, 0.0625f); QuadShape quad = new QuadShape(quadOrigin, Vector3.Up, Vector3.Forward, textureFrame); _quads.Add(quad); } } }
public static void Render(ContentManager content, GraphicsDevice graphicsDevice, TransformComponent transform, CameraComponent camera, BasicEffect effect) { if (_quad == null) { _texture = content.Load <Texture2D>("Images/OryxChar"); TextureFrame textureFrame = new TextureFrame(0.292f, 0.031f, 0.042f, 0.031f); Vector3 normal = camera.Rotation.Forward * -1; Vector3 up = camera.Rotation.Up; _quad = new QuadShape(transform.Position, normal, up, textureFrame, 0.5f, 0.5f); } _quad.Origin = transform.Position + new Vector3(0, _quad.Height / 2.0f, 0); _quad.UpdateVertexData(); effect.Texture = _texture; graphicsDevice.DrawUserIndexedPrimitives <VertexPositionNormalTexture>(PrimitiveType.TriangleList, _quad.Vertices, 0, 4, _quad.Indexes, 0, 2); }
void Start() { qs = new QuadShape(); rs = new RectShape(); ts = new TriangleShape(); }