From 0a84a4307046b0d2e841f3fafb6fd494f99204be Mon Sep 17 00:00:00 2001 From: Joshua Sigona Date: Sun, 14 Nov 2021 22:39:40 +0900 Subject: [PATCH] Create plant model. --- models/auvBG.png | Bin 0 -> 738 bytes models/plant.mtl | 20 +++++++++++ models/plant.obj | 73 ++++++++++++++++++++++++++++++++++++++ models/plant.wings | Bin 0 -> 2395 bytes models/plant.wings~ | Bin 0 -> 2357 bytes src/sig/SigRenderer.java | 31 +++++++++++++--- src/sig/models/Plant.java | 21 +++++++++++ 7 files changed, 141 insertions(+), 4 deletions(-) create mode 100644 models/auvBG.png create mode 100644 models/plant.mtl create mode 100644 models/plant.obj create mode 100644 models/plant.wings create mode 100644 models/plant.wings~ create mode 100644 src/sig/models/Plant.java diff --git a/models/auvBG.png b/models/auvBG.png new file mode 100644 index 0000000000000000000000000000000000000000..456e3d6b00d5a9fe4caa433970299c9b1335d984 GIT binary patch literal 738 zcmeAS@N?(olHy`uVBq!ia0vp^4Is?H1|$#LC7uRSEX7WqAsj$Z!;#X#z`!)q)5S5Q zV$Rz;wqDMTA`TBVGId#IKVaG-suR3}!TbSNPL9gl)*Ias-QSjN*>Z-7#q+s;;^G?} zFLO#65AA(mamM@H&s!_bA4q&~*F1mPw5pBQZ(c6{^7HH$lRtl(=bnBewD99+jXnPk z-;Mt9TfI7Yy?n&K!~d7CCNUJSF{HzZ>*wnpy!vMG=g;4#pYQ*Z{A(6-o8SJw#F63| zJ=zR&7!ODy5iwTmH}1sg?>g`^N4sWT?T)JWFMIa9cAMP$;rINvHf{I!f0H>T%5aY1 z0S^+PH) zl35V)a^H{c#oLNI))lih7&BNfBN4Cv$SnA_@5h-v^C!>PEB=rR$%|ksuK%=j$X@$g zVCkmMk}-@ZE(ALG*Uit567x5HKdQg$O$}Q(s?o*_JLQ`DoUB{|A`P`BT%7!?&@hR_5OF z>G#;ve=D-}_Oq|3wQIx-_0N_L%f8hXy#6b&b|;3-rFDE4qTYTN+Vov13o}%T`6jIR uTUYn`F9&9bpJNo-dfz+aEJjejW6$%NBv@y;Q6HFS89ZJ6T-G@yGywotdN^wU literal 0 HcmV?d00001 diff --git a/models/plant.mtl b/models/plant.mtl new file mode 100644 index 0000000..082f084 --- /dev/null +++ b/models/plant.mtl @@ -0,0 +1,20 @@ +# Exported from Wings 3D 2.2.6.1 +newmtl Cube2_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 auvBG.png + +newmtl default +Ns 19.999999999999996 +d 1.0 +illum 2 +Kd 0.7898538076923077 0.8133333333333334 0.6940444444444445 +Ka 0.0 0.0 0.0 +Ks 0.1689853807692308 0.17133333333333334 0.15940444444444446 +Ke 0.0 0.0 0.0 + diff --git a/models/plant.obj b/models/plant.obj new file mode 100644 index 0000000..900d28e --- /dev/null +++ b/models/plant.obj @@ -0,0 +1,73 @@ +# Exported from Wings 3D 2.2.6.1 +mtllib plant.mtl +o Cube2 +#28 vertices, 32 faces +v -3.2421582e-3 -1.5355904e-2 4.4110059e-3 +v 0.98670734 -1.5355904e-2 0.99436050 +v -3.2421582e-3 0.98464410 4.4110059e-3 +v 0.98670734 0.98464410 0.99436050 +v -3.2421582e-3 -1.5355904e-2 4.4110059e-3 +v 0.98670734 -1.5355904e-2 0.99436050 +v -3.2421582e-3 0.98464410 4.4110059e-3 +v 0.98670734 0.98464410 0.99436050 +v 0.49173259 0.48464410 0.49938575 +v 0.49173259 0.48464410 0.49938575 +v 0.49173259 -1.5355904e-2 0.49938575 +v 0.49173259 0.98464410 0.49938575 +v 0.49173259 -1.5355904e-2 0.49938575 +v 0.49173259 0.98464410 0.49938575 +v 0.98670734 -1.5355904e-2 4.4110059e-3 +v -3.2421582e-3 -1.5355904e-2 0.99436050 +v 0.98670734 0.98464410 4.4110059e-3 +v -3.2421582e-3 0.98464410 0.99436050 +v 0.98670734 -1.5355904e-2 4.4110059e-3 +v -3.2421582e-3 -1.5355904e-2 0.99436050 +v 0.98670734 0.98464410 4.4110059e-3 +v -3.2421582e-3 0.98464410 0.99436050 +v 0.49173259 0.48464410 0.49938575 +v 0.49173259 0.48464410 0.49938575 +v 0.49173259 -1.5355904e-2 0.49938575 +v 0.49173259 0.98464410 0.49938575 +v 0.49173259 -1.5355904e-2 0.49938575 +v 0.49173259 0.98464410 0.49938575 +vt 0.0000000e+0 -1.1102230e-16 +vt 0.0000000e+0 2.2204460e-16 +vt 2.2204460e-16 1.00000000 +vt 2.2204460e-16 1.00000000 +vt 0.50000000 0.0000000e+0 +vt 0.50000000 2.2204460e-16 +vt 0.50000000 0.50000000 +vt 0.50000000 0.50000000 +vt 0.50000000 1.00000000 +vt 0.50000000 1.00000000 +vt 1.00000000 1.1102230e-16 +vt 1.00000000 -1.1102230e-16 +vt 1.00000000 1.00000000 +vt 1.00000000 1.00000000 +g Cube2_Cube2_auv +usemtl Cube2_auv +s 1 +f 1/1/ 9/7/ 3/3/ +f 3/3/ 9/7/ 14/10/ +f 4/13/ 9/7/ 2/12/ +f 4/13/ 14/10/ 9/7/ +f 5/11/ 10/8/ 11/6/ +f 6/2/ 10/8/ 8/4/ +f 6/2/ 11/6/ 10/8/ +f 7/14/ 10/8/ 5/11/ +f 9/7/ 13/5/ 2/12/ +f 10/8/ 12/9/ 8/4/ +f 12/9/ 10/8/ 7/14/ +f 13/5/ 9/7/ 1/1/ +f 15/1/ 23/7/ 17/3/ +f 17/3/ 23/7/ 28/10/ +f 18/13/ 23/7/ 16/12/ +f 18/13/ 28/10/ 23/7/ +f 19/11/ 24/8/ 25/6/ +f 20/2/ 24/8/ 22/4/ +f 20/2/ 25/6/ 24/8/ +f 21/14/ 24/8/ 19/11/ +f 23/7/ 27/5/ 16/12/ +f 24/8/ 26/9/ 22/4/ +f 26/9/ 24/8/ 21/14/ +f 27/5/ 23/7/ 15/1/ \ No newline at end of file diff --git a/models/plant.wings b/models/plant.wings new file mode 100644 index 0000000000000000000000000000000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7Il$Xr<7hbc((75SKF6iGr>!N8JP+jytZ;kveV6y~jNp_t{}@xTP9Kq#f6`8}2J; zAF-(Il@B3Qr>cARWOZv*v;1UV^NhhVXw3mkxR$kx>5{$wn~>Ad>T**k%tC>h5?^Q0pV_~`>OsHNzmDz_t$ z>V$R@&$Uqsw1fd-9hk*l_1emth_;Iwhbs-!xe*@ZJY>WXv4 zYHQ+l-Ae00Z^|?XHwVFg!Q7|07e-Bg3^s-{UF;!(4lgEEzzN?L%uFL%{uvZ8C&@mF zksiP02iZZ`>2C+pR=jLYz>Qh< zoOwnYjvXN;p_r=aWc5LFZPd5lf>D2lN7bqH+J$pJjvc4jANgka8%&8k{Wc6|wz-d^;ld zT(`lwjmmc7CNy#ytB~qz-$S2=z_+wIF5F&KyXsz*v+q*TFMW1{FZD>X(MwN`F9f%q z^4~xETHb7=BA-s^23O6b11e6}f8&i%r_6m;Q$Wkl0LV|as=~KFh1@!nj!alTT@^?q z!eWtMy?j;0@9Epnb-WhX^`BE&qmaF}EV2H;Ir0zG|4#m-@l(k1 zmRyq7i&o{EWF*RZi64rBdQ`cXyUaFtRUaSPe|_0pX5lBB0!Y_`xK(y(mBr=NkMj~F zq7&=eYXem9N`1U6kid&ekP0ZEmGVk}G;AS}IwqVVl7FP&8=-G(z&rxfpCqp zW+D;19_1}Co;b2z>bu&>#ozr~I}vTVBJe>Izq6`PM6_)4-@L7Tc8V1)@n`@4N6RFY N`0gMnK--x(_8)fQJ0<`C literal 0 HcmV?d00001 diff --git a/models/plant.wings~ b/models/plant.wings~ new file mode 100644 index 0000000000000000000000000000000000000000..4667a4f1e6a1419bdd911dabbe21526d4c851703 GIT binary patch literal 2357 zcmZ{gdpr|*AIFtbNJ(?>#F%S}<90e)qOFwVHXXOz+ETgCUC6BEpyaTW9As{}mRnNh zK5|)%oDl877PCfVj@j7#@jQR@I!|?8ug@R9&+GSjeLwH-S6lO1)hpTH39%UV&OPu$lX6y#`yiU%NH*>U#2i&Qc3$#|X|23$xvv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&qr6VF<63WFK z=xbr{Br5Cv1fbSG&TkeCJEEJKA|W5xR{sQ8Q-PA0!pEUmCM-#GH)Tg8Nw~7a}xRg-HP#57&uFXib34K`g49~7GGki z6v7Eh{}6W){a?+OMpO-TSQG}u^lTzH`0v#GuT?xZ8LlMm6bbq_i{RedJyWSH->~Unj&8+y5yt-lUn&-iOzL5p a*n?CgdL8Wj#fl@AtHzhal11aE5B>+m)grh6 literal 0 HcmV?d00001 diff --git a/src/sig/SigRenderer.java b/src/sig/SigRenderer.java index 41b6ccb..a437067 100644 --- a/src/sig/SigRenderer.java +++ b/src/sig/SigRenderer.java @@ -2,6 +2,7 @@ package sig; import javax.imageio.ImageIO; import javax.swing.JFrame; +import sig.models.Plant; import sig.models.Staircase; import java.awt.event.MouseEvent; @@ -28,9 +29,12 @@ import java.awt.Cursor; import java.awt.GraphicsDevice; import java.awt.GraphicsEnvironment; import java.awt.event.MouseWheelListener; +import java.awt.event.WindowEvent; +import java.awt.event.WindowFocusListener; -public class SigRenderer implements KeyListener,MouseListener,MouseMotionListener,MouseWheelListener{ +public class SigRenderer implements WindowFocusListener,KeyListener,MouseListener,MouseMotionListener,MouseWheelListener{ + public static boolean windowActive=true; public static boolean WIREFRAME = false; public static boolean PROFILING = false; public static boolean FLYING_MODE = false; @@ -99,6 +103,7 @@ public class SigRenderer implements KeyListener,MouseListener,MouseMotionListene public static MouseHandler tempAnswer = null; public static Panel panel; + public static JFrame frame; public static Cursor invisibleCursor; @@ -191,6 +196,7 @@ public class SigRenderer implements KeyListener,MouseListener,MouseMotionListene } public void runGameLoop() { + if (!FLYING_MODE) { move(); if (SigRenderer.currentStaircase!=null) { @@ -255,7 +261,8 @@ public class SigRenderer implements KeyListener,MouseListener,MouseMotionListene roll+=MOVESPEED; } if (wHeld||sHeld) { - Vector forward = Vector.multiply(vLookDir,MOVESPEED); + Vector newDir = Vector.normalize(new Vector(vLookDir.x,0,vLookDir.z)); + Vector forward = Vector.multiply(newDir,MOVESPEED); if (!FLYING_MODE) { forward.y=0; } @@ -389,6 +396,7 @@ public class SigRenderer implements KeyListener,MouseListener,MouseMotionListene } SigRenderer(JFrame f) { + SigRenderer.frame=f; //cube = new Mesh(OBJReader.ReadOBJFile("teapot.obj",false)); Random r = new Random(438107); for (int x=0;x<64;x++) { @@ -420,7 +428,10 @@ public class SigRenderer implements KeyListener,MouseListener,MouseMotionListene }*/ } } - addBlock(new Vector(31,1,31),Staircase.class,BlockType.ICE,FacingDirection.NORTH); + addBlock(new Vector(31,1,31),Plant.class,BlockType.SUGARCANE,FacingDirection.NORTH); + addBlock(new Vector(31,2,31),Plant.class,BlockType.SUGARCANE,FacingDirection.NORTH); + addBlock(new Vector(31,3,31),Plant.class,BlockType.SUGARCANE,FacingDirection.NORTH); + addBlock(new Vector(31,4,31),Plant.class,BlockType.SUGARCANE,FacingDirection.NORTH); /*addBlock(new Vector(31,2,32),Staircase.class,BlockType.PLANKS,FacingDirection.EAST); addBlock(new Vector(31,3,33),Staircase.class,BlockType.PLANKS,FacingDirection.WEST); addBlock(new Vector(31,4,34),Staircase.class,BlockType.PLANKS,FacingDirection.SOUTH); @@ -559,7 +570,9 @@ public class SigRenderer implements KeyListener,MouseListener,MouseMotionListene int diffY=-Math.max(-100,Math.min(100,e.getYOnScreen()-middle.y)); yaw+=diffX*TURNSPEED*1.5; pitch=(float)Math.max(-Math.PI/2+0.01f,Math.min(Math.PI/2-0.01f,pitch+diffY*TURNSPEED)); - myRobot.mouseMove(middle.x,middle.y); + if (windowActive) { + myRobot.mouseMove(middle.x,middle.y); + } } @Override @@ -659,4 +672,14 @@ public class SigRenderer implements KeyListener,MouseListener,MouseMotionListene selectedMode+=Math.signum(e.getWheelRotation()); System.out.println("Mode "+selectedMode+"."); } + + @Override + public void windowGainedFocus(WindowEvent e) { + windowActive=true; + } + + @Override + public void windowLostFocus(WindowEvent e) { + windowActive=false; + } } diff --git a/src/sig/models/Plant.java b/src/sig/models/Plant.java new file mode 100644 index 0000000..a52e3ac --- /dev/null +++ b/src/sig/models/Plant.java @@ -0,0 +1,21 @@ +package sig.models; + +import sig.Block; +import sig.BlockType; +import sig.Mesh; +import sig.Triangle; +import sig.utils.OBJReader; + +public class Plant extends Mesh{ + public Plant(BlockType type) { + super(type); + this.type=type; + this.triangles=OBJReader.ReadOBJFile("models/plant.obj",true); + for (Triangle t : triangles) { + t.tex=type.getTexture(BlockType.FRONT); + } + } + public boolean handleCollision(Block b,float x,float z) { + return true; + } +}