コード例 #1
0
        private TextureCube CreateTextureCube(MipMapChainCollection mipMapChainCollection)
        {
            ImageData   mip0     = mipMapChainCollection[0][0];
            int         cubeSize = mip0.Width;
            int         mipCount = mipMapChainCollection[0].Count;
            TextureCube tex      = new TextureCube(cubeSize, mipCount > 1, GetSurfaceFormat(mip0));

            foreach (MipMapChain mipChain in mipMapChainCollection)
            {
                mip0 = mipChain[0];

                //Not sure the order of our faces, so explicitly look at it and set by face. Not even sure if DevIL will give us all 6
                //if one is missing.
                EnvironmentMapFace face = mip0.CubeFace;
                bool        unknownFace = false;
                CubeMapFace cubeFace    = CubeMapFace.PositiveX;
                switch (face)
                {
                case EnvironmentMapFace.PositiveX:
                    cubeFace = CubeMapFace.PositiveX;
                    break;

                case EnvironmentMapFace.NegativeX:
                    cubeFace = CubeMapFace.NegativeX;
                    break;

                case EnvironmentMapFace.PositiveY:
                    cubeFace = CubeMapFace.PositiveY;
                    break;

                case EnvironmentMapFace.NegativeY:
                    cubeFace = CubeMapFace.NegativeY;
                    break;

                case EnvironmentMapFace.PositiveZ:
                    cubeFace = CubeMapFace.PositiveZ;
                    break;

                case EnvironmentMapFace.NegativeZ:
                    cubeFace = CubeMapFace.NegativeZ;
                    break;

                default:
                    unknownFace = true;
                    break;
                }

                if (!unknownFace)
                {
                    for (int i = 0; i < mipChain.Count; i++)
                    {
                        ImageData mip  = mipChain[i];
                        byte[]    data = (mip.HasCompressedData) ? mip.CompressedData : mip.Data;
                        tex.SetData <byte>(cubeFace, data, i, null, 0, data.Length);
                    }
                }
            }

            return(tex);
        }
コード例 #2
0
ファイル: ManagedImage.cs プロジェクト: zyjiang0571/open3mod
        private ManagedImage(ImageID imageID, int imageNum)
        {
            m_faces     = new MipMapChainCollection();
            m_animChain = new AnimationChainCollection();

            LoadFaces(imageID, imageNum);
        }
コード例 #3
0
ファイル: ManagedImage.cs プロジェクト: Woljix/devil-net
        public ManagedImage(Image image) {
            m_faces = new MipMapChainCollection();
            m_animChain = new AnimationChainCollection();

            if(!image.IsValid) {
                return;
            }

            ImageID imageID = image.ImageID;
            LoadFaces(imageID, 0);
            LoadAnimationChain(imageID);
        }
コード例 #4
0
        public ManagedImage(Image image)
        {
            this.m_faces     = new MipMapChainCollection();
            this.m_animChain = new AnimationChainCollection();
            if (!image.IsValid)
            {
                return;
            }
            ImageID imageId = image.ImageID;

            this.LoadFaces(imageId, 0);
            this.LoadAnimationChain(imageId);
        }
コード例 #5
0
ファイル: ManagedImage.cs プロジェクト: zyjiang0571/open3mod
        public ManagedImage(Image image)
        {
            m_faces     = new MipMapChainCollection();
            m_animChain = new AnimationChainCollection();

            if (!image.IsValid)
            {
                return;
            }

            ImageID imageID = image.ImageID;

            LoadFaces(imageID, 0);
            LoadAnimationChain(imageID);
        }
コード例 #6
0
        private Texture CreateTexture(ManagedImage image)
        {
            MipMapChainCollection mipMapChainCollection = image.Faces;
            int faceCount = mipMapChainCollection.Count;

            if (faceCount == 1)
            {
                MipMapChain face = mipMapChainCollection[0];
                if (face.Count > 0)
                {
                    ImageData mip0   = face[0];
                    int       width  = mip0.Width;
                    int       height = mip0.Height;
                    int       depth  = mip0.Depth;

                    //Only create 1D/3D textures if we have width/depth greater than zero. So an image that is 1x1x1
                    //will become a texture2d
                    if (width > 1 && height == 1 && depth == 1)
                    {
                        return(CreateTexture1D(face));
                    }
                    else if (depth > 1)
                    {
                        return(CreateTexture3D(face));
                    }
                    else
                    {
                        return(CreateTexture2D(face));
                    }
                }
            }
            else if (faceCount > 1 && faceCount <= 6)
            {
                return(CreateTextureCube(mipMapChainCollection));
            }

            throw new ArgumentException("Invalid texture type");
        }
コード例 #7
0
ファイル: ManagedImage.cs プロジェクト: Woljix/devil-net
        private ManagedImage(ImageID imageID, int imageNum) {
            m_faces = new MipMapChainCollection();
            m_animChain = new AnimationChainCollection();

            LoadFaces(imageID, imageNum);
        }