hi i'm a complete newbie in computergraphics so sorry if it's a stupid answer. i'm trying to make a simple 3d engine from scratch, more for educational purpose than for real use.
for now i compute only face normals. in this way:
i have a Surface object with inside a Triangle's list. i compute normals inside Triangle class, in this way:
triangle.computeFaceNormals() {
Vec3D u = v1.sub(v3)
Vec3D v = v1.sub(v2)
Vec3D normal = Vec3D.cross(u,v)
normal.normalized()
this.n1 = this.n2 = this.n3 = normal
}
and when building surface:
t = new Triangle(v1,v2,v3)
t.computeFaceNormals()
surface.addTriangle(t)
and i think this is the best way to do that.. isn't it?
now.. this works, ok. but light it's not smoothed. i'm trying to compute also vertex normals. (i'm testing my engine with tubolar surfaces so i have almost all vertex shared with more then one triangles)
i've found this simple algorithm: flipcode vertex normal but.. hei this algorithm has.. exponential complexity? (if my memory doesn't fail my computer science background..) (bytheway.. it has 3 nested loops.. i don't think it's the best way to do it..)
any suggestion?
t
is the result ofcomputeFaceNormals
(which returns nothing), not a triangle. \$\endgroup\$