Adding physics to models is decreasing fps to 0

So when I add physics to my models my fps goes from over 100 to 0 while the object is moving. It is low poly. it is just a hut made from a cylinder with an extruded roof, and basic textures. When I don’t apply physics to it, my fps is completely normal. Also, i know this isnt the right section, but i dont wanna spam with multiple posts, my models have textures in scenecomposer, but when i run the actual app they dont have any texture, theyre just black.

Got code on how you add the model to the game?

private void loadObjects() {

Spatial hut1 = assetManager.loadModel(“Models/Hut/Hut.j3o”);

hut1.setLocalTranslation(0, 20, 400);

hut1.scale(5f, 5f, 5f);

rootNode.attachChild(hut1);

RigidBodyControl hut_phy = new RigidBodyControl(1f);

hut1.addControl(hut_phy);

bulletAppState.getPhysicsSpace().add(hut_phy);

}







i can upload my model if you need that too

Is there a light in your scene?

@zarch said:
Is there a light in your scene?



private void createLight(int x) {
if(x == 0) {
DirectionalLight sun = new DirectionalLight();
sun.setDirection(new Vector3f(0f, 0f, 0f));
rootNode.addLight(sun);
}
}

Yes, you should convert the j3o to xml and import the xml object.

j3o doesn’t work at all for me…



Also, for the texture you need to add them aswell like this:

[java]public static Material Texture(String name){

Material mat = new Material(MainGame.getAsset(),“Common/MatDefs/Misc/Unshaded.j3md”);



Texture img = Load(name);

img.setWrap(WrapMode.Repeat);

mat.setTexture(“ColorMap”, img);







return mat;

}

public static Texture Load(String name){

Texture tex = null;

try{

File imageFile = new File(name);

MainGame.getAsset().registerLocator(imageFile.getParent(), FileLocator.class.getName());

tex = MainGame.getAsset().loadTexture(new TextureKey(name, false));

} catch (Exception e){



}

return tex;

}

[/java]

This is how I load my models w. textures. BULLETPROOF xD

alright, ill give that a try. Also is this the best method for STATIC objects? because really im only adding physics to keep them on the ground

I think so.

I use this method:

[java]public static RigidBodyControl StaticMeshNode(Spatial spatial) {

CollisionShape sceneShape = CollisionShapeFactory.createMeshShape(spatial);

RigidBodyControl house = new RigidBodyControl(sceneShape,0);

spatial.addControl(house);

MainGame.getPhysics().add(house);

return house;

}[/java]

And it works great for me. But I think your method works good aswell.

@dannybarrett said:
private void createLight(int x) {
if(x == 0) {
DirectionalLight sun = new DirectionalLight();
sun.setDirection(new Vector3f(0f, 0f, 0f));
rootNode.addLight(sun);
}
}


[java]new Vector3f(0f, 0f, 0f)[/java] - That isn't a direction :) Try something like
[java] Vector3f lightDirection = new Vector3f(1, -1, 0).normalizeLocal();
[/java]
@Addez said:
j3o doesn't work at all for me..

Probably because you copy the textures and models around? As stated in multiple places, the paths have to be absolute when converting the model, this is why the SDK handles the paths like it does.
@normen said:
Probably because you copy the textures and models around? As stated in multiple places, the paths have to be absolute when converting the model, this is why the SDK handles the paths like it does.

Maybe worth mentioning is that I don't use the SDK :P
But nvm, if j3o works then you really don't need to change..
@Addez said:
Maybe worth mentioning is that I don't use the SDK :P
But nvm, if j3o works then you really don't need to change..

Yes, I was implying that you do things wrong because you don't use the SDK but try to outsmart the ways it does things on your own ^^
@jmaasing said:
[java]new Vector3f(0f, 0f, 0f)[/java] - That isn't a direction :) Try something like
[java] Vector3f lightDirection = new Vector3f(1, -1, 0).normalizeLocal();
[/java]



lolol, didnt even think of that, ty :p

And if you don’t want your physics objects to move you should set their mass to zero, but I guess you know that as you certainly did the tutorials :wink: