Transparent blocks
This commit is contained in:
@@ -9,12 +9,13 @@ Material:
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Blocks
|
||||
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_ShaderKeywords:
|
||||
m_ShaderKeywords: _ALPHATEST_ON
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
m_CustomRenderQueue: 2450
|
||||
stringTagMap:
|
||||
RenderType: TransparentCutout
|
||||
disabledShaderPasses: []
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
@@ -57,14 +58,14 @@ Material:
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Floats:
|
||||
- _BumpScale: 1
|
||||
- _Cutoff: 0.5
|
||||
- _Cutoff: 1
|
||||
- _DetailNormalMapScale: 1
|
||||
- _DstBlend: 0
|
||||
- _GlossMapScale: 1
|
||||
- _Glossiness: 0
|
||||
- _GlossyReflections: 1
|
||||
- _Metallic: 0
|
||||
- _Mode: 0
|
||||
- _Mode: 1
|
||||
- _OcclusionStrength: 1
|
||||
- _Parallax: 0.02
|
||||
- _SmoothnessTextureChannel: 0
|
||||
|
||||
@@ -539,6 +539,8 @@ MonoBehaviour:
|
||||
textures: 000000000000
|
||||
- name: Sand
|
||||
textures: 0a0a0a0a0a0a
|
||||
- name: Leafs
|
||||
textures: 101010101010
|
||||
--- !u!1 &1353507538
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
||||
@@ -81,6 +81,19 @@ public class Chunk
|
||||
triangleIndex++;
|
||||
}
|
||||
|
||||
AddUV(textures[f]);
|
||||
}
|
||||
else if(world.GetBlockID(new Vector3(x + Data.faceChecks[f].x + chunkPosition.x * Data.chunkWidth,
|
||||
y + Data.faceChecks[f].y,
|
||||
z + Data.faceChecks[f].z + chunkPosition.z * Data.chunkWidth)) == 6)
|
||||
{
|
||||
for (int v = 0; v < 6; v++)
|
||||
{
|
||||
vertices.Add(Data.vertices[Data.triangles[f, v]] + new Vector3(x, y, z));
|
||||
triangles.Add(triangleIndex);
|
||||
triangleIndex++;
|
||||
}
|
||||
|
||||
AddUV(textures[f]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@ public class Player : MonoBehaviour
|
||||
if (Physics.Raycast(camera.transform.position, camera.transform.forward, out RaycastHit hit))
|
||||
{
|
||||
hit.point -= camera.transform.forward / 10;
|
||||
client.EditBlock(hit.point, 5);
|
||||
client.EditBlock(hit.point, 6);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -297,4 +297,24 @@ public class World : MonoBehaviour
|
||||
SceneManager.LoadScene("Login");
|
||||
deadScreen.SetActive(false);
|
||||
}
|
||||
|
||||
//return the ID of a block
|
||||
public byte GetBlockID(Vector3 positionInWorld)
|
||||
{
|
||||
if (!(positionInWorld.x < 0 || positionInWorld.y < 0 || positionInWorld.z < 0 ||
|
||||
positionInWorld.x >= worldSize * Data.chunkWidth || positionInWorld.y >= Data.chunkHeight ||
|
||||
positionInWorld.z >= worldSize * Data.chunkWidth))
|
||||
{
|
||||
ChunkCoord chunk = new ChunkCoord((int)(positionInWorld.x / Data.chunkWidth),
|
||||
(int)(positionInWorld.z / Data.chunkWidth));
|
||||
|
||||
int xInChunk = (int)(positionInWorld.x - chunk.x * Data.chunkWidth);
|
||||
int yInChunk = (int)positionInWorld.y;
|
||||
int zInChunk = (int)(positionInWorld.z - chunk.z * Data.chunkWidth);
|
||||
|
||||
return chunks[chunk.x, chunk.z].blocks[xInChunk, yInChunk, zInChunk];
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user