load 3ds max models into opengl program
#21
Posted 22 February 2006 - 12:57 AM
Hope that can help me a lot...:yes:
A lot of thanks.:worthy: Your kindness is appreciated.
#22
Posted 22 February 2006 - 04:13 AM
I have sent the sample.
I hope you have recieved it...
#23
Posted 22 February 2006 - 07:05 AM
Regarding to the lib3ds, I had tried, but I blurrr with this
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
if (argc!=2) {
puts("***ERROR*** No 3DS file specified");
exit(1);
}
filename=argv[1];
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
And I blurrr with where to put the argument to load model.:sad:
Can someone kindly tell me about these? I'm so stuck.
Thanks a lot.
#24
Posted 22 February 2006 - 07:08 AM
Any other information are appreciated.
#25
Posted 22 February 2006 - 08:44 AM
class object{
public:
char name[20];
int numVerts,numPolys;
vertex v[3000];
polygon p[3000];
mapcoord m[3000];
vertex n[3000]; //the normals
};
//-----------------------------------------------------------------------------
// Name: DotProduct(vertex,vertex)
// Desc: Returns the dot product of two vertices
//-----------------------------------------------------------------------------
vertex DotProduct(vertex v1,vertex v2)
{
vertex final;
final.x=(v1.y*v2.z)-(v1.z*v2.y);
final.y=(v1.z*v2.x)-(v1.x*v2.z);
final.z=(v1.x*v2.y)-(v1.y*v2.x);
return final;
}
//-----------------------------------------------------------------------------
// Name: Normalize(vertex)
// Desc: Normalizes a vertex
//-----------------------------------------------------------------------------
vertex Normalize(vertex v)
{
vertex result=v;
float l;
l=(sqrt(v.x*v.x +v.y*v.y +v.z*v.z));;
if(l==0)l=1;
result.x/=l;
result.y/=l;
result.z/=l;
return result;
}
//-----------------------------------------------------------------------------
// Name: CalculateNormals(object *)
// Desc: Calculates the normals of an object
//-----------------------------------------------------------------------------
void CalculateNormals(object *o)
{
int i;
vertex v1,v2,v3,b1,b2,normal;
int con[3000];
for(i=0;i<o->numPolys;i++)
{
v1.x=o->v[o->p[i].a].x;
v1.y=o->v[o->p[i].a].y;
v1.z=o->v[o->p[i].a].z;
v2.x=o->v[o->p[i].b].x;
v2.y=o->v[o->p[i].b].y;
v2.z=o->v[o->p[i].b].z;
v3.x=o->v[o->p[i].c].x;
v3.y=o->v[o->p[i].c].y;
v3.z=o->v[o->p[i].c].z;
b1.x=v2.x-v1.x;
b1.y=v2.y-v1.y;
b1.z=v2.z-v1.z;
b2.x=v3.x-v1.x;
b2.y=v3.y-v1.y;
b2.z=v3.z-v1.z;
normal = DotProduct(b1,b2);
normal = Normalize(normal);
con[o->p[i].a]+=1;
con[o->p[i].b]+=1;
con[o->p[i].c]+=1;
o->n[o->p[i].a].x+=normal.x;
o->n[o->p[i].a].y+=normal.y;
o->n[o->p[i].a].z+=normal.z;
o->n[o->p[i].b].x+=normal.x;
o->n[o->p[i].b].y+=normal.y;
o->n[o->p[i].b].z+=normal.z;
o->n[o->p[i].c].x+=normal.x;
o->n[o->p[i].c].y+=normal.y;
o->n[o->p[i].c].z+=normal.z;
}
for (i=0;i<o->numVerts;i++)
{
if(con[i]>0)
{
o->n[i].x/=con[i];
o->n[i].y/=con[i];
o->n[i].z/=con[i];
}
}
}
#26
Posted 22 February 2006 - 02:26 PM
http://en.wikipedia...._line_interface
http://cplus.about.c...y/aa042902d.htm
http://www.google.com/
#27
Posted 22 February 2006 - 03:29 PM
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/Trial.exe : fatal error LNK1120: 1 unresolved externals
Is there any problem with lib?
Since I haven't put any texture in my model, thus I comment the segments of loading texture.
Well, my model is a house, and the house is build up with a number of polygons plus furnitures inside, will that a problem when loading it? And I'll have more houses in my project.
Thanks a lot for helping me.:worthy:
#28
Posted 22 February 2006 - 03:32 PM
#29
Posted 22 February 2006 - 05:01 PM
I forgot to tell you that all the geometry should be attached together.
As for the link error...I have never seen it. I use MVC++ 6. Did you use the .dsp file I provided? I had it linked to only these libs:
opengl32.lib glu32.lib glaux.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib
And if your model has more than 3000 polys,increase the array sizes in the object class.
#30
Posted 22 February 2006 - 06:27 PM
#31
Posted 23 February 2006 - 10:32 AM
Thanks.
#32
Posted 23 February 2006 - 10:36 AM
Well, can you tell me what're these about?
glutInit(&argc, argv);
if (argc!=2) {
puts("***ERROR*** No 3DS file specified");
exit(1);
}
filename=argv[1];
Thanks!!
#33
Posted 23 February 2006 - 10:46 AM
I'm here really appreciate the warmer hands from all of you.
As the time goes by, I really nervous and scare that I can't complete my project on time, as I can't even load a model into my openGL program. Well, I got 4 house models to be loaded, plus some furnitures inside the houses. :sad:
After loading models, I have to do navigation somemore, and the hardest part for me -- Collision Detection .:wacko:
So, really thanks you all for lending me your warmest hands. Hope to get more info or idea from you all during my project going on.
Really thanks a lot.:worthy:
#34
Posted 23 February 2006 - 12:49 PM
Do you want another sample made by me -- its all about collision detection and response ?
I am happy to know that you could compile it. But 90% of the times you won't
be able to see the models - if you randomly just send in a model with no planning. First, there is the scale factor. Your model could either be too small or too big. Second, your model could be far away from the origin. Make sure
its centres around 0,0,0.
My advice is to use the model I provided and use the exact gluLookAt coordinates in my original code.
Next, go to 3ds max and centre and scale your model so it resembles my box.
And then use your model in place of the box.
Didn't you see the box when you first compile and run the unaltered code ?
First use a simple model.Then move on to better things.
Note that everything should be attached together and be 1 object.
If you model has more than 3000 verts/polys increase the values in the object
class.
#35
Posted 23 February 2006 - 03:06 PM
And I'll check my model's coord and its centre.
Ya, the box is displayed while I compile your original code.
Somemore,you said that all geometry must be attached together become one object, but my model is house with some furniture inside, is it possible to do? Or maybe I can't what you mean...coz I more on coding part, and my partner is more on modeling.:wacko:
Thanks for your advices. I really appreciate it.
#36
Posted 23 February 2006 - 04:54 PM
There is nothing preventing you from exporting every object as a different file using export selected. Then importing every object differently. If the furniture are similar then you should load only the chair/table and scatter them around the house...
Remember that without any view transformations in opengl, the eye position will be at 3ds max's 0,0,0 and will be looking towards the z- axis. i.e. downward in 3ds max.
If you keep having trouble displaying your model, you could mail me your house model and I will transform it as required.
#37
Posted 23 February 2006 - 04:54 PM
chingching said:
Well, can you tell me what're these about?
glutInit(&argc, argv);
if (argc!=2) {
puts("***ERROR*** No 3DS file specified");
exit(1);
}
filename=argv[1];
Thanks!!
Chingching, there have already been several links posted in this thread that should enable you to figure out what the above does. argc and argv are references to the command-line arguments provided to the program. You have to execute the program from a command line like this (suppose the program is called 3dsview): 3dsview my3dsfile.3ds. This provides the filename "my3dsfile.3ds" as a command-line argument.
#38
Posted 24 February 2006 - 05:44 AM
#39
Posted 24 February 2006 - 05:44 AM
#40
Posted 24 February 2006 - 11:47 AM
chingching said:
Can someone kindly tell me about these? I'm so stuck.
Thanks a lot.
when you succuessfully compiled your model, open up a console and tyupe in the name of your executable, followed by your .3DS-file.
Alternatively, on windows, just drag-n-drop your 3DS-file onto the executable.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users












