I am developing an FPS game in the latest version on jMonkey. The map is a 3ds file the I converted to a j3o (obviously). However, this model is so big (in file and physical size) that when I attach it to the root node (basically load it) it causes so much lag that I can’t play the game as there is 0 Frames.
I have looked on other forums and topics, and they say things like “split it up into chunks” and “attach it outside of the main loop”. I am fairley new to jMonkey so I am nt sure how to do this. Any help would be appretiated.
My scource code:
At some point the mesh and textures have to be uploaded to the GPU. That happens when the model is actually rendered and happens in the update loop. You can load the model into the CPU memory outside the update loop (simply on another thread, read up on java threading) but as soon as the model has to be rendered (i.e. its in the frustum) the data gets uploaded to the GPU and you’ll get this “lag” (which is technically the wrong word for this).
One way to circumvent this is simply attaching the model at the beginning of the game and set its cullhint to never, then let one frame be rendered. After that you can detach the model and attach it later without interruptions.
The point of setting the cullhint to never in my example is to force the GPU to render the object no matter if its visible (i.e. in the frustum) or not. Only do that for that first frame, then set it back to inherit.
Think about it. Imagine you are wearing glasses. The position of your glasses is where stuff clips (near frustum). Now you have a 1x1x1 cm model of a house and want to put it so close to your eyes that it looks like a real house - you’ll end up bumping into your glasses with the model. Now you have a real house - will it bump into the glasses when it looks like its real size?