Author Topic: 3ds model with flat surfaces?  (Read 2901 times)

Offline Uwe Siems

  • byte
  • *
  • Posts: 5
    • View Profile
3ds model with flat surfaces?
« on: August 10, 2011, 09:14:20 pm »
I'm currently using a simple textured cube exported from Blender (2.58a) to 3ds to render a sample scene. But when two cubes are rendered side by side there is a clear light intensity step between them, probably because each vertex has only one normal vector that is shared between the faces. So the cube is lighted more like a sphere than a cube. I already have split the cube in Blender to not share the vertices between faces, but the appearance stays the same. Only if I separate the edges a little bit the faces look shaded correctly, but of course I don't want the gaps.

I assume that the vertex sharing of jPCT gets in the way here. Is there a way around this? I also read in the description of the 3ds format that faces can belong to "smoothing groups". I assume that faces not sharing any smoothing group should have a sharp edge between them. Does jPCT support this feature? (But I don't even know if the export filter of Blender uses this feature.)

Regards,
Uwe

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: 3ds model with flat surfaces?
« Reply #1 on: August 10, 2011, 09:31:47 pm »
It's not so much about the vertex sharing...you can disable that. But that won't help as jPCT calculates the vertex normals based on adjacent polygons. That calculation is based on vertex positions in space only. It doesn't care if the positions it compares are from the same vertex or from two vertices that share the same position. What you can do is to provide your own normals by implementing an IVertexController, let it set the new normals once and remove it afterwards....it's a bit awkward though.

Offline Uwe Siems

  • byte
  • *
  • Posts: 5
    • View Profile
Re: 3ds model with flat surfaces?
« Reply #2 on: August 11, 2011, 03:28:54 pm »
I'm pondering if I should try to write my own 3ds loader. I noticed that Loader.load3DS currently uses Object3D.addTriangle to build the mesh, so I would assume that distinct vertices would be merged anyway. Instead I would rather use the Object3D constructor that allows to specify vertices and faces explicitly, create one Object3D for each used material and merge them afterwards with Object3D.mergeAll - provided that mergeAll doesn't do vertex sharing again. I might then calculate the normals from the vertex/face relation information available in the IVertexController. This would of course mean that you always get sharp edges between different materials, but I think that's ok.

By the way, does Object3D.mergeAll mean that normals are re-created, even if they have been generated before on all objects?

Regards,
Uwe

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: 3ds model with flat surfaces?
« Reply #3 on: August 11, 2011, 03:39:03 pm »
Merging also merges the normals. It doesn't recalculates them. Only build() and calcNormals() do this.