i have a problem whit collisions, when my character collides with a big object all is fine, but when my character collides with a small object the fps descrease drastically, and my game run very slow.
some screenshots:
an big object like atree.
an samll object like a mushroom.
and my code for my static models:
[java]
public void cargarModelosEscenario(String idEscenario){
controladorBaseDatos controladorBD= new controladorBaseDatos();
Modelo[] modelos=controladorBD.obtenerDatosAmbientePorEscenarioBD(idEscenario);
for(int modeloActual=0;modeloActual<modelos.length;modeloActual++){
Spatial modelo=assetManager.loadModel(modelos[modeloActual].getModeloXML());
CollisionShape sceneShape = CollisionShapeFactory.createMeshShape((Node) modelo);
RigidBodyControl landscape = new RigidBodyControl(sceneShape, 0);
modelo.addControl(landscape);
bulletAppState.getPhysicsSpace().add(landscape);
}
nodoPadre.attachChild(modelo);
}
[/java]
my code for my character:
[java]
private CharacterControl controlNPC;
private Node nodoPrincipal= new Node();
private Spatial npc ;
public void simpleInitApp() {
bulletAppState = new BulletAppState();
bulletAppState.setThreadingType(BulletAppState.ThreadingType.PARALLEL);
stateManager.attach(bulletAppState);
....
....
}
private void cargarNPC(){
npc = assetManager.loadModel("Models/otromesh/Cube.002.mesh.xml");
Material material = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
material.setTexture("ColorMap", assetManager.loadTexture("Textures/madera.jpg"));
npc.setMaterial(material);
npc.setLocalTranslation(-100f, 5f, 10f);
npc.scale(.15f);
nodoPrincipal.attachChild(npc);
npc.addControl(controlNPC);
bulletAppState.getPhysicsSpace().add(controlNPC);
}
private void crearFisicaNPC(){ //agregando fisica al bicho------------------------------
CapsuleCollisionShape capsuleShape2 = new CapsuleCollisionShape(1f, 0f, 1);
controlNPC = new CharacterControl(capsuleShape2, 1f);
controlNPC.setJumpSpeed(20);
controlNPC.setFallSpeed(30);
controlNPC.setGravity(30);
npc.addControl(controlNPC);
bulletAppState.getPhysicsSpace().add(controlNPC);
}
[/java]
if i resize my mushroom to make it biger, it work fine.
if many objects collide with my character i have the same problem.
i hope somebody help me, and sorry for my bad english.