using Mesh3DS

ghettotek
Unregistered
 
Post: #1
i found what i think to be what the Mesh3DS.framework included with ppinter1's screen saver originated from, but i cant find any documentation on it. it loads the 3DS models fine, but they are all white. i tried my own custom models, and other models and they are all white, so its not a model problem. im hoping that ppinter1 could possibly help me out on this one Grin , but thanks to anyone who can.
Quote this message in a reply
ppinter1
Unregistered
 
Post: #2
Blink

Whoa! I neatly missed this thread till just now... sorry about that.

The all-white meshes usually indicate you have yet to set up your lighting and texture states properly.

In other words, Mesh3DS will load a 3DS mesh but it's up to you to ensure the OpenGL state machine is prepared to display the mesh.

When I get home from work tonight, I'll post a link to a small demo program called Display3DS for Mac OS X that shows how to use the Mesh3DS framework painlessly. I'm 2 hours behind you GhettoTek, so check in around 22:00 EST.

Alternatively, the complete source code to the SpaceTime screen saver, Mesh3DS Framework and Display3DS demo program is available for a sawbuck ($10) via my website in case you're looking to extend the code for your own needs.

/p2
Quote this message in a reply
Mars_999
Unregistered
 
Post: #3
Wouldn't the white models suggest you haven't setup normals? And texturing?
Quote this message in a reply
ghettotek
Unregistered
 
Post: #4
everything else in the scene is textured fine. only the 3DS models are white.
Quote this message in a reply
Mars_999
Unregistered
 
Post: #5
Quote:Originally posted by ghettotek
everything else in the scene is textured fine. only the 3DS models are white.


Ok but that still doesn't mean you have lighting done and you need to define a normal for each triangle on the model.

Here is some code I use to calculate normals
Code:
void Model::CalNormal(float *p1, float *p2, float *p3)
{
   float a[3] = {0.0f};
   float b[3] = {0.0f};
   float result[3] = {0.0f};
   float length = 0.0f;

   a[0] = p1[0] - p2[0];
   a[1] = p1[1] - p2[1];
   a[2] = p1[2] - p2[2];

   b[0] = p1[0] - p3[0];
   b[1] = p1[1] - p3[1];
   b[2] = p1[2] - p3[2];

   result[0] = a[1] * b[2] - b[1] * a[2];
   result[1] = b[0] * a[2] - a[0] * b[2];
   result[2] = a[0] * b[1] - b[0] * a[1];

   length = (float)sqrt(result[0]*result[0] + result[1]*result[1] + result[2]*result[2]);

  glNormal3f(result[0]/length, result[1]/length, result[2]/length);
}
Quote this message in a reply
ghettotek
Unregistered
 
Post: #6
ok but shouldnt textures show even if i dont have lighting enabled? they should still show even if i havent defined normals right? ive tried enabling/disabling different client states but nothing seems to work. also, it doesnt seem that Mesh3DS allows direct access to the vertecies of the models, although i could be mistaken.
Quote this message in a reply
Mars_999
Unregistered
 
Post: #7
I have no experience with 3DS, I use .md2 models. If I remember right you need to setup lighting to render the model correctly? If I am wrong please correct me?? Also are you sending the vertex points to the glTexCoord2f()?

Here are some links that might be helpful? This one has some source code
http://www.gametutorials.com/CodeDump/CodeDump_Pg1.htm

Here the link for the tutorial on 3DS file loader
http://www.gametutorials.com/Tutorials/o...GL_Pg4.htm

Hope this helps?
Quote this message in a reply
ppinter1
Unregistered
 
Post: #8
Okay, download Display3DS for a simple example of how to call the Mesh3DS Framework.

I'm outta here till Monday... have a great weekend everyone!

/p2
Quote this message in a reply
ghettotek
Unregistered
 
Post: #9
so the way it looks is i cant use a textured model unless i have lighting enabled when its drawn. what if i need a model to not be lit? is there a way around this or is that just how it is? either way, ill take it. thanks ppinter.
Quote this message in a reply
Member
Posts: 164
Joined: 2002.04
Post: #10
lighting is not related to texturing.
Quote this message in a reply
Hog
Member
Posts: 151
Joined: 2002.09
Post: #11
Quote:Originally posted by Mars_999
Code:
...
   length = (float)sqrt(result[0]*result[0] + result[1]*result[1] + result[2]*result[2]);

  glNormal3f(result[0]/length, result[1]/length, result[2]/length);
...

i don't think you need to normalize your normals. they still point exactly in the same direction afterwards.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #12
If you're using lighting, you need to normalize your normals. If you're not using lighting, you probably don't need normals at all Rasp
Quote this message in a reply
ghettotek
Unregistered
 
Post: #13
ok. if i dont enable lighting before i draw the model [Mesh3DS Display], then the model is all white. so there must be some relation between lighting and the texture on the models (not in OpenGL, but in the Mesh3DS framework). also, if i have GL_COLOR_MATERIAL enabled before i draw the model, its shaded..but its still white.
Quote this message in a reply
Mars_999
Unregistered
 
Post: #14
I have been told you need to calculate the normals for every model, and then set up lighting depending on whether the vertices are pre-lit or not. Hope that helps?
Quote this message in a reply
ghettotek
Unregistered
 
Post: #15
i dont think you get what im saying. i have no way of calculating normals because i cannot access the vertices in the model. all i can access is the model class' public methods. is there a way to automatically calculate normals for vertices drawn?
Quote this message in a reply
Post Reply