OpenGL collision detection - a thinking problem...?

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

Recommended Posts

Hi! I've started recently an adventure with opengl - with the nehe tutorial. I learned the basics quite fast - coz i had the theory at my highschool. My problem began with the collision detection. I think i have a thinkin' problem :) (wicked :P ) I have a "world" made of some "buildings" (simply cubes) and it should be sth like a FPS (means - FPP and mouselooking - but it doesn't matter ;) ) I draw the scene with this routine:
	for(int i = 0; i < 10; i++){
for(int j = 0; j < 10; j++){
glPushMatrix();
glTranslatef(float(areaSide * i), 0.0f, float(areaSide * j));
switch(map[j]){
case(0):{
glBindTexture(GL_TEXTURE_2D, texture[4]);
glCallList(grass);
break;
}
case(1):{
glBindTexture(GL_TEXTURE_2D, texture[filter]);
glCallList(mauer);
glBindTexture(GL_TEXTURE_2D, texture[3]);
glCallList(dach);
break;
}
case(2):{
glBindTexture(GL_TEXTURE_2D, texture[6]);
glCallList(strasse);
break;
}
}
glPopMatrix();
}

}


The collision detection will be made before this draw. I need therefore a data-structure where i store the vector and normal for the cubes for the ColDet check. Now i'm deliberating how to update that vectors after the transformations - have i to make it with a extra method transforming them manually or can i use the current modelview matrix to translate them... The next problem is - how do i model myself - a circle in the origin? ... The collision detection algorithms aren't the problem - i could find any good, matching, examples that show me the whole context. I would be thankfull if someone could close the right paths in my brain's neuron nets ;) Greets!

Share on other sites
ok, i see my post is a little bit confusing - it was late yesterday ;)

I simply want to know if i can transform somehow automatically my data-layer vectors, with the transformations stored in the MODELVIEW matrix, or have i to write new routines manually that perform that transformations on the data-layer vectors?

Is anybody understanding my problem? ^^

Greets,

rob

Share on other sites
Many people here (including me) suggest not to use the MODELVIEW matrix for tasks like the one you've asked for. Do it yourself.

The MODELVIEW matrix consists of two parts, the VIEW part and the MODEL part. The former one transforms geometrics from global space into view space, while the latter once transforms from local model space to global space.

Collision detection and correction is seldom done in view space. Often the global space is used (e.g. with simple bounding volumes) or in local space (e.g. if the mesh itself is used). Sometimes also a special collision space is used (e.g. for the sweeped sphere collision detection).

Due to this the MODELVIEW matrix as is wouldn't be appropriate at all.

If the project grows it is best to organize the scene in a kind known as "forward kinematics". That simply means something like to relate the position and orientation (i.e. the co-ordinate frame) of an object to a higher level object (this is in fact the beginning of a standard scene graph). Use these relations to do the collision stuff. Notice that the MODEL part of the MODELVIEW matrix in fact is build from exactly there frames, too.

EDIT: Ai, from Dortmund :) Just 30 kilometers away...

Share on other sites
thanks, and Aiii to Selm ;)

1. 1
2. 2
3. 3
Rutin
22
4. 4
frob
18
5. 5

• 33
• 13
• 10
• 10
• 11
• Forum Statistics

• Total Topics
632567
• Total Posts
3007113

×