About Store Forum Documentation Contact



Post Reply 
Raycasting - Physics.ray
Author Message
Mardok Offline
Member

Post: #1
Raycasting - Physics.ray
I test Raycasting and I have strange problem. Please look at screens and check value of COLLIDE variable. It always should be zero(0) because ray nothing hit. I think...

When I turning my Chr 360 deg in some points Rays detect something and variable "collide" is set to 1 but why Rays detect something, since there is nothing there?

All my 6 objects is far away from my Chr.

[Image: 73734044.jpg]
[Image: 51092796.jpg]
[Image: 19075907.jpg]

Code:
OrientP &head = cskel.getPoint("Head");
    start = head.pos + Vec(0,1,0);
      end = start + head.dir*3;
      
    if(Physics.ray(start, end, &phys_hit)) collide = true; else collide = false; //if ray hit something
[/code]
12-28-2010 11:42 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #2
RE: Raycasting - Physics.ray
// if ray cuts with any actor on the scene ('groups'=group flag (ACTOR_GROUP) bit combination specifying which groups should be included in testing, use 'IndexToFlag' function)
static Bool ray(C Vec &pos, C Vec &move

move=delta and not target destination
12-29-2010 01:38 AM
Find all posts by this user Quote this message in a reply
Driklyn Offline
Member

Post: #3
RE: Raycasting - Physics.ray
You can draw where the collision is occurring to better visualize what is happening.

Code:
if(Physics.ray(start, end, &phys_hit, ~IndexToFlag(AG_TERRAIN))) { // ignore terrain
    D.dot(RED, phys_hit.plane.pos, 0.003);
    collide = true;
} else {
    collide = false; //if ray hit something
}

Also, to elaborate more on what Esenthel said about 'move' being a delta and not a target, simply remove the "start +" from the 'end' position.
12-29-2010 06:30 AM
Find all posts by this user Quote this message in a reply
Mardok Offline
Member

Post: #4
RE: Raycasting - Physics.ray
(12-29-2010 01:38 AM)Esenthel Wrote:  static Bool ray(C Vec &pos, C Vec &move
move=delta and not target destination

Of course...

&move = delta and not target destination

I missed it in a hurry and fatigue wink

When i swapped:
Code:
OrientP &head = cskel.getPoint("Head");
            
            start = head.pos + Vec(0,1,0);
              end = start + head.dir*5;

if(Physics.ray(start, end, &phys_hit, ~Inde
on
Code:
if(Physics.ray(start, end-start, &phys_hit, ~Inde

It's work correct smile

Sorry for the confusion and thank you for your help.
This thread was helpful also http://www.esenthel.com/community/showth...ht=PhysHit
(This post was last modified: 12-29-2010 11:17 AM by Mardok.)
12-29-2010 11:11 AM
Find all posts by this user Quote this message in a reply
Mardok Offline
Member

Post: #5
RE: Raycasting - Physics.ray
I have yet one little question about Face Index.
Please check this picture, there is " Face: Ind " - and tell me why Ind doesn't show index value of selected face?

[Image: turret.jpg]

Why it is not showing the number of face index, but only " Ind " ?
Can i set Face Index manually? On example: index of all faces is set to 1 ? Is it possible?

I would like use PhysHit::face...

I need this because i need more precision in collision detection.

When I'm testing ground using Rays then PhysHit::face return to me correct values, but if i set Ray on mesh then PhysHit::face is always 0 :(
12-29-2010 10:15 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #6
RE: Raycasting - Physics.ray
Face:Ind on the image is something else (those are indexes of vertexes)

Quote:PhysHit::face is always 0
which method are you using?
what is the physical body?
12-29-2010 10:25 PM
Find all posts by this user Quote this message in a reply
Mardok Offline
Member

Post: #7
RE: Raycasting - Physics.ray
[Image: 28236589.jpg]

[Image: 63894816.jpg]

[Image: 85453764.jpg]

[Image: 85116108.jpg]

When I look on car collision is detected okay, but phys_hit.face is 0 why?
Code:
Physics.ray(start, end-start, &phys_hit, ~IndexToFlag(AG_CONTROLLER));
PhysBody:
[Image: 34999644.jpg]
12-29-2010 11:19 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #8
RE: Raycasting - Physics.ray
If it's a box then it doesn't have face indexes.

you need to use other method, like detect distance between player and door (for example using Skeleton Point)
12-31-2010 03:38 AM
Find all posts by this user Quote this message in a reply
Mardok Offline
Member

Post: #9
RE: Raycasting - Physics.ray
Thank You for explain.
I did like You said and I'm happy... all works fine ;]
01-01-2011 06:22 PM
Find all posts by this user Quote this message in a reply
Post Reply