I have a procedurally generated cube and the vertices for the top face are
pt1 = [-1,-1,1]
pt2 = [1,-1,1]
pt3 = [1,1,1]
pt4 = [-1,1,1]
I add the vertices and normals like this:
vertex.addData3f(*pt1)
vertex.addData3f(*pt2)
vertex.addData3f(*pt3)
vertex.addData3f(*pt4)
normal.addData3f(Vec3(2 * pt1[0] - 1, 2 * pt1[1] - 1, 2 * pt1[2] - 1))
normal.addData3f(Vec3(2 * pt2[0] - 1, 2 * pt2[1] - 1, 2 * pt2[2] - 1))
normal.addData3f(Vec3(2 * pt3[0] - 1, 2 * pt3[1] - 1, 2 * pt3[2] - 1))
normal.addData3f(Vec3(2 * pt4[0] - 1, 2 * pt4[1] - 1, 2 * pt4[2] - 1))
The lighting doesn’t work quite right when I play around with it using .place().
My suspicion was that it was because of the normal calculations. What is the right way to do this?