Slight Issue

Started by
14 comments, last by xytor 13 years, 6 months ago
Quote:Original post by Buckeye

The line aabbCollision==false appears to be comparing the address of the function to the value for false. Since the address of the function is greater than 0 and false is probably defined as 0, "aabbCollision==false" is always false and Forward never gets called.

Try calling the function:

if( !aabbCollision( Box, Box1 ) ) Forward(5);

I don't know what IDE you're using, but you need to learn how to debug by setting breakpoints in your code (as suggested), outputting messages to a debug window, etc.


Thankyou for the advice[highly appreciated], but whats causing the statements to always return true is a mystery to me at this moment[Debug:It breaks if the first condition is true with every other statement in the collision detection so something is wrong. I corrected my statement to the suggested line you gave above but no success.

The only thing I am unsure I maybe missed is updating the current positions of the AABB's relative to the current position of the objects in 3d space? For example, My objects are drawn in a certain location, will that mean AABB's are calculated but drawn to the exact same location or will no matter what they will be drawn to the same location as the object it relates to?<br><br>I do believe what I have shown you guys already is &#111;n the right track, but I'm no expert which is why I brought my issue to you guys. <br><br>I don't want to irritate people &#111;n this forum, but I'm struggling to see what I'm missing or incorrectly doing. [3d] &#79;ne static object and &#111;ne dynamic object moving with the camera's movement, when hit they have a collision, for this example I'm testing, the user can no longer move forward if that is the case. <br><br>I have examined the Axis-Aligned BoundingBox articles related to C++ etc, found a few books &#111;nline showing similar construction, it's not that I have done lack of research &#111;n this topic, as I'm beginning to find it quite frustrating as to why it's giving undesired result. <br><br><br>
Advertisement
I assume you remove your code and don't post your fixes because you are afraid somebody will steal it. Don't worry; most of us who will help you can write what you are trying to do in a half hour.

My point is, don't be shy about posting your code for every post. If it's in source tags, it will only help us help you.

I can only guess you're not translating the box properly...
Quote:Original post by xytor
I assume you remove your code and don't post your fixes because you are afraid somebody will steal it. Don't worry; most of us who will help you can write what you are trying to do in a half hour.

My point is, don't be shy about posting your code for every post. If it's in source tags, it will only help us help you.

I can only guess you're not translating the box properly...


Would probably take one of you guys to do what Im trying to accomplish in 10minutes :d.

Yeh I apologise, just assumed since I turned my last post into a more unrelated question to my code it wasn't of much use since you had previously checked it.

I will post again, but this time I had a slight development with the OnCollision - It appeared when debugging, the values it was comparing, since the max values had been a negative value it would produce some unwanted results which made the OnCollision always to be true.

I've since fixed that problem by switching some statements(needs to be checked though tbh as its probably a dirty runaround), but now I'm stuck with actually translating the AABB's like you have geussed. I'm unsure of what I have is correct because the OnCollision is checking the current static V-array with one another but doesn't take into account the translated world position of the objects... which I'm having trouble with. This part I can't seem to find in any books/webpages regarding this. Any guidance is welcomed a lot.



[Edited by - Silarr on October 26, 2010 7:57:30 AM]
Your AABB needs to change each frame.

Since you store it as a min and a max, you need to translate those every frame and check collision on the AABBs only.

When you are creating your AABBs, you have a for loop but you don't use i anywhere.

By the way, please don't change your code for the post only. That makes reading it very difficult.

For example, you have two functions called AABB. Also, I cant tell if the high level design sucks because you changed the code for the post or not.
I have made some progress but something is slightly incorrect and can't figure out what's causing it.

For some reason my objects are instantly colliding with themselves, well the AABB is colliding with the object it's surrounding. I tested that if I '+' the AABB surrounding the object in any direction e.g. Z-Axis, my collision is no longer true and I can move once the AABB leaves the object, but when I move the AABB back to touching the object it collides. This all happens without ever touching object #2 far away with its own AABB.

I don't believe I require translation because the AABB's co-ordinates are the objects - If I translate the object, the AABB moves with it no matter what.

I used this to move the AABB outside of the object it's surrounding vice-versa:
 	if (key == 'z'){glPushMatrix();				glTranslatef(Box.max.z -=0.1f);				glTranslatef(Box.min.z -=0.1f);              			glPopMatrix();}	if (key == 'x'){glPushMatrix();				glTranslatef(Box.max.z +=0.1f);				glTranslatef(Box.min.z +=0.1f);              			glPopMatrix();}



I'm puzzled!, The code used is in the previous post and I can't really see whats causing the AABB to collide with the object its encompassing. I'm not trying to do something advanced here, just basic collision...
How are you even getting that to compile? Doesn't glTranslatef take 3 floats?

At this point, I would suggest a better high-level design. For example, try to separate graphics from game code.

Either that, or post your whole entire code so that we can compile and run it ourselves and see what's happening.

This topic is closed to new replies.

Advertisement