MESH programing

Started by
8 comments, last by bzroom 14 years, 8 months ago
Hi, I have recently started programing in VC++ using DirectX. I have searched online and I am unable to find a good tutorial where I can learn mesh programing. All the places I have found that a .x file has to be loaded and manipulations has to be done only on that. I am looking for tutorial where I can create a mesh of my own with many points. I am able to design simple things like square, cube, pyramid...in 3D, but when I am thinking of extending it to many (lets say more than 600 vertices) its too hard to write a code. Can some one tell me where I can find one and if there is a video tutorial that would be an awesome place to learn. Thanks in advance.
Advertisement
Data driven programming is a skill that I think will serve you quite well during your game programming endeavors. I would highly recommend using a program like Blender: Blender to make your 3d models and then load those into your game.

Basically you need to use a modeling program to create your 3d models. These models are saved as files (either binary or text) and then loaded by your engine. If your using a low level engine then usually some formats (like .X afaik) will be supported out of the box, but other formats will require you to write loading code (or use an existing lib/code base).

There are many other programs than Blender for 3d modeling, and some people don't like Blender because of its user interface. However if you take time to learn it and learn the hotkeys, then it is one of the "best" (good feature set, lots of output and input formats, well supported and well documented) free 3d modeling programs out there.
Usually for models that are not geometric primitives, people use 3D modeling programs that enable them to manipulate vertices, textures etc. and save them into files which can be loaded into your program.

The problem is that different programs have different file formats in which they save information about the model. For example, 3DS max is a program that saves models as a .3ds file which a lot of people convert to .X files that can be easily used with DirectX. You just need to choose a program and format to work with.

There is no need to manually program vertices of a complex model, as programs have been made so you can manipulate this data visually and save it in a file to import to your program.
"Only two things are infinite, the universe and human stupidity, and I'm not sure about the former." - Albert Einstein (1879-1955) That is so very true...
Hey thanks for your reply,

yeah I have got that part. What I am trying to do is, taking few values (voltages) which I get from a camera through a data acquisition board. And trying to plot those values as a mesh terrain (3D) using DirectX. So I am not sure whether converting those values into .x files first and then loading them would actually work!!??

Is there a way where you can directly convert some of the given points in a .txt or .doc or .xls file to a 3D image in DirectX.

Thanks
Quote:Original post by garywillams
Is there a way where you can directly convert some of the given points in a .txt or .doc or .xls file to a 3D image in DirectX.


Do you want to actually save the points, or just display them in real time?

If you want to display them in real time, have a look an any beginning tutorial to see how to manually draw polygons. It's really straight forward.

If you want to save them, just create a simple binary file that contains a count of polygons and 3 points per polygon, each point contains an x, y, and z floating point value. This isn't the most optimized solution, but would allow you to quickly load up a saved data set. Once you have this working, expand it to support triangle strips.



Check out Super Play, the SNES inspired Game Engine: http://www.superplay.info

I'd start here: http://triplebuffer.devmaster.net/file.php?id=7&page=3

Basically you need to fill a vertex buffer with your geometry, and then tell d3d to draw it. The code for how to do that is on the second to last page.

Any other D3D vertex buffer tutorial should be able to help you out.
like wat was said earlier. You have to create the file format your self and load it too. You also have to manually tell directx about this mesh.
Bring more Pain
Quote:Original post by garywillams
Hey thanks for your reply,

yeah I have got that part. What I am trying to do is, taking few values (voltages) which I get from a camera through a data acquisition board. And trying to plot those values as a mesh terrain (3D) using DirectX. So I am not sure whether converting those values into .x files first and then loading them would actually work!!??

Is there a way where you can directly convert some of the given points in a .txt or .doc or .xls file to a 3D image in DirectX.

Thanks


Really any model format is just a bunch of numbers specifying the polygons for the model. You would just need to take your data and write a custom loader for it. One place to start might be to look at some terrain generators because they usually take a height map and generate 3d mesh data from that and it might be close to what you are trying to accomplish.

Thank you all for your replies,

yes, I have used similar concepts and wrote a program. I used triangle strip and also triangle list separately.

Thats a big pain to tell DirectX about each and every pixel. As its a 3D programing, it becomes more laborious to write what are base vertices and what are sides.... Moreover as the values will be generating in real time, I have found that it is hard to tell DirextX about all those points.

So, I am looking for a function or algorithm where I can plot a mesh with more than 600 vertices.

For example, I am trying to create a mesh of the shape Gaussian function. In order to make it look a bit smother curve it took me 400 vertices and wrote a code using triangle list. Which is not advisable :( to write such a lengthy code. Is there any solution to make this code look simpler!!


You're using loops and stuff right?

//psuedo codefor (int i = 0; i < pointCount; ++i)  lineStrip.PushPoint(dataPoint);DrawLinesTrip(lineStrip);


As you can see, these 3 lines of code scale pretty extensibly with the size of the data set. Be it 5 points, or 5000 points.

Also D3D has no problem drawing hundreds of thousands of triangles and lines.

This topic is closed to new replies.

Advertisement