Cutting out a triangular chunk in DirectX
-
Hi, I'm completely new to DirectX, and have managed to create a 3D yawing, pitching, and rolling rectangle that zooms in (with the help of the graphics & game programming book by Tom Miller). I need to cut out a 3D triangle chunk (straight through, nothing fancy) from one of the long sides of the rectangle (about 1/4 size of that side and midway down). To create my yawing, pitching, rolling rectangle, I used this:
private Mesh mesh = null; public void InitializeGraphics() { ... mesh = Mesh.Box(device, 0.78f, 2.0f, 0.5f); ... } protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) { ... DrawBox(angle / (float)Math.PI, angle / (float)Math.PI * 8.0f, angle / (float)Math.PI, -0.41f, 0.8f, hDepth); ... } private void DrawBox(float yaw, float pitch, float roll, float x, float y, float z) { angle += 0.01f; device.Transform.World = Matrix.RotationYawPitchRoll(yaw, pitch, roll) * Matrix.Translation(x, y, z); Material boxMaterial = new Material(); device.Lights[0].Type = LightType.Directional; device.Lights[0].Diffuse = Color.Red; device.Lights[0].Direction = new Vector3(0,-1,-1); device.Lights[0].Commit(); device.Lights[0].Enabled = true; boxMaterial.Diffuse = Color.White; device.Material = boxMaterial; mesh.DrawSubset(0); }
I basically tried following the same steps as above to put a black triangle into that chunk of rectangle.private Mesh tmesh = null;
(in InitializeGraphics)tmesh = Mesh.Polygon(device, 0.5f, 3);
(in OnPaint override)DrawTriangle(angle / (float)Math.PI, angle / (float)Math.PI * 8.0f, angle / (float)Math.PI, -0.41f, 0.8f, hDepth);
and then aprivate void DrawTriangle(float yaw, float pitch, float roll, float x, float y, float z)
with basically the same innards as theDrawBox
(replacemesh
withtmesh
, got rid ofboxMaterial
, and madeColor.White
(so I could see it)). I'm thinking that this isn't the way to go because it's not doing what I'd like it to do. It appears to create a triangle, but only in 1 plane (Mesh.Polygon doesn't ask for for depth like Mesh.Box does). I then tried creating a bunch of triangles to create layers and it didn't work so well either. What's the best way to cut this chunk out? Thanks so much! :) Mel