-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathface.go
46 lines (38 loc) · 1.03 KB
/
face.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package three
// Face stores indices to vertices and normals.
type Face struct {
vertexIndices [3]uint16
normalIndices [3]uint16
}
// NewFace returns a new triangle face.
func NewFace(a, b, c uint16) *Face {
return &Face{
vertexIndices: [3]uint16{a, b, c},
}
}
// At returns the vertex index stored at the given position.
func (f *Face) At(i int) uint16 {
return f.vertexIndices[i]
}
// NormalAt returns the normal index stored at the given position
func (f *Face) NormalAt(i int) uint16 {
return f.normalIndices[i]
}
// A returns the index of the first vertex in the triangle.
func (f *Face) A() uint16 {
return f.vertexIndices[0]
}
// B returns the index of the second vertex in the triangle.
func (f *Face) B() uint16 {
return f.vertexIndices[1]
}
// C returns the index of the third vertex in the triangle.
func (f *Face) C() uint16 {
return f.vertexIndices[2]
}
// AddNormal adds normal indices for this face.
func (f *Face) AddNormal(x, y, z uint16) {
f.normalIndices[0] = x
f.normalIndices[1] = y
f.normalIndices[2] = z
}