Cast ray from object to determine where the ground is

Software: Away3D 4.x

Niclas Kjellberg, Newbie
Posted: 07 September 2012 05:08 PM   Total Posts: 2

Hi!

I’m having a problem with casting rays. I’m doing a simple project where I have a ground with different levels, and an object that will move around on the ground.

I’ve been looking at the Ray.getRayToTriangleIntersection() function. And here’s where I bump into problems.
So what I understand is that the first parameter is a vector3d with the position from where I wan’t to shoot the ray.
The second parameter is to where I want to shoot the ray, also a vector3d.
But what is the other three parameters? And what would I send to this function in my case?

I know where my object is, I know which direction I want to shoot. But I can’t wrap my head around the other three parameters I need to define.

Here’s the logic I’ve come up with so far.

var from:Vector3D object.position;
var 
to:Vector3D object.position;
to.-= 100;
var 
intersection:Vector3D Ray.getRayToTriangleIntersection(fromto, ?, ?, ? );
trace("intersection : " intersection); 

Would be very grateful for any help in the right direction.

Thanks!

 

   

Avatar
Fabrice Closier, Administrator
Posted: 07 September 2012 06:12 PM   Total Posts: 1265   [ # 1 ]

What about vertices forming a triangle?

   

Niclas Kjellberg, Newbie
Posted: 07 September 2012 06:52 PM   Total Posts: 2   [ # 2 ]

A triangle of what? Just a random triangle?

What is this triangle representing in that case?

   

Avatar
Fabrice Closier, Administrator
Posted: 07 September 2012 07:44 PM   Total Posts: 1265   [ # 3 ]

You say that you want to check a “ground mesh”, so I guess looping over a sceneTransformed vertices Vector representing this mesh in scenespace should do just fine…

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X