public IMesh CreateMesh (string primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical, bool shouldCache)
        {
            // Remove the reference to the encoded JPEG2000 data so it can be GCed
            primShape.SculptData = Utils.EmptyBytes;

            return null;
        }
        public BSPrim(uint localID, String primName, BSScene parent_scene, OMV.Vector3 pos, OMV.Vector3 size,
            OMV.Quaternion rotation, PrimitiveBaseShape pbs, bool pisPhysical)
            : base(parent_scene, localID, primName, "BSPrim")
        {
            // MainConsole.Instance.DebugFormat("{0}: BSPrim creation of {1}, id={2}", LogHeader, primName, localID);
            _position = pos;
            _size = size;
            Scale = size;   // prims are the size the user wants them to be (different for BSCharactes).
            _orientation = rotation;
            _buoyancy = 0f;
            RawVelocity = OMV.Vector3.Zero;
            _rotationalVelocity = OMV.Vector3.Zero;
            BaseShape = pbs;
            _isPhysical = pisPhysical;
            _isVolumeDetect = false;

            // We keep a handle to the vehicle actor so we can set vehicle parameters later.
            VehicleActor = new BSDynamics(PhysicsScene, this, VehicleActorName);
            PhysicalActors.Add(VehicleActorName, VehicleActor);

            _mass = CalculateMass();

            // DetailLog("{0},BSPrim.constructor,call", LocalID);
            // do the actual object creation at taint time
            PhysicsScene.TaintedObject("BSPrim.create", delegate()
            {
            // Make sure the object is being created with some sanity.
            ExtremeSanityCheck(true /* inTaintTime */);

            CreateGeomAndObject(true);

            CurrentCollisionFlags = PhysicsScene.PE.GetCollisionFlags(PhysBody);
            });
        }
        public BSPrimLinkable(uint localID, String primName, BSScene parent_scene, OMV.Vector3 pos, OMV.Vector3 size,
            OMV.Quaternion rotation, PrimitiveBaseShape pbs, bool pisPhysical, int material, float friction,
            float restitution, float gravityMultiplier, float density)
            : base(localID, primName, parent_scene, pos, size, rotation, pbs, pisPhysical)
        {
            // Default linkset implementation for this prim
            LinksetType = (BSLinkset.LinksetImplementation)BSParam.LinksetImplementation;

            Linkset = BSLinkset.Factory(PhysicsScene, this);
            if (Linkset != null)
                Linkset.Refresh(this);
        }
Example #4
0
        protected SceneObjectPart CreateSceneObjectPart2()
        {
            string             partName       = "Action Man";
            UUID               ownerId        = UUID.Parse("00000000-0000-0000-0000-000000000016");
            PrimitiveBaseShape shape          = PrimitiveBaseShape.CreateCylinder();
            Vector3            groupPosition  = new Vector3(90, 80, 70);
            Quaternion         rotationOffset = new Quaternion(60, 70, 80, 90);

            rotationOffset.Normalize();
            Vector3 offsetPosition = new Vector3(20, 25, 30);

            return(new SceneObjectPart(ownerId, shape, groupPosition, rotationOffset, offsetPosition)
            {
                Name = partName
            });
        }
Example #5
0
        protected SceneObjectPart CreateSceneObjectPart1()
        {
            string             partName       = "My Little Pony";
            UUID               ownerId        = UUID.Parse("00000000-0000-0000-0000-000000000015");
            PrimitiveBaseShape shape          = PrimitiveBaseShape.CreateSphere();
            Vector3            groupPosition  = new Vector3(10, 20, 30);
            Quaternion         rotationOffset = new Quaternion(20, 30, 40, 50);

            rotationOffset.Normalize();
//            Vector3 offsetPosition = new Vector3(5, 10, 15);

            return(new SceneObjectPart(ownerId, shape, groupPosition, rotationOffset, Vector3.Zero)
            {
                Name = partName
            });
        }
Example #6
0
        public static Mesh ToMesh(
#if (COLLIDER_ODE)
            PrimitiveBaseShape pbs,
#endif
            List <Coord> coords, List <Face> faces, List <ViewerFace> viewerFaces, bool isSphere)
        {
            Mesh mesh = new Mesh(

#if COLLIDER_ODE
                pbs
#endif

                );

            int numCoords = coords.Count;
            int numFaces  = faces.Count;

            for (int i = 0; i < numCoords; i++)
            {
                Coord c = coords[i];
                mesh.vertices.Add(new Vertex(c.X, c.Y, c.Z));
            }

            List <Vertex> vertices = mesh.vertices;

            for (int i = 0; i < numFaces; i++)
            {
                Face f = faces[i];
                mesh.triangles.Add(new Triangle(vertices[f.v1], vertices[f.v2], vertices[f.v3]));
            }
            if (UseViewerMode && viewerFaces != null)
            {
                int numViewerFaces = viewerFaces.Count;
                for (uint i = 0; i < numViewerFaces; i++)
                {
                    ViewerFace vf = viewerFaces[(int)i];

                    if (isSphere)
                    {
                        vf.uv1.U = (vf.uv1.U - 0.5f) * 2.0f;
                        vf.uv2.U = (vf.uv2.U - 0.5f) * 2.0f;
                        vf.uv3.U = (vf.uv3.U - 0.5f) * 2.0f;
                    }
                }
            }
            return(mesh);
        }
Example #7
0
        public BSPrimLinkable(uint localID, String primName, BSScene parent_scene, OMV.Vector3 pos, OMV.Vector3 size,
                              OMV.Quaternion rotation, PrimitiveBaseShape pbs, bool pisPhysical, int material, float friction,
                              float restitution, float gravityMultiplier, float density)
            : base(localID, primName, parent_scene, pos, size, rotation, pbs, pisPhysical)
        {
            Linkset = BSLinkset.Factory(PhysicsScene, this);

            PhysicsScene.TaintedObject("BSPrimLinksetCompound.Refresh", delegate()
            {
                base.SetMaterial(material);
                base.Friction          = friction;
                base.Restitution       = restitution;
                base.GravityMultiplier = gravityMultiplier;
                base.Density           = density;
                Linkset.Refresh(this);
            });
        }
Example #8
0
        public IObject Create(Vector3 position, Quaternion rotation)
        {
            ISceneEntity sog = m_scene.SceneGraph.AddNewPrim(m_security.owner.GlobalID,
                                                             UUID.Zero,
                                                             position,
                                                             rotation,
                                                             PrimitiveBaseShape.CreateBox());

            IObject ret = null;

            if (sog != null)
            {
                ret = new SOPObject(m_scene, sog.LocalId, m_security);
            }

            return(ret);
        }
        public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position,
                                                  Vector3 size, Quaternion rotation, bool isPhysical, uint localID)
        {
            // m_log.DebugFormat("{0}: AddPrimShape2: {1}", LogHeader, primName);

            if (!m_initialized)
            {
                return(null);
            }

            // DetailLog("{0},BSScene.AddPrimShape,call", localID);

            BSPhysObject prim = new BSPrimLinkable(localID, primName, this, position, size, rotation, pbs, isPhysical);

            lock (PhysObjects) PhysObjects.Add(localID, prim);
            return(prim);
        }
        public BSPrimLinkable(uint localID, String primName, BSScene parent_scene, OMV.Vector3 pos, OMV.Vector3 size,
            OMV.Quaternion rotation, PrimitiveBaseShape pbs, bool pisPhysical, int material, float friction,
            float restitution, float gravityMultiplier, float density)
            : base(localID, primName, parent_scene, pos, size, rotation, pbs, pisPhysical)
        {
            Linkset = BSLinkset.Factory(PhysicsScene, this);

            PhysicsScene.TaintedObject("BSPrimLinksetCompound.Refresh", delegate()
            {
                base.SetMaterial(material);
                base.Friction = friction;
                base.Restitution = restitution;
                base.GravityMultiplier = gravityMultiplier;
                base.Density = density;
                Linkset.Refresh(this);
            });
        }
Example #11
0
        private ulong GetMeshKey(PrimitiveBaseShape pbs, Vector3 size, float lod)
        {
            ulong hash = 5381;

            hash = djb2(hash, pbs.PathCurve);
            hash = djb2(hash, (byte)((byte)pbs.HollowShape | (byte)pbs.ProfileShape));
            hash = djb2(hash, pbs.PathBegin);
            hash = djb2(hash, pbs.PathEnd);
            hash = djb2(hash, pbs.PathScaleX);
            hash = djb2(hash, pbs.PathScaleY);
            hash = djb2(hash, pbs.PathShearX);
            hash = djb2(hash, pbs.PathShearY);
            hash = djb2(hash, (byte)pbs.PathTwist);
            hash = djb2(hash, (byte)pbs.PathTwistBegin);
            hash = djb2(hash, (byte)pbs.PathRadiusOffset);
            hash = djb2(hash, (byte)pbs.PathTaperX);
            hash = djb2(hash, (byte)pbs.PathTaperY);
            hash = djb2(hash, pbs.PathRevolutions);
            hash = djb2(hash, (byte)pbs.PathSkew);
            hash = djb2(hash, pbs.ProfileBegin);
            hash = djb2(hash, pbs.ProfileEnd);
            hash = djb2(hash, pbs.ProfileHollow);

            // TODO: Separate scale out from the primitive shape data (after
            // scaling is supported at the physics engine level)
            byte[] scaleBytes = size.GetBytes();
            hash = scaleBytes.Aggregate(hash, djb2);

            // Include LOD in hash, accounting for endianness
            byte[] lodBytes = new byte[4];
            Buffer.BlockCopy(BitConverter.GetBytes(lod), 0, lodBytes, 0, 4);
            if (!BitConverter.IsLittleEndian)
            {
                Array.Reverse(lodBytes, 0, 4);
            }
            hash = lodBytes.Aggregate(hash, djb2);

            // include sculpt UUID
            if (pbs.SculptEntry)
            {
                scaleBytes = pbs.SculptTexture.GetBytes();
                hash       = scaleBytes.Aggregate(hash, djb2);
            }

            return(hash);
        }
Example #12
0
        public void CreateAndDropPhysicalCube()
        {
            PrimitiveBaseShape newcube  = PrimitiveBaseShape.CreateBox();
            Vector3            position = new Vector3(((float)Constants.RegionSize * 0.5f), ((float)Constants.RegionSize * 0.5f), 128f);
            Vector3            size     = new Vector3(0.5f, 0.5f, 0.5f);
            Quaternion         rot      = Quaternion.Identity;
            PhysicsActor       prim     = ps.AddPrimShape("CoolShape", newcube, position, size, rot, true);
            OdePrim            oprim    = (OdePrim)prim;
            OdeScene           pscene   = (OdeScene)ps;

            Assert.That(oprim.m_taintadd);

            prim.LocalID = 5;

            for (int i = 0; i < 58; i++)
            {
                ps.Simulate(0.133f);

                Assert.That(oprim.prim_geom != (IntPtr)0);

                Assert.That(oprim.m_targetSpace != (IntPtr)0);

                //Assert.That(oprim.m_targetSpace == pscene.space);
                m_log.Info("TargetSpace: " + oprim.m_targetSpace + " - SceneMainSpace: " + pscene.space);

                Assert.That(!oprim.m_taintadd);
                m_log.Info("Prim Position (" + oprim.m_localID + "): " + prim.Position.ToString());

                // Make sure we're above the ground
                //Assert.That(prim.Position.Z > 20f);
                //m_log.Info("PrimCollisionScore (" + oprim.m_localID + "): " + oprim.m_collisionscore);

                // Make sure we've got a Body
                Assert.That(oprim.Body != (IntPtr)0);
                //m_log.Info(
            }

            // Make sure we're not somewhere above the ground
            Assert.That(prim.Position.Z < 21.5f);

            ps.RemovePrim(prim);
            Assert.That(oprim.m_taintremove);
            ps.Simulate(0.133f);
            Assert.That(oprim.Body == (IntPtr)0);
        }
Example #13
0
        private static OSDArray DecodeMeshLODArray(PrimitiveBaseShape primShape, long start, OSDMap physicsParms)
        {
            int physOffset = physicsParms["offset"].AsInteger() + (int)start;
            int physSize   = physicsParms["size"].AsInteger();

            if (physOffset < 0 || physSize == 0)
            {
                return(null); // no mesh data in asset
            }
            OSD decodedMeshOsd = DecodeCompressedOSD(primShape.SculptData, physOffset, physSize);

            if (decodedMeshOsd == null)
            {
                return(null);
            }

            return(decodedMeshOsd as OSDArray);
        }
        void DoCoverview(Scene scene)
        {
            // We're going to place objects in world
            displayed = slideCount - 1;
            current   = slideCount - 1;
            for (int x = 0; x <= (2 * displayed); x++)
            {
                if (x < displayed)
                {
                    position[x]        = x;
                    updatedPosition[x] = x;
                    offset[x]          = (x - (displayed + 10f)) * spacing;
                }
                if (x == displayed)
                {
                    position[x]        = x;
                    updatedPosition[x] = x;
                    offset[x]          = 0.0f;
                }
                if (x > displayed)
                {
                    offset[x] = (x - (displayed - 10f)) * spacing;
                }
            }

            //Place prims in the region
            for (int x = 0; x <= displayed; x++)
            {
                Vector3          pos = new Vector3(rootPosition + offset[position[x]], yPosition, zPosition);
                SceneObjectGroup sog = new SceneObjectGroup(UUID.Zero, pos, PrimitiveBaseShape.CreateBox());
                if (x == displayed)
                {
                    sog.UpdateGroupRotationR(new Quaternion(0, 0, 1, 1));
                }
                sog.RootPart.Scale = size;
                prims.Add(sog);
            }

            // Now make them visible
            foreach (SceneObjectGroup sogr in prims)
            {
                scene.AddNewSceneObject(sogr, false);
            }
        }
        /// <summary>
        /// Calculate a hash value over fields that can affect the underlying physics shape.
        /// Things like RenderMaterials and TextureEntry data are not included.
        /// </summary>
        /// <param name="shape"></param>
        /// <param name="lod"></param>
        /// <returns>ulong - a calculated hash value</returns>
        public ulong GetMeshShapeHash(PrimitiveBaseShape shape)
        {
            const DetailLevel lod  = DetailLevel.Highest;
            ulong             hash = 5381;

            hash = Murmur2.Hash(shape.PathCurve, hash);
            hash = Murmur2.Hash((byte)((byte)shape.HollowShape | (byte)shape.ProfileShape), hash);
            hash = Murmur2.Hash(shape.PathBegin, hash);
            hash = Murmur2.Hash(shape.PathEnd, hash);
            hash = Murmur2.Hash(shape.PathScaleX, hash);
            hash = Murmur2.Hash(shape.PathScaleY, hash);
            hash = Murmur2.Hash(shape.PathShearX, hash);
            hash = Murmur2.Hash(shape.PathShearY, hash);
            hash = Murmur2.Hash((byte)shape.PathTwist, hash);
            hash = Murmur2.Hash((byte)shape.PathTwistBegin, hash);
            hash = Murmur2.Hash((byte)shape.PathRadiusOffset, hash);
            hash = Murmur2.Hash((byte)shape.PathTaperX, hash);
            hash = Murmur2.Hash((byte)shape.PathTaperY, hash);
            hash = Murmur2.Hash(shape.PathRevolutions, hash);
            hash = Murmur2.Hash((byte)shape.PathSkew, hash);
            hash = Murmur2.Hash(shape.ProfileBegin, hash);
            hash = Murmur2.Hash(shape.ProfileEnd, hash);
            hash = Murmur2.Hash(shape.ProfileHollow, hash);

            // Include LOD in hash, accounting for endianness
            byte[] lodBytes = new byte[4];
            Buffer.BlockCopy(BitConverter.GetBytes((int)lod), 0, lodBytes, 0, 4);
            if (!BitConverter.IsLittleEndian)
            {
                Array.Reverse(lodBytes, 0, 4);
            }

            hash = Murmur2.Hash(shape.ProfileHollow, hash);

            // include sculpt UUID
            if (shape.SculptEntry)
            {
                var sculptUuidBytes = shape.SculptTexture.GetBytes();
                hash = Murmur2.Hash(sculptUuidBytes, hash);
                hash = Murmur2.Hash(shape.SculptType, hash);
            }

            return(hash);
        }
Example #16
0
        public BasicPrim(BasicPrim parent, BasicScene scene, PrimitiveBaseShape baseShape, OpenMetaverse.Vector3 pos,
                         OpenMetaverse.Quaternion rotation, /*PhysicsShape myShape, PhysX.RigidActor myActor,*/
                         bool isPhysical, IPhysicsProperties properties /*, CollisionGroupFlag collisionGroup*/)
        {
            _parentPrim = parent;
            _scene      = scene;
            _pbs        = baseShape;
            _position   = pos;
            _rotation   = rotation;
            _isPhysical = isPhysical;
            _properties = (BasicPhysicsProperties)properties;
            //_collisionGroup = collisionGroup;

            _acceleration = OpenMetaverse.Vector3.Zero;

            _mass = OBJECT_DENSITY * _pbs.Scale.X * _pbs.Scale.Y * _pbs.Scale.Z;

            //this.AssignActor(myActor, myShape, _isPhysical, DeleteActorFlags.None);
        }
Example #17
0
        public static SceneObjectGroup findAarBox(Scene scene)
        {
            SceneObjectGroup aarBox = null;

            foreach (EntityBase ent in scene.Entities.GetEntities())
            {
                if (ent.Name == AAR.AARBOXNAME)
                {
                    aarBox = (SceneObjectGroup)ent;
                }
            }
            if (aarBox == null)
            {
                aarBox      = new SceneObjectGroup(UUID.Zero, Vector3.Zero, PrimitiveBaseShape.CreateBox());
                aarBox.Name = AAR.AARBOXNAME;
                scene.AddNewSceneObject(aarBox, true);
            }
            return(aarBox);
        }
        public SceneObjectGroup CreateEntity(
            UUID ownerID, UUID groupID, Vector3 pos, Quaternion rot, PrimitiveBaseShape shape)
        {
            if (Array.IndexOf(creationCapabilities, (PCode)shape.PCode) < 0)
            {
                m_log.DebugFormat("[VEGETATION]: PCode {0} not handled by {1}", shape.PCode, Name);
                return(null);
            }

            SceneObjectGroup sceneObject = new SceneObjectGroup(ownerID, pos, rot, shape);
            SceneObjectPart  rootPart    = sceneObject.GetPart(sceneObject.UUID);

            rootPart.AddFlag(PrimFlags.Phantom);

            m_scene.AddNewSceneObject(sceneObject, true);
            sceneObject.SetGroup(groupID, null);

            return(sceneObject);
        }
        protected void AdaptTree(ref PrimitiveBaseShape tree)
        {
            // Tree size has to be adapted depending on its type
            switch ((Tree)tree.State)
            {
            case Tree.Cypress1:
            case Tree.Cypress2:
                tree.Scale = new Vector3(4, 4, 10);
                break;

            // case... other tree types
            // tree.Scale = new Vector3(?, ?, ?);
            // break;

            default:
                tree.Scale = new Vector3(4, 4, 4);
                break;
            }
        }
Example #20
0
        // Create a hash of all the shape parameters to be used as a key
        //    for this particular shape.
        private ulong ComputeShapeKey(ShapeData shapeData, PrimitiveBaseShape pbs, out float retLod)
        {
            // level of detail based on size and type of the object
            float lod = PhysicsScene.MeshLOD;

            if (pbs.SculptEntry)
            {
                lod = PhysicsScene.SculptLOD;
            }

            float maxAxis = Math.Max(shapeData.Size.X, Math.Max(shapeData.Size.Y, shapeData.Size.Z));

            if (maxAxis > PhysicsScene.MeshMegaPrimThreshold)
            {
                lod = PhysicsScene.MeshMegaPrimLOD;
            }

            retLod = lod;
            return((ulong)pbs.GetMeshKey(shapeData.Size, lod));
        }
Example #21
0
        public void Init()
        {
            Dictionary<string, string> engineParams = new Dictionary<string, string>();
            engineParams.Add("UseBulletRaycast", "true");
            _physicsScene = BulletSimTestsUtil.CreateBasicPhysicsEngine(engineParams);

            PrimitiveBaseShape pbs = PrimitiveBaseShape.CreateSphere();
            Vector3 pos = new Vector3(100.0f, 100.0f, 50f);
            _targetSpherePosition = pos;
            Vector3 size = new Vector3(10f, 10f, 10f);
            pbs.Scale = size;
            Quaternion rot = Quaternion.Identity;
            bool isPhys = false;

            _physicsScene.AddPrimShape("TargetSphere", pbs, pos, size, rot, isPhys, _targetLocalID);
            _targetSphere = (BSPrim)_physicsScene.PhysObjects[_targetLocalID];
            // The actual prim shape creation happens at taint time
            _physicsScene.ProcessTaints();

        }
Example #22
0
        // Helper functions to understand if object has cut, hollow, dimple, and other affecting number of faces
        private static void hasCutHollowDimpleProfileCut(int primType, PrimitiveBaseShape shape, out bool hasCut, out bool hasHollow,
                                                         out bool hasDimple, out bool hasProfileCut)
        {
            if (primType == (int)PrimType.Box
                ||
                primType == (int)PrimType.Cylinder
                ||
                primType == (int)PrimType.Prism)
            {
                hasCut = (shape.ProfileBegin > 0) || (shape.ProfileEnd > 0);
            }
            else
            {
                hasCut = (shape.PathBegin > 0) || (shape.PathEnd > 0);
            }

            hasHollow     = shape.ProfileHollow > 0;
            hasDimple     = (shape.ProfileBegin > 0) || (shape.ProfileEnd > 0); // taken from llSetPrimitiveParms
            hasProfileCut = hasDimple;                                          // is it the same thing?
        }
Example #23
0
        public override PhysicsActor AddPrimShape(UUID primID, uint localID, string name, byte physicsType,
                                                  PrimitiveBaseShape shape,
                                                  Vector3 position, Vector3 size, Quaternion rotation, bool isPhysical, int material,
                                                  float friction, float restitution, float gravityMultiplier, float density)
        {
            // MainConsole.Instance.DebugFormat("{0}: AddPrimShape2: {1}", LogHeader, primName);

            if (!m_initialized)
            {
                return(null);
            }

            // DetailLog("{0},BSScene.AddPrimShape,call", localID);

            BSPhysObject prim = new BSPrimLinkable(localID, name, this, position, size, rotation, shape, false, material,
                                                   friction, restitution, gravityMultiplier, density);

            prim.UUID = primID;
            lock (PhysObjects) PhysObjects.Add(localID, prim);
            return(prim);
        }
Example #24
0
        // Create a hash of all the shape parameters to be used as a key
        //    for this particular shape.
        private System.UInt64 ComputeShapeKey(OMV.Vector3 size, PrimitiveBaseShape pbs, out float retLod)
        {
            // level of detail based on size and type of the object
            float lod = BSParam.MeshLOD;

            if (pbs.SculptEntry)
            {
                lod = BSParam.SculptLOD;
            }

            // Mega prims usually get more detail because one can interact with shape approximations at this size.
            float maxAxis = Math.Max(size.X, Math.Max(size.Y, size.Z));

            if (maxAxis > BSParam.MeshMegaPrimThreshold)
            {
                lod = BSParam.MeshMegaPrimLOD;
            }

            retLod = lod;
            return(pbs.GetMeshKey(size, lod));
        }
Example #25
0
        private BulletShape CreatePhysicalMesh(string objName, ulong newMeshKey, PrimitiveBaseShape pbs, OMV.Vector3 size, float lod)
        {
            IMesh    meshData = null;
            IntPtr   meshPtr;
            MeshDesc meshDesc;

            if (Meshes.TryGetValue(newMeshKey, out meshDesc))
            {
                // If the mesh has already been built just use it.
                meshPtr = meshDesc.ptr;
            }
            else
            {
                // Pass false for physicalness as this creates some sort of bounding box which we don't need
                meshData = PhysicsScene.mesher.CreateMesh(objName, pbs, size, lod, false);

                int[] indices = meshData.getIndexListAsInt();
                List <OMV.Vector3> vertices = meshData.getVertexList();

                float[] verticesAsFloats = new float[vertices.Count * 3];
                int     vi = 0;
                foreach (OMV.Vector3 vv in vertices)
                {
                    verticesAsFloats[vi++] = vv.X;
                    verticesAsFloats[vi++] = vv.Y;
                    verticesAsFloats[vi++] = vv.Z;
                }

                // m_log.DebugFormat("{0}: CreateGeomMesh: calling CreateMesh. lid={1}, key={2}, indices={3}, vertices={4}",
                //                  LogHeader, prim.LocalID, newMeshKey, indices.Length, vertices.Count);

                meshPtr = BulletSimAPI.CreateMeshShape2(PhysicsScene.World.ptr,
                                                        indices.GetLength(0), indices, vertices.Count, verticesAsFloats);
            }
            BulletShape newShape = new BulletShape(meshPtr, ShapeData.PhysicsShapeType.SHAPE_MESH);

            newShape.shapeKey = newMeshKey;

            return(newShape);
        }
Example #26
0
        // -----------------------------------------------------------------
        /// <summary>
        /// Create one of the objects
        /// </summary>
        // -----------------------------------------------------------------
        private SceneObjectGroup CreateSortableObject()
        {
            Quaternion         rot   = new Quaternion(Vector3.Zero, 1);
            PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere();
            Vector3            pos   = new Vector3();

            pos.X = (float)(m_random.NextDouble() * m_range.X) + m_startingpos.X;
            pos.Y = (float)(m_random.NextDouble() * m_range.Y) + m_startingpos.Y;
            pos.Z = (float)(m_random.NextDouble() * m_range.Z) + m_startingpos.Z;

            SceneObjectPart sop = new SceneObjectPart(UUID.Zero, shape, pos, rot, Vector3.Zero);

            sop.Name         = "quicksort object";
            sop.Scale        = new Vector3(0.2f, 0.2f, 0.2f);
            sop.ObjectFlags |= (uint)PrimFlags.Phantom;


            // Change the color of the object
            // Vector3 color = new Vector3(m_random.Next(256),m_random.Next(256),m_random.Next(256));
            Vector3 color = RandomColor();
            Color4  texcolor;

            Primitive.TextureEntry tex = sop.Shape.Textures;
            texcolor   = tex.DefaultTexture.RGBA;
            texcolor.R = Util.Clip((float)color.X, 0.0f, 1.0f);
            texcolor.G = Util.Clip((float)color.Y, 0.0f, 1.0f);
            texcolor.B = Util.Clip((float)color.Z, 0.0f, 1.0f);
            tex.DefaultTexture.RGBA = texcolor;
            sop.Shape.Textures      = tex;

            SceneObjectGroup sog = new SceneObjectGroup(sop);

            // sog.SetRootPart(sop);
            sog.Color = System.Drawing.Color.FromArgb(0, (int)(color.X * 0xff), (int)(color.Y * 0xff), (int)(color.Z * 0xff));
            sog.Text  = string.Format("obj: {0}", SortValue(sog));

            // sog.SetText("obj",color,1.0);

            return(sog);
        }
Example #27
0
        public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, PhysicsVector size, float lod, bool isPhysical)
        {
            Mesh mesh = null;

            if (size.X < 0.01f)
            {
                size.X = 0.01f;
            }
            if (size.Y < 0.01f)
            {
                size.Y = 0.01f;
            }
            if (size.Z < 0.01f)
            {
                size.Z = 0.01f;
            }

            mesh = CreateMeshFromPrimMesher(primName, primShape, size, lod);

            if (mesh != null)
            {
                if ((!isPhysical) && size.X < minSizeForComplexMesh && size.Y < minSizeForComplexMesh && size.Z < minSizeForComplexMesh)
                {
#if SPAM
                    m_log.Debug("Meshmerizer: prim " + primName + " has a size of " + size.ToString() + " which is below threshold of " +

                                minSizeForComplexMesh.ToString() + " - creating simple bounding box");
#endif
                    mesh = CreateBoundingBoxMesh(mesh);
                    mesh.DumpRaw(baseDir, primName, "Z extruded");
                }

                // trim the vertex and triangle lists to free up memory
                mesh.vertices.TrimExcess();
                mesh.triangles.TrimExcess();
            }

            return(mesh);
        }
Example #28
0
        private static HacdConvexHull[] DecomposeWithHACD(PrimitiveBaseShape shape, float LOD, IMesh mesh)
        {
            int[]   indexes = mesh.getIndexListAsInt();
            float[] verts   = mesh.getVertexListAsFloat();

            mesh.ReleaseSourceMeshData();

            HacdPreset preset;

            if (shape.SculptEntry)
            {
                preset = Hacd.SculptDefaultPreset;
            }
            else
            {
                preset = Hacd.PrimDefaultPreset;
            }

            //we cant use the hash we have here, as Hacd needs the mesh hash prescaled
            HacdConvexHull[] hulls = Hacd.DecomposeToConvexHulls(shape.GetMeshKey(OpenMetaverse.Vector3.One, LOD), shape.SculptEntry == false, preset, verts, indexes);
            return(hulls);
        }
        //public class FallingPrim
        //{
        //public bool DoneMoving = false;
        //public uint localId;

        public void FallingPrim(OdeScene ps, CollisionPlane Plane, PhysicsVector position, int x, int y, float offsetZ)
        {
            uint localId = Plane.fallingPrims;
            PrimitiveBaseShape newcube = PrimitiveBaseShape.CreateBox();
            OdePrim            oprim   = (OdePrim)ps.AddPrimShape("FallingPrim_" + localId, newcube, position, new PhysicsVector(0.1f, 0.1f, 2f), Quaternion.Identity, true);

            oprim.LocalID            = localId + 100000;
            oprim.OnCollisionUpdate += delegate(EventArgs args)
            {
                if (!oprim.m_taintremove)
                {
                    // CollisionEventUpdate arg = (CollisionEventUpdate)args;
                    //simhinfo 58 58 30
                    // DoneMoving = true;
                    LandingHieghts[x, y] = oprim.Position.Z + offsetZ;
                    fallingPrims--;
                    ps.remCollisionEventReporting(oprim);
                    ps.RemovePrim(oprim);
                }
            };
            oprim.SubscribeEvents(30000);
        }
Example #30
0
        public SceneObjectGroup AddTree(
            UUID uuid, UUID groupID, Vector3 scale, Quaternion rotation, Vector3 position, Tree treeType, bool newTree)
        {
            PrimitiveBaseShape treeShape = new PrimitiveBaseShape();

            treeShape.PathCurve = 16;
            treeShape.PathEnd   = 49900;
            treeShape.PCode     = newTree ? (byte)PCode.NewTree : (byte)PCode.Tree;
            treeShape.Scale     = scale;
            treeShape.State     = (byte)treeType;

            SceneObjectGroup sog      = new SceneObjectGroup(uuid, position, rotation, treeShape);
            SceneObjectPart  rootPart = sog.RootPart;

            rootPart.AddFlag(PrimFlags.Phantom);

            sog.SetGroup(groupID, null);
            m_scene.AddNewSceneObject(sog, true, false);
            sog.IsSelected      = false;
            rootPart.IsSelected = false;
            sog.InvalidateEffectivePerms();
            return(sog);
        }
Example #31
0
        public void RequestMesh(ODEPhysRepData repData)
        {
            repData.mesh = null;

            if (repData.meshState == MeshState.needAsset)
            {
                PrimitiveBaseShape pbs = repData.pbs;

                // check if we got outdated

                if (!pbs.SculptEntry || pbs.SculptTexture == UUID.Zero)
                {
                    repData.meshState = MeshState.noNeed;
                    return;
                }

                repData.assetID   = pbs.SculptTexture;
                repData.meshState = MeshState.loadingAsset;

                repData.comand = meshWorkerCmnds.getmesh;
                workQueue.Enqueue(repData);
            }
        }
Example #32
0
        public void Init()
        {
            Dictionary <string, string> engineParams = new Dictionary <string, string>();

            PhysicsScene = BulletSimTestsUtil.CreateBasicPhysicsEngine(engineParams);

            PrimitiveBaseShape pbs = PrimitiveBaseShape.CreateSphere();
            Vector3            pos = new Vector3(100.0f, 100.0f, 0f);

            pos.Z = PhysicsScene.TerrainManager.GetTerrainHeightAtXYZ(pos) + 2f;
            TestVehicleInitPosition = pos;
            Vector3 size = new Vector3(1f, 1f, 1f);

            pbs.Scale = size;
            Quaternion rot     = Quaternion.Identity;
            bool       isPhys  = false;
            uint       localID = 123;

            PhysicsScene.AddPrimShape("testPrim", pbs, pos, size, rot, isPhys, localID);
            TestVehicle = (BSPrim)PhysicsScene.PhysObjects[localID];
            // The actual prim shape creation happens at taint time
            PhysicsScene.ProcessTaints();
        }
Example #33
0
        // Called to update/change the body and shape for an object.
        // First checks the shape and updates that if necessary then makes
        //    sure the body is of the right type.
        // Return 'true' if either the body or the shape changed.
        // Called at taint-time!!
        public bool GetBodyAndShape(bool forceRebuild, BulletSim sim, BSPrim prim,
                                    ShapeData shapeData, PrimitiveBaseShape pbs,
                                    ShapeDestructionCallback shapeCallback, BodyDestructionCallback bodyCallback)
        {
            bool ret = false;

            // This lock could probably be pushed down lower but building shouldn't take long
            lock (m_collectionActivityLock)
            {
                // Do we have the correct geometry for this type of object?
                // Updates prim.BSShape with information/pointers to requested shape
                bool newGeom = CreateGeom(forceRebuild, prim, shapeData, pbs, shapeCallback);
                // If we had to select a new shape geometry for the object,
                //    rebuild the body around it.
                // Updates prim.BSBody with information/pointers to requested body
                bool newBody = CreateBody((newGeom || forceRebuild), prim, PhysicsScene.World, prim.BSShape, shapeData, bodyCallback);
                ret = newGeom || newBody;
            }
            DetailLog("{0},BSShapeCollection.GetBodyAndShape,force={1},ret={2},body={3},shape={4}",
                      prim.LocalID, forceRebuild, ret, prim.BSBody, prim.BSShape);

            return(ret);
        }
        private List <String> getAllTextures(SceneObjectGroup sog)
        {
            if (sog == null)
            {
                return(new List <String>());
            }

            List <String> texturList = new List <String>();

            PrimitiveBaseShape shape = sog.RootPart.Shape;

            if (shape != null && shape.ProfileShape == ProfileShape.Square)
            {
                Primitive.TextureEntry textures = shape.Textures;
                if (textures != null)
                {
                    if (textures.FaceTextures != null)
                    {
                        foreach (Primitive.TextureEntryFace tentry in textures.FaceTextures)
                        {
                            if (tentry != null)
                            {
                                if (tentry.TextureID != UUID.Zero && tentry.TextureID != UUID.Zero && tentry.TextureID != UUID.Zero)
                                {
                                    if (!texturList.Contains(tentry.TextureID.ToString()))
                                    {
                                        texturList.Add(tentry.TextureID.ToString());
                                    }
                                }
                            }
                        }
                    }
                }
            }

            return(texturList);
        }
 static int getScriptPrimType(PrimitiveBaseShape primShape)
 {
     if (primShape.SculptEntry)
         return (int) PrimType.Sculpt;
     if ((primShape.ProfileCurve & 0x07) == (byte) ProfileShape.Square)
     {
         if (primShape.PathCurve == (byte) Extrusion.Straight)
             return (int) PrimType.Box;
         if (primShape.PathCurve == (byte) Extrusion.Curve1)
             return (int) PrimType.Tube;
     }
     else if ((primShape.ProfileCurve & 0x07) == (byte) ProfileShape.Circle)
     {
         if (primShape.PathCurve == (byte) Extrusion.Straight)
             return (int) PrimType.Cylinder;
         if (primShape.PathCurve == (byte) Extrusion.Curve1)
             return (int) PrimType.Torus;
     }
     else if ((primShape.ProfileCurve & 0x07) == (byte) ProfileShape.HalfCircle)
     {
         if (primShape.PathCurve == (byte) Extrusion.Curve1 || primShape.PathCurve == (byte) Extrusion.Curve2)
             return (int) PrimType.Sphere;
     }
     else if ((primShape.ProfileCurve & 0x07) == (byte) ProfileShape.EquilateralTriangle)
     {
         if (primShape.PathCurve == (byte) Extrusion.Straight)
             return (int) PrimType.Prism;
         if (primShape.PathCurve == (byte) Extrusion.Curve1)
             return (int) PrimType.Ring;
     }
     return (int) PrimType.NotPrimitive;
 }
        // Helper functions to understand if object has cut, hollow, dimple, and other affecting number of faces
        static void hasCutHollowDimpleProfileCut(int primType, PrimitiveBaseShape shape, out bool hasCut,
                                                         out bool hasHollow,
                                                         out bool hasDimple, out bool hasProfileCut)
        {
            if (primType == (int) PrimType.Box
                ||
                primType == (int) PrimType.Cylinder
                ||
                primType == (int) PrimType.Prism)

                hasCut = (shape.ProfileBegin > 0) || (shape.ProfileEnd > 0);
            else
                hasCut = (shape.PathBegin > 0) || (shape.PathEnd > 0);

            hasHollow = shape.ProfileHollow > 0;
            hasDimple = (shape.ProfileBegin > 0) || (shape.ProfileEnd > 0); // taken from llSetPrimitiveParms
            hasProfileCut = hasDimple; // is it the same thing?
        }
 private void ProcessShpSculptEntry(PrimitiveBaseShape shp, XmlTextReader reader)
 {
     shp.SculptEntry = reader.ReadElementContentAsBoolean("SculptEntry", String.Empty);
 }
Example #38
0
        /// <summary>
        ///   Create a completely new SceneObjectPart (prim).  This will need to be added separately to a SceneObjectGroup
        /// </summary>
        /// <param name = "ownerID"></param>
        /// <param name = "shape"></param>
        /// <param name = "position"></param>
        /// <param name = "rotationOffset"></param>
        /// <param name = "offsetPosition"></param>
        public SceneObjectPart(
            UUID ownerID, PrimitiveBaseShape shape, Vector3 groupPosition,
            Quaternion rotationOffset, Vector3 offsetPosition, string name, IScene scene)
        {
            m_name = name;
            m_initialScene = scene;

            CreationDate = (int) Utils.DateTimeToUnixTime(DateTime.Now);
            _ownerID = ownerID;
            _creatorID = _ownerID;
            LastOwnerID = UUID.Zero;
            UUID = UUID.Random();
            Shape = shape;
            CRC = 1;
            _ownershipCost = 0;
            _flags = 0;
            _groupID = UUID.Zero;
            _objectSaleType = 0;
            _salePrice = 0;
            _category = 0;
            LastOwnerID = _creatorID;
            m_groupPosition = groupPosition;
            m_offsetPosition = offsetPosition;
            RotationOffset = rotationOffset;
            Velocity = Vector3.Zero;
            AngularVelocity = Vector3.Zero;
            Acceleration = Vector3.Zero;

            ValidpartOOB = false;

            // Prims currently only contain a single folder (Contents).  From looking at the Second Life protocol,
            // this appears to have the same UUID (!) as the prim.  If this isn't the case, one can't drag items from
            // the prim into an agent inventory (Linden client reports that the "Object not found for drop" in its log

            Flags = 0;
            CreateSelected = true;

            TrimPermissions();
            //m_undo = new UndoStack<UndoState>(ParentGroup.GetSceneMaxUndo());

            m_inventory = new SceneObjectPartInventory(this);
        }
        public ISceneEntity CreateEntity(
            ISceneEntity baseEntity, UUID ownerID, UUID groupID, Vector3 pos, Quaternion rot, PrimitiveBaseShape shape)
        {
            if (Array.IndexOf(creationCapabilities, (PCode) shape.PCode) < 0)
            {
                MainConsole.Instance.DebugFormat("[VEGETATION]: PCode {0} not handled by {1}", shape.PCode, Name);
                return null;
            }

            ISceneChildEntity rootPart = baseEntity.GetChildPart(baseEntity.UUID);

            // if grass or tree, make phantom
            //rootPart.TrimPermissions();
            rootPart.AddFlag(PrimFlags.Phantom);
            if (rootPart.Shape.PCode != (byte) PCode.Grass)
                AdaptTree(ref shape);

            m_scene.SceneGraph.AddPrimToScene(baseEntity);
            baseEntity.SetGroup(groupID, ownerID, true);
            baseEntity.ScheduleGroupUpdate(PrimUpdateFlags.ForcedFullUpdate);

            return baseEntity;
        }
Example #40
0
 public void changeshape(PrimitiveBaseShape arg)
 {
     _pbs = arg;
     changeprimsizeshape();
 }
Example #41
0
        /// <summary>
        ///   Constructor.  This object is added to the scene later via AttachToScene()
        /// </summary>
        public SceneObjectGroup(UUID ownerID, Vector3 pos, Quaternion rot, PrimitiveBaseShape shape, string name,
                                IScene scene) : this(scene)
        {
            SceneObjectPart part = new SceneObjectPart(ownerID, shape, pos, rot, Vector3.Zero, name, scene);
            SetRootPart(part);

            //This has to be set, otherwise it will break things like rezzing objects in an area where crossing is disabled, but rez isn't
            m_lastSignificantPosition = pos;

            m_ValidgrpOOB = false;
        }
 public abstract PhysicsActor AddPrimShape(UUID primID, uint localID, string name, byte physicsType, PrimitiveBaseShape shape,
     Vector3 position, Vector3 size, Quaternion rotation, bool isPhysical, int material, float friction, float restitution,
     float gravityMultiplier, float density);
        private void WriteShape(XmlTextWriter writer, PrimitiveBaseShape shp, Dictionary<string, object> options)
        {
            if (shp != null)
            {
                writer.WriteStartElement("Shape");

                writer.WriteElementString("ProfileCurve", shp.ProfileCurve.ToString());

                writer.WriteStartElement("TextureEntry");
                byte[] te;
                if (shp.TextureEntry != null)
                    te = shp.TextureEntry;
                else
                    te = Utils.EmptyBytes;
                writer.WriteBase64(te, 0, te.Length);
                writer.WriteEndElement(); // TextureEntry

                writer.WriteStartElement("ExtraParams");
                byte[] ep;
                if (shp.ExtraParams != null)
                    ep = shp.ExtraParams;
                else
                    ep = Utils.EmptyBytes;
                writer.WriteBase64(ep, 0, ep.Length);
                writer.WriteEndElement(); // ExtraParams

                writer.WriteElementString("PathBegin", shp.PathBegin.ToString());
                writer.WriteElementString("PathCurve", shp.PathCurve.ToString());
                writer.WriteElementString("PathEnd", shp.PathEnd.ToString());
                writer.WriteElementString("PathRadiusOffset", shp.PathRadiusOffset.ToString());
                writer.WriteElementString("PathRevolutions", shp.PathRevolutions.ToString());
                writer.WriteElementString("PathScaleX", shp.PathScaleX.ToString());
                writer.WriteElementString("PathScaleY", shp.PathScaleY.ToString());
                writer.WriteElementString("PathShearX", shp.PathShearX.ToString());
                writer.WriteElementString("PathShearY", shp.PathShearY.ToString());
                writer.WriteElementString("PathSkew", shp.PathSkew.ToString());
                writer.WriteElementString("PathTaperX", shp.PathTaperX.ToString());
                writer.WriteElementString("PathTaperY", shp.PathTaperY.ToString());
                writer.WriteElementString("PathTwist", shp.PathTwist.ToString());
                writer.WriteElementString("PathTwistBegin", shp.PathTwistBegin.ToString());
                writer.WriteElementString("PCode", shp.PCode.ToString());
                writer.WriteElementString("ProfileBegin", shp.ProfileBegin.ToString());
                writer.WriteElementString("ProfileEnd", shp.ProfileEnd.ToString());
                writer.WriteElementString("ProfileHollow", shp.ProfileHollow.ToString());
                writer.WriteElementString("State", shp.State.ToString());

                writer.WriteElementString("ProfileShape", shp.ProfileShape.ToString());
                writer.WriteElementString("HollowShape", shp.HollowShape.ToString());

                WriteUUID(writer, "SculptTexture", shp.SculptTexture, options);
                writer.WriteElementString("SculptType", shp.SculptType.ToString());
                writer.WriteStartElement("SculptData");
                byte[] sd;
                //if (shp.SculptData != null)
                sd = shp.ExtraParams;
                //else
                //    sd = Utils.EmptyBytes;
                if (sd != null) writer.WriteBase64(sd, 0, sd.Length);
                writer.WriteEndElement(); // SculptData

                writer.WriteElementString("FlexiSoftness", shp.FlexiSoftness.ToString());
                writer.WriteElementString("FlexiTension", shp.FlexiTension.ToString());
                writer.WriteElementString("FlexiDrag", shp.FlexiDrag.ToString());
                writer.WriteElementString("FlexiGravity", shp.FlexiGravity.ToString());
                writer.WriteElementString("FlexiWind", shp.FlexiWind.ToString());
                writer.WriteElementString("FlexiForceX", shp.FlexiForceX.ToString());
                writer.WriteElementString("FlexiForceY", shp.FlexiForceY.ToString());
                writer.WriteElementString("FlexiForceZ", shp.FlexiForceZ.ToString());

                writer.WriteElementString("LightColorR", shp.LightColorR.ToString());
                writer.WriteElementString("LightColorG", shp.LightColorG.ToString());
                writer.WriteElementString("LightColorB", shp.LightColorB.ToString());
                writer.WriteElementString("LightColorA", shp.LightColorA.ToString());
                writer.WriteElementString("LightRadius", shp.LightRadius.ToString());
                writer.WriteElementString("LightCutoff", shp.LightCutoff.ToString());
                writer.WriteElementString("LightFalloff", shp.LightFalloff.ToString());
                writer.WriteElementString("LightIntensity", shp.LightIntensity.ToString());

                writer.WriteElementString("FlexiEntry", shp.FlexiEntry.ToString().ToLower());
                writer.WriteElementString("LightEntry", shp.LightEntry.ToString().ToLower());
                writer.WriteElementString("SculptEntry", shp.SculptEntry.ToString().ToLower());

                if (shp.Media != null)
                    writer.WriteElementString("Media", shp.Media.ToXml());

                writer.WriteEndElement(); // Shape
            }
        }
Example #44
0
        /// <summary>
        ///     Create a New SceneObjectGroup/Part by raycasting
        /// </summary>
        /// <param name="ownerID"></param>
        /// <param name="groupID"></param>
        /// <param name="pos"></param>
        /// <param name="rot"></param>
        /// <param name="shape"></param>
        public virtual ISceneEntity AddNewPrim(
            UUID ownerID, UUID groupID, Vector3 pos, Quaternion rot, PrimitiveBaseShape shape)
        {
            SceneObjectGroup sceneObject = new SceneObjectGroup(ownerID, pos, rot, shape, m_DefaultObjectName,
                                                                m_parentScene);

            // If an entity creator has been registered for this prim type then use that
            if (m_entityCreators.ContainsKey((PCode) shape.PCode))
            {
                sceneObject =
                    (SceneObjectGroup)
                    m_entityCreators[(PCode) shape.PCode].CreateEntity(sceneObject, ownerID, groupID, pos, rot, shape);
            }
            else
            {
                // Otherwise, use this default creation code;
                sceneObject.SetGroup(groupID, ownerID, false);
                AddPrimToScene(sceneObject);
                sceneObject.ScheduleGroupUpdate(PrimUpdateFlags.ForcedFullUpdate);
            }


            return sceneObject;
        }
Example #45
0
        public override PhysicsActor AddPrimShape(UUID primID, uint localID, string name, byte physicsType,
            PrimitiveBaseShape shape,
            Vector3 position, Vector3 size, Quaternion rotation, bool isPhysical, int material,
            float friction, float restitution, float gravityMultiplier, float density)
        {
            // MainConsole.Instance.DebugFormat("{0}: AddPrimShape2: {1}", LogHeader, primName);

            if (!m_initialized) return null;

            // DetailLog("{0},BSScene.AddPrimShape,call", localID);

            BSPhysObject prim = new BSPrimLinkable(localID, name, this, position, size, rotation, shape, false, material,
                friction, restitution, gravityMultiplier, density);
            prim.UUID = primID;
            lock (PhysObjects) PhysObjects.Add(localID, prim);
            return prim;
        }
Example #46
0
        public static string PrimitiveBaseShapeToString(PrimitiveBaseShape pbs)
        {
            float pathShearX = pbs.PathShearX < 128 ? (float)pbs.PathShearX * 0.01f : (float)(pbs.PathShearX - 256) * 0.01f;
            float pathShearY = pbs.PathShearY < 128 ? (float)pbs.PathShearY * 0.01f : (float)(pbs.PathShearY - 256) * 0.01f;
            float pathBegin = (float)pbs.PathBegin * 2.0e-5f;
            float pathEnd = 1.0f - (float)pbs.PathEnd * 2.0e-5f;
            float pathScaleX = (float)(200 - pbs.PathScaleX) * 0.01f;
            float pathScaleY = (float)(200 - pbs.PathScaleY) * 0.01f;
            //float pathTaperX = pbs.PathTaperX * 0.01f;
            //float pathTaperY = pbs.PathTaperY * 0.01f;

            float profileBegin = (float)pbs.ProfileBegin * 2.0e-5f;
            float profileEnd = 1.0f - (float)pbs.ProfileEnd * 2.0e-5f;
            float profileHollow = (float)pbs.ProfileHollow * 2.0e-5f;
            if (profileHollow > 0.95f)
                profileHollow = 0.95f;

            StringBuilder buff = new StringBuilder();
            buff.Append("shape=");
            buff.Append(((ProfileShape)pbs.ProfileShape).ToString());
            buff.Append(",");
            buff.Append("hollow=");
            buff.Append(((HollowShape)pbs.HollowShape).ToString());
            buff.Append(",");
            buff.Append("pathCurve=");
            buff.Append(((Extrusion)pbs.PathCurve).ToString());
            buff.Append(",");
            buff.Append("profCurve=");
            buff.Append(((Extrusion)pbs.ProfileCurve).ToString());
            buff.Append(",");
            buff.Append("profHollow=");
            buff.Append(profileHollow.ToString());
            buff.Append(",");
            buff.Append("pathBegEnd=");
            buff.Append(pathBegin.ToString());
            buff.Append("/");
            buff.Append(pathEnd.ToString());
            buff.Append(",");
            buff.Append("profileBegEnd=");
            buff.Append(profileBegin.ToString());
            buff.Append("/");
            buff.Append(profileEnd.ToString());
            buff.Append(",");
            buff.Append("scaleXY=");
            buff.Append(pathScaleX.ToString());
            buff.Append("/");
            buff.Append(pathScaleY.ToString());
            buff.Append(",");
            buff.Append("shearXY=");
            buff.Append(pathShearX.ToString());
            buff.Append("/");
            buff.Append(pathShearY.ToString());
            buff.Append(",");
            buff.Append("taperXY=");
            buff.Append(pbs.PathTaperX.ToString());
            buff.Append("/");
            buff.Append(pbs.PathTaperY.ToString());
            buff.Append(",");
            buff.Append("skew=");
            buff.Append(pbs.PathSkew.ToString());
            buff.Append(",");
            buff.Append("twist/Beg=");
            buff.Append(pbs.PathTwist.ToString());
            buff.Append("/");
            buff.Append(pbs.PathTwistBegin.ToString());

            return buff.ToString();
        }
 private void ProcessShpLightIntensity(PrimitiveBaseShape shp, XmlTextReader reader)
 {
     shp.LightIntensity = reader.ReadElementContentAsFloat("LightIntensity", String.Empty);
 }
        public override PhysicsActor AddPrimShape(UUID primID, uint localID, string name, byte physicsType, PrimitiveBaseShape shape, Vector3 position,
                                                    Vector3 size, Quaternion rotation, bool isPhysical, int material, float friction, float restitution,
                                                    float gravityMultiplier, float density)
        {
            ODEPrim newPrim = new ODEPrim(name, physicsType, shape, position, size, rotation, material, friction, restitution, gravityMultiplier, density, this);
            newPrim.UUID = primID;
            newPrim.LocalID = localID;

            if (isPhysical)
                newPrim.IsPhysical = isPhysical;

            lock (_prims)
                _prims.Add(newPrim);

            return newPrim;
        }
 private void ProcessShpMedia(PrimitiveBaseShape shp, XmlTextReader reader)
 {
     string value = reader.ReadElementContentAsString("Media", String.Empty);
     shp.Media = PrimitiveBaseShape.MediaList.FromXml(value);
 }
Example #50
0
        public AuroraODEPrim(string name, byte physicsType, PrimitiveBaseShape shape, Vector3 position, Vector3 size, Quaternion rotation, 
            int material, float friction, float restitution, float gravityMultiplier, float density, AuroraODEPhysicsScene parent_scene)
        {
            m_vehicle = new AuroraODEDynamics();

            // correct for changed timestep
            PID_D /= (parent_scene.ODE_STEPSIZE*50f); // original ode fps of 50
            PID_G /= (parent_scene.ODE_STEPSIZE*50f);

            body_autodisable_frames = parent_scene.bodyFramesAutoDisable;

            prim_geom = IntPtr.Zero;

            _name = name;
            PhysicsShapeType = physicsType;
            _size = size;
            _position = position;
            fakepos = 0;
            _orientation = rotation;
            fakeori = 0;
            _pbs = shape;

            _parent_scene = parent_scene;
            m_targetSpace = IntPtr.Zero;

            /*
                        m_isphysical = pisPhysical;
                        if (m_isphysical)
                            m_targetSpace = _parent_scene.space;
            */
            m_isphysical = false;

            m_forceacc = Vector3.Zero;
            m_angularforceacc = Vector3.Zero;

            hasOOBoffsetFromMesh = false;
            _triMeshData = IntPtr.Zero;

            SetMaterial(material, friction, restitution, gravityMultiplier, density);

            CalcPrimBodyData();

            _parent_scene.AddSimulationChange(() => changeadd());
        }
 public BSPrimDisplaced(uint localID, String primName, BSScene parent_scene, Vector3 pos, Vector3 size,
     Quaternion rotation, PrimitiveBaseShape pbs, bool pisPhysical)
     : base(localID, primName, parent_scene, pos, size, rotation, pbs, pisPhysical)
 {
     ClearDisplacement();
 }
Example #52
0
        /// <summary>
        ///   Tell us if this object has cut, hollow, dimple, and other factors affecting the number of faces
        /// </summary>
        /// <param name = "primType"></param>
        /// <param name = "shape"></param>
        /// <param name = "hasCut"></param>
        /// <param name = "hasHollow"></param>
        /// <param name = "hasDimple"></param>
        /// <param name = "hasProfileCut"></param>
        protected static void HasCutHollowDimpleProfileCut(PrimType primType, PrimitiveBaseShape shape, out bool hasCut,
                                                           out bool hasHollow,
                                                           out bool hasDimple, out bool hasProfileCut)
        {
            if (primType == PrimType.BOX
                ||
                primType == PrimType.CYLINDER
                ||
                primType == PrimType.PRISM)

                hasCut = (shape.ProfileBegin > 0) || (shape.ProfileEnd > 0);
            else
                hasCut = (shape.PathBegin > 0) || (shape.PathEnd > 0);

            hasHollow = shape.ProfileHollow > 0;
            hasDimple = (shape.ProfileBegin > 0) || (shape.ProfileEnd > 0); // taken from llSetPrimitiveParms
            hasProfileCut = hasDimple; // is it the same thing?
        }
Example #53
0
        public virtual void AddNewPrim(UUID ownerID, UUID groupID, Vector3 RayEnd, Quaternion rot,
                                       PrimitiveBaseShape shape,
                                       byte bypassRaycast, Vector3 RayStart, UUID RayTargetID,
                                       byte RayEndIsIntersection)
        {
            Vector3 pos = GetNewRezLocation(RayStart, RayEnd, RayTargetID, rot, bypassRaycast, RayEndIsIntersection,
                                            true, new Vector3(0.5f, 0.5f, 0.5f), false);

            string reason;
            if (m_parentScene.Permissions.CanRezObject(1, ownerID, pos, out reason))
            {
                AddNewPrim(ownerID, groupID, pos, rot, shape);
            }
            else
            {
                GetScenePresence(ownerID)
                    .ControllingClient.SendAlertMessage("You do not have permission to rez objects here: " + reason);
            }
        }
        public ISceneEntity AddTree(
            UUID uuid, UUID groupID, Vector3 scale, Quaternion rotation, Vector3 position, Tree treeType, bool newTree)
        {
            PrimitiveBaseShape treeShape = new PrimitiveBaseShape
                                               {
                                                   PathCurve = 16,
                                                   PathEnd = 49900,
                                                   PCode = newTree ? (byte) PCode.NewTree : (byte) PCode.Tree,
                                                   Scale = scale,
                                                   State = (byte) treeType
                                               };

            return m_scene.SceneGraph.AddNewPrim(uuid, groupID, position, rotation, treeShape);
        }
        Primitive.TextureEntry SetTexture (PrimitiveBaseShape shape, UUID newID, UUID oldID)
        {
            Primitive.TextureEntry oldShape = shape.Textures;
            Primitive.TextureEntry newShape;
            newShape = shape.Textures.DefaultTexture.TextureID == oldID
                           ? Copy (shape.Textures, newID)
                           : Copy (shape.Textures, shape.Textures.DefaultTexture.TextureID);

            int i = 0;
            foreach (Primitive.TextureEntryFace face in shape.Textures.FaceTextures) {
                if (face != null)
                    if (face.TextureID == oldID) {
                        Primitive.TextureEntryFace f = newShape.CreateFace ((uint)i);
                        CopyFace (oldShape.FaceTextures [i], f);
                        f.TextureID = newID;
                        newShape.FaceTextures [i] = f;
                    } else {
                        Primitive.TextureEntryFace f = newShape.CreateFace ((uint)i);
                        CopyFace (oldShape.FaceTextures [i], f);
                        f.TextureID = oldShape.FaceTextures [i].TextureID;
                        newShape.FaceTextures [i] = f;
                    }
                i++;
            }

            return newShape;
        }
Example #56
0
        public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical)
        {
            Mesh mesh = null;
            ulong key = primShape.GetMeshKey(size, lod);

            if (size.X < 0.01f) size.X = 0.01f;
            if (size.Y < 0.01f) size.Y = 0.01f;
            if (size.Z < 0.01f) size.Z = 0.01f;

            if ((!isPhysical) && size.X < minSizeForComplexMesh && size.Y < minSizeForComplexMesh &&
                size.Z < minSizeForComplexMesh)
                mesh = CreateBoundingBoxMesh(size, key);
            else
                mesh = CreateMeshFromPrimMesher(primName, primShape, size, lod, key);

            return mesh;
        }
        protected void AdaptTree(ref PrimitiveBaseShape tree)
        {
            // Tree size has to be adapted depending on its type
            switch ((Tree) tree.State)
            {
                case Tree.Cypress1:
                case Tree.Cypress2:
                case Tree.Palm1:
                case Tree.Palm2:
                case Tree.WinterAspen:
                    tree.Scale = new Vector3(4, 4, 10);
                    break;
                case Tree.WinterPine1:
                case Tree.WinterPine2:
                    tree.Scale = new Vector3(4, 4, 20);
                    break;

                case Tree.Dogwood:
                    tree.Scale = new Vector3(6.5f, 6.5f, 6.5f);
                    break;

                    // case... other tree types
                    // tree.Scale = new Vector3(?, ?, ?);
                    // break;

                default:
                    tree.Scale = new Vector3(4, 4, 4);
                    break;
            }
        }
Example #58
0
        private Mesh CreateMeshFromPrimMesher(string primName, PrimitiveBaseShape primShape, Vector3 size, float lod,
            ulong key)
        {
            PrimMesh primMesh;
            SculptMesh sculptMesh;

            List<Coord> coords = new List<Coord>();
            List<Face> faces = new List<Face>();

            Image idata = null;
            string decodedSculptFileName = "";

            if (primShape.SculptEntry)
            {
                if (((SculptType) primShape.SculptType & SculptType.Mesh) == SculptType.Mesh)
                {
                    if (!UseMeshesPhysicsMesh)
                        return null;

                    MainConsole.Instance.Debug("[MESH]: experimental mesh proxy generation");

                    OSD meshOsd = null;

                    if (primShape.SculptData == null || primShape.SculptData.Length <= 0)
                    {
                        //MainConsole.Instance.Error("[MESH]: asset data is zero length");
                        return null;
                    }

                    long start = 0;
                    using (MemoryStream data = new MemoryStream(primShape.SculptData))
                    {
                        try
                        {
                            meshOsd = OSDParser.DeserializeLLSDBinary(data);
                        }
                        catch (Exception e)
                        {
                            MainConsole.Instance.Error("[MESH]: Exception deserializing mesh asset header:" + e);
                        }
                        start = data.Position;
                    }

                    if (meshOsd is OSDMap)
                    {
                        OSDMap map = (OSDMap) meshOsd;
                        OSDMap physicsParms = new OSDMap();

                        if (map.ContainsKey("physics_cached"))
                        {
                            OSD cachedMeshMap = map["physics_cached"]; // cached data from Aurora
                            Mesh cachedMesh = new Mesh(key);
                            cachedMesh.Deserialize(cachedMeshMap);
                            cachedMesh.WasCached = true;
                            return cachedMesh; //Return here, we found all of the info right here
                        }
                        if (map.ContainsKey("physics_shape"))
                            physicsParms = (OSDMap) map["physics_shape"]; // old asset format
                        if (physicsParms.Count == 0 && map.ContainsKey("physics_mesh"))
                            physicsParms = (OSDMap) map["physics_mesh"]; // new asset format
                        if (physicsParms.Count == 0 && map.ContainsKey("physics_convex"))
                            // convex hull format, which we can't read, so instead
                            // read the highest lod that exists, and use it instead
                            physicsParms = (OSDMap) map["high_lod"];

                        int physOffset = physicsParms["offset"].AsInteger() + (int) start;
                        int physSize = physicsParms["size"].AsInteger();

                        if (physOffset < 0 || physSize == 0)
                            return null; // no mesh data in asset

                        OSD decodedMeshOsd = new OSD();
                        byte[] meshBytes = new byte[physSize];
                        Buffer.BlockCopy(primShape.SculptData, physOffset, meshBytes, 0, physSize);
                        try
                        {
                            using (MemoryStream inMs = new MemoryStream(meshBytes))
                            {
                                using (MemoryStream outMs = new MemoryStream())
                                {
                                    using (ZOutputStream zOut = new ZOutputStream(outMs))
                                    {
                                        byte[] readBuffer = new byte[2048];
                                        int readLen = 0;
                                        while ((readLen = inMs.Read(readBuffer, 0, readBuffer.Length)) > 0)
                                        {
                                            zOut.Write(readBuffer, 0, readLen);
                                        }
                                        zOut.Flush();
                                        outMs.Seek(0, SeekOrigin.Begin);

                                        byte[] decompressedBuf = outMs.GetBuffer();

                                        decodedMeshOsd = OSDParser.DeserializeLLSDBinary(decompressedBuf);
                                    }
                                }
                            }
                        }
                        catch (Exception e)
                        {
                            MainConsole.Instance.Error("[MESH]: exception decoding physical mesh: " + e);
                            return null;
                        }

                        OSDArray decodedMeshOsdArray = null;

                        // physics_shape is an array of OSDMaps, one for each submesh
                        if (decodedMeshOsd is OSDArray)
                        {
                            decodedMeshOsdArray = (OSDArray) decodedMeshOsd;
                            foreach (OSD subMeshOsd in decodedMeshOsdArray)
                            {
                                if (subMeshOsd is OSDMap)
                                {
                                    OSDMap subMeshMap = (OSDMap) subMeshOsd;

                                    // As per http://wiki.secondlife.com/wiki/Mesh/Mesh_Asset_Format, some Mesh Level
                                    // of Detail Blocks (maps) contain just a NoGeometry key to signal there is no
                                    // geometry for this submesh.
                                    if (subMeshMap.ContainsKey("NoGeometry") && (subMeshMap["NoGeometry"]))
                                        continue;

                                    Vector3 posMax = new Vector3(0.5f, 0.5f, 0.5f);
                                    Vector3 posMin = new Vector3(-0.5f, -0.5f, -0.5f);
                                    if (subMeshMap.ContainsKey("PositionDomain"))
                                        //Optional, so leave the max and min values otherwise
                                    {
                                        posMax = ((OSDMap) subMeshMap["PositionDomain"])["Max"].AsVector3();
                                        posMin = ((OSDMap) subMeshMap["PositionDomain"])["Min"].AsVector3();
                                    }
                                    ushort faceIndexOffset = (ushort) coords.Count;

                                    byte[] posBytes = subMeshMap["Position"].AsBinary();
                                    for (int i = 0; i < posBytes.Length; i += 6)
                                    {
                                        ushort uX = Utils.BytesToUInt16(posBytes, i);
                                        ushort uY = Utils.BytesToUInt16(posBytes, i + 2);
                                        ushort uZ = Utils.BytesToUInt16(posBytes, i + 4);

                                        Coord c = new Coord(
                                            Utils.UInt16ToFloat(uX, posMin.X, posMax.X)*size.X,
                                            Utils.UInt16ToFloat(uY, posMin.Y, posMax.Y)*size.Y,
                                            Utils.UInt16ToFloat(uZ, posMin.Z, posMax.Z)*size.Z);

                                        coords.Add(c);
                                    }

                                    byte[] triangleBytes = subMeshMap["TriangleList"].AsBinary();
                                    for (int i = 0; i < triangleBytes.Length; i += 6)
                                    {
                                        ushort v1 = (ushort) (Utils.BytesToUInt16(triangleBytes, i) + faceIndexOffset);
                                        ushort v2 =
                                            (ushort) (Utils.BytesToUInt16(triangleBytes, i + 2) + faceIndexOffset);
                                        ushort v3 =
                                            (ushort) (Utils.BytesToUInt16(triangleBytes, i + 4) + faceIndexOffset);
                                        Face f = new Face(v1, v2, v3);
                                        faces.Add(f);
                                    }
                                }
                            }
                        }
                    }
                }
                else
                {
                    if (cacheSculptMaps && primShape.SculptTexture != UUID.Zero)
                    {
                        decodedSculptFileName = System.IO.Path.Combine(decodedSculptMapPath,
                                                             "smap_" + primShape.SculptTexture.ToString());
                        try
                        {
                            if (File.Exists(decodedSculptFileName))
                            {
                                idata = Image.FromFile(decodedSculptFileName);
                            }
                        }
                        catch (Exception e)
                        {
                            MainConsole.Instance.Error("[SCULPT]: unable to load cached sculpt map " +
                                                       decodedSculptFileName + " " + e);
                        }
                        //if (idata != null)
                        //    MainConsole.Instance.Debug("[SCULPT]: loaded cached map asset for map ID: " + primShape.SculptTexture.ToString());
                    }

                    if (idata == null)
                    {
                        if (primShape.SculptData == null || primShape.SculptData.Length == 0)
                            return null;

                        try
                        {
                            idata = m_j2kDecoder.DecodeToImage(primShape.SculptData);

                            if (idata != null && cacheSculptMaps &&
                                (cacheSculptAlphaMaps || (((ImageFlags) (idata.Flags) & ImageFlags.HasAlpha) == 0)))
                            {
                                try
                                {
                                    idata.Save(decodedSculptFileName, ImageFormat.MemoryBmp);
                                }
                                catch (Exception e)
                                {
                                    MainConsole.Instance.Error("[SCULPT]: unable to cache sculpt map " +
                                                               decodedSculptFileName + " " +
                                                               e);
                                }
                            }
                        }
                        catch (DllNotFoundException)
                        {
                            MainConsole.Instance.Error(
                                "[PHYSICS]: OpenJpeg is not installed correctly on this system. Physics Proxy generation failed.  Often times this is because of an old version of GLIBC.  You must have version 2.4 or above!");
                            return null;
                        }
                        catch (IndexOutOfRangeException)
                        {
                            MainConsole.Instance.Error(
                                "[PHYSICS]: OpenJpeg was unable to decode this. Physics Proxy generation failed");
                            return null;
                        }
                        catch (Exception ex)
                        {
                            MainConsole.Instance.Error(
                                "[PHYSICS]: Unable to generate a Sculpty physics proxy. Sculpty texture decode failed: " +
                                ex);
                            return null;
                        }
                    }

                    SculptMesh.SculptType sculptType;
                    switch ((SculptType) primShape.SculptType)
                    {
                        case SculptType.Cylinder:
                            sculptType = SculptMesh.SculptType.cylinder;
                            break;
                        case SculptType.Plane:
                            sculptType = SculptMesh.SculptType.plane;
                            break;
                        case SculptType.Torus:
                            sculptType = SculptMesh.SculptType.torus;
                            break;
                        case SculptType.Sphere:
                            sculptType = SculptMesh.SculptType.sphere;
                            break;
                        default:
                            sculptType = SculptMesh.SculptType.plane;
                            break;
                    }

                    bool mirror = ((primShape.SculptType & 128) != 0);
                    bool invert = ((primShape.SculptType & 64) != 0);

                    if (idata == null)
                        return null;

                    sculptMesh = new SculptMesh((Bitmap) idata, sculptType, (int) lod, false, mirror, invert);

                    idata.Dispose();
                    idata = null;

                    sculptMesh.DumpRaw(baseDir, primName, "primMesh");

                    sculptMesh.Scale(size.X, size.Y, size.Z);

                    coords = sculptMesh.coords;
                    faces = sculptMesh.faces;
                }
            }
            else
            {
                float pathShearX = primShape.PathShearX < 128
                                       ? primShape.PathShearX*0.01f
                                       : (primShape.PathShearX - 256)*0.01f;
                float pathShearY = primShape.PathShearY < 128
                                       ? primShape.PathShearY*0.01f
                                       : (primShape.PathShearY - 256)*0.01f;
                float pathBegin = primShape.PathBegin*2.0e-5f;
                float pathEnd = 1.0f - primShape.PathEnd*2.0e-5f;
                float pathScaleX = (primShape.PathScaleX - 100)*0.01f;
                float pathScaleY = (primShape.PathScaleY - 100)*0.01f;

                float profileBegin = primShape.ProfileBegin*2.0e-5f;
                float profileEnd = 1.0f - primShape.ProfileEnd*2.0e-5f;
                float profileHollow = primShape.ProfileHollow*2.0e-5f;
                if (profileHollow > 0.95f)
                {
                    if (profileHollow > 0.99f)
                        profileHollow = 0.99f;
                    float sizeX = primShape.Scale.X - (primShape.Scale.X*profileHollow);
                    if (sizeX < 0.1f) //If its > 0.1, its fine to mesh at the small hollow
                        profileHollow = 0.95f + (sizeX/2); //Scale the rest by how large the size of the prim is
                }

                int sides = 4;
                switch ((primShape.ProfileCurve & 0x07))
                {
                    case (byte) ProfileShape.EquilateralTriangle:
                        sides = 3;
                        break;
                    case (byte) ProfileShape.Circle:
                        sides = 24;
                        break;
                    case (byte) ProfileShape.HalfCircle:
                        sides = 24;
                        profileBegin = 0.5f*profileBegin + 0.5f;
                        profileEnd = 0.5f*profileEnd + 0.5f;
                        break;
                }

                int hollowSides = sides;
                switch (primShape.HollowShape)
                {
                    case HollowShape.Circle:
                        hollowSides = 24;
                        break;
                    case HollowShape.Square:
                        hollowSides = 4;
                        break;
                    case HollowShape.Triangle:
                        hollowSides = 3;
                        break;
                }

                primMesh = new PrimMesh(sides, profileBegin, profileEnd, profileHollow, hollowSides);

                if (primMesh.errorMessage != null)
                    if (primMesh.errorMessage.Length > 0)
                        MainConsole.Instance.Error("[ERROR] " + primMesh.errorMessage);

                primMesh.topShearX = pathShearX;
                primMesh.topShearY = pathShearY;
                primMesh.pathCutBegin = pathBegin;
                primMesh.pathCutEnd = pathEnd;

                if (primShape.PathCurve == (byte) Extrusion.Straight || primShape.PathCurve == (byte) Extrusion.Flexible)
                {
                    primMesh.twistBegin = primShape.PathTwistBegin*18/10;
                    primMesh.twistEnd = primShape.PathTwist*18/10;
                    primMesh.taperX = pathScaleX;
                    primMesh.taperY = pathScaleY;

                    if (profileBegin < 0.0f || profileBegin >= profileEnd || profileEnd > 1.0f)
                    {
                        ReportPrimError("*** CORRUPT PRIM!! ***", primName, primMesh);
                        if (profileBegin < 0.0f) profileBegin = 0.0f;
                        if (profileEnd > 1.0f) profileEnd = 1.0f;
                    }
            #if SPAM
                MainConsole.Instance.Debug("****** PrimMesh Parameters (Linear) ******\n" + primMesh.ParamsToDisplayString());
            #endif
                    try
                    {
                        primMesh.Extrude(primShape.PathCurve == (byte) Extrusion.Straight
                                             ? PathType.Linear
                                             : PathType.Flexible);
                    }
                    catch (Exception ex)
                    {
                        ReportPrimError("Extrusion failure: exception: " + ex, primName, primMesh);
                        return null;
                    }
                }
                else
                {
                    primMesh.holeSizeX = (200 - primShape.PathScaleX)*0.01f;
                    primMesh.holeSizeY = (200 - primShape.PathScaleY)*0.01f;
                    primMesh.radius = 0.01f*primShape.PathRadiusOffset;
                    primMesh.revolutions = 1.0f + 0.015f*primShape.PathRevolutions;
                    primMesh.skew = 0.01f*primShape.PathSkew;
                    primMesh.twistBegin = primShape.PathTwistBegin*36/10;
                    primMesh.twistEnd = primShape.PathTwist*36/10;
                    primMesh.taperX = primShape.PathTaperX*0.01f;
                    primMesh.taperY = primShape.PathTaperY*0.01f;

                    if (profileBegin < 0.0f || profileBegin >= profileEnd || profileEnd > 1.0f)
                    {
                        ReportPrimError("*** CORRUPT PRIM!! ***", primName, primMesh);
                        if (profileBegin < 0.0f) profileBegin = 0.0f;
                        if (profileEnd > 1.0f) profileEnd = 1.0f;
                    }
            #if SPAM
                MainConsole.Instance.Debug("****** PrimMesh Parameters (Circular) ******\n" + primMesh.ParamsToDisplayString());
            #endif
                    try
                    {
                        primMesh.Extrude(PathType.Circular);
                    }
                    catch (Exception ex)
                    {
                        ReportPrimError("Extrusion failure: exception: " + ex, primName, primMesh);
                        return null;
                    }
                }

                primMesh.DumpRaw(baseDir, primName, "primMesh");

                primMesh.Scale(size.X, size.Y, size.Z);

                coords = primMesh.coords;
                faces = primMesh.faces;
                primMesh = null;
            }

            Mesh mesh = new Mesh(key);
            //mesh.m_triangles = faces;
            //mesh.m_vertices = coords;
            // Add the corresponding triangles to the mesh
            mesh.Set(coords, faces);
            coords.Clear();
            faces.Clear();
            coords = null;
            faces = null;
            return mesh;
        }
Example #59
0
 public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical)
 {
     return null;
 }
Example #60
0
 /*
 public override PhysicsActor AddPrim(Vector3 position, Vector3 size, Quaternion rotation)
 {
     return null;
 }
 */
 public override PhysicsActor AddPrimShape(UUID primID, uint localID, string name, byte physicsType, PrimitiveBaseShape shape, 
     Vector3 position, Vector3 size, Quaternion rotation, bool isPhysical)
 {
     return null;
 }