# OpenGL collision detection - a thinking problem...?

## 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[i][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 ;)

## Create an account

Register a new account

• ## Partner Spotlight

• ### Forum Statistics

• Total Topics
627661
• Total Posts
2978496
• ### Similar Content

• Both functions are available since 3.0, and I'm currently using glMapBuffer(), which works fine.
But, I was wondering if anyone has experienced advantage in using glMapBufferRange(), which allows to specify the range of the mapped buffer. Could this be only a safety measure or does it improve performance?
Note: I'm not asking about glBufferSubData()/glBufferData. Those two are irrelevant in this case.
• By xhcao
Before using void glBindImageTexture(    GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format), does need to make sure that texture is completeness.
• By cebugdev
hi guys,
are there any books, link online or any other resources that discusses on how to build special effects such as magic, lightning, etc. in OpenGL? i mean, yeah most of them are using particles but im looking for resources specifically on how to manipulate the particles to look like an effect that can be use for games,. i did fire particle before, and I want to learn how to do the other 'magic' as well.
Like are there one book or link(cant find in google) that atleast featured how to make different particle effects in OpenGL (or DirectX)? If there is no one stop shop for it, maybe ill just look for some tips on how to make a particle engine that is flexible enough to enable me to design different effects/magic
let me know if you guys have recommendations.
• By dud3
How do we rotate the camera around x axis 360 degrees, without having the strange effect as in my video below?
Mine behaves exactly the same way spherical coordinates would, I'm using euler angles.
Tried googling, but couldn't find a proper answer, guessing I don't know what exactly to google for, googled 'rotate 360 around x axis', got no proper answers.

References:
Code: https://pastebin.com/Hcshj3FQ
The video shows the difference between blender and my rotation:

• By Defend
I've had a Google around for this but haven't yet found some solid advice. There is a lot of "it depends", but I'm not sure on what.
My question is what's a good rule of thumb to follow when it comes to creating/using VBOs & VAOs? As in, when should I use multiple or when should I not? My understanding so far is that if I need a new VBO, then I need a new VAO. So when it comes to rendering multiple objects I can either:
* make lots of VAO/VBO pairs and flip through them to render different objects, or
* make one big VBO and jump around its memory to render different objects.
I also understand that if I need to render objects with different vertex attributes, then a new VAO is necessary in this case.
If that "it depends" really is quite variable, what's best for a beginner with OpenGL, assuming that better approaches can be learnt later with better understanding?

• 10
• 12
• 22
• 13
• 33