best way to compute vertex normals from a Triangle's list
Posted
by
nkint
on Game Development
See other posts from Game Development
or by nkint
Published on 2011-02-10T23:00:22Z
Indexed on
2011/02/10
23:34 UTC
Read the original article
Hit count: 379
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.
i have a Surface object with inside a Triangle's list. For now 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).computeFaceNormals()
surface.addTriangle(t)
and i think this is the best way to do that.. isn't it?
now.. what about for vertex normals? 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?
© Game Development or respective owner