コード例 #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 static NVRVertexType GetVertexTypeFromMaterial(NVRMaterial mat)
 {
     if (mat.Type == NVRMaterialType.MATERIAL_TYPE_DEFAULT)
     {
         if (mat.Flags.HasFlag(NVRMaterialFlags.ColoredVertex) || mat.Flags.HasFlag(NVRMaterialFlags.GroundVertex))
         {
             if (mat.Flags.HasFlag(NVRMaterialFlags.GroundVertex) && ContainsGroundKeyword(mat.Channels[0].Name))
             {
                 return(NVRVertexType.NVRVERTEX_GROUND_8);
             }
             else
             {
                 return(NVRVertexType.NVRVERTEX_8);
             }
         }
         else
         {
             return(NVRVertexType.NVRVERTEX_4);
         }
     }
     else if (mat.Type == NVRMaterialType.MATERIAL_TYPE_FOUR_BLEND)
     {
         return(NVRVertexType.NVRVERTEX_12);
     }
     else
     {
         return(NVRVertexType.NVRVERTEX_4);
     }
 }
コード例 #3
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);
        }
コード例 #4
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);
 }
コード例 #5
0
        public static NVRMaterial CreateMaterial(string materialName, string textureName, ColorRGBAVector4 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 ColorRGBAVector4(0, 0, 0, 0), new R3DMatrix44()));
            }
            NVRMaterial newMat = new NVRMaterial(materialName, matType, matFlags, channels);

            return(newMat);
        }
コード例 #6
0
 public static bool IsGroundType(NVRMaterial mat)
 {
     return(mat.Flags.HasFlag(NVRMaterialFlags.GroundVertex) && ContainsGroundKeyword(mat.Channels[0].Name));
 }