Start New Discussion within our **Software Development Community** Answered # How do I control 3d models with c++?

daviddoria 334 mike_2000_17 2,649 PixelExchange Discussion Starter punchinello

0

I use VTK for everything 3D (vtk.org). You ask for c++ and VB in the same sentence though - which would you prefer?

0

Well basically, for rendering it (displaying it) there are two main libraries, OpenGL and Direct3D. I am familiar with OpenGL, which also has a few possibly useful utility tools like GLUT (some extra functions, and cross-platform windows), GLUI (some functions for User Interfaces), and OpenInventor (for some tools to load models, display simple 3D objects and their 3D transformations). Basic tutorials for OpenGL from NEHE are very helpful to start, and it has example code mainly in C++, but also in about two dozen other programming languages.. it's all pretty much the same anyway. They will also show how to apply the translation and rotation transformations.

For moving 3D objects, there are two things to handle, translation and rotation. The former is a piece of cake, the latter can be a real nightmare. All renderers use homogeneous transformation matrices for both modelview (the motion of the 3D models) and projection (project models onto a 2D screen with a 3D look). So to learn about it, you should look into "representation of 3D rotations" and "the homogeneous transformation matrix", but I warn you, it's a bit of mathematics and geometry. I personally rely almost exclusively on quaternions for rotation, but there are options like the rotation matrix or Euler angles or Euler axis/angle which are also possible. It depends on what you want to do. For static pose of models, they are all pretty OK. If you want to do some movement (time integration of 3D rotational motion), then quaternions are the best choice by far, but they are a bit hard to grasp at first, in that case, the rotation matrix is also a good alternative.

Finally, what do you mean by 3D model? Do you want to control the movement of different parts of it and stuff? This will be quite a bit more math, look up "kinematic chains", "skeletal animation" and "rag-doll models". And techniques to render them include the old-school method of splitting the model into parts and figuring out their individual transformations, or a fancier method called "skinning" (which involves vertex shaders, a semi-advanced concept in 3D rendering). But there must be free libraries that accomplish all that already, that I am not familiar with (my knowledge of 3D game programming is a bit outdated). VTK does look very sweet!

0

If you are talking about "pre-made" 3d models, such as .3ds, .obj, etc, your best bet is going to be: http://spacesimulator.net Otherwise, you can google search: Displaying .3ds with OpenGL/C++. (replace .3ds with the type of 3d file you are using)

(Please note: You are going to HAVE to learn OpenGL or Direct X at some point to be able to manipulate pre-made 3d models, or any other type of 3d models for that matter).

0

Sorry davi sir but I think I meant "vc6.0". Must have misspelled it. :P And thank you all! That's very kind of you! Your suggestions are so detailed and very helpful. Guess I'll try to start with those. Thanks again! :D

This question has already been answered. Start a new discussion instead.