3D Model/View Problem

Hi, apologies for this vague question, but I have a problem: whenever my 3D model appears in the field of view, the view goes crazy, and the model seems to get stretched over the whole view. This video shows what I mean:

I know there’s nothing wrong with the model itself since I can load that into another game. I’ve tried scaling the mode to virtually zero, stopped animating it, and moved it far away but this problem still occurs when the model appears in view. I’ve obviously put something in the code to cause this, but I’ve no clue what. I’m no expert in 3D, and I’m not using any special shaders or preprocessors.

Any help telling me what could cause this would be much appreciated as I’ve spent ages removing bits of my code but nothing makes a difference. Thanks!

What’s the shader on the model? Looks like as soon as the model gets unculled by the engine it gets drawn without any view projection transform which should be one or more last lines in the vert shader. Also the shader could be fine and your transform could be NaN or something like that.

Also, animation skinning is only calculated when the object is in view, so depending on what you mean by “stopped animating it”, that could also be something to look at.

Try removing the animation control before adding it to the scene and see if the problem persists.

Thanks for your replies. I’m not using any shader (unless JME adds a default shader or something?). I’ve also not added any animation to it (by removing the animation control). It’s just a straight model.

Welp, seems like we’re gonna have to see some code or the model file to help you any further. Everything you’ve said so far checks out.

Also, log/print the world transforms of the model to see if they check out. A crazy quaternion somewhere could in theory cause this also… though it would be strange.

I would post some code, but it’s a large complex project and it’s a long process for me to try and strip out all the excess, and it uses multiple projects. (The code is open-source though). The other thing is, I can happily load and show the model at an earlier stage of the game without a problem. It’s like I’m calling some method or something at some point, which is causing the problem. I did think I might be accidentally adding the model to the Gui node when it comes into view or something, but that doesn’t seem to be it.


Just a guess, but maybe you’re calling one of the"local" methods such as.addLocal() on the model’s quaternion in your code somehwere, where you’d instead want to be using .add() or call .clone()on the model’s vectors/quaternions to avoid altering them unintentionally

Fair enough, that does sound like I’m describing every bug ever written since computers were invented, but I meant that I’m doing something “wrong” prior to the bit that’s going wrong (which, I admit, doesn’t help much either).

Anyhoo, I’m not really getting anywhere at the moment. I can load the exact same model at a different part of the game without a problem. I can load all other models I’ve tried, both Blender and .obj without a problem. But when I load this model at this particular juncture and add it to the root node, it goes crazy when I look at it. And all I’m doing is

		Spatial m = assetManager.loadModel("Models/Animated Human.blend");
		m.setLocalTranslation(1,  1,  1);

It’s like SCP-419 or something (</obscure reference>)

Call Dr. Bright and Dr. Clef, they will handle it. Right after they give you a class A amnestic.

1 Like

Also make sure you aren’t modifying a JME math ‘constant’ somewhere or passing one of the constants to a method that does.

I assume your model is not using instancing or somesuch.

Well, I think I’ve sort of found the problem, and it’s a relief to find I wasn’t doing something stupid!

I’m using the jME-TTF font library ( jttf ) which has worked well for me before. However, after slowly removing lines of my code, I’ve discovered that if I don’t call a particular method in this library, everything works. The the bit of code is:-


which is (currently) line 165 in this file: https://bitbucket.org/SteveSmith16384/moonbaseassault/src/master/src/com/scs/moonbaseassault/client/hud/MoonbaseAssaultHUD.java

I’ve no idea why this line should affect the loading of a model since there is no direct connection between a font that appears on the guiNode, and a model that appears on the rootNode. I’ll do it a bit more digging to see if I can work out why, but I’m just relieved to have found it after almost 4 days of debugging and churning up my code. Thanks for the help though.

It’s not necessarily affecting the loading, eh? You said the model works fine when loaded earlier so it could just be related to how it’s displayed.

Not sure how exactly you tested that part or whether it was just loading earlier or also attaching earlier or whatever.

I just meant that it was affecting the model in some way, whether loading or rendering or whatever. Or affecting something else which was then affecting the model.

Ok. I wasn’t trying to be picky… just that if you had indeed narrowed it down to loading then that would have eliminated a lot of other things to look at. (and would be the strangest)

Did you ever unravel the root cause of the issue?

No, unfortunately not. I couldn’t directly recreate the problem under “controlled conditions”. I tried manually adding strings to the font container but that didn’t break the game, but somehow something I was adding during a regular game made it stop rendering models properly. I discovered that if I limited the text to only 5 lines, that seemed to make the problem go away, and I decided I’d spent far too much time on it to spend any more.

1 Like

I have narrowed this problem down: I’ve written a new game which has the same problem, even without showing anything in the Gui node. The problem only occurs in JME 3.2.2, not 3.2.0.

It would be better to create a minimal test code so we can check it.