Add proper brightness to entities, closes #45. (Thanks Goodlyay)

This commit is contained in:
UnknownShadow200 2015-09-03 20:14:10 +10:00
parent 9a69dba8c5
commit 875ec23b5b
3 changed files with 15 additions and 1 deletions

View File

@ -47,7 +47,7 @@
<StartAction>Project</StartAction> <StartAction>Project</StartAction>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug_DX' "> <PropertyGroup Condition=" '$(Configuration)' == 'Debug_DX' ">
<PlatformTarget>x86</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
<OutputPath>..\output\debug\</OutputPath> <OutputPath>..\output\debug\</OutputPath>
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
<DebugType>Full</DebugType> <DebugType>Full</DebugType>

View File

@ -175,6 +175,16 @@ namespace ClassicalSharp {
} }
} }
public bool IsLit( int x, int y, int z ) {
if( !IsValidPos( x, y, z ) ) return true;
return y > heightmap[z * Width + x];
}
public bool IsLit( Vector3I p ) {
if( !IsValidPos( p.X, p.Y, p.Z ) ) return true;
return p.Y > heightmap[p.Z * Width + p.X];
}
public void SetBlock( int x, int y, int z, byte blockId ) { public void SetBlock( int x, int y, int z, byte blockId ) {
int index = ( y * Length + z ) * Width + x; int index = ( y * Length + z ) * Width + x;
byte oldBlock = mapData[index]; byte oldBlock = mapData[index];

View File

@ -32,6 +32,7 @@ namespace ClassicalSharp.Model {
pos = p.Position; pos = p.Position;
cosA = (float)Math.Cos( p.YawRadians ); cosA = (float)Math.Cos( p.YawRadians );
sinA = (float)Math.Sin( p.YawRadians ); sinA = (float)Math.Sin( p.YawRadians );
curCol = game.Map.IsLit( Vector3I.Floor( p.EyePosition ) ) ? (byte)255 : (byte)178;
graphics.BeginVbBatch( VertexFormat.Pos3fTex2fCol4b ); graphics.BeginVbBatch( VertexFormat.Pos3fTex2fCol4b );
DrawPlayerModel( p ); DrawPlayerModel( p );
@ -45,6 +46,7 @@ namespace ClassicalSharp.Model {
public int DefaultTexId; public int DefaultTexId;
protected FastColour col = new FastColour( 178, 178, 178 ); protected FastColour col = new FastColour( 178, 178, 178 );
protected byte curCol = 178;
protected VertexPos3fTex2fCol4b[] vertices; protected VertexPos3fTex2fCol4b[] vertices;
protected int index; protected int index;
@ -114,6 +116,7 @@ namespace ClassicalSharp.Model {
VertexPos3fTex2fCol4b vertex = vertices[part.Offset + i]; VertexPos3fTex2fCol4b vertex = vertices[part.Offset + i];
Vector3 newPos = Utils.RotateY( vertex.X, vertex.Y, vertex.Z, cosA, sinA ) + pos; Vector3 newPos = Utils.RotateY( vertex.X, vertex.Y, vertex.Z, cosA, sinA ) + pos;
vertex.X = newPos.X; vertex.Y = newPos.Y; vertex.Z = newPos.Z; vertex.X = newPos.X; vertex.Y = newPos.Y; vertex.Z = newPos.Z;
vertex.R = curCol; vertex.G = curCol; vertex.B = curCol;
cache.vertices[index++] = vertex; cache.vertices[index++] = vertex;
} }
} }
@ -134,6 +137,7 @@ namespace ClassicalSharp.Model {
Vector3 newPos = Utils.RotateY( loc.X, loc.Y, loc.Z, cosA, sinA ) + offset; Vector3 newPos = Utils.RotateY( loc.X, loc.Y, loc.Z, cosA, sinA ) + offset;
vertex.X = newPos.X; vertex.Y = newPos.Y; vertex.Z = newPos.Z; vertex.X = newPos.X; vertex.Y = newPos.Y; vertex.Z = newPos.Z;
vertex.R = curCol; vertex.G = curCol; vertex.B = curCol;
cache.vertices[index++] = vertex; cache.vertices[index++] = vertex;
} }
} }