/// <summary> /// Convert a Openmetaverse.Primitive to a PrimMesh /// </summary> /// <param name="thePrim"></param> /// <param name="detail"></param> /// <param name="pos"></param> /// <param name="rot"></param> /// <returns></returns> public PrimMesh PrimitiveToPrimMesh(Primitive thePrim, LevelOfDetail detail, Vector3 Scale, Quaternion rot) { bool UseExtremeDetail = Scale.X + Scale.Y + Scale.Z > UseExtremeDetailSize; PrimMesh mesh = ConstructionDataToPrimMesh(thePrim.PrimData, detail, UseExtremeDetail ? 2 : 1); #if COLLIDER_ODE mesh.PBS = PrimToBaseShape(thePrim); #endif mesh.Scale(Scale.X, Scale.Y, Scale.Z); // if (rot != Quaternion.Identity) mesh.AddRot(QuaternionToQuat(rot)); return(mesh); }
public Mesh PrimitiveToMesh(Primitive primitive, Vector3 Scale, Quaternion rot) { bool wasSculpt = primitive.Sculpt != null; if (wasSculpt && WorldPathSystem.SculptCollisions) { Primitive.SculptData SD = primitive.Sculpt; UUID Id = SD.SculptTexture; SculptMesh SM; if (!SculptedMeshes.TryGetValue(Id, out SM)) { byte[] bytes = WorldObjects.GridMaster.TextureBytesForUUID(SD.SculptTexture); SM = ToSculptMesh(bytes, primitive.Sculpt, "" + primitive); if (MaintainSculptPool) { SculptedMeshes[Id] = SM; } // SM.DumpRaw(".", primitive.ID.ToString(), "sculptMesh" + primitive.LocalID); } if (SM != null) { SM = SM.Copy(); SM.Scale(Scale.X, Scale.Y, Scale.Z); SM.AddRot(QuaternionToQuat(rot)); return(ToMesh( #if COLLIDER_ODE PrimToBaseShape(primitive), #endif SM.coords, SM.faces, SM.viewerFaces, primitive.Type == PrimType.Sphere)); } } this.scaleSize = Scale.X + Scale.Y + Scale.Z; bool UseExtremeDetail = scaleSize > UseExtremeDetailSize; //LevelOfDetail detail; if (scaleSize < UseLowDetailSize) { detail = LevelOfDetail.Low; } else { detail = LevelOfDetail.Medium; } if (UseExtremeDetail) { if (primitive.Type == PrimType.Box) { detail = LevelOfDetail.Medium; } else { detail = LevelOfDetail.High; } } PrimMesh primMesh = ConstructionDataToPrimMesh(primitive.PrimData, detail, UseExtremeDetail ? 2 : 1); primMesh.Scale(Scale.X, Scale.Y, Scale.Z); primMesh.AddRot(QuaternionToQuat(rot)); Mesh m = PrimMeshToMesh(primMesh); #if COLLIDER_ODE m.PBS = PrimToBaseShape(primitive); #endif return(m); }