www.jpct.net

jPCT-AE - a 3d engine for Android => Support => Topic started by: Uncle Ray on September 01, 2014, 06:46:31 am

Title: question?why checkForCollision worked only single side?
Post by: Uncle Ray on September 01, 2014, 06:46:31 am
SOLVED THX EGO

1.
             │
         →→ │→→→→→→→→Passed
            │
The checkforcollision is not worked,pass through the plane   



2.                   

                 │
stoped       │←←←←
                  │
The checkforcollision worked,everyththing is work.



what is wrong,anyone can tell me how to solved it,thanks.             
Title: Re: question?why checkForCollision worked only single side?
Post by: EgonOlsen on September 01, 2014, 07:40:47 am
The collision detection methods don't work on back faces. If you need this behaviour, you have to use separate objects (one normal, one inverted) at least during the collision detection stage (you might want to set the inverted object to invisible in the render stage).
Title: Re: question?why checkForCollision worked only single side?
Post by: Uncle Ray on September 01, 2014, 08:20:01 am
but when object set invisible,all collision method will never work.
because all the collision_detect  without calmindistance(the only which can detect invisible object)
can not detect invisible object.
Title: Re: question?why checkForCollision worked only single side?
Post by: EgonOlsen on September 01, 2014, 08:34:34 am
It doesn't matter if it's visible during rendering or not. It only matters what's visible when doing the collision detection. So you can add "collision objects" to the world that won't be rendered but used for collision detection only by altering their visibility between the two operations.
Title: Re: question?why checkForCollision worked only single side?
Post by: Uncle Ray on September 02, 2014, 04:40:07 am
sorry,i am not clear got it.how to add "collision objects" to the world that won't be rendered ?

Title: Re: question?why checkForCollision worked only single side?
Post by: Uncle Ray on September 02, 2014, 04:44:03 am
is that createDummyObj?
Title: Re: question?why checkForCollision worked only single side?
Post by: EgonOlsen on September 02, 2014, 09:19:31 am
No, there are just regular objects. In your case, it would be a copy of your plane that is inverted. For example by calling invert(). It sits in the same location as the normal plane. In your case, you might not even have to deal with visibility because it might be feasible to let the plane visible all the time. But that depends on your scene. What are you using that plane for and has culling been disabled on it?
Title: Re: question?why checkForCollision worked only single side?
Post by: Uncle Ray on September 02, 2014, 09:37:18 am
In my scene,i creat a car racing game,this plane is used for fense,i want it to be invsible,and keep the collition-detect,let the car runing in the track rightly.
how to make a invisble object ues the collide_detect(i know the calmindistance is ok,but others....)
Title: Re: question?why checkForCollision worked only single side?
Post by: EgonOlsen on September 02, 2014, 11:16:51 am
If it's a fence, just build it in a way that it is two sided and you don't have to deal with visibility at all. You can't detect collisions on invisible objects...i guess, i'm still not clear enough on what i mean. It's basically this: You render one set of objects and you detect collisions on another one. There's no magic method that deals with this, you have to do this in your own code. I usually do it this way:


However, i don't think that this will be needed in your case. Just make a two sided model out of your fence (i.e. visible from both sides) and you are good to go.
Title: Re: question?why checkForCollision worked only single side?
Post by: Uncle Ray on September 02, 2014, 04:45:55 pm
I know your means,two objects set in the same place but  opposite backface(which is depended on opengl rendering clockwise or counterclockwise)

Here is my question
1.collide two sides?
your suggestion is right,the problem is solved.Thx,ego.

2.invisible object collide?
you said in jpct collide with invisible object was impossible.

Here is my idea:
could i bounding a texture which is transparent with the object.
Although the object setvisible(true),but it's texture is transparent,in fact we can't see the object.   

Is this the best method for the invisible object collide detect?
or,if there is better method,could your tell me how,
 i dont want the detailed code,just the thought.

At last,thank ego again.for your huge help with me.
 
Title: Re: question?why checkForCollision worked only single side?
Post by: Uncle Ray on September 02, 2014, 07:25:04 pm
I found the second solution,if i want the "A" invisible and collideable,here is the code:

{
Object3D A;
A.setTransparency(0);
Config.glTransparencyOffset=0;
}

it's perfect,invisible,and all the collide method are worked.
last question,is there a better solution for invisible and colideable?
Title: Re: question?why checkForCollision worked only single side?
Post by: EgonOlsen on September 03, 2014, 09:22:45 am
You could do that, but it causes additional overhead when rendering the scene. It might not be noticable though.
Title: Re: question?why checkForCollision worked only single side?
Post by: Uncle Ray on September 03, 2014, 11:14:50 am
Thx,is there a better solution for invisible collide?

Title: Re: question?why checkForCollision worked only single side?
Post by: EgonOlsen on September 03, 2014, 12:09:56 pm
Yes...just what i said multiple times before: Alter the visibility between rendering and collision detection. In your case, set the transparent plane to invisible during rendering and you'll save the additional render cycles for processing it.