Results 1 to 8 of 8

Thread: draw 3D cube Direct3D

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Sep 2009
    Location
    Belgium
    Posts
    98

    draw 3D cube Direct3D

    Hi all,

    I have a question. Does somebody knows a good tutorial to draw 3D with Direct3D and VB.NET.
    I'm trying to draw a cube on the screen with Direct3D, and afterwards I want to draw cylinders and other 3D polygons.
    Can somebody help me?

    Thanks in advance.
    Geemuse

  2. #2
    PowerPoster Jenner's Avatar
    Join Date
    Jan 2008
    Location
    Mentor, OH
    Posts
    3,712

    Re: draw 3D cube Direct3D

    I got one for a cube. It uses Managed Direct3D and isn't the prettiest in the world since the triangles that make up each vertexed side are hard coded, but the end result is nice. You can spin the thing in 3D space with the mouse. It's my only example of "drawing" a 3D object in DirectX, rather than just loading in a mesh.

    I tried to do a sphere generator as well but it suffered from vertex inversion that I couldn't quite figure out (half the triangles were drawn the wrong way and thus, appeared as holes in the sphere)

    If this is what you're looking for, I can pack it up and post it.
    My CodeBank Submissions: TETRIS using VB.NET2010 and XNA4.0, Strong Encryption Class, Hardware ID Information Class, Generic .NET Data Provider Class, Lambda Function Example, Lat/Long to UTM Conversion Class, Audio Class using BASS.DLL

    Remember to RATE the people who helped you and mark your forum RESOLVED when you're done!

    "Two things are infinite: the universe and human stupidity; and I'm not sure about the universe. "
    - Albert Einstein

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Sep 2009
    Location
    Belgium
    Posts
    98

    Re: draw 3D cube Direct3D

    What is the best way to do...create a mesh and draw every object in it and then put it on the screen, or just put everything right a way on the screen.

    Yeah please, so I can look at it and see how it really works. I want to convert it into a dynamically created cube...with the points stored in databases.

    Thanks
    Geemuse

  4. #4
    PowerPoster Jenner's Avatar
    Join Date
    Jan 2008
    Location
    Mentor, OH
    Posts
    3,712

    Re: draw 3D cube Direct3D

    Sorry it took a little while for me to post this. Things got frantic suddenly.

    You need the Managed DirectX SDK installed to compile this. You can get these files here direct from Microsoft.

    Attached is the project; I included the compiled binary if you just want to check it out. A picture of the program running is posted below. Click and drag the cube to spin and rotate it.

    RenderTest.zip

    Name:  RenderTest.png
Views: 12928
Size:  29.0 KB
    My CodeBank Submissions: TETRIS using VB.NET2010 and XNA4.0, Strong Encryption Class, Hardware ID Information Class, Generic .NET Data Provider Class, Lambda Function Example, Lat/Long to UTM Conversion Class, Audio Class using BASS.DLL

    Remember to RATE the people who helped you and mark your forum RESOLVED when you're done!

    "Two things are infinite: the universe and human stupidity; and I'm not sure about the universe. "
    - Albert Einstein

  5. #5
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    25,464

    Re: draw 3D cube Direct3D

    Quote Originally Posted by Jenner View Post
    Sorry it took a little while for me to post this. Things got frantic suddenly.

    You need the Managed DirectX SDK installed to compile this. You can get these files here direct from Microsoft.

    Attached is the project; I included the compiled binary if you just want to check it out. A picture of the program running is posted below. Click and drag the cube to spin and rotate it.

    RenderTest.zip

    Name:  RenderTest.png
Views: 12928
Size:  29.0 KB
    interesting directX. how would i show an image on each side so i could make the cube a dice?

    + more complicated i know, how could i convert this cube into a rubiks cube?

    any advice would be appreciated

  6. #6
    PowerPoster Jenner's Avatar
    Join Date
    Jan 2008
    Location
    Mentor, OH
    Posts
    3,712

    Re: draw 3D cube Direct3D

    In this example, I'm just drawing the triangles of the cube object manually rather than load in a mesh, but since it's only a cube, it's easily done. Now, drawing on the faces would be done by applying textures to them. You would make a set of textures each representing the face of a dice and tell the engine to apply them to the appropriate face. I have an example of this somewhere using a meshed object. Let me see if I can adapt it to this generated object.

    A Rubik's cube would be easiest done by generating multiple cube objects. Make 26 individual cubes, and stack them into a 3x3x3 arrangement (you can skip the center-most cube). This way, you can create rotation methods for rotating the various slices.
    Last edited by Jenner; Mar 12th, 2011 at 06:28 PM.
    My CodeBank Submissions: TETRIS using VB.NET2010 and XNA4.0, Strong Encryption Class, Hardware ID Information Class, Generic .NET Data Provider Class, Lambda Function Example, Lat/Long to UTM Conversion Class, Audio Class using BASS.DLL

    Remember to RATE the people who helped you and mark your forum RESOLVED when you're done!

    "Two things are infinite: the universe and human stupidity; and I'm not sure about the universe. "
    - Albert Einstein

  7. #7
    New Member
    Join Date
    Aug 2012
    Posts
    12

    Re: draw 3D cube Direct3D

    Well I made one in WPF which supports meshes and all kinds of things

  8. #8
    PowerPoster Jenner's Avatar
    Join Date
    Jan 2008
    Location
    Mentor, OH
    Posts
    3,712

    Re: draw 3D cube Direct3D

    Easy enough and nothing new since WPF natively uses Direct3D and has plenty of support for simple 3D operations. This example is more about setting up your own Direct3D environment using WinForms as a base and drawing to it. You realize this thread is over a year and a half old too?
    My CodeBank Submissions: TETRIS using VB.NET2010 and XNA4.0, Strong Encryption Class, Hardware ID Information Class, Generic .NET Data Provider Class, Lambda Function Example, Lat/Long to UTM Conversion Class, Audio Class using BASS.DLL

    Remember to RATE the people who helped you and mark your forum RESOLVED when you're done!

    "Two things are infinite: the universe and human stupidity; and I'm not sure about the universe. "
    - Albert Einstein

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width