Exemple #1
0
        static Material BuildMaterial(byte[] bytes, int startIndex)
        {
            Material mat = new Material();
            byte matType = bytes[startIndex];
            mat.Type = matType;

            if (matType == (byte)MaterialType.MaterialColor)
            {
                MaterialColor mColor = new MaterialColor();
                mColor.Red = bytes[startIndex + 1];
                mColor.Green = bytes[startIndex + 2];
                mColor.Blue = bytes[startIndex + 3];
                mat.Data = mColor;
            }
            else if (matType == (byte)MaterialType.MaterialTextureMap)
            {
                MaterialTextureMap mTexMap = new MaterialTextureMap();
                mTexMap.Bpp = bytes[startIndex + 1];
                mTexMap.Width = BitConverter.ToInt16(bytes, startIndex + 2);
                mTexMap.Height = BitConverter.ToInt16(bytes, startIndex + 4);
                mTexMap.Size = BitConverter.ToInt32(bytes, startIndex + 6);
                mTexMap.TCType = BitConverter.ToInt32(bytes, startIndex + 10);
                mTexMap.TexBuff = BuildBytes(bytes, startIndex + 14, mTexMap.Size);
                mat.Data = mTexMap;
            }
            else if (matType == (byte)MaterialType.MaterialTransparency)
            {
                MaterialTransparency mTrans = new MaterialTransparency();
                mTrans.Transparency = bytes[startIndex + 1];
                mat.Data = mTrans;
            }
            else if (matType == (byte)MaterialType.MaterialShininess)
            {
                MaterialShininess mShin = new MaterialShininess();
                mShin.Shininess = bytes[startIndex + 1];
                mat.Data = mShin;
            }
            else if (matType == (byte)MaterialType.MaterialSharedTexture)
            {
                MaterialSharedTexture mSharedTex = new MaterialSharedTexture();
                mSharedTex.MaterialIndex = BitConverter.ToInt32(bytes, startIndex + 1);
                mat.Data = mSharedTex;
            }
            else if (matType == (byte)MaterialType.MaterialCullBackFaces)
            {
                MaterialCullBackFaces mCullBackFaces = new MaterialCullBackFaces();
                mat.Data = mCullBackFaces;
            }
            else if (matType == (byte)MaterialType.MaterialEdgeColor)
            {
                MaterialEdgeColor mEdgeColor = new MaterialEdgeColor();
                mEdgeColor.Red = bytes[startIndex + 1];
                mEdgeColor.Green = bytes[startIndex + 2];
                mEdgeColor.Blue = bytes[startIndex + 3];
                mat.Data = mEdgeColor;
            }
            else if (matType == (byte)MaterialType.MaterialEdgeWidth)
            {
                MaterialEdgeWidth mEdgeWidth = new MaterialEdgeWidth();
                mEdgeWidth.Width = bytes[startIndex + 1];
                mat.Data = mEdgeWidth;
            }
            else if (matType == (byte)MaterialType.MaterialLast)
            {
            }
            return mat;
        }
Exemple #2
0
 static Material[] BuildMaterials(byte[] bytes, int startIndex, int[] materialParts, int numMaterial)
 {
     Material[] materials = new Material[numMaterial];
     for (int i = 0; i < numMaterial; ++i)
     {
         materials[i] = BuildMaterial(bytes, startIndex + materialParts[i]);
     }
     return materials;
 }
Exemple #3
0
 public MultiPatchZM(Envelope box, int numParts, int numPoints,
     int[] parts, int[] partTypes, Point[] points,
     double zMin, double zMax, double[] zArray,
     double mMin, double mMax, double[] mArray,
     int numIDs, int[] ids,
     int numNormals, Normal[] normals,
     int numTex, int texDim, int[] texParts, float[,] texCoords,
     int numMaterial, int texCompType, int[] materialParts, Material[] materials)
 {
     BoundingBox = box;
     NumParts = numParts;
     NumPoints = numPoints;
     Parts = parts;
     PartTypes = partTypes;
     Points = points;
     ZMin = zMin;
     ZMax = zMax;
     Zs = zArray;
     MMin = mMin;
     MMax = mMax;
     Ms = mArray;
     NumIDs = numIDs;
     IDs = ids;
     NumNormals = numNormals;
     Normals = normals;
     NumTex = numTex;
     TexDim = texDim;
     TexParts = texParts;
     TexCoords = texCoords;
     NumMaterials = numMaterial;
     TexCompType = texCompType;
     MaterialParts = materialParts;
     Materials = materials;
 }