Пример #1
0
        public NVRMesh AddMesh(NVRMeshQuality meshQualityLevel, NVRMaterial material, List <NVRVertex> vertices, List <int> indices)
        {
            NVRMesh newMesh = new NVRMesh(meshQualityLevel, 0, material, vertices, indices);

            this.Meshes.Add(newMesh);
            return(newMesh);
        }
Пример #2
0
        public NVRMesh(NVRMeshQuality meshQualityLevel, int flag, NVRMaterial material, List <NVRVertex> vertices, List <int> indices)
        {
            this.QualityLevel         = meshQualityLevel;
            this.Flag                 = flag;
            this.Material             = material;
            this.IndexedPrimitives[0] = new NVRDrawIndexedPrimitive(this, vertices, indices, true);
            this.IndexedPrimitives[1] = new NVRDrawIndexedPrimitive(this, vertices, indices, false);

            float[] min = new float[3] {
                vertices[0].Position.X, vertices[0].Position.Y, vertices[0].Position.Z
            };
            float[] max = new float[3] {
                vertices[0].Position.X, vertices[0].Position.Y, vertices[0].Position.Z
            };
            for (int i = 1; i < vertices.Count; i++)
            {
                Vector3 position = vertices[i].Position;
                if (position.X < min[0])
                {
                    min[0] = position.X;
                }
                if (position.Y < min[1])
                {
                    min[1] = position.Y;
                }
                if (position.Z < min[2])
                {
                    min[2] = position.Z;
                }
                if (position.X > max[0])
                {
                    max[0] = position.X;
                }
                if (position.Y > max[1])
                {
                    max[1] = position.Y;
                }
                if (position.Z > max[2])
                {
                    max[2] = position.Z;
                }
            }
            this.BoundingBox = new R3DBox(new Vector3(min[0], min[1], min[2]), new Vector3(max[0], max[1], max[2]));

            float radius = max[0] - min[0];

            if (max[1] - min[1] > radius)
            {
                radius = max[1] - min[1];
            }
            if (max[2] - min[2] > radius)
            {
                radius = max[2] - min[2];
            }
            this.BoundingSphere = new R3DSphere(new Vector3((min[0] + max[0]) / 2, (min[1] + max[1]) / 2, (min[2] + max[2]) / 2), radius / 2);
        }
Пример #3
0
 public static NVRVertexType GetVertexTypeFromMaterial(NVRMaterial mat)
 {
     if (mat.Type == NVRMaterialType.MATERIAL_TYPE_FOUR_BLEND)
     {
         return(NVRVertexType.NVRVERTEX_12);
     }
     else if (mat.Type == NVRMaterialType.MATERIAL_TYPE_DEFAULT && mat.Flags.HasFlag(NVRMaterialFlags.ColoredVertex))
     {
         return(NVRVertexType.NVRVERTEX_8);
     }
     return(NVRVertexType.NVRVERTEX_4);
 }
Пример #4
0
        public static NVRMaterial CreateMaterial(string materialName, string textureName, Color color, NVRMaterialType matType, NVRMaterialFlags matFlags)
        {
            List <NVRChannel> channels = new List <NVRChannel>();

            channels.Add(new NVRChannel(textureName, color, new R3DMatrix44()));
            for (int i = 0; i < 7; i++)
            {
                channels.Add(new NVRChannel("", new Color(0, 0, 0, 0), new R3DMatrix44()));
            }
            NVRMaterial newMat = new NVRMaterial(materialName, matType, matFlags, channels);

            return(newMat);
        }
Пример #5
0
 public static bool IsGroundType(NVRMaterial mat)
 {
     return(mat.Flags.HasFlag(NVRMaterialFlags.GroundVertex) && ContainsGroundKeyword(mat.Channels[0].Name));
 }