Exemplo n.º 1
0
        void DebugBones(Matrix4d viewproj, Matrix4d parentmodel, Matrix4x4[] transforms)
        {
            if (Globals.RenderPass != Globals.eRenderPass.ShadowDepth)
            {
                GL.Clear(ClearBufferMask.DepthBufferBit);

                Vector3d v  = Globals.Avatar.GetPosition();
                Vector3d v1 = Vector3d.Zero;
                Vector3d v2 = Vector3d.Zero;

                // _debug.UserColorCoding = true;
                Matrix4 test = Matrix4.CreateTranslation(0, 0.5f, 0);
                float   f    = 0;
                for (int i = 0; i < m_bone_matrices.Count; i++)
                {
                    //(MBone b in Bones)

                    f += 0.1f;
                    v1 = v2;
                    v2 = MassiveTools.Vector3dFromVector3(
                        TKMatrix(transforms[i]).ExtractTranslation()
                        );

                    Vector3d r1 = v1 + v;
                    Vector3d r2 = v2 + v;
                    // _debug.DrawLine(ref r1, ref r2, i == 0 ? OpenTK.Graphics.Color4.Red : OpenTK.Graphics.Color4.White);
                }

                // _debug.Render(viewproj, parentmodel);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="pt">an x z index to a vertex (0-255)</param>
        /// <returns></returns>
        public Vector3d GetPointOnSurfaceFromGrid(Vector3d grid)
        {
            int index = (int)(grid.Z * z_res + grid.X);

            if (index >= Vertices.Length)
            {
                index = 0;
            }
            if (index < 0)
            {
                index = 0;
            }

            Vector3d pi = MassiveTools.Vector3dFromVector3(Vertices[index]._position);

            //Vector3d zpl = Vector3d.Lerp(Boundary.TL, Boundary.BL, pt.Z);
            //Vector3d zpr = Vector3d.Lerp(Boundary.TR, Boundary.BR, pt.Z);
            //Vector3d p = Vector3d.Lerp(zpr, zpl, pt.X ) - transform.Position;
            return(pi);
        }
Exemplo n.º 3
0
        void ApplyHeightMap()
        {
            //Random r = new Random(123);
            int    i = 0;
            double d = z_res / (z_res + 1);

            for (int y = 0; y < z_res; y++)
            {
                //for (int x = -x_res / 2; x < x_res / 2; x++)
                for (int x = 0; x < x_res; x++)
                {
                    int      pos    = y * x_res + x;
                    float    height = HeightColorToHeight(x, y);
                    Vector3d normal = MassiveTools.Vector3dFromVector3(Vertices[i]._position) + transform.Position - CurrentBody.Position;
                    normal.Normalize();
                    Vertices[i]._position += MassiveTools.Vector3FromVector3d(normal) * height;
                    Vertices[i]._normal    = MassiveTools.Vector3FromVector3d(normal);
                    heights[x, y]          = height;
                    ///Vertices[i]._position.Y = HeightColorToHeight(x, y);
                    i++;
                }
            }
        }