Added rifle to player rendering schema.
This commit is contained in:
parent
ad4178e7a5
commit
33bacf0632
|
@ -34,6 +34,7 @@ public class GameRenderer {
|
||||||
private final Camera camera;
|
private final Camera camera;
|
||||||
private final ClientWorld world;
|
private final ClientWorld world;
|
||||||
private Model playerModel; // Standard player model used to render all players.
|
private Model playerModel; // Standard player model used to render all players.
|
||||||
|
private Model rifleModel;
|
||||||
|
|
||||||
private long windowHandle;
|
private long windowHandle;
|
||||||
private int screenWidth = 800;
|
private int screenWidth = 800;
|
||||||
|
@ -116,6 +117,7 @@ public class GameRenderer {
|
||||||
this.modelRenderer = new ModelRenderer();
|
this.modelRenderer = new ModelRenderer();
|
||||||
try {
|
try {
|
||||||
playerModel = new Model("model/player_simple.obj", "model/simple_player.png");
|
playerModel = new Model("model/player_simple.obj", "model/simple_player.png");
|
||||||
|
rifleModel = new Model("model/rifle.obj", "model/rifle.png");
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
@ -162,12 +164,21 @@ public class GameRenderer {
|
||||||
// Draw players.
|
// Draw players.
|
||||||
modelRenderer.setView(camera.getViewTransformData());
|
modelRenderer.setView(camera.getViewTransformData());
|
||||||
playerModel.bind();
|
playerModel.bind();
|
||||||
Matrix4f playerModelTransform = new Matrix4f();
|
Matrix4f modelTransform = new Matrix4f();
|
||||||
for (var player : world.getPlayers()) {
|
for (var player : world.getPlayers()) {
|
||||||
playerModelTransform.identity().translate(player.getPosition());
|
modelTransform.identity().translate(player.getPosition());
|
||||||
modelRenderer.render(playerModel, playerModelTransform);
|
modelRenderer.render(playerModel, modelTransform);
|
||||||
}
|
}
|
||||||
playerModel.unbind();
|
playerModel.unbind();
|
||||||
|
rifleModel.bind();
|
||||||
|
for (var player : world.getPlayers()) {
|
||||||
|
modelTransform.identity()
|
||||||
|
.translate(player.getPosition())
|
||||||
|
.rotate((float) (player.getOrientation().x - Math.PI / 2), Camera.UP)
|
||||||
|
.translate(0, 0, -0.45f);
|
||||||
|
modelRenderer.render(rifleModel, modelTransform);
|
||||||
|
}
|
||||||
|
rifleModel.unbind();
|
||||||
|
|
||||||
guiRenderer.draw();
|
guiRenderer.draw();
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
# Blender MTL File: 'rifle.blend'
|
||||||
|
# Material Count: 1
|
||||||
|
|
||||||
|
newmtl Material
|
||||||
|
Ns 323.999994
|
||||||
|
Ka 1.000000 1.000000 1.000000
|
||||||
|
Kd 0.800000 0.800000 0.800000
|
||||||
|
Ks 0.500000 0.500000 0.500000
|
||||||
|
Ke 0.000000 0.000000 0.000000
|
||||||
|
Ni 1.450000
|
||||||
|
d 1.000000
|
||||||
|
illum 2
|
||||||
|
map_Kd rifle.png
|
|
@ -0,0 +1,150 @@
|
||||||
|
# Blender v2.82 (sub 7) OBJ File: 'rifle.blend'
|
||||||
|
# www.blender.org
|
||||||
|
mtllib rifle.mtl
|
||||||
|
o Cube
|
||||||
|
v 0.169557 1.084944 -0.055830
|
||||||
|
v 0.169557 0.937055 -0.055830
|
||||||
|
v 0.169557 1.084944 0.055830
|
||||||
|
v 0.169557 0.937055 0.055830
|
||||||
|
v -0.451262 1.079071 -0.024118
|
||||||
|
v -0.451262 1.030835 -0.024118
|
||||||
|
v -0.451262 1.079071 0.024118
|
||||||
|
v -0.451262 1.030835 0.024118
|
||||||
|
v 0.051097 0.943710 -0.073945
|
||||||
|
v 0.051097 1.091599 0.073945
|
||||||
|
v 0.051097 0.943710 0.073945
|
||||||
|
v 0.051097 1.091599 -0.073945
|
||||||
|
v -0.280923 0.943710 -0.073945
|
||||||
|
v -0.280923 1.091599 0.073945
|
||||||
|
v -0.280923 0.943710 0.073945
|
||||||
|
v -0.280923 1.091599 -0.073945
|
||||||
|
v -0.835438 1.079071 -0.024118
|
||||||
|
v -0.835438 1.030835 -0.024118
|
||||||
|
v -0.835438 1.079071 0.024118
|
||||||
|
v -0.835438 1.030835 0.024118
|
||||||
|
v 0.340133 1.033939 -0.037043
|
||||||
|
v 0.313955 0.898315 -0.037043
|
||||||
|
v 0.340133 1.033939 0.037043
|
||||||
|
v 0.313955 0.898315 0.037043
|
||||||
|
vt 0.558335 0.340476
|
||||||
|
vt 0.683269 0.472604
|
||||||
|
vt 0.494855 0.472604
|
||||||
|
vt 0.045283 0.471847
|
||||||
|
vt 0.139168 0.342889
|
||||||
|
vt 0.233148 0.480641
|
||||||
|
vt 0.825161 0.646216
|
||||||
|
vt 0.763706 0.942145
|
||||||
|
vt 0.763706 0.646216
|
||||||
|
vt 0.723305 0.156537
|
||||||
|
vt 0.888641 0.248599
|
||||||
|
vt 0.700226 0.248599
|
||||||
|
vt 0.197905 0.831321
|
||||||
|
vt 0.058321 0.958172
|
||||||
|
vt 0.010040 0.822527
|
||||||
|
vt 0.444089 0.260592
|
||||||
|
vt 0.253228 0.176906
|
||||||
|
vt 0.441093 0.168112
|
||||||
|
vt 0.288471 0.527586
|
||||||
|
vt 0.476336 0.518792
|
||||||
|
vt 0.888641 0.504352
|
||||||
|
vt 0.700226 0.504352
|
||||||
|
vt 0.200901 0.738841
|
||||||
|
vt 0.494855 0.731177
|
||||||
|
vt 0.660191 0.823714
|
||||||
|
vt 0.517934 0.823714
|
||||||
|
vt 0.382356 0.656544
|
||||||
|
vt 0.013036 0.730047
|
||||||
|
vt 0.683269 0.731177
|
||||||
|
vt 0.899885 0.156741
|
||||||
|
vt 0.961339 0.119119
|
||||||
|
vt 0.961339 0.156741
|
||||||
|
vt 0.619789 0.041284
|
||||||
|
vt 0.619789 0.340476
|
||||||
|
vt 0.358393 0.958172
|
||||||
|
vt 0.321080 0.659412
|
||||||
|
vt 0.077892 0.340021
|
||||||
|
vt 0.176481 0.044129
|
||||||
|
vt 0.995753 0.112578
|
||||||
|
vt 0.901367 0.004848
|
||||||
|
vt 0.995753 0.004848
|
||||||
|
vt 0.301509 0.041261
|
||||||
|
vt 0.476337 0.053554
|
||||||
|
vt 0.841627 0.040571
|
||||||
|
vt 0.865562 0.156537
|
||||||
|
vt 0.541869 0.958716
|
||||||
|
vt 0.825161 0.942145
|
||||||
|
vt 0.233148 0.945879
|
||||||
|
vt 0.256224 0.269386
|
||||||
|
vt 0.899885 0.119119
|
||||||
|
vt 0.558335 0.041284
|
||||||
|
vt 0.419669 0.955304
|
||||||
|
vt 0.115206 0.041261
|
||||||
|
vt 0.901367 0.112578
|
||||||
|
vt 0.747240 0.040571
|
||||||
|
vt 0.636255 0.958716
|
||||||
|
vn -0.0734 0.9973 0.0000
|
||||||
|
vn -0.2807 0.0000 0.9598
|
||||||
|
vn 0.0000 -1.0000 0.0000
|
||||||
|
vn -0.0561 -0.9984 0.0000
|
||||||
|
vn 0.1095 0.0000 0.9940
|
||||||
|
vn 0.1512 0.0000 -0.9885
|
||||||
|
vn 0.0000 0.0000 -1.0000
|
||||||
|
vn 0.1512 0.0000 0.9885
|
||||||
|
vn 0.0561 0.9984 0.0000
|
||||||
|
vn -0.4554 -0.8903 0.0000
|
||||||
|
vn -0.2807 0.0000 -0.9598
|
||||||
|
vn 0.0000 0.0000 1.0000
|
||||||
|
vn 0.0000 1.0000 0.0000
|
||||||
|
vn -1.0000 0.0000 0.0000
|
||||||
|
vn 0.9819 -0.1895 0.0000
|
||||||
|
vn 0.1227 -0.0237 -0.9922
|
||||||
|
vn -0.2591 -0.9658 0.0000
|
||||||
|
vn 0.2865 0.9581 0.0000
|
||||||
|
vn 0.1227 -0.0237 0.9922
|
||||||
|
vn 0.1095 0.0000 -0.9940
|
||||||
|
usemtl Material
|
||||||
|
s off
|
||||||
|
f 5/1/1 14/2/1 16/3/1
|
||||||
|
f 14/4/2 8/5/2 15/6/2
|
||||||
|
f 8/7/3 18/8/3 6/9/3
|
||||||
|
f 2/10/4 11/11/4 9/12/4
|
||||||
|
f 4/13/5 23/14/5 3/15/5
|
||||||
|
f 9/16/6 1/17/6 2/18/6
|
||||||
|
f 16/19/7 9/16/7 13/20/7
|
||||||
|
f 9/12/3 15/21/3 13/22/3
|
||||||
|
f 3/15/8 11/23/8 4/13/8
|
||||||
|
f 12/24/9 3/25/9 1/26/9
|
||||||
|
f 13/22/10 8/7/10 6/9/10
|
||||||
|
f 6/27/11 16/19/11 13/20/11
|
||||||
|
f 10/28/12 15/6/12 11/23/12
|
||||||
|
f 16/3/13 10/29/13 12/24/13
|
||||||
|
f 19/30/14 18/31/14 20/32/14
|
||||||
|
f 5/1/13 19/33/13 7/34/13
|
||||||
|
f 6/27/7 17/35/7 5/36/7
|
||||||
|
f 7/37/12 20/38/12 8/5/12
|
||||||
|
f 21/39/15 24/40/15 22/41/15
|
||||||
|
f 2/18/16 21/42/16 22/43/16
|
||||||
|
f 2/10/17 24/44/17 4/45/17
|
||||||
|
f 3/25/18 21/46/18 1/26/18
|
||||||
|
f 5/1/1 7/34/1 14/2/1
|
||||||
|
f 14/4/2 7/37/2 8/5/2
|
||||||
|
f 8/7/3 20/47/3 18/8/3
|
||||||
|
f 2/10/4 4/45/4 11/11/4
|
||||||
|
f 4/13/19 24/48/19 23/14/19
|
||||||
|
f 9/16/6 12/49/6 1/17/6
|
||||||
|
f 16/19/7 12/49/7 9/16/7
|
||||||
|
f 9/12/3 11/11/3 15/21/3
|
||||||
|
f 3/15/8 10/28/8 11/23/8
|
||||||
|
f 12/24/9 10/29/9 3/25/9
|
||||||
|
f 13/22/10 15/21/10 8/7/10
|
||||||
|
f 6/27/11 5/36/11 16/19/11
|
||||||
|
f 10/28/12 14/4/12 15/6/12
|
||||||
|
f 16/3/13 14/2/13 10/29/13
|
||||||
|
f 19/30/14 17/50/14 18/31/14
|
||||||
|
f 5/1/13 17/51/13 19/33/13
|
||||||
|
f 6/27/7 18/52/7 17/35/7
|
||||||
|
f 7/37/12 19/53/12 20/38/12
|
||||||
|
f 21/39/15 23/54/15 24/40/15
|
||||||
|
f 2/18/20 1/17/20 21/42/20
|
||||||
|
f 2/10/17 22/55/17 24/44/17
|
||||||
|
f 3/25/18 23/56/18 21/46/18
|
Binary file not shown.
After Width: | Height: | Size: 5.3 KiB |
|
@ -91,4 +91,13 @@ public class Player {
|
||||||
public Vector3f getViewVector() {
|
public Vector3f getViewVector() {
|
||||||
return viewVector;
|
return viewVector;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Vector3f getRightVector() {
|
||||||
|
float x = orientation.x - (float) (Math.PI / 2);
|
||||||
|
return new Vector3f(
|
||||||
|
sin(orientation.x),
|
||||||
|
0,
|
||||||
|
cos(orientation.x)
|
||||||
|
).normalize();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,13 @@
|
||||||
|
# Blender MTL File: 'rifle.blend'
|
||||||
|
# Material Count: 1
|
||||||
|
|
||||||
|
newmtl Material
|
||||||
|
Ns 323.999994
|
||||||
|
Ka 1.000000 1.000000 1.000000
|
||||||
|
Kd 0.800000 0.800000 0.800000
|
||||||
|
Ks 0.500000 0.500000 0.500000
|
||||||
|
Ke 0.000000 0.000000 0.000000
|
||||||
|
Ni 1.450000
|
||||||
|
d 1.000000
|
||||||
|
illum 2
|
||||||
|
map_Kd rifle.png
|
|
@ -0,0 +1,150 @@
|
||||||
|
# Blender v2.82 (sub 7) OBJ File: 'rifle.blend'
|
||||||
|
# www.blender.org
|
||||||
|
mtllib rifle.mtl
|
||||||
|
o Cube
|
||||||
|
v 0.169557 1.084944 -0.055830
|
||||||
|
v 0.169557 0.937055 -0.055830
|
||||||
|
v 0.169557 1.084944 0.055830
|
||||||
|
v 0.169557 0.937055 0.055830
|
||||||
|
v -0.451262 1.079071 -0.024118
|
||||||
|
v -0.451262 1.030835 -0.024118
|
||||||
|
v -0.451262 1.079071 0.024118
|
||||||
|
v -0.451262 1.030835 0.024118
|
||||||
|
v 0.051097 0.943710 -0.073945
|
||||||
|
v 0.051097 1.091599 0.073945
|
||||||
|
v 0.051097 0.943710 0.073945
|
||||||
|
v 0.051097 1.091599 -0.073945
|
||||||
|
v -0.280923 0.943710 -0.073945
|
||||||
|
v -0.280923 1.091599 0.073945
|
||||||
|
v -0.280923 0.943710 0.073945
|
||||||
|
v -0.280923 1.091599 -0.073945
|
||||||
|
v -0.835438 1.079071 -0.024118
|
||||||
|
v -0.835438 1.030835 -0.024118
|
||||||
|
v -0.835438 1.079071 0.024118
|
||||||
|
v -0.835438 1.030835 0.024118
|
||||||
|
v 0.340133 1.033939 -0.037043
|
||||||
|
v 0.313955 0.898315 -0.037043
|
||||||
|
v 0.340133 1.033939 0.037043
|
||||||
|
v 0.313955 0.898315 0.037043
|
||||||
|
vt 0.558335 0.340476
|
||||||
|
vt 0.683269 0.472604
|
||||||
|
vt 0.494855 0.472604
|
||||||
|
vt 0.045283 0.471847
|
||||||
|
vt 0.139168 0.342889
|
||||||
|
vt 0.233148 0.480641
|
||||||
|
vt 0.825161 0.646216
|
||||||
|
vt 0.763706 0.942145
|
||||||
|
vt 0.763706 0.646216
|
||||||
|
vt 0.723305 0.156537
|
||||||
|
vt 0.888641 0.248599
|
||||||
|
vt 0.700226 0.248599
|
||||||
|
vt 0.197905 0.831321
|
||||||
|
vt 0.058321 0.958172
|
||||||
|
vt 0.010040 0.822527
|
||||||
|
vt 0.444089 0.260592
|
||||||
|
vt 0.253228 0.176906
|
||||||
|
vt 0.441093 0.168112
|
||||||
|
vt 0.288471 0.527586
|
||||||
|
vt 0.476336 0.518792
|
||||||
|
vt 0.888641 0.504352
|
||||||
|
vt 0.700226 0.504352
|
||||||
|
vt 0.200901 0.738841
|
||||||
|
vt 0.494855 0.731177
|
||||||
|
vt 0.660191 0.823714
|
||||||
|
vt 0.517934 0.823714
|
||||||
|
vt 0.382356 0.656544
|
||||||
|
vt 0.013036 0.730047
|
||||||
|
vt 0.683269 0.731177
|
||||||
|
vt 0.899885 0.156741
|
||||||
|
vt 0.961339 0.119119
|
||||||
|
vt 0.961339 0.156741
|
||||||
|
vt 0.619789 0.041284
|
||||||
|
vt 0.619789 0.340476
|
||||||
|
vt 0.358393 0.958172
|
||||||
|
vt 0.321080 0.659412
|
||||||
|
vt 0.077892 0.340021
|
||||||
|
vt 0.176481 0.044129
|
||||||
|
vt 0.995753 0.112578
|
||||||
|
vt 0.901367 0.004848
|
||||||
|
vt 0.995753 0.004848
|
||||||
|
vt 0.301509 0.041261
|
||||||
|
vt 0.476337 0.053554
|
||||||
|
vt 0.841627 0.040571
|
||||||
|
vt 0.865562 0.156537
|
||||||
|
vt 0.541869 0.958716
|
||||||
|
vt 0.825161 0.942145
|
||||||
|
vt 0.233148 0.945879
|
||||||
|
vt 0.256224 0.269386
|
||||||
|
vt 0.899885 0.119119
|
||||||
|
vt 0.558335 0.041284
|
||||||
|
vt 0.419669 0.955304
|
||||||
|
vt 0.115206 0.041261
|
||||||
|
vt 0.901367 0.112578
|
||||||
|
vt 0.747240 0.040571
|
||||||
|
vt 0.636255 0.958716
|
||||||
|
vn -0.0734 0.9973 0.0000
|
||||||
|
vn -0.2807 0.0000 0.9598
|
||||||
|
vn 0.0000 -1.0000 0.0000
|
||||||
|
vn -0.0561 -0.9984 0.0000
|
||||||
|
vn 0.1095 0.0000 0.9940
|
||||||
|
vn 0.1512 0.0000 -0.9885
|
||||||
|
vn 0.0000 0.0000 -1.0000
|
||||||
|
vn 0.1512 0.0000 0.9885
|
||||||
|
vn 0.0561 0.9984 0.0000
|
||||||
|
vn -0.4554 -0.8903 0.0000
|
||||||
|
vn -0.2807 0.0000 -0.9598
|
||||||
|
vn 0.0000 0.0000 1.0000
|
||||||
|
vn 0.0000 1.0000 0.0000
|
||||||
|
vn -1.0000 0.0000 0.0000
|
||||||
|
vn 0.9819 -0.1895 0.0000
|
||||||
|
vn 0.1227 -0.0237 -0.9922
|
||||||
|
vn -0.2591 -0.9658 0.0000
|
||||||
|
vn 0.2865 0.9581 0.0000
|
||||||
|
vn 0.1227 -0.0237 0.9922
|
||||||
|
vn 0.1095 0.0000 -0.9940
|
||||||
|
usemtl Material
|
||||||
|
s off
|
||||||
|
f 5/1/1 14/2/1 16/3/1
|
||||||
|
f 14/4/2 8/5/2 15/6/2
|
||||||
|
f 8/7/3 18/8/3 6/9/3
|
||||||
|
f 2/10/4 11/11/4 9/12/4
|
||||||
|
f 4/13/5 23/14/5 3/15/5
|
||||||
|
f 9/16/6 1/17/6 2/18/6
|
||||||
|
f 16/19/7 9/16/7 13/20/7
|
||||||
|
f 9/12/3 15/21/3 13/22/3
|
||||||
|
f 3/15/8 11/23/8 4/13/8
|
||||||
|
f 12/24/9 3/25/9 1/26/9
|
||||||
|
f 13/22/10 8/7/10 6/9/10
|
||||||
|
f 6/27/11 16/19/11 13/20/11
|
||||||
|
f 10/28/12 15/6/12 11/23/12
|
||||||
|
f 16/3/13 10/29/13 12/24/13
|
||||||
|
f 19/30/14 18/31/14 20/32/14
|
||||||
|
f 5/1/13 19/33/13 7/34/13
|
||||||
|
f 6/27/7 17/35/7 5/36/7
|
||||||
|
f 7/37/12 20/38/12 8/5/12
|
||||||
|
f 21/39/15 24/40/15 22/41/15
|
||||||
|
f 2/18/16 21/42/16 22/43/16
|
||||||
|
f 2/10/17 24/44/17 4/45/17
|
||||||
|
f 3/25/18 21/46/18 1/26/18
|
||||||
|
f 5/1/1 7/34/1 14/2/1
|
||||||
|
f 14/4/2 7/37/2 8/5/2
|
||||||
|
f 8/7/3 20/47/3 18/8/3
|
||||||
|
f 2/10/4 4/45/4 11/11/4
|
||||||
|
f 4/13/19 24/48/19 23/14/19
|
||||||
|
f 9/16/6 12/49/6 1/17/6
|
||||||
|
f 16/19/7 12/49/7 9/16/7
|
||||||
|
f 9/12/3 11/11/3 15/21/3
|
||||||
|
f 3/15/8 10/28/8 11/23/8
|
||||||
|
f 12/24/9 10/29/9 3/25/9
|
||||||
|
f 13/22/10 15/21/10 8/7/10
|
||||||
|
f 6/27/11 5/36/11 16/19/11
|
||||||
|
f 10/28/12 14/4/12 15/6/12
|
||||||
|
f 16/3/13 14/2/13 10/29/13
|
||||||
|
f 19/30/14 17/50/14 18/31/14
|
||||||
|
f 5/1/13 17/51/13 19/33/13
|
||||||
|
f 6/27/7 18/52/7 17/35/7
|
||||||
|
f 7/37/12 19/53/12 20/38/12
|
||||||
|
f 21/39/15 23/54/15 24/40/15
|
||||||
|
f 2/18/20 1/17/20 21/42/20
|
||||||
|
f 2/10/17 22/55/17 24/44/17
|
||||||
|
f 3/25/18 23/56/18 21/46/18
|
Binary file not shown.
After Width: | Height: | Size: 5.3 KiB |
Loading…
Reference in New Issue