Ejemplo n.º 1
0
        public void SetMaterial(int material)
        {
            Material = (MaterialAttributes.Material)material;

            // Setting the material sets the material attributes also.
            MaterialAttributes matAttrib = BSMaterials.GetAttributes(Material, false);

            Friction    = matAttrib.friction;
            Restitution = matAttrib.restitution;
            Density     = matAttrib.density / BSParam.DensityScaleFactor;
            // DetailLog("{0},{1}.SetMaterial,Mat={2},frict={3},rest={4},den={5}", LocalID, TypeName, Material, Friction, Restitution, Density);
        }
Ejemplo n.º 2
0
        // Use reflection to set the value in the attribute structure.
        static void SetAttributeValue(int matType, string attribName, float val)
        {
            // Get the current attribute values for this material
            MaterialAttributes thisAttrib = Attributes[matType];
            // Find the field for the passed attribute name (eg, find field named 'friction')
            FieldInfo fieldInfo = thisAttrib.GetType().GetField(attribName.ToLower());

            if (fieldInfo != null)
            {
                fieldInfo.SetValue(thisAttrib, val);
                // Copy new attributes back to array -- since MaterialAttributes is 'struct', passed by value, not reference.
                Attributes[matType] = thisAttrib;
            }
        }
Ejemplo n.º 3
0
 // Given a material type, return a structure of attributes.
 public static MaterialAttributes GetAttributes(MaterialAttributes.Material type, bool isPhysical)
 {
     int ind = (int)type;
     if (isPhysical) ind += (int)MaterialAttributes.Material.NumberOfTypes;
     return Attributes[ind];
 }