本文整理汇总了C#中MeshData.AddColors方法的典型用法代码示例。如果您正苦于以下问题:C# MeshData.AddColors方法的具体用法?C# MeshData.AddColors怎么用?C# MeshData.AddColors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MeshData
的用法示例。
在下文中一共展示了MeshData.AddColors方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CrossMeshRenderer
public static void CrossMeshRenderer(Chunk chunk, BlockPos pos, MeshData meshData, TextureCollection texture, Block block)
{
float halfBlock = (Config.Env.BlockSize / 2) + Config.Env.BlockFacePadding;
float colliderOffest = 0.05f * Config.Env.BlockSize;
float blockHeight = halfBlock * 2 * (block.data2 / 255f);
float offsetX = (halfBlock * 2 * ((byte)(block.data3 & 0x0F) / 32f)) - (halfBlock/2);
float offsetZ = (halfBlock * 2 * ((byte)((block.data3 & 0xF0) >> 4) / 32f)) - (halfBlock/2);
//Converting the position to a vector adjusts it based on block size and gives us real world coordinates for x, y and z
Vector3 vPos = pos;
Vector3 vPosCollider = pos;
vPos += new Vector3(offsetX, 0, offsetZ);
float blockLight = ( (block.data1/255f) * Config.Env.BlockLightStrength) + (0.8f*Config.Env.AOStrength);
meshData.AddVertex(new Vector3(vPos.x - halfBlock, vPos.y - halfBlock, vPos.z + halfBlock));
meshData.AddVertex(new Vector3(vPos.x - halfBlock, vPos.y - halfBlock + blockHeight, vPos.z + halfBlock));
meshData.AddVertex(new Vector3(vPos.x + halfBlock, vPos.y - halfBlock + blockHeight, vPos.z - halfBlock));
meshData.AddVertex(new Vector3(vPos.x + halfBlock, vPos.y - halfBlock, vPos.z - halfBlock));
meshData.AddQuadTriangles();
BlockBuilder.BuildTexture(chunk, vPos, meshData, Direction.north, texture);
meshData.AddColors(blockLight, blockLight, blockLight, blockLight, blockLight);
meshData.AddVertex(new Vector3(vPos.x + halfBlock, vPos.y - halfBlock, vPos.z - halfBlock));
meshData.AddVertex(new Vector3(vPos.x + halfBlock, vPos.y - halfBlock + blockHeight, vPos.z - halfBlock));
meshData.AddVertex(new Vector3(vPos.x - halfBlock, vPos.y - halfBlock + blockHeight, vPos.z + halfBlock));
meshData.AddVertex(new Vector3(vPos.x - halfBlock, vPos.y - halfBlock, vPos.z + halfBlock));
meshData.AddQuadTriangles();
BlockBuilder.BuildTexture(chunk, vPos, meshData, Direction.north, texture);
meshData.AddColors(blockLight, blockLight, blockLight, blockLight, blockLight);
meshData.AddVertex(new Vector3(vPos.x + halfBlock, vPos.y - halfBlock, vPos.z + halfBlock));
meshData.AddVertex(new Vector3(vPos.x + halfBlock, vPos.y - halfBlock + blockHeight, vPos.z + halfBlock));
meshData.AddVertex(new Vector3(vPos.x - halfBlock, vPos.y - halfBlock + blockHeight, vPos.z - halfBlock));
meshData.AddVertex(new Vector3(vPos.x - halfBlock, vPos.y - halfBlock, vPos.z - halfBlock));
meshData.AddQuadTriangles();
BlockBuilder.BuildTexture(chunk, vPos, meshData, Direction.north, texture);
meshData.AddColors(blockLight, blockLight, blockLight, blockLight, blockLight);
meshData.AddVertex(new Vector3(vPos.x - halfBlock, vPos.y - halfBlock, vPos.z - halfBlock));
meshData.AddVertex(new Vector3(vPos.x - halfBlock, vPos.y - halfBlock + blockHeight, vPos.z - halfBlock));
meshData.AddVertex(new Vector3(vPos.x + halfBlock, vPos.y - halfBlock + blockHeight, vPos.z + halfBlock));
meshData.AddVertex(new Vector3(vPos.x + halfBlock, vPos.y - halfBlock, vPos.z + halfBlock));
meshData.AddQuadTriangles();
BlockBuilder.BuildTexture(chunk, vPos, meshData, Direction.north, texture);
meshData.AddColors(blockLight, blockLight, blockLight, blockLight, blockLight);
meshData.AddVertex(new Vector3(vPosCollider.x - halfBlock, vPosCollider.y - halfBlock + colliderOffest, vPosCollider.z + halfBlock), collisionMesh: true);
meshData.AddVertex(new Vector3(vPosCollider.x + halfBlock, vPosCollider.y - halfBlock + colliderOffest, vPosCollider.z + halfBlock), collisionMesh: true);
meshData.AddVertex(new Vector3(vPosCollider.x + halfBlock, vPosCollider.y - halfBlock + colliderOffest, vPosCollider.z - halfBlock), collisionMesh: true);
meshData.AddVertex(new Vector3(vPosCollider.x - halfBlock, vPosCollider.y - halfBlock + colliderOffest, vPosCollider.z - halfBlock), collisionMesh: true);
meshData.AddQuadTriangles(collisionMesh:true);
}
示例2: AddColors
static void AddColors(MeshData meshData, bool wnSolid, bool nSolid, bool neSolid, bool eSolid, bool esSolid, bool sSolid, bool swSolid, bool wSolid, float light)
{
float ne = 1;
float es = 1;
float sw = 1;
float wn = 1;
float aoContrast = 0.2f;
if (nSolid)
{
wn -= aoContrast;
ne -= aoContrast;
}
if (eSolid)
{
ne -= aoContrast;
es -= aoContrast;
}
if (sSolid)
{
es -= aoContrast;
sw -= aoContrast;
}
if (wSolid)
{
sw -= aoContrast;
wn -= aoContrast;
}
if (neSolid)
ne -= aoContrast;
if (swSolid)
sw -= aoContrast;
if (wnSolid)
wn -= aoContrast;
if (esSolid)
es -= aoContrast;
meshData.AddColors(ne, es, sw, wn, light);
}