@@ -0,0 +1,149 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<mesh> | |||
<sharedgeometry vertexcount="24"> | |||
<vertexbuffer colours_diffuse="False" normals="true" positions="true" texture_coords="1"> | |||
<vertex> | |||
<position y="-1.000000" z="1.000000" x="1.000000"/> | |||
<normal y="-1.000000" z="0.000000" x="0.000000"/> | |||
<texcoord v="0.637624" u="0.125767"/> | |||
</vertex> | |||
<vertex> | |||
<position y="-1.000000" z="1.000000" x="-1.000000"/> | |||
<normal y="-1.000000" z="0.000000" x="0.000000"/> | |||
<texcoord v="0.637624" u="0.255208"/> | |||
</vertex> | |||
<vertex> | |||
<position y="-1.000000" z="-1.000000" x="-1.000000"/> | |||
<normal y="-1.000000" z="0.000000" x="0.000000"/> | |||
<texcoord v="0.508183" u="0.255208"/> | |||
</vertex> | |||
<vertex> | |||
<position y="-1.000000" z="-1.000000" x="1.000000"/> | |||
<normal y="-1.000000" z="0.000000" x="0.000000"/> | |||
<texcoord v="0.508183" u="0.125767"/> | |||
</vertex> | |||
<vertex> | |||
<position y="1.000000" z="1.000000" x="1.000000"/> | |||
<normal y="1.000000" z="-0.000000" x="-0.000000"/> | |||
<texcoord v="0.642195" u="0.127299"/> | |||
</vertex> | |||
<vertex> | |||
<position y="1.000000" z="-1.000000" x="1.000000"/> | |||
<normal y="1.000000" z="-0.000000" x="-0.000000"/> | |||
<texcoord v="0.504590" u="0.127299"/> | |||
</vertex> | |||
<vertex> | |||
<position y="1.000000" z="-1.000000" x="-1.000000"/> | |||
<normal y="1.000000" z="-0.000000" x="-0.000000"/> | |||
<texcoord v="0.504590" u="0.001320"/> | |||
</vertex> | |||
<vertex> | |||
<position y="1.000000" z="1.000000" x="-1.000000"/> | |||
<normal y="1.000000" z="-0.000000" x="-0.000000"/> | |||
<texcoord v="0.642195" u="0.001320"/> | |||
</vertex> | |||
<vertex> | |||
<position y="-1.000000" z="1.000000" x="1.000000"/> | |||
<normal y="0.000000" z="1.000000" x="-0.000000"/> | |||
<texcoord v="0.500401" u="0.257550"/> | |||
</vertex> | |||
<vertex> | |||
<position y="1.000000" z="1.000000" x="1.000000"/> | |||
<normal y="0.000000" z="1.000000" x="-0.000000"/> | |||
<texcoord v="0.004050" u="0.257551"/> | |||
</vertex> | |||
<vertex> | |||
<position y="1.000000" z="1.000000" x="-1.000000"/> | |||
<normal y="0.000000" z="1.000000" x="-0.000000"/> | |||
<texcoord v="0.004050" u="0.128401"/> | |||
</vertex> | |||
<vertex> | |||
<position y="-1.000000" z="1.000000" x="-1.000000"/> | |||
<normal y="0.000000" z="1.000000" x="-0.000000"/> | |||
<texcoord v="0.500401" u="0.128401"/> | |||
</vertex> | |||
<vertex> | |||
<position y="-1.000000" z="1.000000" x="-1.000000"/> | |||
<normal y="-0.000000" z="-0.000000" x="-1.000000"/> | |||
<texcoord v="0.499039" u="0.511562"/> | |||
</vertex> | |||
<vertex> | |||
<position y="1.000000" z="1.000000" x="-1.000000"/> | |||
<normal y="-0.000000" z="-0.000000" x="-1.000000"/> | |||
<texcoord v="0.002312" u="0.511243"/> | |||
</vertex> | |||
<vertex> | |||
<position y="1.000000" z="-1.000000" x="-1.000000"/> | |||
<normal y="-0.000000" z="-0.000000" x="-1.000000"/> | |||
<texcoord v="0.002312" u="0.389646"/> | |||
</vertex> | |||
<vertex> | |||
<position y="-1.000000" z="-1.000000" x="-1.000000"/> | |||
<normal y="-0.000000" z="-0.000000" x="-1.000000"/> | |||
<texcoord v="0.499039" u="0.389965"/> | |||
</vertex> | |||
<vertex> | |||
<position y="-1.000000" z="-1.000000" x="-1.000000"/> | |||
<normal y="-0.000000" z="-1.000000" x="0.000000"/> | |||
<texcoord v="0.500401" u="0.386992"/> | |||
</vertex> | |||
<vertex> | |||
<position y="1.000000" z="-1.000000" x="-1.000000"/> | |||
<normal y="-0.000000" z="-1.000000" x="0.000000"/> | |||
<texcoord v="0.004050" u="0.386992"/> | |||
</vertex> | |||
<vertex> | |||
<position y="1.000000" z="-1.000000" x="1.000000"/> | |||
<normal y="-0.000000" z="-1.000000" x="0.000000"/> | |||
<texcoord v="0.004050" u="0.257842"/> | |||
</vertex> | |||
<vertex> | |||
<position y="-1.000000" z="-1.000000" x="1.000000"/> | |||
<normal y="-0.000000" z="-1.000000" x="0.000000"/> | |||
<texcoord v="0.500401" u="0.257842"/> | |||
</vertex> | |||
<vertex> | |||
<position y="1.000000" z="1.000000" x="1.000000"/> | |||
<normal y="0.000000" z="0.000000" x="1.000000"/> | |||
<texcoord v="0.004451" u="-0.001422"/> | |||
</vertex> | |||
<vertex> | |||
<position y="-1.000000" z="1.000000" x="1.000000"/> | |||
<normal y="0.000000" z="0.000000" x="1.000000"/> | |||
<texcoord v="0.500802" u="-0.001422"/> | |||
</vertex> | |||
<vertex> | |||
<position y="-1.000000" z="-1.000000" x="1.000000"/> | |||
<normal y="0.000000" z="0.000000" x="1.000000"/> | |||
<texcoord v="0.500802" u="0.127810"/> | |||
</vertex> | |||
<vertex> | |||
<position y="1.000000" z="-1.000000" x="1.000000"/> | |||
<normal y="0.000000" z="0.000000" x="1.000000"/> | |||
<texcoord v="0.004451" u="0.127810"/> | |||
</vertex> | |||
</vertexbuffer> | |||
</sharedgeometry> | |||
<submeshes> | |||
<submesh material="Material" operationtype="triangle_list" use32bitindexes="False" usesharedvertices="true"> | |||
<faces count="12"> | |||
<face v3="2" v2="1" v1="0"/> | |||
<face v3="3" v2="2" v1="0"/> | |||
<face v3="6" v2="5" v1="4"/> | |||
<face v3="7" v2="6" v1="4"/> | |||
<face v3="10" v2="9" v1="8"/> | |||
<face v3="11" v2="10" v1="8"/> | |||
<face v3="14" v2="13" v1="12"/> | |||
<face v3="15" v2="14" v1="12"/> | |||
<face v3="18" v2="17" v1="16"/> | |||
<face v3="19" v2="18" v1="16"/> | |||
<face v3="22" v2="21" v1="20"/> | |||
<face v3="23" v2="22" v1="20"/> | |||
</faces> | |||
</submesh> | |||
</submeshes> | |||
<submeshnames> | |||
<submesh index="0" name="Material"> | |||
</submesh> | |||
</submeshnames> | |||
</mesh> |
@@ -0,0 +1,42 @@ | |||
// Material genrated by blender2ogre 0.5.8 | |||
material Material | |||
{ | |||
receive_shadows on | |||
technique | |||
{ | |||
pass Material | |||
{ | |||
ambient 0.800000011920929 0.800000011920929 0.800000011920929 1.0 | |||
diffuse 0.6400000190734865 0.6400000190734865 0.6400000190734865 1.0 | |||
specular 0.5 0.5 0.5 1.0 12.5 | |||
emissive 0.0 0.0 0.0 1.0 | |||
alpha_to_coverage off | |||
colour_write on | |||
cull_hardware clockwise | |||
depth_check on | |||
depth_func less_equal | |||
depth_write on | |||
illumination_stage | |||
light_clip_planes off | |||
light_scissor off | |||
lighting on | |||
normalise_normals off | |||
polygon_mode solid | |||
scene_blend one zero | |||
scene_blend_op add | |||
shading gouraud | |||
transparent_sorting on | |||
texture_unit | |||
{ | |||
texture person.png | |||
tex_address_mode wrap | |||
scale 1.0 1.0 | |||
colour_op modulate | |||
} | |||
} | |||
} | |||
} |
@@ -0,0 +1,24 @@ | |||
<scene exported_by="dejvino" export_time="1483218291.9523585" formatVersion="1.0.1" previous_export_time="1483218209.9221447" > | |||
<nodes > | |||
<node name="Cube" > | |||
<position y="1.693228" z="-0.000000" x="0.000000" /> | |||
<rotation qz="-0.000000" qw="1.000000" qx="0.000000" qy="0.000000" /> | |||
<scale y="1.642234" z="0.377920" x="0.377920" /> | |||
<game > | |||
<sensors /> | |||
<actuators /> | |||
</game> | |||
<entity damping_trans="0.02539999969303608" meshFile="Cube.mesh" ghost="False" friction_y="1.0" lock_rot_x="False" mass="1.0" anisotropic_friction="False" actor="False" lock_trans_z="False" lock_rot_z="False" name="Cube" lock_trans_y="False" mass_radius="1.0" damping_rot="0.1589999943971634" velocity_max="0.0" velocity_min="0.0" lock_trans_x="False" lock_rot_y="False" friction_x="1.0" physics_type="STATIC" inertia_tensor="0.4000000059604645" friction_z="1.0" /> | |||
</node> | |||
</nodes> | |||
<externals > | |||
<item type="material" > | |||
<file name="P:\Development\roadtrip\assets-src\Models\Material.material" /> | |||
</item> | |||
</externals> | |||
<environment > | |||
<colourAmbient g="0.0" r="0.0" b="0.0" /> | |||
<colourBackground g="0.05087608844041824" r="0.05087608844041824" b="0.05087608844041824" /> | |||
<colourDiffuse g="0.05087608844041824" r="0.05087608844041824" b="0.05087608844041824" /> | |||
</environment> | |||
</scene> |
@@ -0,0 +1,3 @@ | |||
# | |||
#Sat Dec 31 22:05:36 CET 2016 | |||
ORIGINAL_PATH=Models/person.scene |
@@ -5,6 +5,8 @@ import com.jme3.bullet.BulletAppState; | |||
import com.jme3.bullet.PhysicsSpace; | |||
import com.jme3.bullet.collision.shapes.BoxCollisionShape; | |||
import com.jme3.bullet.collision.shapes.CompoundCollisionShape; | |||
import com.jme3.bullet.control.BetterCharacterControl; | |||
import com.jme3.bullet.control.RigidBodyControl; | |||
import com.jme3.bullet.control.VehicleControl; | |||
import com.jme3.input.KeyInput; | |||
import com.jme3.input.controls.ActionListener; | |||
@@ -17,6 +19,7 @@ import com.jme3.math.Vector3f; | |||
import com.jme3.scene.Geometry; | |||
import com.jme3.scene.Node; | |||
import com.jme3.scene.Spatial; | |||
import com.jme3.scene.shape.Box; | |||
import com.jme3.scene.shape.Cylinder; | |||
/** | |||
@@ -25,6 +28,7 @@ import com.jme3.scene.shape.Cylinder; | |||
*/ | |||
public class RoadTrip extends SimpleApplication implements ActionListener { | |||
public static boolean DEBUG = false;//true; | |||
final int WEAK = 1; | |||
final int TRUCK = 2; | |||
final int SPORT = 3; | |||
@@ -51,7 +55,7 @@ public class RoadTrip extends SimpleApplication implements ActionListener { | |||
public void simpleInitApp() { | |||
bulletAppState = new BulletAppState(); | |||
stateManager.attach(bulletAppState); | |||
bulletAppState.getPhysicsSpace().enableDebug(assetManager); | |||
if (DEBUG) bulletAppState.getPhysicsSpace().enableDebug(assetManager); | |||
PhysicsTestHelper.createPhysicsTestWorld(rootNode, assetManager, bulletAppState.getPhysicsSpace()); | |||
setupKeys(); | |||
buildPlayer(); | |||
@@ -61,6 +65,12 @@ public class RoadTrip extends SimpleApplication implements ActionListener { | |||
getPhysicsSpace().addAll(map); | |||
vehicle.setPhysicsLocation(new Vector3f(5f, 30f, 5f)); | |||
addPerson(); | |||
addPerson(); | |||
addPerson(); | |||
addPerson(); | |||
addPerson(); | |||
} | |||
private PhysicsSpace getPhysicsSpace(){ | |||
@@ -87,7 +97,7 @@ public class RoadTrip extends SimpleApplication implements ActionListener { | |||
private void buildPlayer() { | |||
Material mat = new Material(getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md"); | |||
mat.getAdditionalRenderState().setWireframe(true); | |||
mat.setColor("Color", ColorRGBA.Red); | |||
mat.setColor("Color", ColorRGBA.Black); | |||
//create a compound shape and attach the BoxCollisionShape for the car body at 0,1,0 | |||
//this shifts the effective center of mass of the BoxCollisionShape to 0,-1,0 | |||
@@ -127,6 +137,12 @@ public class RoadTrip extends SimpleApplication implements ActionListener { | |||
float xOff = 1.6f; | |||
float zOff = 2f; | |||
Geometry carBody = new Geometry("car body", new Box(new Vector3f(0.0f, 1f, 0.0f), 1.4f, 0.5f, 3.6f)); | |||
Material matBody = new Material(getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md"); | |||
matBody.setColor("Color", ColorRGBA.Red); | |||
carBody.setMaterial(matBody); | |||
vehicleNode.attachChild(carBody); | |||
Cylinder wheelMesh = new Cylinder(16, 16, radius, radius * 0.2f, true); | |||
Node node1 = new Node("wheel 1 node"); | |||
@@ -207,6 +223,7 @@ public class RoadTrip extends SimpleApplication implements ActionListener { | |||
accelerationForce = 20000f; | |||
brakeForce = 200f; | |||
} | |||
mat.getAdditionalRenderState().setWireframe(false); | |||
} | |||
@Override | |||
@@ -285,4 +302,25 @@ public class RoadTrip extends SimpleApplication implements ActionListener { | |||
} | |||
} | |||
} | |||
private void addPerson() { | |||
Spatial personModel = assetManager.loadModel("Models/person.j3o"); | |||
Node person = new Node("person"); | |||
person.attachChild(personModel); | |||
BetterCharacterControl personControl = new BetterCharacterControl(1f, 4f, 10f); | |||
/*personModel.setLocalTranslation(0f, -1f, 0f); | |||
BoxCollisionShape personShape = new BoxCollisionShape(new Vector3f(0.5f, 2f, 0.5f)); | |||
RigidBodyControl personControl = new RigidBodyControl(personShape, 80f);/**/ | |||
person.addControl(personControl); | |||
/**/personControl.setJumpForce(new Vector3f(0,5f,0)); | |||
personControl.setGravity(new Vector3f(0,1f,0)); | |||
personControl.warp(new Vector3f(10f + (float)Math.random() * 10f, 30f, 12f + (float)Math.random() * 10f));/**/ | |||
//personControl.setPhysicsLocation(new Vector3f(10f, 30f, 12f)); | |||
getPhysicsSpace().add(personControl); | |||
getPhysicsSpace().addAll(person); | |||
rootNode.attachChild(person); | |||
Vector3f dir = new Vector3f((float)Math.random() * 2f - 1f, 0f, (float)Math.random() * 2f - 1f); | |||
personControl.setViewDirection(dir); | |||
personControl.setWalkDirection(dir); | |||
} | |||
} |