Can anyone explain the instructions, in an order, to have a smooth mesh?

@pspeed said: None of us can see the picture because it's on your desktop. You need to upload it somewhere like imgur for us to be able to see it.

I have seen your perfect Animated Marching Cubes video on the page

http://hub.jmonkeyengine.org/forum/topic/march-2014-monthly-wip-screenshot-thread/page/3/#post-264510

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.

1 Like
@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:

  1. First part is calculating the normals so that the normal of a vertex is the average of the normals of the faces.
  2. ?
  3. ?
  4. ?
    .
    .
    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 :

  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.

1 Like
@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.

  1. 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?

  2. Do we calculate the normals per coordinate or per triangular face?

  3. How do we apply the term “average” on computing the normals?

  4. Is the class TangentBinormalGenerator.java applicable/capable for the purpose I have?

  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.

  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?

Thank you for providing a better point of view(big picture) and guidance, let me have your kind response at your earliest convenience.

@Sarpp-Daltabann said: Then probably I calculate the normals of the faces or vertices wrong. I have unfortunately additional questions.
  1. 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?

There are about a hundred articles on google on this very subject that go into way more detail than we could:
https://www.google.com/search?q=calculating+vertex+normals

Short answer: cross product

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.

  1. There is no general solution for generating normals.
  2. 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.

Have you looked at the documentation at all? https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:advanced:materials_overview

Short answer: lighting can also do vertex colors.

@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.

1 Like

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.

http://hub.jmonkeyengine.org/forum/topic/there-is-a-normal-calculation-for-mesh-from-class-asetojme-java/#post-279627