[SOLVED] Program freezing when using models

I made a nice grenade using blender, and have exported it in fbx. When I try to run my program with the model, the screen is black for ~30 seconds, then it pops up and seems to run normally. But ~10 seconds in, it freezes.

The terminal shows no errors (even though there is a lot of red, which is normal). I also tried j3o, with the same result.

protected void build(AssetManager manager) {
	Spatial grenSpat/* = new Geometry(name, new Sphere(10, 15, 0.5f, true, true))*/;
	grenSpat = manager.loadModel("Models/FragGrenade.fbx");
	Material mat = new Material(manager, "Common/MatDefs/Misc/ShowNormals.j3md");
	//mat.setBoolean("UseMaterialColors", true);
	//mat.setColor("Color", ColorRGBA.Green);
	phys.setGravity(new Vector3f(0, -10, 0));
	built = true;

BTW, when I try to convert a file to j3o, there is sometimes a button above the “convert to j3o” button called “convert to blend”. When I try to click the j3o button, it instead clicks the blend button. Any idea what that is?

1 Like

So , if build() is called multiple times , as 3 times or 4 or more in update() for instance without a control to the tpf , it may lead to this , it happened with me once a time.

idk about convert to j3o button issue.

But multiple things:

  • j3o load faster
  • high poly models will always load longer
  • you should use Threads to load model (app.enqueue() after done) to avoid freeze

Tell me how many verts and how big textures have your model?

1 Like

Ooh, that’s a good point. My model has ~15,000 verts :dizzy_face:

I’ve deleted some modifiers and brought it down to 1,000. Now it runs just fine! Except…

My model is composed of a sphere, and cube, and a torus. When I run my program, the model’s sphere, cube, and torus become separated. Is there some way I can merge the separate shapes into a single mesh?

15k verts is not Very much, FPS game characters have average 5-20k “tris” each.

Unless you are doing Android game.

Anyway for a Grenade, it should be just like 500 tris max

I think it could also load slower bacause of Texture size.

About separate sphere/cube/torus you probably use different material for each of them, or have them as separated Objects in Blender. This 2 reasons can cause it. to fix, you need merge materials into single one and in second case you just need merge meshes in Blender.

1 Like

Add them as only one RigidBodyControl for only a Spatial or a node , even if they are separated in blender , they must be under only one node & this node would be controlled by only one RigidBodyControl.