Ejemplo n.º 1
0
        unsafe void updateVisualHandle(ref RealLOSVisualData handle, int minX, int minZ)
        {
            if (handle == null)
            {
                return;
            }

            int width = (int)(mNumXVertsPerCell + 1);

            GraphicsStream stream = handle.mVB.Lock(0, handle.mNumVerts * sizeof(VertexTypes.Pos_Color), LockFlags.None);

            VertexTypes.Pos_Color *verts = (VertexTypes.Pos_Color *)stream.InternalDataPointer;

            uint obsCol = 0x440000FF;

            obsCol = mColors[minX * mWidth + minZ];
            //generate each tile as a seperate triList
            int counter = 0;

            for (int x = 0; x < width; x++)
            {
                for (int z = 0; z < width; z++)
                {
                    int    offX = (int)BMathLib.Clamp(minX + x, 0, mWidth - 1);
                    int    offZ = (int)BMathLib.Clamp(minZ + z, 0, mHeight - 1);
                    float3 wsp  = new float3(offX * mTileScale, getCompositeHeight(offX, offZ), offZ * mTileScale);
                    verts[counter].x     = wsp.X;
                    verts[counter].y     = wsp.Y + cVisualHeightOffset;
                    verts[counter].z     = wsp.Z;
                    verts[counter].color = (int)obsCol;
                    counter++;
                }
            }
            handle.mVB.Unlock();
        }
Ejemplo n.º 2
0
        void renderCell(RealLOSVisualData handle)
        {
            BRenderDevice.getDevice().VertexDeclaration = VertexTypes.Pos_Color.vertDecl;
            BRenderDevice.getDevice().VertexFormat      = VertexTypes.Pos_Color.FVF_Flags;

            BRenderDevice.getDevice().VertexShader = null;
            BRenderDevice.getDevice().PixelShader  = null;
            BRenderDevice.getDevice().SetTexture(0, null);

            BRenderDevice.getDevice().SetStreamSource(0, handle.mVB, 0);
            BRenderDevice.getDevice().Indices = handle.mIB;

            BRenderDevice.getDevice().RenderState.CullMode = Cull.None;

            BRenderDevice.getDevice().SetRenderState(RenderStates.ZBufferWriteEnable, false);
            BRenderDevice.getDevice().SetRenderState(RenderStates.FillMode, (int)FillMode.WireFrame);
            //BRenderDevice.getDevice().DrawPrimitives(PrimitiveType.TriangleList, 0, handle.mNumPrims);
            BRenderDevice.getDevice().DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, handle.mNumVerts, 0, handle.mNumPrims);
            BRenderDevice.getDevice().SetRenderState(RenderStates.FillMode, (int)FillMode.Solid);

            BRenderDevice.getDevice().SetRenderState(RenderStates.AlphaTestEnable, false);

            BRenderDevice.getDevice().SetRenderState(RenderStates.SourceBlend, (int)Blend.SourceAlpha);
            BRenderDevice.getDevice().SetRenderState(RenderStates.DestinationBlend, (int)Blend.InvSourceAlpha);
            BRenderDevice.getDevice().SetRenderState(RenderStates.AlphaBlendEnable, true);
            //BRenderDevice.getDevice().DrawPrimitives(PrimitiveType.TriangleList, 0, handle.mNumPrims);
            BRenderDevice.getDevice().DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, handle.mNumVerts, 0, handle.mNumPrims);
            BRenderDevice.getDevice().SetRenderState(RenderStates.AlphaBlendEnable, false);
            BRenderDevice.getDevice().SetRenderState(RenderStates.ZBufferWriteEnable, true);
            BRenderDevice.getDevice().RenderState.CullMode = Cull.CounterClockwise;
        }
Ejemplo n.º 3
0
 public void destroy()
 {
     if (mVisualHandle != null)
     {
         mVisualHandle.destroy();
         mVisualHandle = null;
     }
 }
Ejemplo n.º 4
0
        unsafe RealLOSVisualData newVisualHandle(int minX, int minZ)
        {
            int width = (int)mNumXVertsPerCell;
            int vd    = width + 1;
            int tw    = width;
            int td    = width;


            RealLOSVisualData svd = new RealLOSVisualData();

            svd.mNumVerts = vd * vd;
            svd.mVB       = new VertexBuffer(typeof(VertexTypes.Pos_Color), (int)svd.mNumVerts, BRenderDevice.getDevice(), Usage.None, VertexTypes.Pos_Color.FVF_Flags, Pool.Managed);

            //standard IB
            svd.mNumPrims = vd * vd * 2;
            svd.mIB       = new IndexBuffer(typeof(int), svd.mNumPrims * 3, BRenderDevice.getDevice(), Usage.None, Pool.Managed);
            GraphicsStream stream = svd.mIB.Lock(0, 0, LockFlags.None);
            int *          inds   = (int *)stream.InternalDataPointer;

            //fill our intex buffer
            int counter = 0;

            for (int z = 0; z < td; z++)
            {
                for (int x = 0; x < tw; x++)
                {
                    int k = (x + (z * vd));
                    inds[counter++] = (k);
                    inds[counter++] = (k + vd);
                    inds[counter++] = (k + 1);

                    inds[counter++] = (k + 1);
                    inds[counter++] = (k + vd);
                    inds[counter++] = (k + vd + 1);
                }
            }
            svd.mIB.Unlock();

            //update and fill our vertex buffer
            updateVisualHandle(ref svd, minX, minZ);

            return(svd);
        }