Please Help me I'm going to study Game Programming and I going adapt Flagrush Tutorial for my Game.
I have many problem about Collision
It doesn't Work when I Load 3ds Charactor CollisionResults can't check :?
I write this in InitGame()
CollisionTreeManager.getInstance().setTreeType(CollisionTree.AABB_TREE);
results = new TriangleCollisionResults();
And Write This to Update()
results.clear();
n1.findCollisions(n2, results);
if (results.getNumber() > 0) {
System.out.println("Hello Collision");
}
and build player with 3ds
private void buildPlayer(){
Node model = null;
n1 = new Node("Node 1 for collision");
try {
MaxToJme C1 = new MaxToJme();
ByteArrayOutputStream BO = new ByteArrayOutputStream();
URL maxFile = Level4Again.class.getClassLoader().getResource("Model/zaara.3ds");
C1.convert(new BufferedInputStream(maxFile.openStream()),BO);
model = (Node)BinaryImporter.getInstance().load(new ByteArrayInputStream(BO.toByteArray()));
model.setModelBound(new BoundingBox());
model.updateModelBound();
//scale it to be MUCH smaller than it is originally
model.setLocalScale(.01f);
} catch (IOException e) {
logger.throwing(this.getClass().toString(), "buildPlayer()",
e);
}
//set the vehicles attributes (these numbers can be thought
//of as Unit/Second).
player = new Vehicle("Player Node", model);
player.setLocalScale(10);
((Vehicle) player).setAcceleration(6);
((Vehicle) player).setBraking(6);
((Vehicle) player).setTurnSpeed(2);
((Vehicle) player).setWeight(15);
((Vehicle) player).setMaxSpeed(10);
((Vehicle) player).setMinSpeed(2);
player.setLocalTranslation(new Vector3f(100,0, 100));
n1.attachChild(player);
scene.attachChild(player);
scene.updateGeometricState(0, true);
player.setRenderQueueMode(Renderer.QUEUE_OPAQUE);
}
and build model from class village
private void buildVillage(){
n2 = new Node("Node 2 for collision");
t = new Village();
t.buildTower("Tower2","Model/Tower.3ds");
t.setLocalScale(2);
t.setLocalTranslation(new Vector3f(105,0,50));
n2.attachChild(t);
scene.attachChild(n2);}
When player walk near Node n2 Why if (results.getNumber() > 0) {} not work ?
Sorry my english is bad.