public override void Render()
        {
            PreRender();
            //Dibujar todo.
            //Una vez actualizadas las diferentes posiciones internas solo debemos asignar la matriz de world.
            mesh.Transform =
                TGCMatrix.Scaling(mesh.Scale)
                * TGCMatrix.RotationYawPitchRoll(mesh.Rotation.Y, mesh.Rotation.X, mesh.Rotation.Z)
                * TGCMatrix.Translation(mesh.Position);
            mesh.Render();
            //Actualmente los bounding box se actualizan solos en momento de hacer render, esto no es recomendado ya que trae overhead
            //Igualmente aqui podemos tener un objeto debug de nuestro mesh.
            mesh.BoundingBox.Render();

            box2.Transform =
                TGCMatrix.Scaling(box2.Scale)
                * TGCMatrix.RotationYawPitchRoll(box2.Rotation.Y, box2.Rotation.X, box2.Rotation.Z)
                * TGCMatrix.Translation(box2.Position);
            box2.Render();

            //Los bounding volume por la forma actual de framework no realizan transformaciones entonces podemos hacer esto:
            //D3DDevice.Instance.Device.Transform.World =
            //    TGCMatrix.Scaling(new TGCVector3(sphere.Radius, sphere.Radius, sphere.Radius))
            //                * TGCMatrix.Identity //No tienen sentido las rotaciones con la esfera.
            //                * TGCMatrix.Translation(sphere.Position);
            boundingSphere.Render();

            //Las mesh por defecto tienen el metodo UpdateMeshTransform que realiza el set por defecto.
            //Esto es igual que utilizar AutoTransform en true, con lo cual no es recomendado para casos complejos.
            meshObb.UpdateMeshTransform();
            meshObb.Render();
            //La implementacion de Obb por el momento reconstruye el obb debug siempre. Practica no recomendada.
            obb.Render();

            //triangulo
            D3DDevice.Instance.Device.Transform.World = TGCMatrix.Identity.ToMatrix();
            D3DDevice.Instance.Device.VertexFormat    = CustomVertex.PositionColored.Format;
            D3DDevice.Instance.Device.DrawUserPrimitives(PrimitiveType.TriangleList, 1, triangle);

            PostRender();
        }
Exemplo n.º 2
0
        public override void Render()
        {
            PreRender();
            //Dibujar todo.
            //Una vez actualizadas las diferentes posiciones internas solo debemos asignar la matriz de world.
            mesh.Transform = TGCMatrix.Scaling(mesh.Scale) *
                             TGCMatrix.RotationYawPitchRoll(mesh.Rotation.Y, mesh.Rotation.X, mesh.Rotation.Z) *
                             TGCMatrix.Translation(mesh.Position);
            mesh.Render();
            //Actualmente los bounding box se actualizan solos en momento de hacer render, esto no es recomendado ya que trae overhead
            //Igualmente aqui podemos tener un objeto debug de nuestro mesh.
            mesh.BoundingBox.Render();

            box2.Transform = TGCMatrix.Scaling(box2.Scale) *
                             TGCMatrix.RotationYawPitchRoll(box2.Rotation.Y, box2.Rotation.X, box2.Rotation.Z) *
                             TGCMatrix.Translation(box2.Position);
            box2.Render();

            boundingSphere.Render();

            //Las mesh por defecto tienen el metodo UpdateMeshTransform que realiza el set por defecto.
            meshObb.Transform = TGCMatrix.Scaling(meshObb.Scale) *
                                TGCMatrix.RotationYawPitchRoll(meshObb.Rotation.Y, meshObb.Rotation.X, meshObb.Rotation.Z) *
                                TGCMatrix.Translation(meshObb.Position);
            meshObb.Render();

            //La implementacion de Obb por el momento reconstruye el obb debug siempre. Practica no recomendada.
            obb.Render();

            //triangulo
            D3DDevice.Instance.Device.Transform.World = TGCMatrix.Identity.ToMatrix();
            D3DDevice.Instance.Device.VertexFormat    = CustomVertex.PositionColored.Format;
            D3DDevice.Instance.Device.DrawUserPrimitives(PrimitiveType.TriangleList, 1, triangle);

            PostRender();
        }
 public void Render(float tiempo)
 {
     OBB.setRotation(TGCVector3.Multiply(vRotacionOBB, tiempo));
     OBB.Render();
 }