コード例 #1
0
        static public void scaleSelection(float amt, bool addOrPercent)
        {
            int totalNumVerts = TerrainGlobals.getTerrain().getNumXVerts();

            float fact = 0;

            for (int x = 0; x < totalNumVerts; x++)
            {
                for (int z = 0; z < totalNumVerts; z++)
                {
                    if (Masking.isPointSelected(x, z, ref fact))
                    {
                        if (addOrPercent)
                        {
                            fact = BMathLib.Clamp(fact + amt, 0, 1);
                        }
                        else
                        {
                            fact = BMathLib.Clamp(fact * amt, 0, 1);
                        }
                        Masking.addSelectedVert(x, z, fact);
                    }
                }
            }
            rebuildVisualsAfterSelection();
        }
コード例 #2
0
        //----------------------------------------------
        unsafe static public bool setMaskAlphaToTextureBlending(BTerrainQuadNode node, uint dstImgWidth, uint dstImgHeight,
                                                                UInt32 *mskImg, uint mskImgWidth, uint mskImgHeight, float intensity,
                                                                int xpos, int ypos, bool alternate)
        {
            BTerrainQuadNodeDesc desc = node.getDesc();

            bool changed = false;

            //create our position in the dst img, adjust for boundries
            int mskMaxX = (int)mskImgWidth;

            if (mskImgWidth + xpos >= dstImgWidth)
            {
                mskMaxX -= ((int)mskImgWidth) + xpos - ((int)dstImgWidth);
            }

            int mskMaxY = (int)mskImgHeight;

            if (mskImgHeight + ypos >= dstImgHeight)
            {
                mskMaxY -= ((int)mskImgHeight) + ypos - ((int)dstImgHeight);
            }

            int mskMinX = 0;
            int mskMinY = 0;

            if (xpos < 0)
            {
                mskMinX = -xpos;
            }
            if (ypos < 0)
            {
                mskMinY = -ypos;
            }

            //validate extents...
            if (mskMinX > mskImgWidth || mskMinY > mskImgHeight)
            {
                return(false);
            }


            int minX = (int)(desc.m_min.X / TerrainGlobals.getTerrain().getTileScale());
            int maxX = (int)(desc.m_max.X / TerrainGlobals.getTerrain().getTileScale());
            int minZ = (int)(desc.m_min.Z / TerrainGlobals.getTerrain().getTileScale());
            int maxZ = (int)(desc.m_max.Z / TerrainGlobals.getTerrain().getTileScale());

            for (int x = minX; x <= maxX; x++)
            {
                for (int z = minZ; z <= maxZ; z++)
                {
                    int maskX = x - minX + mskMinX;
                    int maskY = z - minZ + mskMinY;

                    int  mIP   = maskX * ((int)mskImgWidth) + maskY;
                    char alpha = (char)(((mskImg[mIP] & 0xFF000000) >> 24));

                    float factor = alpha / 255.0f * intensity;;

                    int   vertIndex = (int)(x * TerrainGlobals.getTerrain().getNumZVerts() + z);
                    float curWeight = Masking.getCurrSelectionMaskWeights().GetMaskWeight(vertIndex);
                    float newWeight;

                    if (!alternate)
                    {
                        newWeight = (curWeight > factor) ? curWeight : factor;
                    }
                    else//CLM Changes to erasing..
                    {
                        newWeight = BMathLib.Clamp(curWeight - factor, 0, 1);
                    }
                    Masking.addSelectedVert(x, z, newWeight);
                    changed = true;
                }
            }

            return(changed);
        }