Normalize Imported Model

I am new to JME. Working on one project. I just imported a human model (ogre3D). I scaled my model which is messing with the mesh normals. I know in C++ i can add this line glEnable(GL_NORMALIZE) to normalize my model. What i have to do in JME 3 to normalize my model?

@ch.gulraiz said: I am new to JME. Working on one project. I just imported a human model (ogre3D). I scaled my model which is messing with the mesh normals. I know in C++ i can add this line glEnable(GL_NORMALIZE) to normalize my model. What i have to do in JME 3 to normalize my model?

As mentioned in the other thread, the JME default lighting shader already normalizes the normals:
vec3 wvNormal = normalize(g_NormalMatrix * modelSpaceNorm);

…so either you are using different shaders or your problem is something else. Do use normal maps? Have you generated tangents?

Many thanks pspeed.

I am importing my model and scaling it. I am not playing with anything else. If i am not scaling then model appears very big. Some how i have to scale it or have manipulate. My code is given below …

[java] Spatial mymodel = assetManager.loadModel(“human.obj”);
mymodel.setLocalScale(0.4f);

	rootNode.attachChild(mymodel);
	DirectionalLight sun = new DirectionalLight();
	sun.setDirection((new Vector3f(-1.0f, -1.0f, -1.0f)));
	sun.setColor(ColorRGBA.White);
	rootNode.addLight(sun); [/java]

Whatever 3d modeling software you used (blender,3DSmax etc) can influence the size of the model. I see in your code setLocalScale. If its too big or small you can change the scale. What benefit of normalizing it would you have over setting the scale?

@Jacob Thanks for the response. Another question i have to ask. My target is to change / update human model when ever i will get different height of a person / chest size etc. When i am trying to scale geometries it stretch the model that does not look good. How i can achieve this ?

If you are scaling the whole model, make sure you scale X,Y and Z at the same ratios,I have not scaled an isolated bone or mesh on a model (e.g chest size) hopefully someone else can answer.

I tried X,Y and Z as well. Having same problem.

What’s the “same problem” exactly?
How do you conclude this “I scaled my model which is messing with the mesh normals”? This is very unlikely to happen considering the code you posted.
Do you have a screenshot?
Do you use a normal map?
Do you generate the tangents?

If you want to adjust part of a mesh then you have to edit the mesh to transform it. Then, you’ll have to transform the normals too, but not only. The tangent buffer needs to be transformed too…that is if you ise a normal map and if your tangents are generated…

@nehon Thanks for your reply

I am not familiar with normal map and tangents. I need an opengl call that ensures that all normals are normalized after scaling. Here is the screenshot of model.

Can you please send me an example how to use normal map and tangents?

@ch.gulraiz said: I need an opengl call that ensures that all normals are normalized after scaling.
This is what you think you need, but it's not your issue. Explain what seems wrong to you I can't see what's the issue on the picture.

@nehon Thanks once again… I need a perfect model. Some thing goes wrong after scaling … I just need a perfect model to apply sizing parameters. Even i can provide you jar file and you can see how it’s norms stretched…

Human Avatar Image

@ch.gulraiz said: @nehon Thanks once again.. I need a perfect model. Some thing goes wrong after scaling ... I just need a perfect model to apply sizing parameters. Even i can provide you jar file and you can see how it's norms stretched..

Human Avatar Image

I am only going to say this one time before I stop repeating myself. So listen very carefully:

ALL NORMALS ARE NORMALIZED. THE NORMALS ARE ALWAYS NORMALIZED. THIS IS 100000000000% NOT YOU ISSUE.

There. Now maybe we can start sorting out what the real problem is… because it is definitely not normalizing normals. Because as said, the normals are always normalized. No matter the scale, normals get normalized. Every path through the shader normalizes the normals because all of the normals are normalized in every path. There is physically no way to avoid normalizing the normals in the JME lighting shader because it always normalizes the normals.

1 Like
@ch.gulraiz said: Many thanks pspeed.

I am importing my model and scaling it. I am not playing with anything else. If i am not scaling then model appears very big. Some how i have to scale it or have manipulate. My code is given below …

[java] Spatial mymodel = assetManager.loadModel(“human.obj”);
mymodel.setLocalScale(0.4f);

	rootNode.attachChild(mymodel);
	DirectionalLight sun = new DirectionalLight();
	sun.setDirection((new Vector3f(-1.0f, -1.0f, -1.0f)));
	sun.setColor(ColorRGBA.White);
	rootNode.addLight(sun); [/java]</blockquote>

What if you normalize your lighting direction so that it’s not 1.7 times the length of a proper direction vector? I don’t know if it will fix it but it might.

Also:
http://hub.jmonkeyengine.org/javadoc/com/jme3/util/TangentBinormalGenerator.html

…but that only matters if you are actually using normal maps. It seems difficult to be sure of that given the information provided so far.

@pspeed said: ALL NORMALS ARE NORMALIZED. THE NORMALS ARE ALWAYS NORMALIZED. THIS IS 100000000000% NOT YOU ISSUE.

There. Now maybe we can start sorting out what the real problem is… because it is definitely not normalizing normals. Because as said, the normals are always normalized. No matter the scale, normals get normalized. Every path through the shader normalizes the normals because all of the normals are normalized in every path. There is physically no way to avoid normalizing the normals in the JME lighting shader because it always normalizes the normals.

I’m getting this printed on a shirt.

EDIT Dr. Suess does JME3

@t0neg0d said: I'm getting this printed on a shirt.

EDIT Dr. Suess does JME3

:slight_smile: In case there were language translation problems, I wanted to state it in as many different ways that I could think of. Give the translators the best chance. I should have tried to make it rhyme, though.

@t0neg0d I would like to buy one shirt :slight_smile: @pspeed Thanks. I got it and it was lighting issue in my original code. Thanks every body for your kind support.