예제 #1
0
        public void drawSign(Camera camera)
        {
            TexturedBatch3D texturedBatch3D = primitivesRenderer3D.TexturedBatch(m_renderTarget, false, 0, DepthStencilState.None, RasterizerState.CullCounterClockwiseScissor, BlendState.AlphaBlend, SamplerState.PointWrap);

            foreach (KeyValuePair <Point3, int> item in pointlist)
            {
                renderPoint = item.Key;
                if (Vector3.DistanceSquared(new Vector3(renderPoint), camera.ViewPosition) > 400f)
                {
                    continue;                                                                                               //超出20f视野
                }
                ComponentSingleChest singleChest = subsystemBlockEntities.GetBlockEntity(renderPoint.X, renderPoint.Y, renderPoint.Z).Entity.FindComponent <ComponentSingleChest>(true);
                if (singleChest == null || singleChest.GetSlotCount(0) == 0)
                {
                    continue;
                }
                int       mvalue = subsystemTerrain.Terrain.GetCellValue(renderPoint.X, renderPoint.Y, renderPoint.Z);
                int       mpos   = ILibrary.GetDirection(mvalue);
                BlockMesh signSurfaceBlockMesh = MekiasmInit.faceMeshes.Array[ILibrary.normalpos[mpos]];
                float     s                 = LightingManager.LightIntensityByLightValue[Terrain.ExtractLight(mvalue)];
                Color     color             = new Color(s, s, s);
                Vector3   signSurfaceNormal = MekiasmInit.faceNormals.Array[ILibrary.normalface[ILibrary.normalpos[mpos]]];
                Vector3   vector            = new Vector3(renderPoint);
                float     num3              = Vector3.Dot(camera.ViewPosition - (vector + new Vector3(0.5f)), signSurfaceNormal);
                Vector3   v                 = MathUtils.Max(0.01f * num3, 0.005f) * signSurfaceNormal;
                int       indecies          = signSurfaceBlockMesh.Indices.Count / 3;
                for (int i = 0; i < indecies; i += 2)
                {
                    if (i >= indecies)
                    {
                        break;
                    }
                    BlockMeshVertex blockMeshVertex  = signSurfaceBlockMesh.Vertices.Array[signSurfaceBlockMesh.Indices.Array[i * 3]];
                    BlockMeshVertex blockMeshVertex2 = signSurfaceBlockMesh.Vertices.Array[signSurfaceBlockMesh.Indices.Array[i * 3 + 1]];
                    BlockMeshVertex blockMeshVertex3 = signSurfaceBlockMesh.Vertices.Array[signSurfaceBlockMesh.Indices.Array[i * 3 + 2]];
                    Vector3         p  = blockMeshVertex.Position + vector + v;
                    Vector3         p2 = blockMeshVertex2.Position + vector + v;
                    Vector3         p3 = blockMeshVertex3.Position + vector + v;
                    Vector2         textureCoordinates  = ILibrary.getTexcoord(2);
                    Vector2         textureCoordinates2 = ILibrary.getTexcoord(3);
                    Vector2         textureCoordinates3 = ILibrary.getTexcoord(4);
                    texturedBatch3D.QueueTriangle(p, p2, p3, textureCoordinates, textureCoordinates2, textureCoordinates3, color);
                    BlockMeshVertex blockMeshVertex11 = signSurfaceBlockMesh.Vertices.Array[signSurfaceBlockMesh.Indices.Array[++i * 3]];
                    BlockMeshVertex blockMeshVertex22 = signSurfaceBlockMesh.Vertices.Array[signSurfaceBlockMesh.Indices.Array[i * 3 + 1]];
                    BlockMeshVertex blockMeshVertex33 = signSurfaceBlockMesh.Vertices.Array[signSurfaceBlockMesh.Indices.Array[i * 3 + 2]];
                    Vector3         p11 = blockMeshVertex11.Position + vector + v;
                    Vector3         p22 = blockMeshVertex22.Position + vector + v;
                    Vector3         p33 = blockMeshVertex33.Position + vector + v;
                    Vector2         textureCoordinates11 = ILibrary.getTexcoord(2);
                    Vector2         textureCoordinates22 = ILibrary.getTexcoord(4);
                    Vector2         textureCoordinates33 = ILibrary.getTexcoord(1);
                    texturedBatch3D.QueueTriangle(p11, p22, p33, textureCoordinates11, textureCoordinates22, textureCoordinates33, color);
                }
                Updated(singleChest.GetSlotValue(0), singleChest.GetSlotCount(0));
                primitivesRenderer3D.Flush(camera.ViewProjectionMatrix);
            }
        }
예제 #2
0
        public override int GetFaceTextureSlot(int face, int value)
        {
            int pos    = ILibrary.GetDirection(value);//朝向
            int itemid = ILibrary.getItemId(value);

            switch (face)
            {                            //返回基础的各个面
            case 4: return(18 + itemid); //顶面固定

            case 5: return(17);          //底面固定

            default:
                if (face == pos)
                {
                    return(22 + itemid);
                }
                else
                {
                    return(17);
                }
            }
        }