public static MaterialPrimitivePair CreatePair(ref Primitive primitive, ref int materialID, ref MaterialProperties materialProperties) { MaterialPrimitivePair newPair = new MaterialPrimitivePair(); newPair.Primitive = primitive; newPair.MaterialProperties = materialProperties; return newPair; }
/// <summary> /// Adds a primitive to this collision skin - the primitive is /// copied (so you can pass in something on the stack, or delete /// the original) - perhaps using reference counting. Returns the /// primitive index, or -1 if failure Also takes that material ID /// and the properties used when a collision ID is USER_DEFINED /// </summary> private int AddPrimitive(Primitive prim, int matID, MaterialProperties matProps) { Primitive newPrim = prim.Clone(); if (newPrim == null) throw new ArgumentException("Not able to clone primitive!"); materialIDs.Add(matID); materialProperties.Add(matProps); primitivesOldWorld.Add(prim.Clone()); primitivesNewWorld.Add(prim.Clone()); primitivesLocal.Add(newPrim); UpdateWorldBoundingBox(); return materialIDs.Count - 1; }
public int AddPrimitive(Primitive prim, MaterialProperties matProps) { return AddPrimitive(prim, (int)MaterialTable.MaterialID.UserDefined, matProps); }
public int AddPrimitive(Primitive prim, int matID) { if (matID == (int)MaterialTable.MaterialID.UserDefined) throw new ArgumentException("matID can't be set to 'UserDefined'"); return AddPrimitive(prim, matID, MaterialProperties.Unset); }
public static MaterialPrimitivePair CreatePair(Primitive primitive, int materialID, ref MaterialProperties materialProperties) { return CreatePair(ref primitive, ref materialID, ref materialProperties); }
public void Add(Primitive primitive, MaterialProperties materialProperties) { _materialPrimitivePairs.Add(MaterialPrimitivePair.CreatePair(primitive, (int)MaterialTable.MaterialID.UserDefined, ref materialProperties)); }
public void Add(Primitive primitive, int materialID, MaterialProperties materialProperties) { _materialPrimitivePairs.Add(MaterialPrimitivePair.CreatePair(primitive, materialID, ref materialProperties)); }
private void Initialize(Primitive primitive, MaterialProperties materialProperties, PrimitiveProperties primitiveProperties, bool enableBody) { float mass; Vector3 centerOfMass; Matrix inertiaTensor; Matrix inertiaTensorCoM; // Set variables ... _primitive = primitive; _primitiveProperties = primitiveProperties; _materialProperties = materialProperties; // Create and link Body and CollisionSkin. _body = new Body(); _skin = new CollisionSkin(_body); _body.CollisionSkin = _skin; // Add primitive to CollisionSkin. _skin.AddPrimitive(primitive, materialProperties); // Set body properties. _skin.GetMassProperties(primitiveProperties, out mass, out centerOfMass, out inertiaTensor, out inertiaTensorCoM); _body.BodyInertia = inertiaTensorCoM; _body.Mass = mass; // Sync CollisionSkin and Body. _body.MoveTo(Vector3.Zero, Matrix.Identity); _skin.ApplyLocalTransform(new Transform(-centerOfMass, Matrix.Identity)); // Enable Body. if (enableBody) { _body.EnableBody(); } else { _body.DisableBody(); } }
public void Dispose() { _primitive = null; _body = null; _skin = null; }
/// <summary> /// Initializes a new BasicObject. /// </summary> /// <param name="primitive">Primitive that will define the CollisionSkin.</param> /// <param name="materialProperties"></param> /// <param name="primitiveProperties"></param> /// <param name="enableBody"></param> public BasicObject(Primitive primitive, MaterialProperties materialProperties, PrimitiveProperties primitiveProperties, bool enableBody) { Initialize(primitive, materialProperties, primitiveProperties, enableBody); }
/// <summary> /// Initializes a new BasicObject. Body is enabled by default. /// </summary> /// <param name="primitive">Primitive that will define the CollisionSkin.</param> /// <param name="materialProperties"></param> /// <param name="primitiveProperties"></param> public BasicObject(Primitive primitive, MaterialProperties materialProperties, PrimitiveProperties primitiveProperties) { Initialize(primitive, materialProperties, primitiveProperties, true); }
/// <summary> /// /// </summary> /// <param name="type">Only AABox, Box, Capsule & Sphere will be accepted.</param> /// <param name="color"></param> private void Initialize(PrimitiveType type, MaterialProperties materialProperties, Color4 color) { switch(type) { case PrimitiveType.AABox: _primitive = new AABox(new Vector3(-0.5f), new Vector3(0.5f)); break; case PrimitiveType.Box: _primitive = new Box(Vector3.Zero, Matrix.Identity, new Vector3(1f)); break; case PrimitiveType.Capsule: _primitive = new Capsule(Vector3.Zero, Matrix.Identity, 1f, 1f); break; case PrimitiveType.Sphere: _primitive = new Sphere(Vector3.Zero, 1f); break; default: goto case PrimitiveType.Box; } _materialProperties = materialProperties; _color = color; }