コード例 #1
0
        public void Draw()
        {
            Particle tmpParticle;
            float    CurrTime;
            float    TimeDiff;

            if (this.Particles.Count < 1)
            {
                NeedsDelete = true;
            }
            CurrTime = DXUtil.Timer(DirectXTimer.GetApplicationTime);
            TimeDiff = CurrTime - LastUpdateTime;
            for (int i = 0; i < Particles.Count; i++)
            {
                tmpParticle = (Particle)Particles[i];
                tmpParticle.Velocities.Y -= tmpParticle.Gravity * TimeDiff;
                tmpParticle.Positions.X  += tmpParticle.Velocities.X * TimeDiff;
                tmpParticle.Positions.Y  += tmpParticle.Velocities.Y * TimeDiff;
                tmpParticle.Positions.Z  += tmpParticle.Velocities.Z * TimeDiff;

                if (CurrTime - tmpParticle.TimeCreated <= 1.5f)
                {
                    tmpParticle.Height = 1.5f * (1.5f - (CurrTime - tmpParticle.TimeCreated));
                    tmpParticle.Width  = 1.5f * (1.5f - (CurrTime - tmpParticle.TimeCreated));
                    tmpParticle.GenerateVerticies();
                }

                this.CurrDevice.Transform.World = DirectX.Matrix.RotationYawPitchRoll(0, 0, 0) * DirectX.Matrix.Translation(tmpParticle.Positions.X, tmpParticle.Positions.Y, tmpParticle.Positions.Z) * SpaceAndTime.ScaleStandard;
                this.CurrDevice.SetTexture(0, ExplosionTexture);
                CurrDevice.DrawUserPrimitives(Direct3D.PrimitiveType.TriangleStrip, 2, tmpParticle.Verticies);
                if (tmpParticle.Positions.Y < -2.0f)
                {
                    this.Particles.Remove(tmpParticle);
                }
            }
            if (CurrTime - ExplosionFlash.TimeCreated <= .25)
            {
                ExplosionFlash.Height = 256 * (CurrTime - ExplosionFlash.TimeCreated);
                ExplosionFlash.Width  = 256 * (CurrTime - ExplosionFlash.TimeCreated);
                ExplosionFlash.GenerateVerticies();
            }
            else
            {
                ExplosionFlash.Height = 0.0f;
                ExplosionFlash.Width  = 0.0f;
                ExplosionFlash.GenerateVerticies();
            }
            this.CurrDevice.Transform.World = DirectX.Matrix.RotationYawPitchRoll(0, 0, 0) * DirectX.Matrix.Translation(ExplosionFlash.Positions.X, ExplosionFlash.Positions.Y, ExplosionFlash.Positions.Z) * SpaceAndTime.ScaleStandard;
            this.CurrDevice.SetTexture(0, LightTexture);
            CurrDevice.DrawUserPrimitives(Direct3D.PrimitiveType.TriangleStrip, 2, ExplosionFlash.Verticies);
            this.LastUpdateTime = DXUtil.Timer(DirectXTimer.GetApplicationTime);
        }
コード例 #2
0
        public void Draw(Microsoft.DirectX.Direct3D.Device device, PrimitiveType type)
        {
            if (index > 0)
            {
                int primCount = 0;
                switch (type)
                {
                case PrimitiveType.LineList:
                    primCount = index / 2;
                    break;

                case PrimitiveType.LineStrip:
                    primCount = index - 1;
                    break;

                case PrimitiveType.PointList:
                    primCount = index;
                    break;

                case PrimitiveType.TriangleStrip:
                case PrimitiveType.TriangleFan:
                    primCount = index - 2;
                    break;

                case PrimitiveType.TriangleList:
                    primCount = index / 3;
                    break;
                }
                device.DrawUserPrimitives(type, primCount, vertices);
            }
        }
コード例 #3
0
ファイル: DX2D.cs プロジェクト: Deleeete/Gleee
            /// <summary>
            /// 在场景中加入空心矩形
            /// </summary>
            /// <param name="x">左上顶点的x坐标</param>
            /// <param name="y">左上顶点的y坐标</param>
            /// <param name="width">矩形的横向长度(的绝对值)</param>
            /// <param name="height">矩形的纵向长度(的绝对值)</param>
            /// <param name="color">矩形的颜色</param>
            public static void ImportEmptyRect(float x, float y, float width, float height, Color color)
            {
                CustomVertex.TransformedColored[] vertices = new CustomVertex.TransformedColored[8];
                Vector4 a = new Vector4(x, y, 0, 1);
                Vector4 b = new Vector4(x + Math.Abs(width), y, 0, 1);
                Vector4 c = new Vector4(x + Math.Abs(width), y + Math.Abs(height), 0, 1);
                Vector4 d = new Vector4(x, y + Math.Abs(height), 0, 1);

                vertices[0].Position = a;
                vertices[0].Color    = color.ToArgb();
                vertices[1].Position = b;
                vertices[1].Color    = color.ToArgb();

                vertices[2]          = vertices[1];
                vertices[3].Position = c;
                vertices[3].Color    = color.ToArgb();

                vertices[4]          = vertices[3];
                vertices[5].Position = d;
                vertices[5].Color    = color.ToArgb();

                vertices[6]         = vertices[5];
                vertices[6].Color   = color.ToArgb();
                vertices[7]         = vertices[0];
                Device.VertexFormat = CustomVertex.TransformedColored.Format;
                Device.DrawUserPrimitives(PrimitiveType.LineList, 4, vertices);
            }
コード例 #4
0
 public void Render()
 {
     device.Clear(ClearFlags.Target, Color.DarkSlateGray, 1, 0);
     device.BeginScene();
     device.VertexFormat = CustomVertex.PositionNormalColored.Format;
     device.DrawUserPrimitives(PrimitiveType.TriangleList, vertex.Length / 3, vertex);
     device.EndScene();
     device.Present();
 }
コード例 #5
0
ファイル: Form1.cs プロジェクト: jaisal1311/GP
 private void Form1_Paint(object sender, PaintEventArgs e)
 {
     device.Clear(ClearFlags.Target, Color.Chartreuse, 1, 0);
     device.BeginScene();
     device.SetTexture(0, texture);
     device.VertexFormat = CustomVertex.PositionTextured.Format;
     device.DrawUserPrimitives(PrimitiveType.TriangleList, vertex.Length / 3, vertex);
     device.EndScene();
     device.Present();
 }
コード例 #6
0
ファイル: DX2D.cs プロジェクト: Deleeete/Gleee
            /// <summary>
            /// 在场景中加入点
            /// </summary>
            /// <param name="x">点的x坐标</param>
            /// <param name="y">点的y坐标</param>
            /// <param name="color">点的颜色</param>
            public static void ImportPoint(float x, float y, Color color)
            {
                CustomVertex.TransformedColored[] vertices = new CustomVertex.TransformedColored[1];
                Vector4 p = new Vector4(x, y, 0, 1);

                vertices[0].Position = p;
                vertices[0].Color    = color.ToArgb();
                Device.VertexFormat  = CustomVertex.TransformedColored.Format;
                Device.DrawUserPrimitives(PrimitiveType.PointList, 1, vertices);
            }
コード例 #7
0
ファイル: DX2D.cs プロジェクト: Deleeete/Gleee
            /// <summary>
            /// 在场景中加入渐变直线
            /// </summary>
            /// <param name="x1">端点1的x坐标</param>
            /// <param name="y1">端点1的y坐标</param>
            /// <param name="x2">端点2的x坐标</param>
            /// <param name="y2">端点2的y坐标</param>
            /// <param name="color1">端点1的颜色</param>
            /// <param name="color2">端点2的颜色</param>
            public static void ImportLine(float x1, float y1, float x2, float y2, Color color1, Color color2)
            {
                CustomVertex.TransformedColored[] vertices = new CustomVertex.TransformedColored[1];
                Vector4 a = new Vector4(x1, y1, 0, 1);
                Vector4 b = new Vector4(x2, y2, 0, 1);

                vertices[0].Position = a;
                vertices[0].Color    = color1.ToArgb();
                vertices[1].Position = b;
                vertices[1].Color    = color2.ToArgb();
                Device.VertexFormat  = CustomVertex.TransformedColored.Format;
                Device.DrawUserPrimitives(PrimitiveType.LineList, 1, vertices);
            }
コード例 #8
0
        protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
        {
            device.Clear(ClearFlags.Target, Color.Navy, 1.0f, 0);
            device.BeginScene();

            device.VertexFormat    = CustomVertex.PositionColored.Format;
            device.Transform.World = Matrix.Translation(MyMaticeX, MyMaticeY, MyMaticeZ);
            device.DrawUserPrimitives(PrimitiveType.TriangleList, 1, vertices);

            device.EndScene();
            device.Present();
            this.Invalidate();

            ReadKeyboard();
        }
コード例 #9
0
ファイル: DX2D.cs プロジェクト: Deleeete/Gleee
            /// <summary>
            /// 在场景中加入实心矩形
            /// </summary>
            /// <param name="x"></param>
            /// <param name="y"></param>
            /// <param name="width"></param>
            /// <param name="height"></param>
            /// <param name="color"></param>
            public static void ImportRect(float x, float y, float width, float height, Color color)
            {
                CustomVertex.TransformedColored[] vertices = new CustomVertex.TransformedColored[4];
                Vector4 a = new Vector4(x, y, 0, 1);
                Vector4 b = new Vector4(x + Math.Abs(width), y, 0, 1);
                Vector4 c = new Vector4(x + Math.Abs(width), y + Math.Abs(height), 0, 1);
                Vector4 d = new Vector4(x, y + Math.Abs(height), 0, 1);

                vertices[0].Position = a;
                vertices[1].Position = b;
                vertices[2].Position = c;
                vertices[3].Position = d;
                vertices[0].Color    = color.ToArgb();
                vertices[1].Color    = color.ToArgb();
                vertices[2].Color    = color.ToArgb();
                vertices[3].Color    = color.ToArgb();
                Device.VertexFormat  = CustomVertex.TransformedColored.Format;
                Device.DrawUserPrimitives(PrimitiveType.TriangleStrip, 2, vertices);
            }
コード例 #10
0
        private void Render()
        {
            CustomVertex.TransformedColored[] vertexes = new CustomVertex.TransformedColored[3];
            vertexes[0].Position = new Vector4(240, 110, 0, 1.0f);  //first point
            vertexes[0].Color    = System.Drawing.Color.FromArgb(0, 255, 0).ToArgb();

            vertexes[1].Position = new Vector4(380, 420, 0, 1.0f);  //second point
            vertexes[1].Color    = System.Drawing.Color.FromArgb(0, 0, 255).ToArgb();

            vertexes[2].Position = new Vector4(110, 420, 0, 1.0f);  //third point
            vertexes[2].Color    = System.Drawing.Color.FromArgb(255, 0, 0).ToArgb();
            device.Clear(ClearFlags.Target, Color.CornflowerBlue, 1.0f, 0);
            device.BeginScene();

            device.VertexFormat = CustomVertex.TransformedColored.Format;
            device.DrawUserPrimitives(PrimitiveType.TriangleList, 1, vertexes);
            device.EndScene();
            device.Present();
        }
コード例 #11
0
        public static void DrawSpriteArray(SpriteAccess[] Sprites)
        {
            Direct3D.Device CurrDevice = null;

            //For each associated sprite on the screen
            for (int i = 0; i < Sprites.Length; i++)
            {
                if (CurrDevice != Sprites[i].ParentDevice)
                {
                    CurrDevice = Sprites[i].ParentDevice;
                    CurrDevice.VertexFormat = Direct3D.CustomVertex.PositionTextured.Format;
                }

                CurrDevice.Transform.World = Matrix.RotationYawPitchRoll(Sprites[i].RotationX / (float)Math.PI, Sprites[i].RotationY / (float)Math.PI * 2.0f, Sprites[i].RotationZ / (float)Math.PI / 4.0f) * Matrix.Translation(Sprites[i].X, Sprites[i].Y, Sprites[i].Z) * SpaceAndTime.ScaleStandard;

                CurrDevice.SetTexture(0, Sprites[i].textures[Sprites[i].Frame]);
                CurrDevice.DrawUserPrimitives(Direct3D.PrimitiveType.TriangleStrip, 2, Sprites[i].Verticies);
            }
        }
コード例 #12
0
        public static void renderBackground(Texture texture)
        {
            // To store the converted video
            // no longer required - textures now saved out and sent to a memory stream.
            //convertedVideo[frameCounter++] = texture;

            // Prevent anything from being rendered until ready
            if (globalSettings.videoPortal_eRenderReady == false)
            {
                return;
            }


            // Origionaly split out but more stable as part of this method
            if (device == null || device.Disposed)
            {
                return;
            }


            device.BeginScene();


            // Renders to a flat plane - i.e. the screen
            CustomVertex.TransformedTextured[] screenVert = new CustomVertex.TransformedTextured[4];
            screenVert[0] = new CustomVertex.TransformedTextured(0, 0, 0, 1, 0, 0);
            screenVert[1] = new CustomVertex.TransformedTextured(clientForm.Width, 0, 0, 1, 1, 0);
            screenVert[2] = new CustomVertex.TransformedTextured(clientForm.Width, clientForm.Height, 0, 1, 1, 1);
            screenVert[3] = new CustomVertex.TransformedTextured(0, clientForm.Height, 0, 1, 0, 1);
            // To tile textures, use the wrap texture type - It's used by default...
            // device.SamplerState[1].AddressU = TextureAddress.Wrap; device.SamplerState[1].AddressV = TextureAddress.Wrap;
            // Then set the U&V co-ordinates to the number of times you want the texture replicated
            // i.e. if you change both the U&V co-ords to 2 then you will see the texture tiled 4 times, 2 across and 2 down



            // Turn off while drawing the background
            //device.RenderState.ZBufferEnable = false;

            // Test with vertex buffer
            // buffer.SetData(screenVert, 0, LockFlags.None);


            // -----------Stuffn with --------------------------------
            //SamplerStateManager sam = new SamplerStateManager();
            //sam = TextureAddress.Border;
            //device.SetSamplerState(0,SamplerStageStates.SrgbTexture, true);

            //TextureAddress tex = new TextureAddress();
            //tex = TextureAddress.Border;

            // -----------Stuffn with --------------------------------


            //// These would probably work if the textures were first copied to a newly created texture in this
            //// transactions scope
            //fUtil.addFrame(device.GetTexture(0));
            //fUtil.addFrame(texture);


            //// This works to save the rendered frame to a BMP
            //Bitmap bmp = SaveToBitmap(device);
            //fUtil.addBmpFrame(bmp);


            // Attemptng to save the frame as a memory stream in the DDS format
            //SaveToDDSFile(device);
            //fUtil.addDDSFrame("TempDDSConv.dds");

            //fUtil.addMSFrame(aMS);



            // Set the texture to render to the background
            device.SetTexture(0, texture);


            if (lastFrame != null)
            {
                // For Vertex Buffer
                //device.SetStreamSource(0, buffer, 0,0);



                device.SetTexture(1, lastFrame);

                // Sets the U&V co-ordinates for the '1' (i.e. second) texture stage to the same as the first!
                // I wish ths was better f*****g documented, seriosuly
                device.TextureState[1].TextureCoordinateIndex = 0;

                // For Vertex Buffer
                //device.SetStreamSource(1, buffer, 0,0);


                //-------------- more stuffn
                //device.SamplerState[0].AddressU = TextureAddress.Border;
                //device.SamplerState[0].AddressV = TextureAddress.Border;

                // wrap is the default mode
                device.SamplerState[1].AddressU = TextureAddress.Wrap;
                device.SamplerState[1].AddressV = TextureAddress.Wrap;
                //-------------



                //// Blend and mix - around 50% transperancy
                device.SetTextureStageState(0, TextureStageStates.ColorArgument1, (int)TextureArgument.TextureColor);
                device.SetTextureStageState(0, TextureStageStates.ColorOperation, (int)TextureOperation.SelectArg1);
                device.SetTextureStageState(1, TextureStageStates.ColorArgument1, (int)TextureArgument.Current);
                device.SetTextureStageState(1, TextureStageStates.ColorArgument2, (int)TextureArgument.TextureColor);
                device.SetTextureStageState(1, TextureStageStates.ColorOperation, (int)TextureOperation.Add);


                // Lighter blend
                //device.SetTextureStageState(0, TextureStageStates.ColorArgument1, (int)TextureArgument.TextureColor);
                //device.SetTextureStageState(0, TextureStageStates.ColorOperation, (int)TextureOperation.SelectArg1);
                //device.SetTextureStageState(1, TextureStageStates.ColorArgument1, (int)TextureArgument.Current);
                //device.SetTextureStageState(1, TextureStageStates.ColorArgument2, (int)TextureArgument.TextureColor);
                //device.SetTextureStageState(1, TextureStageStates.ColorOperation, (int)TextureOperation.MultiplyAdd);

                // Subtract the darker colour from the lighter colour
                //device.SetTextureStageState(0, TextureStageStates.ColorArgument1, (int)TextureArgument.TextureColor);
                //device.SetTextureStageState(0, TextureStageStates.ColorOperation, (int)TextureOperation.SelectArg1);
                //device.SetTextureStageState(1, TextureStageStates.ColorArgument1, (int)TextureArgument.Current);
                //device.SetTextureStageState(1, TextureStageStates.ColorArgument2, (int)TextureArgument.TextureColor);
                //device.SetTextureStageState(1, TextureStageStates.ColorOperation, (int)TextureOperation.Subtract);

                // Add with a darker tinge
                //device.SetTextureStageState(0, TextureStageStates.ColorArgument1, (int)TextureArgument.TextureColor);
                //device.SetTextureStageState(0, TextureStageStates.ColorOperation, (int)TextureOperation.SelectArg1);
                //device.SetTextureStageState(1, TextureStageStates.ColorArgument1, (int)TextureArgument.Current);
                //device.SetTextureStageState(1, TextureStageStates.ColorArgument2, (int)TextureArgument.TextureColor);
                //device.SetTextureStageState(1, TextureStageStates.ColorOperation, (int)TextureOperation.AddSigned);

                // Add with highted highlights and darkened shadows
                //device.SetTextureStageState(0, TextureStageStates.ColorArgument1, (int)TextureArgument.TextureColor);
                //device.SetTextureStageState(0, TextureStageStates.ColorOperation, (int)TextureOperation.SelectArg1);
                //device.SetTextureStageState(1, TextureStageStates.ColorArgument1, (int)TextureArgument.Current);
                //device.SetTextureStageState(1, TextureStageStates.ColorArgument2, (int)TextureArgument.TextureColor);
                //device.SetTextureStageState(1, TextureStageStates.ColorOperation, (int)TextureOperation.AddSigned2X);

                // Add with a lighter mix
                //device.SetTextureStageState(0, TextureStageStates.ColorArgument1, (int)TextureArgument.TextureColor);
                //device.SetTextureStageState(0, TextureStageStates.ColorOperation, (int)TextureOperation.SelectArg1);
                //device.SetTextureStageState(1, TextureStageStates.ColorArgument1, (int)TextureArgument.Current);
                //device.SetTextureStageState(1, TextureStageStates.ColorArgument2, (int)TextureArgument.TextureColor);
                //device.SetTextureStageState(1, TextureStageStates.ColorOperation, (int)TextureOperation.AddSmooth);

                // Use colour to tint image mix
                //device.SetTextureStageState(0, TextureStageStates.ColorArgument1, (int)TextureArgument.TextureColor);
                //device.SetTextureStageState(0, TextureStageStates.ColorOperation, (int)TextureOperation.SelectArg1);
                //device.SetTextureStageState(1, TextureStageStates.ColorArgument1, (int)TextureArgument.Current);
                //device.SetTextureStageState(1, TextureStageStates.ColorArgument2, (int)TextureArgument.TextureColor);
                //device.SetTextureStageState(1, TextureStageStates.ColorOperation, (int)TextureOperation.Modulate);

                // Add image and inverse white parts of the image being added
                //device.SetTextureStageState(0, TextureStageStates.ColorArgument1, (int)TextureArgument.TextureColor);
                //device.SetTextureStageState(0, TextureStageStates.ColorOperation, (int)TextureOperation.SelectArg1);
                //device.SetTextureStageState(1, TextureStageStates.ColorArgument1, (int)TextureArgument.Current);
                //device.SetTextureStageState(1, TextureStageStates.ColorArgument2, (int)TextureArgument.TextureColor);
                //device.SetTextureStageState(1, TextureStageStates.ColorOperation, (int)TextureOperation.Lerp);


                // Black and white image add.
                //device.SetTextureStageState(0, TextureStageStates.ColorArgument1, (int)TextureArgument.TextureColor);
                //device.SetTextureStageState(0, TextureStageStates.ColorOperation, (int)TextureOperation.SelectArg1);
                //device.SetTextureStageState(1, TextureStageStates.ColorArgument1, (int)TextureArgument.Current);
                //device.SetTextureStageState(1, TextureStageStates.ColorArgument2, (int)TextureArgument.TextureColor);
                //device.SetTextureStageState(1, TextureStageStates.ColorOperation, (int)TextureOperation.DotProduct3);



                //if (secondLastFrame != null)
                //{

                //    device.TextureState[2].TextureCoordinateIndex = 0;
                //    device.SetTextureStageState(1, TextureStageStates.ColorOperation, (int)TextureOperation.SelectArg1);

                //    device.SetTexture(2, secondLastFrame);

                //    device.SetTextureStageState(2, TextureStageStates.ColorArgument1, (int)TextureArgument.Current);
                //    device.SetTextureStageState(2, TextureStageStates.ColorArgument2, (int)TextureArgument.TextureColor);
                //    device.SetTextureStageState(2, TextureStageStates.ColorOperation, (int)TextureOperation.Add);
                //}
            }
            //secondLastFrame = lastFrame;
            lastFrame = texture;


            //device.VertexFormat = CustomVertex.TransformedTextured.Format;
            device.VertexFormat = vertexFormat;

            device.DrawUserPrimitives(PrimitiveType.TriangleFan, 2, screenVert);

            // Turn it back on
            // device.RenderState.ZBufferEnable = true;



            // Origionaly split out but more stable in the same method
            device.EndScene();
            device.Present();
        }
コード例 #13
0
        public override void render(float elapsedTime)
        {
            Microsoft.DirectX.Direct3D.Device d3dDevice = GuiController.Instance.D3dDevice;

            float velocidadCaminar = 50f * elapsedTime;

            //Calcular proxima posicion de personaje segun Input
            TgcD3dInput d3dInput = GuiController.Instance.D3dInput;
            bool        moving   = false;
            Vector3     movement = new Vector3(0, 0, 0);

            //Adelante
            if (d3dInput.keyDown(Key.W))
            {
                movement.Z = velocidadCaminar;
                moving     = true;
            }

            //Atras
            if (d3dInput.keyDown(Key.S))
            {
                movement.Z = -velocidadCaminar;
                moving     = true;
            }

            //Derecha
            if (d3dInput.keyDown(Key.D))
            {
                movement.X = velocidadCaminar;
                moving     = true;
            }

            //Izquierda
            if (d3dInput.keyDown(Key.A))
            {
                movement.X = -velocidadCaminar;
                moving     = true;
            }
            //Salto
            if (d3dInput.keyDown(Key.Space))
            {
                movement.Y = velocidadCaminar;
                moving     = true;
            }
            //Agachar
            if (d3dInput.keyDown(Key.LeftControl))
            {
                movement.Y = -velocidadCaminar;
                moving     = true;
            }
            //Si hubo desplazamiento
            if (moving)
            {
                //Aplicar movimiento
                box.move(movement);
            }
            //Hacer que la camara siga al personaje en su nueva posicion
            GuiController.Instance.ThirdPersonCamera.Target = box.Position;



            //Detectar colision con triangulo
            if (TgcCollisionUtils.testTriangleAABB(triangle[0].Position, triangle[1].Position, triangle[2].Position, box.BoundingBox))
            {
                box.BoundingBox.render();
                triagleAABB.render();
            }
            //Detectar colision con el otro AABB
            if (TgcCollisionUtils.testAABBAABB(box.BoundingBox, box2.BoundingBox))
            {
                box.BoundingBox.render();
                box2.BoundingBox.render();
            }
            //Detectar colision con la esfera
            if (TgcCollisionUtils.testSphereAABB(sphere, box.BoundingBox))
            {
                box.BoundingBox.render();
                sphere.setRenderColor(Color.Red);
            }
            else
            {
                sphere.setRenderColor(Color.Yellow);
            }

            //Detectar colision con la obb
            if (TgcCollisionUtils.testObbAABB(obb, box.BoundingBox))
            {
                box.BoundingBox.render();
                obb.setRenderColor(Color.Red);
            }
            else
            {
                obb.setRenderColor(Color.Yellow);
            }


            //Dibujar
            box.render();
            box2.render();
            sphere.render();
            esfera.render();
            obb.render();

            //triangulo
            d3dDevice.Transform.World = Matrix.Identity;
            d3dDevice.VertexFormat    = CustomVertex.PositionColored.Format;
            d3dDevice.DrawUserPrimitives(PrimitiveType.TriangleList, 1, triangle);
        }