Esempio n. 1
0
        /// <summary>
        /// Single Primitive Constructor with predefined MaterialProperty
        /// </summary>
        /// <param name="position">Initial Body Position</param>
        /// <param name="scale">Scale</param>
        /// <param name="primative">Primitive to add to Skin</param>
        /// <param name="propId">Predefined Material Properties of Primitive</param>
        public Gobject(Vector3 position, Vector3 scale, Primitive primative, MaterialTable.MaterialID propId, Model model)
            : this()
        {
            Skin.AddPrimitive(primative, (int)propId);

            CommonInit(position, scale, model, true);
        }
Esempio n. 2
0
        private unsafe void Init(CollDetectInfo info, Vector3 dirToBody0, SmallCollPointInfo *pointInfos, int numPointInfos)
        {
            this.SkinInfo   = info;
            this.dirToBody0 = dirToBody0;

            int ID0 = info.Skin0.GetMaterialID(info.IndexPrim0);
            int ID1 = info.Skin1.GetMaterialID(info.IndexPrim1);

            MaterialTable matTable = info.Skin0.CollisionSystem.MaterialTable;

            if (ID0 == (int)MaterialTable.MaterialID.UserDefined || (int)ID1 == (int)MaterialTable.MaterialID.UserDefined)
            {
                MaterialProperties prop0, prop1;

                if (ID0 == (int)MaterialTable.MaterialID.UserDefined)
                {
                    prop0 = info.Skin0.GetMaterialProperties(info.IndexPrim0);
                }
                else
                {
                    prop0 = matTable.GetMaterialProperties(ID0);
                }

                if (ID1 == (int)MaterialTable.MaterialID.UserDefined)
                {
                    prop1 = info.Skin1.GetMaterialProperties(info.IndexPrim1);
                }
                else
                {
                    prop1 = matTable.GetMaterialProperties(ID1);
                }

                MatPairProperties.Restitution     = prop0.Elasticity * prop1.Elasticity;
                MatPairProperties.StaticFriction  = prop0.StaticRoughness * prop1.StaticRoughness;
                MatPairProperties.DynamicFriction = prop0.DynamicRoughness * prop1.DynamicRoughness;
            }
            else
            {
                MatPairProperties = matTable.GetPairProperties(ID0, ID1);
            }

            numPointInfos = (numPointInfos > MaxCollisionPoints) ? MaxCollisionPoints : numPointInfos;

            NumCollPts = 0;
            for (int i = 0; i < numPointInfos; ++i)
            {
                if (freePtInfos.Count == 0)
                {
                    freePtInfos.Push(new CollPointInfo());
                }
                this.PointInfo[NumCollPts] = freePtInfos.Pop();
                this.PointInfo[NumCollPts++].Init(ref pointInfos[i]);
            }
        }