Mardok
Member
|
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.
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 |
|
Esenthel
Administrator
|
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 |
|
Driklyn
Member
|
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 |
|
Mardok
Member
|
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
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
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 |
|
Mardok
Member
|
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?
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 |
|
Esenthel
Administrator
|
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 |
|
Mardok
Member
|
RE: Raycasting - Physics.ray
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:
|
|
12-29-2010 11:19 PM |
|
Esenthel
Administrator
|
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 |
|
Mardok
Member
|
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 |
|