Jump to content
  • Advertisement
Sign in to follow this  
hahaha

Model Export Question

This topic is 4069 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

In 3ds max(any version with MaxScript)how could i properly write an exporter in MaxScript that will export only the vertices and faces properly so it can be easily read and rendered? Thanks

Share this post


Link to post
Share on other sites
Advertisement
This article provides some good insight.

Basically, open an existing script and see how it's put together. Then write your script similar to the example one.

Share this post


Link to post
Share on other sites
Thanks that was helpful but it doesnt really talk about rendering your own format. Just in case im using c++, opengl and win32

Share this post


Link to post
Share on other sites
Quote:
Original post by hahaha
Thanks that was helpful but it doesnt really talk about rendering your own format. Just in case im using c++, opengl and win32

Rendering your own format is an entirely different matter. Basically you just load your file into whatever data structures you are using to render in OpenGL (vertex arrays or VBOs, etc.). Specifics depend on how you are rendering, and how your file format is laid out.
I think NeHe has a few articles on model loading, probably worth looking at.

Share this post


Link to post
Share on other sites
If i have these structs:

struct Vertex
{
float x,y,z
};
struct Face
{
float x,y,z;
}



and this is the vertex and face data loaded into a pointer of the structures


Vertices:
-3.23639 0.0 -29.2095
3.23639 0.0 -29.2095
-3.23639 0.0 29.2095
3.23639 0.0 29.2095
-3.23639 11.3347 -29.2095
3.23639 11.3347 -29.2095
-3.23639 11.3347 29.2095
3.23639 11.3347 29.2095
Faces:
1.0 4.0 3.0
4.0 1.0 2.0
5.0 8.0 6.0
8.0 5.0 7.0
1.0 6.0 2.0
6.0 1.0 5.0
2.0 8.0 4.0
8.0 2.0 6.0
4.0 7.0 3.0
7.0 4.0 8.0
3.0 5.0 1.0
5.0 3.0 7.0


How would i go about rendering it?

Share this post


Link to post
Share on other sites
I am not sure you understand rendering triangles. The vertices are fine, but each Face needs to be a collection of 3 vertices, not 3 floats. After all, a Face is a triangle, and it therefore needs a vertex for each corner. In actual fact, most systems just store 3 indices (offsets) into the array of vertices for each face.

Share this post


Link to post
Share on other sites
As swift coder said, you should change your data structures


Vertices:
Vertices 1: -3.23639 0.0 -29.2095
Vertices 2: 3.23639 0.0 -29.2095
Vertices 3: -3.23639 0.0 29.2095
Vertices 4: 3.23639 0.0 29.2095
Vertices 5: -3.23639 11.3347 -29.2095
Vertices 6: 3.23639 11.3347 -29.2095
Vertices 7: -3.23639 11.3347 29.2095
Vertices 8: 3.23639 11.3347 29.2095

Faces:
Face1: 1 4 3
Face2: 4 1 2
Face3: 5 8 6
Face4: 8 5 7
Face5: 1 6 2
Face6: 6 1 5
Face7: 2 8 4
Face8: 8 2 6
Face9: 4 7 3
Face10: 7 4 8
Face11: 3 5 1
Face12: 5 3 7


Now you can iterate over your faces using the face pointer, using face n(a,b,c) to render a triangle.


// you can do this alot faster using vertex and index arrays, but for immediate rendering this will work.

for (int i=1; i<=numFaces; ++i)
{
vertex1 = Vertices[Faces.a];
vertex2 = Vertices[Faces.b];
vertex3 = Vertices[Faces.c];

DrawTriangle(vertex1, vertex2, vertex3);
}


This data is based on a 1 index, You should start working from a 0 index.

0123456789 instead of 123456789(10)

[Edited by - lubby on July 28, 2007 6:01:41 AM]

Share this post


Link to post
Share on other sites
Ive come across another problem. Ive written this code for exporting the texture verts:


for i = 1 to NumTVerts do
(
tv = GetTVert Mesh i
format "%\n%\n%\n" tv.x tv.y tv.z to:out --file
)


when i execute the script with a texture mapped cube i get 3 values(tv.x tv.y tv.z...(either 0.0 or 0.1)) for each face. I can render the faces fine but when it comes to using those texture coords im lost!
Please can someone tell me how to use the texture coords.

Thanks

Share this post


Link to post
Share on other sites
For every face-value (3 for every triangle) you must att two more floats, the (u,v) texture coordinate.

Do not try to use the so called "sticky uv's" method where you put the uv's whith the vertice, this will make it a lot harder to make nice models since two or more triangles MUST share uv coords.

You're still on easystreet now, just wait until you get to bones, vertexgroups, frames and transforms :)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!