-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVertex.cpp
More file actions
46 lines (41 loc) · 900 Bytes
/
Vertex.cpp
File metadata and controls
46 lines (41 loc) · 900 Bytes
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
#include "Vertex.hpp"
#include <string.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdio.h>
Vertex::Vertex(vector_t *_vertex, vector_t *_texcoord, vector_t *_normal)
{
vertex = _vertex;
texcoord = _texcoord;
normal = _normal;
}
Vertex::~Vertex()
{
}
Vertex::vector_t Vertex::parseObjLine(char* line)
{
char *word = strtok( line, " " );
uint8_t index = 0;
// make default vector_t
Vertex::vector_t ret;
ret.x = 0;
ret.y = 0;
ret.z = 0;
ret.w = 1;
float *iterator = (float*)&ret;
while ( word ) {
*iterator = atof(word);
if ( ++index>=3 ) // currently not supporting additional numbers
break;
// on to the next one
iterator+=1;
word = strtok( NULL, " " );
}
return ret;
}
bool Vertex::operator==(const Vertex &rhs)
{
return this->vertex==rhs.vertex &&
this->texcoord==rhs.texcoord &&
this->normal==rhs.normal;
}