public void Draw(Camera camera) { GameObject.device.SetVertexBuffer(cubeBuffer); cubeEffect.World = worldTranslation; cubeEffect.View = camera.view; cubeEffect.Projection = camera.projection; cubeEffect.DiffuseColor = color.ToVector3(); //cubeEffect.DiffuseColor = Color.Red.ToVector3(); cubeEffect.TextureEnabled = true; cubeEffect.Texture = texture; foreach (EffectPass pass in cubeEffect.CurrentTechnique.Passes) { pass.Apply(); GameObject.device.DrawUserPrimitives<VertexPositionColorTexture>(PrimitiveType.TriangleStrip, cubeFront, 0, 2); } }
public void Draw(Camera camera, Matrix matWorld) { GameObject.device.SetVertexBuffer(cubeBuffer); Matrix rotMatrix = Matrix.CreateRotationY(rotOffset); this.worldTranslation = rotMatrix * matWorld; cubeEffect.World = worldTranslation; cubeEffect.View = camera.view; cubeEffect.Projection = camera.projection; // Render background of Square cubeEffect.DiffuseColor = color.ToVector3(); cubeEffect.TextureEnabled = true; cubeEffect.Texture = cubeTex; cubeEffect.DiffuseColor = backColor.ToVector3(); foreach (EffectPass pass in cubeEffect.CurrentTechnique.Passes) { pass.Apply(); GameObject.device.DrawUserPrimitives<VertexPositionColorTexture>(PrimitiveType.TriangleStrip, cubeFront, 0, 2); } // Render foreground of Square with shape cubeEffect.DiffuseColor = color.ToVector3(); cubeEffect.TextureEnabled = true; cubeEffect.Texture = texture; foreach (EffectPass pass in cubeEffect.CurrentTechnique.Passes) { pass.Apply(); GameObject.device.DrawUserPrimitives<VertexPositionColorTexture>(PrimitiveType.TriangleStrip, cubeFront, 0, 2); } }