Raycasting and Terrain

SiWi

04-01-2008 17:06:40

Just some Basic questions.
When I do a raycast that hits an Terrainactor:
What do I get as result for the nearestActor?
Do I get the TerrainActor I created before or something before?
I ask this because of the following reason:
I create my TerrainActor with the name terrain. When I do a raycast later and ask for the closestActor, I get an Actor with the name Ground[...].

betajaen

04-01-2008 17:55:37

Theoretically you should get the terrain and the hit position. Terrain is pretty much like any other mesh-like shape to PhysX, so there isn't anything difference between the raycasts.

"Ground" is the name of the Actor with the GroundShape aka "floor: yes" in the Scene params. You should just compare pointers; which is faster and more reliable.

SiWi

05-01-2008 09:12:15

Ah, that´s wierd. When I turn off the floor now my Ray doesn´t return any actor.
My terrain is set up properly and this is the code I use for my raycasting:

Ray mouseRay = m_pCamera->getCameraToViewportRay(x, y);

m_pMouseRaycast = new RayCaster(mouseRay.getOrigin(), mouseRay.getDirection().normalisedCopy(), 100, RayCaster::RCT_CLOSEST, m_pScene);
m_pMouseRaycast->castShape(RayCaster::AF_NONE);

Actor *actor = m_pMouseRaycast->getClosestActor();


I take x,y from the position of my betagui cursor.

EDIT:
When I use getClosestRaycastHit, I get a result, but worldimpact is always the same, wherever i click.
Another question: Shouldn´t getClosestActor also return a Character´s Actor?

betajaen

05-01-2008 09:50:15

No, The Character's Actor is filtered out.

SiWi

05-01-2008 15:53:49

So is there another way to do raycasting with characters? Should I derive a class from the character class, that has another Actor?

betajaen

05-01-2008 18:18:02

The raycaster does do characters, there is a getNearestCharacter function is there not?

SiWi

05-01-2008 20:41:45

Sorry. :oops:
EDIT: I don´t want to make an extra thread about it, so 3 short questions:
1.When I create a Character with an Capsule Shape, I have to pass three arguments. Why? What do they stand for?
2. When I attach a Camera to a Character and I change the characters direction, the Camera also changes it´s direction somehow. How does the direction get changed exactly?
3. How do I know where the character will walk when I add Movement?
Are the movement directions relative to the Characters Direction?