Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void DrawMesh(Mesh mesh, int frame, Material mat, Vector3 position, Vector3 rotation, Vector3 scale,
- float morphFactor, Vector2 uv)
- {
- if(mesh != null)
- {
- Matrix matrix = Matrix.Identity;
- matrix *= Matrix.Scaling(scale) *
- Matrix.RotationY(rotation.Y * Mathf.DegToRad) *
- Matrix.RotationZ(rotation.Z * Mathf.DegToRad) *
- Matrix.RotationX(rotation.X * Mathf.DegToRad) *
- Matrix.Translation(position);
- if (mat.Flags.HasFlag(MaterialFlags.ShadowMesh))
- matrix *= Matrix.Shadow(new Vector4(0, 1, 1, 0), new Plane(new Vector3(0, 1, 0), 0.95f)); // Note: This is hardcoded. We should calculate mesh height by it's bounding box(not implemented yet)
- device.SetTransform(TransformState.World, matrix);
- SetRenderState(mat);
- if (mat.Flags.HasFlag(MaterialFlags.ShadowMesh))
- {
- SetShadowMeshState();
- }
- else
- {
- device.SetRenderState(RenderState.Lighting, !mat.NonLit);
- SetTextureState(mat);
- }
- bool lerpEnable = Game.Current.Config.GetBool("renderer.lerp");
- if (morphFactor > 0)
- {
- if (frame < mesh.Frames.Length && lerpEnable)
- {
- mesh.UpdateMorphTarget(frame, frame + 1, morphFactor);
- }
- }
- if (morphFactor > 0 && lerpEnable)
- device.DrawUserPrimitives<Vertex>(PrimitiveType.TriangleList, mesh.Frames[frame].Length / 3, mesh.MorphVerts);
- else
- device.DrawUserPrimitives<Vertex>(PrimitiveType.TriangleList, mesh.Frames[frame].Length / 3, mesh.Frames[frame]);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement