void RenderPrim(RenderPrimitive mesh, RenderPass pass, int primNr)\r
{\r
Primitive prim = mesh.Prim;\r
- RenderPrimitive parent = null;\r
- RenderAvatar parentav = null;\r
-\r
- if (prim.ParentID != 0 && !Prims.TryGetValue(prim.ParentID, out parent) && !Avatars.TryGetValue(prim.ParentID, out parentav)) return;\r
\r
// Don't render objects too small to matter\r
if (LODFactor(mesh.DistanceSquared, prim.Scale, mesh.BoundingVolume.R) < minLODFactor) return;\r
// Individual prim matrix\r
GL.PushMatrix();\r
\r
- //TODO we really need a scene graph but for the moment simple if/else logic checks and parent finding are used\r
- if (prim.ParentID != 0) // Does this prim have a parent\r
- {\r
- if (parent != null) // Check the parent is valid\r
- {\r
- if (parent.Prim.ParentID != 0) // Does the parent have a parent? if so it must be an avatar \r
- {\r
- if (Avatars.TryGetValue(parent.Prim.ParentID, out parentav)) // Get the parent avatar\r
- {\r
- // Child prims of parents that have avatar as parent\r
-\r
- if (prim.PrimData.AttachmentPoint >= AttachmentPoint.HUDCenter2 && prim.PrimData.AttachmentPoint <= AttachmentPoint.HUDBottomRight)\r
- {\r
- // Child HUD elements\r
- }\r
- else\r
- {\r
- //This is a child prim attachment\r
-\r
- // Apply prim translation and rotation relative to the root prim\r
- GL.MultMatrix(Math3D.CreateTranslationMatrix(parentav.avatar.Position));\r
- GL.MultMatrix(Math3D.CreateRotationMatrix(parentav.avatar.Rotation));\r
-\r
- int attachment_index = (int)parent.Prim.PrimData.AttachmentPoint;\r
- if (attachment_index > GLAvatar.attachment_points.Count())\r
- {\r
- // invalid LL attachment point\r
- return;\r
- }\r
-\r
- attachment_point apoint = GLAvatar.attachment_points[attachment_index];\r
-\r
- Vector3 point = parentav.glavatar.skel.getOffset(apoint.joint) + apoint.position;\r
- Quaternion qrot = parentav.glavatar.skel.getRotation(apoint.joint) * apoint.rotation;\r
- //Vector3 point = Bone.getOffset(apoint.joint) + apoint.position;\r
- // Quaternion qrot = Bone.getRotation(apoint.joint) * apoint.rotation;\r
-\r
- GL.MultMatrix(Math3D.CreateTranslationMatrix(point));\r
- GL.MultMatrix(Math3D.CreateRotationMatrix(qrot));\r
-\r
- // Apply prim translation and rotation relative to the root prim\r
- GL.MultMatrix(Math3D.CreateTranslationMatrix(parent.Prim.Position));\r
- GL.MultMatrix(Math3D.CreateRotationMatrix(parent.Prim.Rotation));\r
- }\r
- }\r
- }\r
- else // This prims parent does not have a parent there for its a regular prim and this must be its child\r
- {\r
- // Regular child prim\r
- // Apply prim translation and rotation relative to the root prim\r
- GL.MultMatrix(Math3D.CreateTranslationMatrix(parent.Prim.Position));\r
- GL.MultMatrix(Math3D.CreateRotationMatrix(parent.Prim.Rotation));\r
- }\r
- }\r
- else // This prim has a parent but does not have a parent in the ObjectsList, its parent is therefor parentav from the avatars list \r
- {\r
- //Root prims with avatar as parent\r
-\r
- if (prim.PrimData.AttachmentPoint >= AttachmentPoint.HUDCenter2 && prim.PrimData.AttachmentPoint <= AttachmentPoint.HUDBottomRight)\r
- {\r
- // Root HUD elements\r
- }\r
- else\r
- {\r
- // Root attachments\r
-\r
- // Apply prim translation and rotation relative to the root prim\r
- GL.MultMatrix(Math3D.CreateTranslationMatrix(parentav.avatar.Position));\r
- GL.MultMatrix(Math3D.CreateRotationMatrix(parentav.avatar.Rotation));\r
-\r
- int attachment_index = (int)prim.PrimData.AttachmentPoint;\r
- if (attachment_index > GLAvatar.attachment_points.Count())\r
- {\r
- // invalid LL attachment point\r
- return;\r
- }\r
-\r
- attachment_point apoint = GLAvatar.attachment_points[attachment_index];\r
-\r
- //Vector3 point = Bone.getOffset(apoint.joint) + apoint.position;\r
- //Quaternion qrot = Bone.getRotation(apoint.joint) * apoint.rotation;\r
- Vector3 point = parentav.glavatar.skel.getOffset(apoint.joint) + apoint.position;\r
- Quaternion qrot = parentav.glavatar.skel.getRotation(apoint.joint) * apoint.rotation;\r
-\r
- GL.MultMatrix(Math3D.CreateTranslationMatrix(point));\r
- GL.MultMatrix(Math3D.CreateRotationMatrix(qrot));\r
- }\r
- }\r
- }\r
-\r
-\r
// Prim roation and position\r
- GL.MultMatrix(Math3D.CreateTranslationMatrix(prim.Position));\r
- GL.MultMatrix(Math3D.CreateRotationMatrix(prim.Rotation));\r
+ GL.MultMatrix(Math3D.CreateTranslationMatrix(mesh.SimPosition));\r
+ GL.MultMatrix(Math3D.CreateRotationMatrix(mesh.SimRotation));\r
\r
// Prim scaling\r
GL.Scale(prim.Scale.X, prim.Scale.Y, prim.Scale.Z);\r