示例#1
0
        public override bool applyToDstImg(BTerrainQuadNode node, int x, int z, bool selectionMode, bool alternate)
        {
            BTerrainLayerContainer       layers = node.mLayerContainer;
            BTerrainActiveDecalContainer decal  = TerrainGlobals.getTexturing().getActiveDecal(TerrainGlobals.getTerrainFrontEnd().SelectedDecalIndex);

            bool changed = false;



            return(changed);
        }
示例#2
0
        public bool init(int decalIndex)
        {
            mDecalArrayIndex = decalIndex;

            BTerrainActiveDecalContainer decal = TerrainGlobals.getTexturing().getActiveDecal(TerrainGlobals.getTerrainFrontEnd().SelectedDecalIndex);
            SurfaceDescription           sd    = decal.mTexChannels[0].mTexture.GetLevelDescription(0);

            mDecalRadius = sd.Width / 2;
            mDecalWidth  = sd.Width;
            mDecalHeight = sd.Height;
            return(true);
        }
示例#3
0
        public void computeDecalLayerAlphaContrib(int layerIndex, int minXVertex, int minZVertex)
        {
            if (layerIndex < 0 || layerIndex >= mLayers.Count)
            {
                return;
            }

            //grab our decal instance
            if (mLayers[layerIndex].mLayerType != BTerrainTexturingLayer.eLayerType.cLayer_Decal)
            {
                return;
            }

            float vertsToHighResPixelSpaceRatio = BTerrainTexturing.getTextureWidth() / BTerrainQuadNode.cMaxWidth;

            BTerrainDecalInstance        dcli = TerrainGlobals.getTexturing().getActiveDecalInstance(mLayers[layerIndex].mActiveTextureIndex);
            BTerrainActiveDecalContainer dcl  = TerrainGlobals.getTexturing().getActiveDecal(dcli.mActiveDecalIndex);


            //scale, rotate, translate us
            int h  = dcl.mHeight;
            int w  = dcl.mWidth;
            int nW = (int)(w * ((1.0f / dcli.mUScale) / vertsToHighResPixelSpaceRatio));
            int nH = (int)(h * ((1.0f / dcli.mVScale) / vertsToHighResPixelSpaceRatio));
            int tW = 0;
            int tH = 0;

            byte[] tImgResized = null;
            byte[] tImgRotated = null;
            byte[] imgDat      = new byte[h * w];
            imgDat      = ImageManipulation.valueGreyScaleImg(imgDat, w, h, ImageManipulation.eValueOperation.cValue_Set, 255);
            tImgResized = ImageManipulation.resizeGreyScaleImg(imgDat, w, h, nW, nH, ImageManipulation.eFilterType.cFilter_Linear);
            tImgRotated = ImageManipulation.rotateGreyScaleImg(tImgResized, nW, nH, (float)(-dcli.mRotation * (180.0f / Math.PI)), false, out nW, out nH, ImageManipulation.eFilterType.cFilter_Nearest);

            byte[] tImg   = tImgRotated;
            int    startX = (int)((dcli.mTileCenter.X / vertsToHighResPixelSpaceRatio) - (nW >> 1) - minXVertex);
            int    startY = (int)((dcli.mTileCenter.Y / vertsToHighResPixelSpaceRatio) - (nH >> 1) - minZVertex);

            clearLayerAlpha(layerIndex);

            //copy back to masking
            for (int i = 0; i < nW; i++)
            {
                for (int j = 0; j < nH; j++)
                {
                    int iS = startX + i;
                    if (iS < 0 || iS >= BTerrainTexturing.getAlphaTextureWidth())
                    {
                        continue;
                    }

                    int jS = startY + j;
                    if (jS < 0 || jS >= BTerrainTexturing.getAlphaTextureHeight())
                    {
                        continue;
                    }

                    int srcIndex = j + i * nW;
                    int dstIndex = (int)(iS + BTerrainTexturing.getAlphaTextureHeight() * jS);

                    byte val = tImg[srcIndex];
                    mLayers[layerIndex].mAlphaLayer[dstIndex] = val;
                }
            }

            //also, walk any layers that exist above us, and subtract out their values as well
            for (int k = layerIndex + 1; k < mLayers.Count; k++)
            {
                if (mLayers[k].mLayerType == BTerrainTexturingLayer.eLayerType.cLayer_Splat)
                {
                    for (int i = 0; i < BTerrainTexturing.getAlphaTextureWidth() * BTerrainTexturing.getAlphaTextureHeight(); i++)
                    {
                        mLayers[layerIndex].mAlphaLayer[i] = (byte)BMathLib.Clamp(mLayers[layerIndex].mAlphaLayer[i] - mLayers[k].mAlphaLayer[i], 0, 255);
                    }
                }
            }

            imgDat      = null;
            tImgResized = null;
            tImgRotated = null;
            tImg        = null;
        }