コード例 #1
0
        internal void GenerateColliders(float collisionReductionFactor, List <ICollider> colliders)
        {
            var mesh = _meshGenerator.GetMesh();

            if (mesh == null)
            {
                Logger.Warn($"Primitive {_meshGenerator.name} did not return a mesh for collider generation.");
                return;
            }
            mesh = mesh.Transform(_meshGenerator.GetTransformationMatrix());

            var reducedVertices = math.max(
                (uint)MathF.Pow(mesh.Vertices.Length,
                                MathF.Clamp(1f - collisionReductionFactor, 0f, 1f) * 0.25f + 0.75f),
                420u                 //!! 420 = magic
                );

            if (reducedVertices < mesh.Vertices.Length)
            {
                mesh = ComputeReducedMesh(mesh, reducedVertices);
            }

            ColliderUtils.GenerateCollidersFromMesh(mesh, _api.GetColliderInfo(), colliders);
        }
コード例 #2
0
        public void UpdateData()
        {
            MaterialData.Name                    = Name;
            MaterialData.BaseColor               = BaseColor.ToInt(ColorFormat.Bgr);
            MaterialData.Glossiness              = Glossiness.ToInt(ColorFormat.Bgr);
            MaterialData.ClearCoat               = ClearCoat.ToInt(ColorFormat.Bgr);
            MaterialData.WrapLighting            = WrapLighting;
            MaterialData.Roughness               = Roughness;
            MaterialData.GlossyImageLerp         = (byte)BiffFloatAttribute.QuantizeUnsigned(8, MathF.Clamp(1f - GlossyImageLerp, 0f, 1f));
            MaterialData.Thickness               = (byte)BiffFloatAttribute.QuantizeUnsigned(8, MathF.Clamp(Thickness, 0f, 1f));
            MaterialData.Edge                    = Edge;
            MaterialData.Opacity                 = Opacity;
            MaterialData.IsMetal                 = IsMetal ? (byte)1 : (byte)0;
            MaterialData.OpacityActiveEdgeAlpha  = IsOpacityActive ? (byte)1 : (byte)0;
            MaterialData.OpacityActiveEdgeAlpha |= (byte)(BiffFloatAttribute.QuantizeUnsigned(7, MathF.Clamp(EdgeAlpha, 0f, 1f)) << 1);

            PhysicsMaterialData.Name              = Name;
            PhysicsMaterialData.Elasticity        = Elasticity;
            PhysicsMaterialData.ElasticityFallOff = ElasticityFalloff;
            PhysicsMaterialData.Friction          = Friction;
            PhysicsMaterialData.ScatterAngle      = ScatterAngle;
        }