コード例 #1
0
        public void SetTexture(Grendgine_Collada_Texture sourceTex, string texName, Bitmap bmp)
        {
            BinaryTextureImage tex = null;

            // Check to see if we need an alpha channel in our texture
            bool hasAlpha = HasAlpha(bmp);

            // If so, we'll use RGB565
            if (hasAlpha)
            {
                tex = new BinaryTextureImage(texName, bmp, BinaryTextureImage.TextureFormats.RGBA32);

                // This sets the alpha compare settings so that alpha is set correctly.
                // It won't allow translucency, just a sharp transparent/opaque dichotemy.
                AlphCompare.Comp0      = GXCompareType.GEqual;
                AlphCompare.Comp1      = GXCompareType.LEqual;
                AlphCompare.Operation  = GXAlphaOp.And;
                AlphCompare.Reference0 = 0x80;
                AlphCompare.Reference1 = 0xFF;

                // We'll default to showing the texture on both sides for now. Maybe it'll be changable in the future
                CullMode = GXCullMode.None;

                // Make sure z compare happens *after* texture look up so we can take the alpha compare results into account
                ZCompLoc = false;
            }
            // Otherwise, we'll use CMPR to save space
            else
            {
                tex = new BinaryTextureImage(texName, bmp, BinaryTextureImage.TextureFormats.CMPR);
            }

            tex.SetTextureSettings(sourceTex);
            CullMode = GXCullMode.None;

            // Search for an open texture slot and if there is one, put the texture there,
            // Include tex cooord gens,
            // Include a tex matrix,
            // And configure tev orders
            for (int i = 0; i < 8; i++)
            {
                if (Textures[i] == null)
                {
                    Textures[i]      = tex;
                    TexCoord1Gens[i] = new TexCoordGen(GXTexGenType.Matrix2x4, GXTexGenSrc.Tex0 + i, GXTexMatrix.TexMtx0);
                    TexMatrix1[i]    = new TexMatrix();

                    TevOrders[i].TexCoordId = GXTexCoordSlot.TexCoord0 + i;
                    TevOrders[i].TexMap     = (byte)i;
                    TevOrders[i].ChannelId  = GXColorChannelId.Color0A0;
                    break;
                }
            }

            TevStages[0].ColorIn[0] = GXCombineColorInput.TexColor;
            TevStages[0].ColorIn[1] = GXCombineColorInput.TexColor;
            TevStages[0].AlphaIn[0] = GXCombineAlphaInput.TexAlpha;
        }
コード例 #2
0
ファイル: TexCoordGen.cs プロジェクト: jellees/BMDCubed
 private bool Compare(TexCoordGen obj)
 {
     if ((Type == obj.Type) && (Source == obj.Source) && (TexMatrixSource == obj.TexMatrixSource))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }