Rendering flat surface without smoothing the edge

Started by imiyar, May 04, 2017, 11:29:43 PM

Previous topic - Next topic

imiyar

Hi again,

I want to load a model of a building which has a lot of hard edges, and it looks very weird because all the edges are smoothed. Is there a way to call the build() method without calling calcNormals()? I also checked the IVertexController class, but I don't know how to use it... Is there any example code for IVertexController?

I attached an image of my building model with this post.

SonicBurst2

hi...
You can use  "yourObject3D.setShadingMode(Object3D.SHADING_FAKED_FLAT);"

imiyar

Quote from: SonicBurst2 on May 05, 2017, 12:52:32 AM
hi...
You can use  "yourObject3D.setShadingMode(Object3D.SHADING_FAKED_FLAT);"

Thank you so much!!

EgonOlsen

Not sure if that's the best solution. The best way would be to store the normals in the 3d file (has to be OBJ in that case) and set Config.useNormalsFromOBJ=true before loading the model. That will make jPCT-AE skip the internal normal calculations and use normals from the file.

imiyar

Quote from: EgonOlsen on May 05, 2017, 08:25:10 AM
Not sure if that's the best solution. The best way would be to store the normals in the 3d file (has to be OBJ in that case) and set Config.useNormalsFromOBJ=true before loading the model. That will make jPCT-AE skip the internal normal calculations and use normals from the file.

Yeah actually I set the shading mode to be FAKE_FLAT but it somehow doesn't work... But Config.useNormalsFromOBJ=true works very well. Thanks!!

imiyar

Well, I solved this flat rendering problem, and now I have another weird thing... I attached some screenshots here. The cube and the cone on the right side are rendered correctly, but the building was extremely bright. And if I move the camera, I can see a weird "shadow line" moving with my camera (see the image below). Can't understand why this happened. Any clues?





EgonOlsen

That's caused by the normals as they are defined in the file now. Have you played around a little with the light source's position? Maybe it's location isn't optimal...or maybe the normals aren't.