Page 1 of 1

Ray Cast Terrain

Posted: Sun Sep 06, 2009 2:53 pm
by BoltonBeedz
Hi again. How are you?
i think i've got a bug or rounding issue on terrain. heres the gist of my code.

Code: Select all

        public static RayResult terrainray(Ray r, RayCastableContainerWithoutMargins terrain)
        {
            RayResult result = RayResult.Zero;
            terrain.rayCast(r.Position, r.Direction, 10000, 
                out result.hitEntity, out result.CollisionPos, 
                out result.normal, out result.time);

            //CONVERT NORMAL TO DECAL MATRIX
            result.CollisionMatrix = Matrix.Invert(Matrix.CreateLookAt(
                Vector3.Zero, result.normal, 
                new Vector3(1,0.9f,1))) 
                * Matrix.CreateTranslation(result.CollisionPos);

            return result;
        }
i'm putting a bullet hole onto a StaticTriangleGroup using this but the terrain doesn't work.
It just returns a non-collision
result.CollisionPos = {X:-3.402823E+38 Y:-3.402823E+38 Z:-3.402823E+38}
result.time = -9999.0
any ideas?

Re: Ray Cast Terrain

Posted: Sun Sep 06, 2009 4:47 pm
by Norbo
I'm unable to replicate the issue in v0.10.1. Does the terrain's position and ray's data match what you expect from the graphics?