You are hereForums / Papervision3D / Question and Answer / Hit Test inside a Cube

Hit Test inside a Cube


By taniss - Posted on 03 July 2008

Hello everybody!

I'm trying to build a game-like Scenario with an object ("player") inside a Room (Cube).

The thing is, when i use hitTestObject or hitTestPoint in order to tell when my character has hit a wall, the fact that hitTest is using a boundingSphere shape to calculate hits, is not allowing my character to get nowhere near none of the four corners of the room.

What I tried next to that, is using planes for walls (insted of just a simple cube). This looks much better, in fact, when trying to build more complex scenarios later on, it seems like the correct choice for achieving that.

The problem i am getting now is this:

taking one wall as target; even though my object is inside the cube, I noticed that hittest is giving true for that wall, but as soon as i get somewhere far that same wall (still being inside my "room"), hittest returns (unexplainably) false...

any directions on this??

any other way to resolve wall collision events?

thanks a lot.

Maybe you could make the room from 6 planes, not a cube..( ?? )

llike i said....

"What I tried next to that, is using planes for walls (insted of just a simple cube). This looks much better, in fact, when trying to build more complex scenarios later on, it seems like the correct choice for achieving that.

The problem i am getting now is this:

taking one wall as target; even though my object is inside the cube, I noticed that hittest is giving true for that wall, but as soon as i get somewhere far that same wall (still being inside my "room"), hittest returns (unexplainably) false..."

.. maybe the problem is that your object is not 'hitting' the wall..? Hittest only giving true if the object is hiiting that.. and what is your problem? I mean, what would you like to achive?

trying to build a "doom-like" scenario, allowing my character to walk through the whole room, without letting him step thru the walls, neither thru other objects...

of course, it would suffice to calculate using coords (the idea is to make it the most flexible as possible for creating new scenarios later on)

taniss, I am new to PV3d, but with shockwave 3d I never use the built in collision detection because of the boundingsphere issue ( like you suggested );

instead I use character position ( x , y , ignore z ) and check the distance in "front" of the character; ofcourse this is only possible because shockwave provides:

list_of_models = modelsUnderRay( ... , vector position , vector direction , ... )

where
list_of_models =
[
[ #model: model("modelA"), #distance: distanceA, ...] ,
[ #model: model("modelB"), #distance: distanceB, ...] ,
...
]

I am not far along enough with PV3d to know if it provides something like modelsUnderRay, but if so it might be the right way to go;

of course, it is limited because it is only modelsunder(ONE)ray which leaves all other directions unchecked;

dsdsdsdsd

taniss, I am new to PV3d, but with shockwave 3d I never use the built in collision detection because of the boundingsphere issue ( like you suggested );

instead I use character position ( x , y , ignore z ) and check the distance in "front" of the character; ofcourse this is only possible because shockwave provides:

list_of_models = modelsUnderRay( ... , vector position , vector direction , ... )

where
list_of_models =
[
[ #model: model("modelA"), #distance: distanceA, ...] ,
[ #model: model("modelB"), #distance: distanceB, ...] ,
...
]

I am not far along enough with PV3d to know if it provides something like modelsUnderRay, but if so it might be the right way to go;

of course, it is limited because it is only modelsunder(ONE)ray which leaves all other directions unchecked;

dsdsdsdsd

I fail to see how hitTestObject or hitTestPoint would be functional for 3D collision. Instead of testing against the walls try testing space beyond the walls.