Esempio n. 1
0
        public override void LoadContent(DeviceContext context)
        {
            _milkShapeMeshfactory.LoadMesh(@"\Meshes\block.txt", out _cubeMeshBluePrint, 0);

            _cubeTextureView = _config.CubeTextureManager.CubeArrayTexture;
            //ArrayTexture.CreateTexture2DFromFiles(_d3DEngine.Device, _d3DEngine.ImmediateContext, ClientSettings.TexturePack + @"Terran/", @"ct*.png", FilterFlags.Point, "ArrayTexture_DefaultEntityRenderer", out _cubeTextureView);

            foreach (var cube in _config.WorldParameters.Configuration.GetAllCubesProfiles())
            {
                CubePack pack;

                //Prapare to creation of a new mesh with the correct texture mapping ID
                var materialChangeMapping = new Dictionary <int, int>();
                materialChangeMapping[0] = cube.Tex_Back.TextureArrayId;    //Change the Back Texture Id
                materialChangeMapping[1] = cube.Tex_Front.TextureArrayId;   //Change the Front Texture Id
                materialChangeMapping[2] = cube.Tex_Bottom.TextureArrayId;  //Change the Bottom Texture Id
                materialChangeMapping[3] = cube.Tex_Top.TextureArrayId;     //Change the Top Texture Id
                materialChangeMapping[4] = cube.Tex_Left.TextureArrayId;    //Change the Left Texture Id
                materialChangeMapping[5] = cube.Tex_Right.TextureArrayId;   //Change the Right Texture Id

                pack.Mesh = _cubeMeshBluePrint.Clone(materialChangeMapping);

                pack.Vb = ToDispose(new VertexBuffer <VertexMesh>(_d3DEngine.Device, _cubeMeshBluePrint.Vertices.Length, SharpDX.Direct3D.PrimitiveTopology.TriangleList, "Block VB"));
                pack.Ib = ToDispose(new IndexBuffer <ushort>(_d3DEngine.Device, _cubeMeshBluePrint.Indices.Length, "Block IB"));

                pack.Vb.SetData(_d3DEngine.ImmediateContext, pack.Mesh.Vertices);
                pack.Ib.SetData(_d3DEngine.ImmediateContext, pack.Mesh.Indices);

                _cache.Add(cube.Id, pack);
            }

            _cubeEffect = ToDispose(new HLSLCubeTool(_d3DEngine.Device, ClientSettings.EffectPack + @"Entities/CubeTool.hlsl", VertexMesh.VertexDeclaration));
            _cubeEffect.DiffuseTexture.Value = _cubeTextureView;
            _cubeEffect.SamplerDiffuse.Value = RenderStatesRepo.GetSamplerState(DXStates.Samplers.UVClamp_MinMagMipPoint);
        }
Esempio n. 2
0
        public void LoadContent(DeviceContext context)
        {
            //Prepare Textured Block rendering when equiped ==============================================================
            _milkShapeMeshfactory.LoadMesh(@"\Meshes\block.txt", out _cubeMeshBluePrint, 0);

            _cubeTextureView = _visualWorldParameters.CubeTextureManager.CubeArrayTexture;

            //Create Vertex/Index Buffer to store the loaded cube mesh.
            _cubeVb = ToDispose(new VertexBuffer <VertexMesh>(context.Device, _cubeMeshBluePrint.Vertices.Length, SharpDX.Direct3D.PrimitiveTopology.TriangleList, "Block VB"));
            _cubeIb = ToDispose(new IndexBuffer <ushort>(context.Device, _cubeMeshBluePrint.Indices.Length, "Block IB"));

            _cubeToolEffect = ToDispose(new HLSLCubeTool(context.Device, ClientSettings.EffectPack + @"Entities/CubeTool.hlsl", VertexMesh.VertexDeclaration));
            _cubeToolEffect.DiffuseTexture.Value = _cubeTextureView;
            _cubeToolEffect.SamplerDiffuse.Value = RenderStatesRepo.GetSamplerState(DXStates.Samplers.UVClamp_MinMagMipPoint);
        }
        public override void LoadContent(DeviceContext context)
        {
            //ArrayTexture.CreateTexture2DFromFiles(context.Device, context, ClientSettings.TexturePack + @"Terran/", @"ct*.png", FilterFlags.Point, "ArrayTexture_DefaultEntityRenderer", out _cubeTextureView);
            //ToDispose(_cubeTextureView);
            _cubeTextureView = _visualWorldParameters.CubeTextureManager.CubeArrayTexture;


            //Create Vertex/Index Buffer to store the loaded cube mesh.
            _cubeVb = ToDispose(new VertexBuffer <VertexMesh>(context.Device, _cubeMeshBluePrint.Vertices.Length, SharpDX.Direct3D.PrimitiveTopology.TriangleList, "Block VB"));
            _cubeIb = ToDispose(new IndexBuffer <ushort>(context.Device, _cubeMeshBluePrint.Indices.Length, "Block IB"));

            _cubeToolEffect = ToDispose(new HLSLCubeTool(context.Device, ClientSettings.EffectPack + @"Entities/CubeTool.hlsl", VertexMesh.VertexDeclaration));
            _cubeToolEffect.DiffuseTexture.Value = _cubeTextureView;
            _cubeToolEffect.SamplerDiffuse.Value = RenderStatesRepo.GetSamplerState(DXStates.Samplers.UVClamp_MinMagMipPoint);

            _voxelModelEffect      = ToDispose(new HLSLVoxelModelInstanced(context.Device, ClientSettings.EffectPack + @"Entities\VoxelModelInstanced.hlsl", VoxelInstanceData.VertexDeclaration));
            _voxelToolEffect       = ToDispose(new HLSLVoxelModel(context.Device, ClientSettings.EffectPack + @"Entities\VoxelModel.hlsl", VertexVoxel.VertexDeclaration));
            _materialChangeMapping = new Dictionary <int, int>();

            //Create the font to base use by the sprite3dText Processor
            _dynamicEntityNameFont = ToDispose(new SpriteFont());
            _dynamicEntityNameFont.Initialize("Lucida Console", 32f, System.Drawing.FontStyle.Regular, true, context.Device, false);

            //Create the processor that will be used by the Sprite3DRenderer
            Sprite3DTextProc textProcessor = ToDispose(new Sprite3DTextProc(_dynamicEntityNameFont, RenderStatesRepo.GetSamplerState(DXStates.Samplers.UVWrap_Text), ToDispose(new UtopiaIncludeHandler()), _sharedFrameCB.CBPerFrame, ClientSettings.EffectPack + @"Sprites\PointSprite3DText.hlsl"));

            //Create a sprite3Drenderer that will use the previously created processor to accumulate text data for drawing.
            _dynamicEntityNameRenderer = ToDispose(new Sprite3DRenderer <Sprite3DTextProc>(textProcessor,
                                                                                           DXStates.Rasters.Default,
                                                                                           DXStates.Blenders.Enabled,
                                                                                           DXStates.DepthStencils.DepthReadWriteEnabled,
                                                                                           context));
            Sprite3DColorBillBoardProc energyBarProcessor = ToDispose(new Sprite3DColorBillBoardProc(ToDispose(new UtopiaIncludeHandler()), _sharedFrameCB.CBPerFrame, ClientSettings.EffectPack + @"Sprites\PointSpriteColor3DBillBoard.hlsl"));

            _dynamicEntityEnergyBarRenderer = ToDispose(new Sprite3DRenderer <Sprite3DColorBillBoardProc>(energyBarProcessor,
                                                                                                          DXStates.Rasters.Default,
                                                                                                          DXStates.Blenders.Enabled,
                                                                                                          DXStates.DepthStencils.DepthReadWriteEnabled,
                                                                                                          context));
        }