mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-10-07 04:56:04 -04:00
32 lines
1.1 KiB
C#
32 lines
1.1 KiB
C#
using System;
|
|
using OpenTK;
|
|
|
|
namespace ClassicalSharp.Particles {
|
|
|
|
public sealed class TerrainParticle : CollidableParticle {
|
|
|
|
static Vector2 terrainSize = new Vector2( 1/8f, 1/8f );
|
|
internal TextureRec rec;
|
|
|
|
public TerrainParticle( Game game ) : base( game ) { }
|
|
|
|
public override bool Tick( double delta ) {
|
|
return Tick( 5.4f, delta );
|
|
}
|
|
|
|
public override void Render( double delta, float t, VertexPos3fTex2fCol4b[] vertices, ref int index ) {
|
|
Position = Vector3.Lerp( lastPos, nextPos, t );
|
|
Vector3 p111, p121, p212, p222;
|
|
Utils.CalcBillboardPoints( terrainSize, Position, ref game.View,
|
|
out p111, out p121, out p212, out p222 );
|
|
Map map = game.Map;
|
|
FastColour col = map.IsLit( Vector3I.Floor( Position ) ) ? map.Sunlight : map.Shadowlight;
|
|
|
|
vertices[index++] = new VertexPos3fTex2fCol4b( p111, rec.U1, rec.V2, col );
|
|
vertices[index++] = new VertexPos3fTex2fCol4b( p121, rec.U1, rec.V1, col );
|
|
vertices[index++] = new VertexPos3fTex2fCol4b( p222, rec.U2, rec.V1, col );
|
|
vertices[index++] = new VertexPos3fTex2fCol4b( p212, rec.U2, rec.V2, col );
|
|
}
|
|
}
|
|
}
|