mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-14 10:05:44 -04:00
Particles should use shadow colour when in shadow, fixes #59.
This commit is contained in:
parent
e43add1d32
commit
896408a751
@ -13,7 +13,7 @@ namespace ClassicalSharp.Particles {
|
||||
protected Game game;
|
||||
protected Vector3 lastPos, nextPos;
|
||||
|
||||
public abstract void Render( double delta, float t, VertexPos3fTex2f[] vertices, ref int index );
|
||||
public abstract void Render( double delta, float t, VertexPos3fTex2fCol4b[] vertices, ref int index );
|
||||
|
||||
public abstract void Dispose();
|
||||
|
||||
|
@ -15,16 +15,16 @@ namespace ClassicalSharp.Particles {
|
||||
public ParticleManager( Game game ) {
|
||||
this.game = game;
|
||||
graphics = game.Graphics;
|
||||
vb = graphics.CreateDynamicVb( VertexFormat.Pos3fTex2f, 1000 );
|
||||
vb = graphics.CreateDynamicVb( VertexFormat.Pos3fTex2fCol4b, 1000 );
|
||||
}
|
||||
|
||||
VertexPos3fTex2f[] vertices = new VertexPos3fTex2f[0];
|
||||
VertexPos3fTex2fCol4b[] vertices = new VertexPos3fTex2fCol4b[0];
|
||||
public void Render( double delta, float t ) {
|
||||
if( particles.Count == 0 ) return;
|
||||
|
||||
int count = particles.Count * 6;
|
||||
if( count > vertices.Length ) {
|
||||
vertices = new VertexPos3fTex2f[count];
|
||||
vertices = new VertexPos3fTex2fCol4b[count];
|
||||
}
|
||||
int index = 0;
|
||||
for( int i = 0; i < particles.Count; i++ ) {
|
||||
@ -36,7 +36,7 @@ namespace ClassicalSharp.Particles {
|
||||
graphics.AlphaTest = true;
|
||||
count = Math.Min( count, 1000 );
|
||||
|
||||
graphics.BeginVbBatch( VertexFormat.Pos3fTex2f );
|
||||
graphics.BeginVbBatch( VertexFormat.Pos3fTex2fCol4b );
|
||||
graphics.DrawDynamicIndexedVb( DrawMode.Triangles, vb, vertices, count, count * 6 / 4 );
|
||||
graphics.AlphaTest = false;
|
||||
graphics.Texturing = false;
|
||||
|
@ -13,15 +13,17 @@ namespace ClassicalSharp.Particles {
|
||||
maxY = Position.Y;
|
||||
}
|
||||
|
||||
public override void Render( double delta, float t, VertexPos3fTex2f[] vertices, ref int index ) {
|
||||
public override void Render( double delta, float t, VertexPos3fTex2fCol4b[] vertices, ref int index ) {
|
||||
Position = Vector3.Lerp( lastPos, nextPos, t );
|
||||
Vector3 p111, p121, p212, p222;
|
||||
TranslatePoints( out p111, out p121, out p212, out p222 );
|
||||
|
||||
vertices[index++] = new VertexPos3fTex2f( p111, Rectangle.U1, Rectangle.V2 );
|
||||
vertices[index++] = new VertexPos3fTex2f( p121, Rectangle.U1, Rectangle.V1 );
|
||||
vertices[index++] = new VertexPos3fTex2f( p222, Rectangle.U2, Rectangle.V1 );
|
||||
vertices[index++] = new VertexPos3fTex2f( p212, Rectangle.U2, Rectangle.V2 );
|
||||
Map map = game.Map;
|
||||
FastColour col = map.IsLit( Vector3I.Floor( Position ) ) ? map.Sunlight : map.Shadowlight;
|
||||
|
||||
vertices[index++] = new VertexPos3fTex2fCol4b( p111, Rectangle.U1, Rectangle.V2, col );
|
||||
vertices[index++] = new VertexPos3fTex2fCol4b( p121, Rectangle.U1, Rectangle.V1, col );
|
||||
vertices[index++] = new VertexPos3fTex2fCol4b( p222, Rectangle.U2, Rectangle.V1, col );
|
||||
vertices[index++] = new VertexPos3fTex2fCol4b( p212, Rectangle.U2, Rectangle.V2, col );
|
||||
}
|
||||
|
||||
public override bool Tick( double delta ) {
|
||||
|
@ -62,6 +62,12 @@ namespace ClassicalSharp {
|
||||
R = c.R; G = c.G; B = c.B; A = c.A;
|
||||
}
|
||||
|
||||
public VertexPos3fTex2fCol4b( Vector3 p, float u, float v, FastColour c ) {
|
||||
X = p.X; Y = p.Y; Z = p.Z;
|
||||
U = u; V = v;
|
||||
R = c.R; G = c.G; B = c.B; A = c.A;
|
||||
}
|
||||
|
||||
public VertexPos3fTex2fCol4b( float x, float y, float z, float u, float v, Color c ) {
|
||||
X = x; Y = y; Z = z;
|
||||
U = u; V = v;
|
||||
|
Loading…
x
Reference in New Issue
Block a user