X file or mesh with 3D app

Started by
16 comments, last by jagguy2 16 years, 2 months ago
q)i want to create a model with Blender and import it into directx. Do i save it as a X file or just a mesh file somehow? q)The reason i ask is because i need to know the height of the object as i want to go over it with a camera so I need the Y value of where i am at. Can i get a current height value of the object i import in from Blender
Advertisement
Quote:Original post by jagguy2
q)i want to create a model with Blender and import it into directx. Do i save it as a X file or just a mesh file somehow?


sorry, I can't answer your second question.

To your 1st Q:
Yes, you must save it as a .X file in order to use it with the D3DXLoadMeshFromX()-type functions. To do this, you must export the model you currently have open, with File->Export->.X File (I havent used blender in a while, look for export though, then the .x extension.)

I have used blender and have tried saving and then using exported .X files. It was mainly hit-and-miss (mostly miss). For some reason, the D3DXLoadMeshFromX()-types wouldn't work with the exported files. I even tried using other .X exporters available at the blender site with no luck.

I would try saving under a more structured format (.3ds for example), loading that file into a different modeling program, then export to .X with that other program (or just not use blender :/ , even though I do like it's interface)

Hope that helps
-----------------------------std::string is the way to go.
Yes your post helped thanks.

q)I found the export into X file. Creating an X file eg for terrain isnt useful if i cant get the current height of what triangle i am on. Also for collisions i need the world coordinated of an object.
Can i get the X,Y,Z point of a triangle somehow of a loaded X file?

Quote:Original post by jagguy2
Can i get the X,Y,Z point of a triangle somehow of a loaded X file?


Yes, though not easily. You can access the data contained by the mesh's vertex buffer. It contains the position, texture coordinate, normals, etc of each vertex.
ok by the sounds of it i dont load a terrain into an X file but to load a another file format eg raw is very complicated and to get the Y position requires a lot of code .

This is a confusing problem terrain loading
You don't need to use a mesh for that. Just load the image, and generate triangles based on the height data it contains and render them yourself.
if i have a terrain with hills ,valleys etc it is complicated to come up with a few thousand triangles, textures and vertices and indices by hand
Quote:Original post by jagguy2
if i have a terrain with hills ,valleys etc it is complicated to come up with a few thousand triangles, textures and vertices and indices by hand


Not really. You can do it in a couple for loops. For each x and y iteration of the loops, create a triangle with vertices who's y position is defined by the value in the image at that point.

The really complicated stuff will come later when you have to optimize it with a LOD algorithm.
isnt using a terrain generator much easier then all by hand because it is very complicated to work out where a dozen hills , valleys and lakes should be in 60000 triangles.
You're missing the point: you do generate your terrain in another program/generator/whatever. You then store the generated terrain info in an image file. You load the image into your game, and position vertices based on that info.

This topic is closed to new replies.

Advertisement