Implemented basic model viewing and attachment in game engine. Weapon swap test.

master
sigonasr2 6 years ago
parent 32b29e4434
commit f5e2a711ce
  1. 1
      Maud
  2. BIN
      SigDN/assets/Models/Ar_BigBow_Fire_00/Ar_BigBow_Fire_00.j3o
  3. 3
      SigDN/assets/Models/Ar_BigBow_Fire_00/Ar_BigBow_Fire_00.j3odata
  4. BIN
      SigDN/assets/Models/Ar_BigBow_Fire_00/ar_bigbow_ice.dds.png
  5. BIN
      SigDN/assets/Models/Archer_finalrig/Archer_finalrig.mesh.j3o
  6. 71
      SigDN/src/mygame/Main.java
  7. 11
      Weapons/Ar_BigBow_Fire_00.mtl
  8. 7877
      Weapons/Ar_BigBow_Fire_00.obj
  9. BIN
      Weapons/ar_bigbow_ice.dds
  10. BIN
      Weapons/ar_bigbow_ice.dds.png

@ -0,0 +1 @@
Subproject commit ce057d1da8e1abc409e82d07a2398ca89a640c80

@ -0,0 +1,3 @@
#
#Sun Jun 16 00:22:39 KST 2019
ORIGINAL_PATH=Models/Ar_BigBow_Fire_00/Ar_BigBow_Fire_00.obj

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

@ -12,8 +12,11 @@ import com.jme3.scene.Geometry;
import com.jme3.scene.Spatial;
import com.jme3.scene.shape.Box;
import com.jme3.animation.*;
import com.jme3.input.KeyInput;
import com.jme3.input.controls.ActionListener;
import com.jme3.input.controls.KeyTrigger;
import com.jme3.math.FastMath;
import com.jme3.math.Matrix3f;
import com.jme3.math.Quaternion;
import com.jme3.scene.Node;
@ -23,19 +26,27 @@ import com.jme3.scene.Node;
* @author normenhansen
*/
public class Main extends SimpleApplication implements
AnimEventListener,ActionListener{
AnimEventListener{
public static Main game;
private AnimChannel channel;
private AnimControl control;
private Geometry geom;
Spatial bow;
Spatial bow1,bow2;
public static void main(String[] args) {
Main app = new Main();
app.start();
game = new Main();
game.start();
}
@Override
public void simpleInitApp() {
bow1 = (Spatial) assetManager.loadModel("Models/Ar_BigBow_Fire_00/Ar_BigBow_Fire_00.j3o");
bow2 = (Spatial) assetManager.loadModel("Models/Smallbow_Mimiyala/Smallbow_Mimiyala.j3o");
bow = bow1;
flyCam.setMoveSpeed(20f);
flyCam.setZoomSpeed(20f);
cam.setLocation(new Vector3f(6.4013605f, 7.488437f, 12.843031f));
@ -54,8 +65,6 @@ public class Main extends SimpleApplication implements
float scale = 0.05f;
Archer.scale(scale, scale, scale);
Spatial bow = (Spatial) assetManager.loadModel("Models/Smallbow_Mimiyala/Smallbow_Mimiyala.j3o");
control = Archer.getControl(AnimControl.class);
control.addListener(this);
@ -68,11 +77,15 @@ public class Main extends SimpleApplication implements
geom = (Geometry)((Node)Archer).getChild(0);
SkeletonControl skeletonControl = Archer.getControl(SkeletonControl.class);
Node n = skeletonControl.getAttachmentsNode("Torso");
final Node n = skeletonControl.getAttachmentsNode("Torso");
bow.setLocalTranslation(5.7983f,2.0104f,12.5006f);
//bow.setLocalRotation(new Quaternion().fromAngleAxis(FastMath.PI*1f/4, new Vector3f(1,0,0)));
bow.setLocalRotation(new Quaternion().fromAngleAxis(FastMath.PI*1f/4, new Vector3f(1,0,0)).mult(
new Quaternion().fromAngleAxis(FastMath.PI*3f/2, new Vector3f(0,1,0))));
bow.setLocalRotation(new Quaternion().fromAngleAxis(FastMath.PI*(-90f/180), new Vector3f(0,1,0))
.mult(new Quaternion().fromAngleAxis(FastMath.PI*(45f/180), new Vector3f(1,0,0)))
.mult(new Quaternion().fromAngleAxis(FastMath.PI*(0f/180), new Vector3f(0,0,1)))
);
//bow.setLocalRotation();
//new Quaternion().fromAngleAxis(FastMath.PI*3f/2, new Vector3f(0,1,0))));
//bow.setLocalRotation(new Matrix3f());
//n.set
n.attachChild(bow);
//n.setLocalTranslation(5.7983f,99.0104f,12.5006f);
@ -84,6 +97,29 @@ public class Main extends SimpleApplication implements
rootNode.attachChild(Archer);
//rootNode.attachChild(bow);
inputManager.addMapping("Swap Weapon",
new KeyTrigger(KeyInput.KEY_SPACE));
ActionListener actionListener = new ActionListener(){
public void onAction(String name, boolean pressed, float tpf){
if (pressed) {
n.detachChild(bow);
if (Main.game.bow.equals(Main.game.bow1)) {
Main.game.bow = Main.game.bow2;
} else {
Main.game.bow = Main.game.bow1;
}
bow.setLocalTranslation(5.7983f,2.0104f,12.5006f);
bow.setLocalRotation(new Quaternion().fromAngleAxis(FastMath.PI*(-90f/180), new Vector3f(0,1,0))
.mult(new Quaternion().fromAngleAxis(FastMath.PI*(45f/180), new Vector3f(1,0,0)))
.mult(new Quaternion().fromAngleAxis(FastMath.PI*(0f/180), new Vector3f(0,0,1)))
);
n.attachChild(bow);
}
}
};
inputManager.addListener(actionListener, "Swap Weapon");
}
@Override
@ -96,24 +132,11 @@ public class Main extends SimpleApplication implements
//TODO: add render code
}
@Override
public void onAnimCycleDone(AnimControl control, AnimChannel channel, String animName) {
if (animName.equals("Dodge")){
channel.setAnim("stand", 0.50f);
channel.setLoopMode(LoopMode.DontLoop);
channel.setSpeed(1f);
}
}
@Override
public void onAnimChange(AnimControl control, AnimChannel channel, String animName) {
}
public void onAction(String binding, boolean value, float tpf) {
if (binding.equals("Attack") && value){
if (!channel.getAnimationName().equals("Dodge")){
channel.setAnim("Dodge", 0.50f);
channel.setLoopMode(LoopMode.Cycle);
channel.setSpeed(0.10f);
}
}
}
}

@ -0,0 +1,11 @@
# Exported from Wings 3D 2.2.4
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
map_Kd ar_bigbow_ice.dds.png

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

Loading…
Cancel
Save