Implement staircase model
This commit is contained in:
parent
21e2e19e67
commit
81c8ece1c3
BIN
models/#staircase.wings#
Normal file
BIN
models/#staircase.wings#
Normal file
Binary file not shown.
BIN
models/Cube1_auv.png
Normal file
BIN
models/Cube1_auv.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 868 B |
@ -1,85 +1,47 @@
|
||||
# Exported from Wings 3D 2.2.6.1
|
||||
mtllib staircase.mtl
|
||||
o Cube1
|
||||
#14 vertices, 24 faces
|
||||
v -1.00000000 0.0000000e+0 -1.00000000
|
||||
v -1.00000000 0.0000000e+0 1.00000000
|
||||
v -1.00000000 1.00000000 -1.00000000
|
||||
v -1.00000000 1.00000000 1.00000000
|
||||
v 1.00000000 0.0000000e+0 -1.00000000
|
||||
v 1.00000000 0.0000000e+0 1.00000000
|
||||
v 1.00000000 1.00000000 -1.00000000
|
||||
v 1.00000000 1.00000000 1.00000000
|
||||
v -1.00000000 1.00000000 0.0000000e+0
|
||||
v 1.00000000 1.00000000 0.0000000e+0
|
||||
v -1.00000000 2.00000000 -1.00000000
|
||||
v -1.00000000 2.00000000 0.0000000e+0
|
||||
v 1.00000000 2.00000000 0.0000000e+0
|
||||
v 1.00000000 2.00000000 -1.00000000
|
||||
vt -3.3222222e-3 -3.8777778e-3
|
||||
vt -3.3222222e-3 0.49612222
|
||||
vt -2.1666667e-3 3.5555556e-3
|
||||
vt -2.1666667e-3 0.50355556
|
||||
vt -1.5888889e-3 6.4011111e-2
|
||||
vt -1.5888889e-3 0.56401111
|
||||
vt -1.5888889e-3 1.06401111
|
||||
vt 1.3530843e-16 3.2959746e-17
|
||||
vt 1.3530843e-16 0.50000000
|
||||
vt 5.7777778e-4 3.3888889e-3
|
||||
vt 5.7777778e-4 0.50338889
|
||||
vt 2.0539683e-3 -2.5777778e-3
|
||||
vt 2.0539683e-3 0.49665556
|
||||
vt 2.0539683e-3 0.99588889
|
||||
vt 2.2111111e-3 0.49387778
|
||||
vt 2.2111111e-3 0.99387778
|
||||
vt 5.5222222e-3 5.0888889e-3
|
||||
vt 5.5222222e-3 0.99548889
|
||||
vt 0.50000000 0.50000000
|
||||
vt 0.50000000 1.00000000
|
||||
vt 0.50128730 0.49665556
|
||||
vt 0.50128730 0.99588889
|
||||
vt 0.99592222 5.0888889e-3
|
||||
vt 0.99592222 0.99548889
|
||||
vt 0.99667778 -3.8777778e-3
|
||||
vt 0.99667778 0.49612222
|
||||
vt 0.99783333 3.5555556e-3
|
||||
vt 0.99783333 0.50355556
|
||||
vt 0.99841111 6.4011111e-2
|
||||
vt 0.99841111 0.56401111
|
||||
vt 0.99841111 1.06401111
|
||||
vt 1.00000000 3.2959746e-17
|
||||
vt 1.00000000 0.50000000
|
||||
vt 1.00000000 1.00000000
|
||||
vt 1.00052063 -2.5777778e-3
|
||||
vt 1.00052063 0.49665556
|
||||
vt 1.00057778 3.3888889e-3
|
||||
vt 1.00057778 0.50338889
|
||||
vt 1.00221111 0.49387778
|
||||
vt 1.00221111 0.99387778
|
||||
g Cube1_Cube1_auv
|
||||
usemtl Cube1_auv
|
||||
s 1
|
||||
f 1/17/ 5/23/ 2/18/
|
||||
f 1/12/ 9/21/ 3/13/
|
||||
f 2/18/ 5/23/ 6/24/
|
||||
f 2/15/ 6/39/ 4/16/
|
||||
f 2/35/ 9/21/ 1/12/
|
||||
f 3/6/ 5/31/ 1/7/
|
||||
f 3/6/ 14/29/ 7/30/
|
||||
f 4/16/ 6/39/ 8/40/
|
||||
f 4/36/ 9/21/ 2/35/
|
||||
f 4/10/ 10/38/ 9/11/
|
||||
f 5/32/ 10/19/ 6/8/
|
||||
f 6/8/ 10/19/ 8/9/
|
||||
f 7/30/ 5/31/ 3/6/
|
||||
f 7/33/ 10/19/ 5/32/
|
||||
f 7/33/ 14/34/ 10/19/
|
||||
f 8/37/ 10/38/ 4/10/
|
||||
f 9/21/ 12/22/ 3/13/
|
||||
f 10/25/ 12/2/ 9/1/
|
||||
f 11/14/ 3/13/ 12/22/
|
||||
f 11/5/ 14/29/ 3/6/
|
||||
f 12/2/ 10/25/ 13/26/
|
||||
f 12/3/ 14/28/ 11/4/
|
||||
f 13/20/ 10/19/ 14/34/
|
||||
f 13/27/ 14/28/ 12/3/
|
||||
#14 vertices, 20 faces
|
||||
v 1 0.0000000e+0 1 #1
|
||||
v 1 0.0000000e+0 0 #2
|
||||
v 1 0.50000000 1 #3
|
||||
v 1 0.50000000 0 #4
|
||||
v 0 0.0000000e+0 1 #5
|
||||
v 0 0.0000000e+0 0 #6
|
||||
v 0 0.50000000 1 #7
|
||||
v 0 0.50000000 0 #8
|
||||
v 1 0.50000000 0.5 #9
|
||||
v 0 0.50000000 0.5 #10
|
||||
v 1 1.00000000 1 #11
|
||||
v 1 1.00000000 0.5 #12
|
||||
v 0 1.00000000 0.5 #13
|
||||
v 0 1.00000000 1 #14
|
||||
vt 0 0 #1
|
||||
vt 0 0.5 #2
|
||||
vt 1 0.5 #3
|
||||
vt 1 0 #4
|
||||
vt 0 1 #5
|
||||
vt 0.5 1 #6
|
||||
vt 0.5 0.5 #7
|
||||
vt 1 1 #8
|
||||
vt 1 0.5 #9
|
||||
f 2/1 8/3 4/2 #1 FRONT FRONT
|
||||
f 6/4 8/3 2/1 #2
|
||||
f 13/8 12/5 9/2 #3 FRONT TOP
|
||||
f 10/9 13/8 9/2 #4
|
||||
f 14/3 11/2 12/1 #5 TOP TOP
|
||||
f 13/4 14/3 12/1 #6
|
||||
f 10/3 9/2 4/1 #7 TOP FRONT
|
||||
f 8/4 10/3 4/1 #8
|
||||
f 11/8 14/5 5/1 #9 BACK
|
||||
f 1/4 11/8 5/1 #10
|
||||
f 6/8 2/5 1/1 #11 BOTTOM
|
||||
f 5/4 6/8 1/1 #12
|
||||
f 10/7 14/8 13/6 #13 RIGHT TOP
|
||||
f 10/7 7/9 14/8 #14
|
||||
f 7/3 8/2 6/1 #15 RIGHT BOTTOM
|
||||
f 5/4 7/3 6/1 #16
|
||||
f 3/2 12/6 11/5 #17 LEFT TOP
|
||||
f 9/7 12/6 3/2 #18
|
||||
f 1/1 4/3 3/2 #19 LEFT BOTTOM
|
||||
f 1/1 2/4 4/3 #20
|
Binary file not shown.
BIN
models/staircase.wings~
Normal file
BIN
models/staircase.wings~
Normal file
Binary file not shown.
11
models/staircase_original.mtl
Normal file
11
models/staircase_original.mtl
Normal file
@ -0,0 +1,11 @@
|
||||
# Exported from Wings 3D 2.2.6.1
|
||||
newmtl Cube1_auv
|
||||
Ns 19.999999999999996
|
||||
d 1.0
|
||||
illum 2
|
||||
Kd 1.0 1.0 1.0
|
||||
Ka 0.0 0.0 0.0
|
||||
Ks 0.19 0.19 0.19
|
||||
Ke 0.0 0.0 0.0
|
||||
map_Kd Cube1_auv.png
|
||||
|
81
models/staircase_original.obj
Normal file
81
models/staircase_original.obj
Normal file
@ -0,0 +1,81 @@
|
||||
# Exported from Wings 3D 2.2.6.1
|
||||
mtllib staircase_original.mtl
|
||||
o Cube1
|
||||
#14 vertices, 20 faces
|
||||
v 0.50000000 0.0000000e+0 0.48571429
|
||||
v 0.50000000 0.0000000e+0 -0.51428571
|
||||
v 0.50000000 0.50000000 0.48571429
|
||||
v 0.50000000 0.50000000 -0.51428571
|
||||
v -0.50000000 0.0000000e+0 0.48571429
|
||||
v -0.50000000 0.0000000e+0 -0.51428571
|
||||
v -0.50000000 0.50000000 0.48571429
|
||||
v -0.50000000 0.50000000 -0.51428571
|
||||
v 0.50000000 0.50000000 -1.4285714e-2
|
||||
v -0.50000000 0.50000000 -1.4285714e-2
|
||||
v 0.50000000 1.00000000 0.48571429
|
||||
v 0.50000000 1.00000000 -1.4285714e-2
|
||||
v -0.50000000 1.00000000 -1.4285714e-2
|
||||
v -0.50000000 1.00000000 0.48571429
|
||||
vt -3.3222222e-3 -3.8777778e-3
|
||||
vt -3.3222222e-3 0.49612222
|
||||
vt -2.1666667e-3 3.5555556e-3
|
||||
vt -2.1666667e-3 0.50355556
|
||||
vt -1.5888889e-3 6.4011111e-2
|
||||
vt -1.5888889e-3 0.56401111
|
||||
vt -1.5888889e-3 1.06401111
|
||||
vt 1.3530843e-16 3.2959746e-17
|
||||
vt 1.3530843e-16 0.50000000
|
||||
vt 5.7777778e-4 3.3888889e-3
|
||||
vt 5.7777778e-4 0.50338889
|
||||
vt 2.0539683e-3 -2.5777778e-3
|
||||
vt 2.0539683e-3 0.49665556
|
||||
vt 2.0539683e-3 0.99588889
|
||||
vt 2.2111111e-3 0.49387778
|
||||
vt 2.2111111e-3 0.99387778
|
||||
vt 5.5222222e-3 5.0888889e-3
|
||||
vt 5.5222222e-3 0.99548889
|
||||
vt 0.50000000 0.50000000
|
||||
vt 0.50000000 1.00000000
|
||||
vt 0.50128730 0.49665556
|
||||
vt 0.50128730 0.99588889
|
||||
vt 0.99592222 5.0888889e-3
|
||||
vt 0.99592222 0.99548889
|
||||
vt 0.99667778 -3.8777778e-3
|
||||
vt 0.99667778 0.49612222
|
||||
vt 0.99783333 3.5555556e-3
|
||||
vt 0.99783333 0.50355556
|
||||
vt 0.99841111 6.4011111e-2
|
||||
vt 0.99841111 0.56401111
|
||||
vt 0.99841111 1.06401111
|
||||
vt 1.00000000 3.2959746e-17
|
||||
vt 1.00000000 0.50000000
|
||||
vt 1.00000000 1.00000000
|
||||
vt 1.00052063 -2.5777778e-3
|
||||
vt 1.00052063 0.49665556
|
||||
vt 1.00057778 3.3888889e-3
|
||||
vt 1.00057778 0.50338889
|
||||
vt 1.00221111 0.49387778
|
||||
vt 1.00221111 0.99387778
|
||||
g Cube1_Cube1_auv
|
||||
usemtl Cube1_auv
|
||||
s 1
|
||||
f 1/7/ 3/6/ 11/5/ 5/31/
|
||||
f 1/17/ 6/24/ 2/18/
|
||||
f 2/35/ 4/36/ 1/12/
|
||||
f 2/15/ 8/40/ 4/16/
|
||||
f 3/13/ 1/12/ 4/36/ 9/21/
|
||||
f 4/10/ 10/38/ 9/11/
|
||||
f 5/23/ 6/24/ 1/17/
|
||||
f 5/32/ 7/33/ 6/8/
|
||||
f 6/8/ 7/33/ 10/19/ 8/9/
|
||||
f 6/39/ 8/40/ 2/15/
|
||||
f 7/33/ 14/34/ 10/19/
|
||||
f 8/37/ 10/38/ 4/10/
|
||||
f 9/21/ 12/22/ 3/13/
|
||||
f 10/25/ 13/26/ 9/1/
|
||||
f 11/14/ 3/13/ 12/22/
|
||||
f 12/2/ 9/1/ 13/26/
|
||||
f 12/3/ 14/28/ 11/4/
|
||||
f 13/20/ 10/19/ 14/34/
|
||||
f 13/27/ 14/28/ 12/3/
|
||||
f 14/29/ 7/30/ 5/31/ 11/5/
|
@ -1,5 +1,6 @@
|
||||
package sig;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@ -11,23 +12,25 @@ public class Block {
|
||||
final static int NORTH = 2;
|
||||
final static int EAST = 3;
|
||||
Vector pos;
|
||||
Mesh block;
|
||||
FaceList neighbors;
|
||||
public Mesh block;
|
||||
public FaceList neighbors;
|
||||
private FacingDirection facingDir;
|
||||
Block(Vector pos,Mesh block,FacingDirection facingDir) {
|
||||
this.neighbors=new FaceList();
|
||||
this.pos=pos;
|
||||
List<Triangle> newTris = new ArrayList<>();
|
||||
for (Triangle t : block.triangles) {
|
||||
Triangle newT = (Triangle)t.clone();
|
||||
newT.b=this;
|
||||
newTris.add(newT);
|
||||
try {
|
||||
this.block=block.getClass().getConstructor(BlockType.class).newInstance(block.type);
|
||||
for (Triangle t : this.block.triangles) {
|
||||
t.b = this;
|
||||
}
|
||||
} catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
this.block=new Mesh(newTris);
|
||||
this.facingDir=facingDir;
|
||||
}
|
||||
private void updateFacingDirection(FacingDirection targetDirection) {
|
||||
while (facingDir!=targetDirection) {
|
||||
if (block instanceof Cube) {
|
||||
Texture t1 = block.triangles.get(Texture.SOUTH).tex;
|
||||
Texture t2 = block.triangles.get(Texture.SOUTH+1).tex;
|
||||
block.triangles.get(Texture.SOUTH).tex=block.triangles.get(Texture.EAST).tex;
|
||||
@ -47,6 +50,7 @@ public class Block {
|
||||
vec.v=newOrder.v;
|
||||
}
|
||||
}
|
||||
}
|
||||
facingDir=facingDir.clockwise();
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,15 @@
|
||||
package sig;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import sig.utils.OBJReader;
|
||||
|
||||
public class Cube extends Mesh{
|
||||
|
||||
Cube(BlockType type) {
|
||||
public Cube(BlockType type) {
|
||||
super(type);
|
||||
this.type = type;
|
||||
this.triangles=OBJReader.ReadOBJFile("cube.obj",true);
|
||||
triangles.get(0).tex=type.getTexture(BlockType.FRONT);
|
||||
triangles.get(1).tex=type.getTexture(BlockType.FRONT);
|
||||
@ -27,4 +31,32 @@ public class Cube extends Mesh{
|
||||
triangles.get(10).dir=triangles.get(11).dir=BlockType.BOTTOM;
|
||||
}
|
||||
|
||||
protected List<Triangle> prepareRender(Block b) {
|
||||
List<Triangle> tris = new ArrayList<Triangle>();
|
||||
if (!b.neighbors.UP) {
|
||||
tris.add(b.block.triangles.get(8));
|
||||
tris.add(b.block.triangles.get(9));
|
||||
}
|
||||
if (!b.neighbors.DOWN) {
|
||||
tris.add(b.block.triangles.get(10));
|
||||
tris.add(b.block.triangles.get(11));
|
||||
}
|
||||
if (!b.neighbors.LEFT) {
|
||||
tris.add(b.block.triangles.get(6));
|
||||
tris.add(b.block.triangles.get(7));
|
||||
}
|
||||
if (!b.neighbors.RIGHT) {
|
||||
tris.add(b.block.triangles.get(2));
|
||||
tris.add(b.block.triangles.get(3));
|
||||
}
|
||||
if (!b.neighbors.FORWARD) {
|
||||
tris.add(b.block.triangles.get(4));
|
||||
tris.add(b.block.triangles.get(5));
|
||||
}
|
||||
if (!b.neighbors.BACKWARD) {
|
||||
tris.add(b.block.triangles.get(0));
|
||||
tris.add(b.block.triangles.get(1));
|
||||
}
|
||||
return tris;
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
package sig;
|
||||
|
||||
public class FaceList {
|
||||
boolean UP=false; //+Y
|
||||
boolean DOWN=false;
|
||||
boolean FORWARD=false; //+Z
|
||||
boolean RIGHT=false; //+X
|
||||
boolean LEFT=false;
|
||||
boolean BACKWARD=false;
|
||||
public boolean UP=false; //+Y
|
||||
public boolean DOWN=false;
|
||||
public boolean FORWARD=false; //+Z
|
||||
public boolean RIGHT=false; //+X
|
||||
public boolean LEFT=false;
|
||||
public boolean BACKWARD=false;
|
||||
}
|
||||
|
@ -7,7 +7,8 @@ import java.util.List;
|
||||
import sig.utils.OBJReader;
|
||||
|
||||
public class Mesh {
|
||||
List<Triangle> triangles = new ArrayList<>();
|
||||
public List<Triangle> triangles = new ArrayList<>();
|
||||
protected BlockType type;
|
||||
Mesh(List<Triangle> tris) {
|
||||
this.triangles=tris;
|
||||
}
|
||||
@ -21,6 +22,9 @@ public class Mesh {
|
||||
t.tex=te;
|
||||
}
|
||||
}
|
||||
Mesh(BlockType type) {;
|
||||
protected Mesh(BlockType type) {;
|
||||
}
|
||||
protected List<Triangle> prepareRender(Block b) {
|
||||
return b.block.triangles;
|
||||
}
|
||||
}
|
||||
|
@ -134,29 +134,8 @@ public class Panel extends JPanel implements Runnable {
|
||||
ConcurrentLinkedQueue<Triangle> newTris = new ConcurrentLinkedQueue<>();
|
||||
for (String key : SigRenderer.blockGrid.keySet()) {
|
||||
Block b = SigRenderer.blockGrid.get(key);
|
||||
if (!b.neighbors.UP) {
|
||||
prepareTriForRender(matWorld2, matView, b.block.triangles.get(8), newTris);
|
||||
prepareTriForRender(matWorld2, matView, b.block.triangles.get(9), newTris);
|
||||
}
|
||||
if (!b.neighbors.DOWN) {
|
||||
prepareTriForRender(matWorld2, matView, b.block.triangles.get(10), newTris);
|
||||
prepareTriForRender(matWorld2, matView, b.block.triangles.get(11), newTris);
|
||||
}
|
||||
if (!b.neighbors.LEFT) {
|
||||
prepareTriForRender(matWorld2, matView, b.block.triangles.get(6), newTris);
|
||||
prepareTriForRender(matWorld2, matView, b.block.triangles.get(7), newTris);
|
||||
}
|
||||
if (!b.neighbors.RIGHT) {
|
||||
prepareTriForRender(matWorld2, matView, b.block.triangles.get(2), newTris);
|
||||
prepareTriForRender(matWorld2, matView, b.block.triangles.get(3), newTris);
|
||||
}
|
||||
if (!b.neighbors.FORWARD) {
|
||||
prepareTriForRender(matWorld2, matView, b.block.triangles.get(4), newTris);
|
||||
prepareTriForRender(matWorld2, matView, b.block.triangles.get(5), newTris);
|
||||
}
|
||||
if (!b.neighbors.BACKWARD) {
|
||||
prepareTriForRender(matWorld2, matView, b.block.triangles.get(0), newTris);
|
||||
prepareTriForRender(matWorld2, matView, b.block.triangles.get(1), newTris);
|
||||
for (Triangle t : b.block.prepareRender(b)) {
|
||||
prepareTriForRender(matWorld2, matView, t, newTris);
|
||||
}
|
||||
}
|
||||
if (renderFirst) {
|
||||
|
@ -2,6 +2,8 @@ package sig;
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.swing.JFrame;
|
||||
|
||||
import sig.models.Staircase;
|
||||
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseListener;
|
||||
import java.awt.event.MouseMotionListener;
|
||||
@ -28,7 +30,7 @@ public class SigRenderer implements KeyListener,MouseListener,MouseMotionListene
|
||||
|
||||
public static boolean WIREFRAME = false;
|
||||
public static boolean PROFILING = false;
|
||||
public static boolean FLYING_MODE = false;
|
||||
public static boolean FLYING_MODE = true;
|
||||
public static int SCREEN_WIDTH=1280;
|
||||
public static int SCREEN_HEIGHT=720;
|
||||
public final static long TIMEPERTICK = 16666667l;
|
||||
@ -166,8 +168,8 @@ public class SigRenderer implements KeyListener,MouseListener,MouseMotionListene
|
||||
}
|
||||
|
||||
public void runGameLoop() {
|
||||
if (!FLYING_MODE) {
|
||||
move();
|
||||
|
||||
if (checkCollisionSquare(0,-gravity,0)) {
|
||||
fallSpd=Math.max(-maxCameraSpeed.y,fallSpd-gravity);
|
||||
friction(vCameraSpeed,0.004f); //Air friction.
|
||||
@ -198,6 +200,7 @@ public class SigRenderer implements KeyListener,MouseListener,MouseMotionListene
|
||||
jumpsAvailable=0;
|
||||
fallSpd=0.2f;
|
||||
}
|
||||
}
|
||||
|
||||
if (upHeld) {
|
||||
pitch+=TURNSPEED;
|
||||
@ -217,26 +220,34 @@ public class SigRenderer implements KeyListener,MouseListener,MouseMotionListene
|
||||
forward.y=0;
|
||||
}
|
||||
if (wLast&&wHeld) {
|
||||
if (FLYING_MODE) {
|
||||
vCamera = Vector.add(vCamera,forward);
|
||||
}
|
||||
addSpeed(forward);
|
||||
// move(MOVESPEED);
|
||||
}
|
||||
if (!wLast&&sHeld) {
|
||||
if (FLYING_MODE) {
|
||||
vCamera = Vector.subtract(vCamera,forward);
|
||||
}
|
||||
addSpeed(Vector.multiply(forward,-1));
|
||||
//move(MOVESPEED);
|
||||
}
|
||||
}
|
||||
if (aLast&&aHeld) {
|
||||
Vector leftStrafe = Vector.multiply(Matrix.MultiplyVector(Matrix.MakeRotationY((float)-Math.PI/2), vLookDir),MOVESPEED);
|
||||
if (!FLYING_MODE) {
|
||||
leftStrafe.y=0;
|
||||
if (FLYING_MODE) {
|
||||
vCamera = Vector.add(vCamera,leftStrafe);
|
||||
}
|
||||
addSpeed(leftStrafe);
|
||||
//move(MOVESPEED);
|
||||
}
|
||||
if (!aLast&&dHeld) {
|
||||
Vector rightStrafe = Vector.multiply(Matrix.MultiplyVector(Matrix.MakeRotationY((float)Math.PI/2), vLookDir),MOVESPEED);
|
||||
if (!FLYING_MODE) {
|
||||
rightStrafe.y=0;
|
||||
if (FLYING_MODE) {
|
||||
vCamera = Vector.add(vCamera,rightStrafe);
|
||||
}
|
||||
addSpeed(rightStrafe);
|
||||
//move(MOVESPEED);
|
||||
@ -275,7 +286,7 @@ public class SigRenderer implements KeyListener,MouseListener,MouseMotionListene
|
||||
}
|
||||
|
||||
public static void addBlock(Vector pos,BlockType type,FacingDirection facingDir) {
|
||||
Block b = new Block(pos,new Cube(type),FacingDirection.SOUTH);
|
||||
Block b = new Block(pos,new Staircase(type),FacingDirection.SOUTH);
|
||||
b.setFacingDirection(facingDir);
|
||||
blockGrid.put(pos.x+"_"+pos.y+"_"+pos.z,b);
|
||||
b.updateFaces();
|
||||
@ -308,10 +319,12 @@ public class SigRenderer implements KeyListener,MouseListener,MouseMotionListene
|
||||
Random r = new Random(438107);
|
||||
for (int x=0;x<64;x++) {
|
||||
for (int z=0;z<64;z++) {
|
||||
addBlock(new Vector(x,0,z),BlockType.GRASS,FacingDirection.SOUTH);
|
||||
for (int y=1;y<r.nextInt(5);y++) {
|
||||
addBlock(new Vector(x,y,z),BlockType.DIRT,FacingDirection.SOUTH);
|
||||
}
|
||||
addBlock(new Vector(x,0,z),BlockType.PLANKS,FacingDirection.SOUTH);
|
||||
//addBlock(new Vector(x,1,z),BlockType.JUNGLE_PLANK,FacingDirection.SOUTH);
|
||||
//addBlock(new Vector(x,2,z),BlockType.SPRUCE_PLANK,FacingDirection.SOUTH);
|
||||
/*for (int y=1;y<r.nextInt(5);y++) {
|
||||
addBlock(new Vector(x,y,z),BlockType.PLANKS,FacingDirection.SOUTH);
|
||||
}*/
|
||||
/*if (r.nextInt(2)<1) {
|
||||
switch (r.nextInt(7)) {
|
||||
case 1:{
|
||||
@ -334,6 +347,10 @@ public class SigRenderer implements KeyListener,MouseListener,MouseMotionListene
|
||||
}
|
||||
}
|
||||
|
||||
Block b = new Block(new Vector(31,3,31),new Staircase(BlockType.PLANKS),FacingDirection.SOUTH);
|
||||
b.setFacingDirection(FacingDirection.SOUTH);
|
||||
blockGrid.put("31.0_3.0_31.0",b);
|
||||
|
||||
for (int x=0;x<64;x++) {
|
||||
for (int y=1;y<5;y++) {
|
||||
/*
|
||||
|
58
src/sig/models/Staircase.java
Normal file
58
src/sig/models/Staircase.java
Normal file
@ -0,0 +1,58 @@
|
||||
package sig.models;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import sig.Block;
|
||||
import sig.BlockType;
|
||||
import sig.Mesh;
|
||||
import sig.Triangle;
|
||||
import sig.utils.OBJReader;
|
||||
|
||||
public class Staircase extends Mesh{
|
||||
public Staircase(BlockType type) {
|
||||
super(type);
|
||||
this.type = type;
|
||||
this.triangles=OBJReader.ReadOBJFile("models/staircase.obj",true);
|
||||
for (Triangle t : triangles) {
|
||||
t.tex=type.getTexture(BlockType.FRONT);
|
||||
}
|
||||
}
|
||||
|
||||
protected List<Triangle> prepareRender(Block b) {
|
||||
List<Triangle> tris = new ArrayList<Triangle>();
|
||||
if (!b.neighbors.UP) {
|
||||
}
|
||||
if (!b.neighbors.DOWN) {
|
||||
}
|
||||
if (!b.neighbors.LEFT) {
|
||||
tris.add(b.block.triangles.get(12));
|
||||
tris.add(b.block.triangles.get(13));
|
||||
tris.add(b.block.triangles.get(14));
|
||||
tris.add(b.block.triangles.get(15));
|
||||
}
|
||||
if (!b.neighbors.RIGHT) {
|
||||
tris.add(b.block.triangles.get(16));
|
||||
tris.add(b.block.triangles.get(17));
|
||||
tris.add(b.block.triangles.get(18));
|
||||
tris.add(b.block.triangles.get(19));
|
||||
}
|
||||
if (!b.neighbors.FORWARD) {
|
||||
}
|
||||
if (!b.neighbors.BACKWARD) {
|
||||
tris.add(b.block.triangles.get(0));
|
||||
tris.add(b.block.triangles.get(1));
|
||||
}
|
||||
tris.add(b.block.triangles.get(4));
|
||||
tris.add(b.block.triangles.get(5));
|
||||
tris.add(b.block.triangles.get(10));
|
||||
tris.add(b.block.triangles.get(11));
|
||||
tris.add(b.block.triangles.get(8));
|
||||
tris.add(b.block.triangles.get(9));
|
||||
tris.add(b.block.triangles.get(2));
|
||||
tris.add(b.block.triangles.get(3));
|
||||
tris.add(b.block.triangles.get(6));
|
||||
tris.add(b.block.triangles.get(7));
|
||||
return tris;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user