Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Cutting out a triangular chunk in DirectX

Cutting out a triangular chunk in DirectX

Scheduled Pinned Locked Moved C#
graphicsgame-devhelpquestionlearning
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    melanieab
    wrote on last edited by
    #1

    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 a private void DrawTriangle(float yaw, float pitch, float roll, float x, float y, float z) with basically the same innards as the DrawBox (replace mesh with tmesh, got rid of boxMaterial, and made Color.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

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups