And you have said that the meshes are regenerated with respect to the changes of vertices. Well it is normal since as vertices change, mesh must be regenerated with new vertices(and new indices and normals are generated w.r.t. new vertices). Additionally, you had your animation smooth. Probably, you set the material asset as
[java]new Material(assetManager, âCommon/MatDefs/Light/Lighting.j3mdâ);[/java]
and added a light(directional, pointlight or other types).
You are experienced enough to understand and tell me what I need to learn.
If you mean a smooth mesh as in smooth shaded thatâs probably that your normals calculation is wrong. If you set the face normal to each vertex of a face thatâs flat shading.
To have a smooth shaded mesh, you have to compute your normals so that the normal of a vertex is the average of the normals of the faces itâs part of.
Then you have to use the lighting material and a light source to see the result.
EDIT : Reading back the thread, all of this was clearly stated in previous answers by pspeed and sgold.
@nehon said:
If you mean a smooth mesh as in smooth shaded that's probably that your normals calculation is wrong. If you set the face normal to each vertex of a face that's flat shading.
To have a smooth shaded mesh, you have to compute your normals so that the normal of a vertex is the average of the normals of the faces itâs part of.
Then you have to use the lighting material and a light source to see the result.
EDIT : Reading back the thread, all of this was clearly stated in previous answers by pspeed and sgold.
To have a smooth shaded mesh, I have to compute my normals so that the normal of a vertex is the average of the normals of the faces itâs part of the instructions I am asking.
Then if I have a mesh as in the photos above:
First part is calculating the normals so that the normal of a vertex is the average of the normals of the faces.
?
?
?
.
.
n. Then I have to use the lighting material and a light source to see the result.
The title of this topic clearly refers what I state and ask. I wonder the steps/instructions in an order(1,2,3,âŚ,n) to obtain a smooth shaded mesh from an unshaded mesh. The nâth step may be repeated several times after different steps to debug the algorithm I produce.
You claim you read the custom mesh tutorial so Iâm gonna assume you did and that you are familiar with what it depicts.
then your steps are like that :
compute your normals
do what is done in the custom mesh tutorial (seems itâs done or you wouldnât have those screenshots)
use the lighting material on the geometry that hold this mesh and have a light source (maybe read the HelloMaterial tutorial for that).
The thing isâŚfrom what you said you did, there is no additional step, but you keep asking about them.
Now if it doesnât work, itâs that something went wrong in the process.
@nehon said:
You claim you read the custom mesh tutorial so I'm gonna assume you did and that you are familiar with what it depicts.
then your steps are like that :
1. compute your normals
2. do what is done in the custom mesh tutorial (seems it's done or you wouldn't have those screenshots)
3. use the lighting material on the geometry that hold this mesh and have a light source (maybe read the HelloMaterial tutorial for that).
The thing isâŚfrom what you said you did, there is no additional step, but you keep asking about them.
Now if it doesnât work, itâs that something went wrong in the process.
Then probably I calculate the normals of the faces or vertices wrong. I have unfortunately additional questions.
When a triangular face lies on x-y plane, do we determine its normal as (0,0,1) or (0,0,-1) or am I wrong?
Do we calculate the normals per coordinate or per triangular face?
How do we apply the term âaverageâ on computing the normals?
Is the class TangentBinormalGenerator.java applicable/capable for the purpose I have?
When we use
[java]mtrl = new Material(assetManager, âCommon/MatDefs/Light/Lighting.j3mdâ);[/java]
instead of
[java]mtrl = new Material(assetManager, âCommon/MatDefs/Misc/Unshaded.j3mdâ);[/java]
then we are not able to use
[java]mtrl.setBoolean(âVertexColorâ, true);[/java]
It means that, we will only be able to determine the color of the material, but not to attach a colorRGBA value per vertice. Not only color but also the transparency will be applicable per material instead of per vertice.
When the other steps are done and normals are calculated well, will a spere like mesh(or the output views above), that is constituted by corners in essence, look like smooth?
Thank you for providing a better point of view(big picture) and guidance, let me have your kind response at your earliest convenience.
When learning about something brand new to you then you will have to do a little research.
@Sarpp-Daltabann said:
2) Do we calculate the normals per coordinate or per triangular face?
Per coordinate and per face⌠then average the shared coordinates. I already said that, though.
@Sarpp-Daltabann said:
3) How do we apply the term "average" on computing the normals?
How do you think you would average them? How do you average anything? Add them all together and divide by the number.
@Sarpp-Daltabann said:
4) Is the class TangentBinormalGenerator.java applicable/capable for the purpose I have?
That generates tangents. You need normals. So, no. As I already said, there is no generally accurate solution for generating smooth normals because it depends on what the mesh is and where it comes from. Averaging is just an approximation that may work in some cases⌠and probably works in your case. I can tell you about a dozen examples where it will generate bad normals.
There is no general solution for generating normals.
For people with a little 3D graphics experience, itâs not difficult to do.
âŚso, JME does not include a utility for this.
@Sarpp-Daltabann said:
5) When we use
[java]mtrl = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");[/java]
instead of
[java]mtrl = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");[/java]
then we are not able to use
[java]mtrl.setBoolean("VertexColor", true);[/java]
It means that, we will only be able to determine the color of the material, but not to attach a colorRGBA value per vertice. Not only color but also the transparency will be applicable per material instead of per vertice.
@Sarpp-Daltabann said:
6) When the other steps are done and normals are calculated well, will a spere like mesh(or the output views above), that is constituted by corners in essence, look like smooth?
Yes. Spheres are one shape where averaging the triangle normals works fine.
Cant you propose any method or way to do this? There is not a solid example to observe deeply to understand mesh smoothing concept in jme3. Can anyone upload a tutorial kinda example like TestCustomMesh.java?
@Sarpp-Daltabann said:
Cant you propose any method or way to do this? There is not a solid example to observe deeply to understand mesh smoothing concept in jme3. Can anyone upload a tutorial kinda example like TestCustomMesh.java?
This isnât jMonkey-specific, not even 3D specific, its simple vector math.