mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-10 16:03:15 -04:00
Use single VB for all other models (untested).
This commit is contained in:
parent
b07dff9bf6
commit
a13b88c81c
@ -10,7 +10,7 @@ namespace ClassicalSharp.Model {
|
||||
|
||||
ModelSet Set;
|
||||
public ChickenModel( Game window ) : base( window ) {
|
||||
vertices = new VertexPos3fTex2fCol4b[6 * 6];
|
||||
vertices = new VertexPos3fTex2fCol4b[partVertices * 6 + planeVertices * 2 * 2];
|
||||
Set = new ModelSet();
|
||||
Set.Head = MakeHead();
|
||||
Set.Head2 = MakeHead2(); // TODO: Find a more appropriate name.
|
||||
@ -20,8 +20,10 @@ namespace ClassicalSharp.Model {
|
||||
Set.RightLeg = MakeLeg( 0f, 0.1875f, 0.0625f, 0.125f );
|
||||
Set.LeftWing = MakeWing( -0.25f, -0.1875f );
|
||||
Set.RightWing = MakeWing( 0.1875f, 0.25f );
|
||||
|
||||
vb = graphics.InitVb( vertices, VertexFormat.Pos3fTex2fCol4b );
|
||||
Set.SetVb( vb );
|
||||
vertices = null;
|
||||
|
||||
DefaultTexId = graphics.LoadTexture( "chicken.png" );
|
||||
}
|
||||
|
||||
@ -46,12 +48,10 @@ namespace ClassicalSharp.Model {
|
||||
}
|
||||
|
||||
ModelPart MakeLeg( float x1, float x2, float legX1, float legX2 ) {
|
||||
index = 0;
|
||||
const float y1 = 0f, y2 = 0.3125f, z2 = 0.0625f, z1 = -0.125f;
|
||||
YPlane( 32, 0, 3, 3, x2, x1, z1, z2, y1, false ); // bottom feet
|
||||
ZPlane( 36, 3, 1, 5, legX1, legX2, y1, y2, z2, false ); // vertical part of leg
|
||||
int vb = graphics.InitVb( vertices, VertexFormat.Pos3fTex2fCol4b, 2 * 6 );
|
||||
return new ModelPart( vb, 0, 2 * 6, graphics );
|
||||
return new ModelPart( vb, index - 12, 2 * 6, graphics );
|
||||
}
|
||||
|
||||
public override float NameYOffset {
|
||||
@ -75,7 +75,7 @@ namespace ClassicalSharp.Model {
|
||||
}
|
||||
|
||||
public override void Dispose() {
|
||||
Set.Dispose();
|
||||
graphics.DeleteVb( vb );
|
||||
graphics.DeleteTexture( ref DefaultTexId );
|
||||
}
|
||||
|
||||
@ -83,15 +83,9 @@ namespace ClassicalSharp.Model {
|
||||
|
||||
public ModelPart Head, Head2, Head3, Torso, LeftLeg, RightLeg, LeftWing, RightWing;
|
||||
|
||||
public void Dispose() {
|
||||
RightLeg.Dispose();
|
||||
LeftLeg.Dispose();
|
||||
Torso.Dispose();
|
||||
Head.Dispose();
|
||||
Head2.Dispose();
|
||||
Head3.Dispose();
|
||||
LeftWing.Dispose();
|
||||
RightWing.Dispose();
|
||||
public void SetVb( int vb ) {
|
||||
Head.Vb = Head2.Vb = Head3.Vb = Torso.Vb = LeftLeg.Vb =
|
||||
RightLeg.Vb = LeftWing.Vb = RightWing.Vb = vb;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,4 @@
|
||||
using OpenTK;
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System;
|
||||
using ClassicalSharp.GraphicsAPI;
|
||||
using ClassicalSharp.Renderers;
|
||||
|
||||
@ -10,7 +8,7 @@ namespace ClassicalSharp.Model {
|
||||
|
||||
ModelSet Set;
|
||||
public CreeperModel( Game window ) : base( window ) {
|
||||
vertices = new VertexPos3fTex2fCol4b[6 * 6];
|
||||
vertices = new VertexPos3fTex2fCol4b[partVertices * 6];
|
||||
Set = new ModelSet();
|
||||
Set.Head = MakeHead();
|
||||
Set.Torso = MakeTorso();
|
||||
@ -18,8 +16,10 @@ namespace ClassicalSharp.Model {
|
||||
Set.RightLegFront = MakeLeg( 0, 0.25f, -0.375f, -0.125f );
|
||||
Set.LeftLegBack = MakeLeg( -0.25f, 0, 0.125f, 0.375f );
|
||||
Set.RightLegBack = MakeLeg( 0, 0.25f, 0.125f, 0.375f );
|
||||
|
||||
vb = graphics.InitVb( vertices, VertexFormat.Pos3fTex2fCol4b );
|
||||
Set.SetVb( vb );
|
||||
vertices = null;
|
||||
|
||||
DefaultTexId = graphics.LoadTexture( "creeper.png" );
|
||||
}
|
||||
|
||||
@ -54,7 +54,7 @@ namespace ClassicalSharp.Model {
|
||||
}
|
||||
|
||||
public override void Dispose() {
|
||||
Set.Dispose();
|
||||
graphics.DeleteVb( vb );
|
||||
graphics.DeleteTexture( ref DefaultTexId );
|
||||
}
|
||||
|
||||
@ -62,13 +62,9 @@ namespace ClassicalSharp.Model {
|
||||
|
||||
public ModelPart Head, Torso, LeftLegFront, RightLegFront, LeftLegBack, RightLegBack;
|
||||
|
||||
public void Dispose() {
|
||||
RightLegFront.Dispose();
|
||||
LeftLegFront.Dispose();
|
||||
RightLegBack.Dispose();
|
||||
LeftLegBack.Dispose();
|
||||
Torso.Dispose();
|
||||
Head.Dispose();
|
||||
public void SetVb( int vb ) {
|
||||
Head.Vb = Torso.Vb = LeftLegFront.Vb = RightLegFront.Vb
|
||||
= LeftLegBack.Vb = RightLegBack.Vb = vb;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,8 @@ namespace ClassicalSharp.Model {
|
||||
|
||||
protected Game window;
|
||||
protected IGraphicsApi graphics;
|
||||
protected const int planeVertices = 6;
|
||||
protected const int partVertices = 6 * planeVertices;
|
||||
|
||||
public IModel( Game window ) {
|
||||
this.window = window;
|
||||
@ -53,29 +55,17 @@ namespace ClassicalSharp.Model {
|
||||
|
||||
protected ModelPart MakePart( int x, int y, int sidesW, int sidesH, int endsW, int endsH, int bodyW, int bodyH,
|
||||
float x1, float x2, float y1, float y2, float z1, float z2, bool _64x64 ) {
|
||||
// TODO: temp hack until we change other classes.
|
||||
if( !( this is PlayerModel ) ) {
|
||||
index = 0;
|
||||
}
|
||||
YPlane( x + sidesW, y, endsW, endsH, x2, x1, z2, z1, y2, _64x64 ); // top
|
||||
YPlane( x + sidesW + bodyW, y, endsW, endsH, x2, x1, z1, z2, y1, _64x64 ); // bottom
|
||||
ZPlane( x + sidesW, y + endsH, bodyW, bodyH, x2, x1, y1, y2, z1, _64x64 ); // front
|
||||
ZPlane( x + sidesW + bodyW + sidesW, y + endsH, bodyW, bodyH, x1, x2, y1, y2, z2, _64x64 ); // back
|
||||
XPlane( x, y + endsH, sidesW, sidesH, z2, z1, y1, y2, x2, _64x64 ); // left
|
||||
XPlane( x + sidesW + bodyW, y + endsH, sidesW, sidesH, z1, z2, y1, y2, x1, _64x64 ); // right
|
||||
if( !( this is PlayerModel ) ) {
|
||||
int vb = graphics.InitVb( vertices, VertexFormat.Pos3fTex2fCol4b, 6 * 6 );
|
||||
return new ModelPart( vb, 0, 6 * 6, graphics );
|
||||
} else {
|
||||
return new ModelPart( this.vb, index - 36, 6 * 6, graphics );
|
||||
}
|
||||
return new ModelPart( this.vb, index - 36, 6 * 6, graphics );
|
||||
}
|
||||
|
||||
protected ModelPart MakeRotatedPart( int x, int y, int sidesW, int sidesH, int endsW, int endsH, int bodyW, int bodyH,
|
||||
float x1, float x2, float y1, float y2, float z1, float z2, bool _64x64 ) {
|
||||
if( !( this is PlayerModel ) ) {
|
||||
index = 0;
|
||||
}
|
||||
YPlane( x + sidesW + bodyW + sidesW, y + endsH, bodyW, bodyH, x1, x2, z1, z2, y2, _64x64 ); // top
|
||||
YPlane( x + sidesW, y + endsH, bodyW, bodyH, x2, x1, z1, z2, y1, _64x64 ); // bottom
|
||||
ZPlane( x + sidesW, y, endsW, endsH, x2, x1, y1, y2, z1, _64x64 ); // front
|
||||
@ -90,12 +80,7 @@ namespace ClassicalSharp.Model {
|
||||
vertex.Y = z;
|
||||
vertices[i] = vertex;
|
||||
}
|
||||
if( !( this is PlayerModel ) ) {
|
||||
int vb = graphics.InitVb( vertices, VertexFormat.Pos3fTex2fCol4b, 6 * 6 );
|
||||
return new ModelPart( vb, 0, 6 * 6, graphics );
|
||||
} else {
|
||||
return new ModelPart( this.vb, index - 36, 6 * 6, graphics );
|
||||
}
|
||||
return new ModelPart( this.vb, index - 36, 6 * 6, graphics );
|
||||
}
|
||||
|
||||
protected static TextureRectangle SkinTexCoords( int x, int y, int width, int height, float skinWidth, float skinHeight ) {
|
||||
|
@ -5,7 +5,7 @@ namespace ClassicalSharp {
|
||||
|
||||
public class ModelPart {
|
||||
|
||||
public int VbId;
|
||||
public int Vb;
|
||||
public int Offset = 0;
|
||||
public int Count;
|
||||
public IGraphicsApi Graphics;
|
||||
@ -14,15 +14,11 @@ namespace ClassicalSharp {
|
||||
Offset = offset;
|
||||
Count = count;
|
||||
Graphics = graphics;
|
||||
VbId = vb;
|
||||
Vb = vb;
|
||||
}
|
||||
|
||||
public void Render() {
|
||||
Graphics.DrawVb( DrawMode.Triangles, VertexFormat.Pos3fTex2fCol4b, VbId, Offset, Count );
|
||||
}
|
||||
|
||||
public void Dispose() {
|
||||
Graphics.DeleteVb( VbId );
|
||||
Graphics.DrawVb( DrawMode.Triangles, VertexFormat.Pos3fTex2fCol4b, Vb, Offset, Count );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,7 @@ namespace ClassicalSharp.Model {
|
||||
|
||||
ModelSet Set;
|
||||
public PigModel( Game window ) : base( window ) {
|
||||
vertices = new VertexPos3fTex2fCol4b[6 * 6];
|
||||
vertices = new VertexPos3fTex2fCol4b[partVertices * 6];
|
||||
Set = new ModelSet();
|
||||
Set.Head = MakeHead();
|
||||
Set.Torso = MakeTorso();
|
||||
@ -18,8 +18,10 @@ namespace ClassicalSharp.Model {
|
||||
Set.RightLegFront = MakeLeg( 0.0625f, 0.3125f, -0.4375f, -0.1875f );
|
||||
Set.LeftLegBack = MakeLeg( -0.3125f, -0.0625f, 0.3125f, 0.5625f );
|
||||
Set.RightLegBack = MakeLeg( 0.0625f, 0.3125f, 0.3125f, 0.5625f );
|
||||
|
||||
vb = graphics.InitVb( vertices, VertexFormat.Pos3fTex2fCol4b );
|
||||
Set.SetVb( vb );
|
||||
vertices = null;
|
||||
|
||||
DefaultTexId = graphics.LoadTexture( "pig.png" );
|
||||
}
|
||||
|
||||
@ -54,7 +56,7 @@ namespace ClassicalSharp.Model {
|
||||
}
|
||||
|
||||
public override void Dispose() {
|
||||
Set.Dispose();
|
||||
graphics.DeleteVb( vb );
|
||||
graphics.DeleteTexture( ref DefaultTexId );
|
||||
}
|
||||
|
||||
@ -62,13 +64,9 @@ namespace ClassicalSharp.Model {
|
||||
|
||||
public ModelPart Head, Torso, LeftLegFront, RightLegFront, LeftLegBack, RightLegBack;
|
||||
|
||||
public void Dispose() {
|
||||
RightLegFront.Dispose();
|
||||
LeftLegFront.Dispose();
|
||||
RightLegBack.Dispose();
|
||||
LeftLegBack.Dispose();
|
||||
Torso.Dispose();
|
||||
Head.Dispose();
|
||||
public void SetVb( int vb ) {
|
||||
Head.Vb = Torso.Vb = LeftLegFront.Vb = RightLegFront.Vb
|
||||
= LeftLegBack.Vb = RightLegBack.Vb = vb;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
using OpenTK;
|
||||
using System;
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using ClassicalSharp.GraphicsAPI;
|
||||
using ClassicalSharp.Renderers;
|
||||
@ -10,7 +9,7 @@ namespace ClassicalSharp.Model {
|
||||
|
||||
ModelSet Set64x32, Set64x64, Set64x64Slim;
|
||||
public PlayerModel( Game window ) : base( window ) {
|
||||
vertices = new VertexPos3fTex2fCol4b[( 6 * 6 ) * 7 * 3];
|
||||
vertices = new VertexPos3fTex2fCol4b[partVertices * 7 * 3];
|
||||
Set64x32 = new ModelSet();
|
||||
Set64x32.Head = MakeHead( false );
|
||||
Set64x32.Torso = MakeTorso( false );
|
||||
@ -112,8 +111,8 @@ namespace ClassicalSharp.Model {
|
||||
public ModelPart Head, Torso, LeftLeg, RightLeg, LeftArm, RightArm, Hat;
|
||||
|
||||
public void SetVb( int vb ) {
|
||||
Head.VbId = Torso.VbId = LeftLeg.VbId = RightLeg.VbId =
|
||||
LeftArm.VbId = RightArm.VbId = Hat.VbId = vb;
|
||||
Head.Vb = Torso.Vb = LeftLeg.Vb = RightLeg.Vb =
|
||||
LeftArm.Vb = RightArm.Vb = Hat.Vb = vb;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ namespace ClassicalSharp.Model {
|
||||
int furTextureId;
|
||||
|
||||
public SheepModel( Game window ) : base( window ) {
|
||||
vertices = new VertexPos3fTex2fCol4b[6 * 6];
|
||||
vertices = new VertexPos3fTex2fCol4b[partVertices * 6 * ( Fur ? 2 : 1 )];
|
||||
Set = new ModelSet( Fur );
|
||||
Set.Head = MakeHead();
|
||||
Set.Torso = MakeTorso();
|
||||
@ -29,8 +29,10 @@ namespace ClassicalSharp.Model {
|
||||
Set.FurLeftLegBack = MakeFurLeg( -0.34375f, -0.03125f, 0.28125f, 0.59375f );
|
||||
Set.FurRightLegBack = MakeFurLeg( 0.03125f, 0.34375f, 0.28125f, 0.59375f );
|
||||
}
|
||||
|
||||
vb = graphics.InitVb( vertices, VertexFormat.Pos3fTex2fCol4b );
|
||||
Set.SetVb( vb );
|
||||
vertices = null;
|
||||
|
||||
DefaultTexId = graphics.LoadTexture( "sheep.png" );
|
||||
furTextureId = graphics.LoadTexture( "sheep_fur.png" );
|
||||
}
|
||||
@ -87,7 +89,7 @@ namespace ClassicalSharp.Model {
|
||||
}
|
||||
|
||||
public override void Dispose() {
|
||||
Set.Dispose();
|
||||
graphics.DeleteVb( vb );
|
||||
graphics.DeleteTexture( ref DefaultTexId );
|
||||
if( Fur ) {
|
||||
graphics.DeleteTexture( ref furTextureId );
|
||||
@ -104,20 +106,12 @@ namespace ClassicalSharp.Model {
|
||||
this.fur = fur;
|
||||
}
|
||||
|
||||
public void Dispose() {
|
||||
RightLegFront.Dispose();
|
||||
LeftLegFront.Dispose();
|
||||
RightLegBack.Dispose();
|
||||
LeftLegBack.Dispose();
|
||||
Torso.Dispose();
|
||||
Head.Dispose();
|
||||
public void SetVb( int vb ) {
|
||||
Head.Vb = Torso.Vb = LeftLegFront.Vb = RightLegFront.Vb
|
||||
= LeftLegBack.Vb = RightLegBack.Vb = vb;
|
||||
if( fur ) {
|
||||
FurHead.Dispose();
|
||||
FurTorso.Dispose();
|
||||
FurLeftLegBack.Dispose();
|
||||
FurLeftLegFront.Dispose();
|
||||
FurRightLegBack.Dispose();
|
||||
FurRightLegFront.Dispose();
|
||||
FurHead.Vb = FurTorso.Vb = FurLeftLegFront.Vb = FurRightLegFront.Vb
|
||||
= FurLeftLegBack.Vb = FurRightLegBack.Vb = vb;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ namespace ClassicalSharp.Model {
|
||||
|
||||
ModelSet Set;
|
||||
public SkeletonModel( Game window ) : base( window ) {
|
||||
vertices = new VertexPos3fTex2fCol4b[6 * 6];
|
||||
vertices = new VertexPos3fTex2fCol4b[partVertices * 6];
|
||||
Set = new ModelSet();
|
||||
Set.Head = MakeHead();
|
||||
Set.Torso = MakeTorso();
|
||||
@ -18,8 +18,10 @@ namespace ClassicalSharp.Model {
|
||||
Set.RightLeg = MakeRightLeg( 0.0625f, 0.1875f );
|
||||
Set.LeftArm = MakeLeftArm( 0.375f, 0.25f );
|
||||
Set.RightArm = MakeRightArm( 0.25f, 0.375f );
|
||||
|
||||
vb = graphics.InitVb( vertices, VertexFormat.Pos3fTex2fCol4b );
|
||||
Set.SetVb( vb );
|
||||
vertices = null;
|
||||
|
||||
DefaultTexId = graphics.LoadTexture( "skeleton.png" );
|
||||
}
|
||||
|
||||
@ -66,7 +68,7 @@ namespace ClassicalSharp.Model {
|
||||
}
|
||||
|
||||
public override void Dispose() {
|
||||
Set.Dispose();
|
||||
graphics.DeleteVb( vb );
|
||||
graphics.DeleteTexture( ref DefaultTexId );
|
||||
}
|
||||
|
||||
@ -74,13 +76,9 @@ namespace ClassicalSharp.Model {
|
||||
|
||||
public ModelPart Head, Torso, LeftLeg, RightLeg, LeftArm, RightArm;
|
||||
|
||||
public void Dispose() {
|
||||
RightArm.Dispose();
|
||||
LeftArm.Dispose();
|
||||
RightLeg.Dispose();
|
||||
LeftLeg.Dispose();
|
||||
Torso.Dispose();
|
||||
Head.Dispose();
|
||||
public void SetVb( int vb ) {
|
||||
Head.Vb = Torso.Vb = LeftLeg.Vb = RightLeg.Vb =
|
||||
LeftArm.Vb = RightArm.Vb = vb;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,15 +10,17 @@ namespace ClassicalSharp.Model {
|
||||
|
||||
ModelSet Set;
|
||||
public SpiderModel( Game window ) : base( window ) {
|
||||
vertices = new VertexPos3fTex2fCol4b[6 * 6];
|
||||
vertices = new VertexPos3fTex2fCol4b[partVertices * 5];
|
||||
Set = new ModelSet();
|
||||
Set.Head = MakeHead();
|
||||
Set.Link = MakeLink();
|
||||
Set.End = MakeEnd();
|
||||
Set.LeftLeg = MakeLeg( -1.1875f, -0.1875f );
|
||||
Set.RightLeg = MakeLeg( 0.1875f, 1.1875f );
|
||||
|
||||
vb = graphics.InitVb( vertices, VertexFormat.Pos3fTex2fCol4b );
|
||||
Set.SetVb( vb );
|
||||
vertices = null;
|
||||
|
||||
DefaultTexId = graphics.LoadTexture( "spider.png" );
|
||||
}
|
||||
|
||||
@ -62,7 +64,7 @@ namespace ClassicalSharp.Model {
|
||||
}
|
||||
|
||||
public override void Dispose() {
|
||||
Set.Dispose();
|
||||
graphics.DeleteVb( vb );
|
||||
graphics.DeleteTexture( ref DefaultTexId );
|
||||
}
|
||||
|
||||
@ -70,12 +72,9 @@ namespace ClassicalSharp.Model {
|
||||
|
||||
public ModelPart Head, Link, End, LeftLeg, RightLeg;
|
||||
|
||||
public void Dispose() {
|
||||
RightLeg.Dispose();
|
||||
LeftLeg.Dispose();
|
||||
End.Dispose();
|
||||
Head.Dispose();
|
||||
Link.Dispose();
|
||||
public void SetVb( int vb ) {
|
||||
Head.Vb = Link.Vb = LeftLeg.Vb = RightLeg.Vb =
|
||||
End.Vb = vb;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ namespace ClassicalSharp.Model {
|
||||
|
||||
ModelSet Set;
|
||||
public ZombieModel( Game window ) : base( window ) {
|
||||
vertices = new VertexPos3fTex2fCol4b[6 * 6];
|
||||
vertices = new VertexPos3fTex2fCol4b[partVertices * 6];
|
||||
Set = new ModelSet();
|
||||
Set.Head = MakeHead();
|
||||
Set.Torso = MakeTorso();
|
||||
@ -18,8 +18,10 @@ namespace ClassicalSharp.Model {
|
||||
Set.RightLeg = MakeRightLeg( 0, 0.25f );
|
||||
Set.LeftArm = MakeLeftArm( 0.5f, 0.25f );
|
||||
Set.RightArm = MakeRightArm( 0.25f, 0.5f );
|
||||
vertices = null;
|
||||
|
||||
|
||||
vb = graphics.InitVb( vertices, VertexFormat.Pos3fTex2fCol4b );
|
||||
Set.SetVb( vb );
|
||||
vertices = null;
|
||||
DefaultTexId = graphics.LoadTexture( "zombie.png" );
|
||||
}
|
||||
|
||||
@ -66,7 +68,7 @@ namespace ClassicalSharp.Model {
|
||||
}
|
||||
|
||||
public override void Dispose() {
|
||||
Set.Dispose();
|
||||
graphics.DeleteVb( vb );
|
||||
graphics.DeleteTexture( ref DefaultTexId );
|
||||
}
|
||||
|
||||
@ -74,13 +76,9 @@ namespace ClassicalSharp.Model {
|
||||
|
||||
public ModelPart Head, Torso, LeftLeg, RightLeg, LeftArm, RightArm;
|
||||
|
||||
public void Dispose() {
|
||||
RightArm.Dispose();
|
||||
LeftArm.Dispose();
|
||||
RightLeg.Dispose();
|
||||
LeftLeg.Dispose();
|
||||
Torso.Dispose();
|
||||
Head.Dispose();
|
||||
public void SetVb( int vb ) {
|
||||
Head.Vb = Torso.Vb = LeftLeg.Vb = RightLeg.Vb =
|
||||
LeftArm.Vb = RightArm.Vb = vb;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user