2
* $Id: RAS_TexVert.cpp,v 1.4 2004/03/22 22:02:13 jesterking Exp $
2
* $Id: RAS_TexVert.cpp,v 1.9 2005/01/03 18:05:24 sirdude Exp $
3
3
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
5
5
* This program is free software; you can redistribute it and/or
35
35
#include <config.h>
38
#define SHORT(x) short(x*32767.0)
38
40
RAS_TexVert::RAS_TexVert(const MT_Point3& xyz,
39
41
const MT_Point2& uv,
40
42
const unsigned int rgba,
43
const MT_Vector3& normal,
44
46
xyz.getValue(m_localxyz);
45
47
uv.getValue(m_uv1);
47
m_normal[0] = normal[0];
48
m_normal[1] = normal[1];
49
m_normal[2] = normal[2];
57
53
const MT_Point3& RAS_TexVert::xyz()
59
55
g_pt3.setValue(m_localxyz);
59
void RAS_TexVert::SetRGBA(const MT_Vector4& rgba)
61
unsigned char *colp = (unsigned char*) &m_rgba;
62
colp[0] = (unsigned char) (rgba[0]*255.0);
63
colp[1] = (unsigned char) (rgba[1]*255.0);
64
colp[2] = (unsigned char) (rgba[2]*255.0);
65
colp[3] = (unsigned char) (rgba[3]*255.0);
63
69
void RAS_TexVert::SetXYZ(const MT_Point3& xyz)
65
71
xyz.getValue(m_localxyz);
87
93
void RAS_TexVert::SetNormal(const MT_Vector3& normal)
89
m_normal[0] = short(normal.x()*32767.0);
90
m_normal[1] = short(normal.y()*32767.0);
91
m_normal[2] = short(normal.z()*32767.0);
95
normal.getValue(m_normal);
95
98
#ifndef RAS_TexVert_INLINE
96
100
// leave multiline for debugging
97
101
const float* RAS_TexVert::getUV1 () const
103
const short* RAS_TexVert::getNormal() const
107
const float* RAS_TexVert::getNormal() const
110
112
const float* RAS_TexVert::getLocalXYZ() const
112
114
return m_localxyz;
117
const unsigned int& RAS_TexVert::getRGBA() const
117
const unsigned char* RAS_TexVert::getRGBA() const
119
return (unsigned char*) &m_rgba;
124
124
// compare two vertices, and return TRUE if both are almost identical (they can be shared)
125
125
bool RAS_TexVert::closeTo(const RAS_TexVert* other)
127
return ((MT_Vector3(m_localxyz) - MT_Vector3(other->m_localxyz)).fuzzyZero() &&
128
(MT_Vector2(m_uv1) - MT_Vector2(other->m_uv1)).fuzzyZero() &&
129
m_normal[0] == other->m_normal[0] &&
130
m_normal[1] == other->m_normal[1] &&
131
m_normal[2] == other->m_normal[2] &&
132
m_flag == other->m_flag &&
133
m_rgba == other->m_rgba) ;
127
return (m_flag == other->m_flag &&
128
m_rgba == other->m_rgba &&
129
MT_fuzzyEqual(MT_Vector3(m_normal), MT_Vector3(other->m_normal)) &&
130
MT_fuzzyEqual(MT_Vector2(m_uv1), MT_Vector2(other->m_uv1)) &&
131
MT_fuzzyEqual(MT_Vector3(m_localxyz), MT_Vector3(other->m_localxyz))) ;
139
bool RAS_TexVert::closeTo(const MT_Point3& otherxyz,
140
const MT_Point2& otheruv,
141
const unsigned int otherrgba,
142
short othernormal[3]) const
144
return ((MT_Vector3(m_localxyz) - otherxyz).fuzzyZero() &&
145
(MT_Vector2(m_uv1) - otheruv).fuzzyZero() &&
146
m_normal[0] == othernormal[0] &&
147
m_normal[1] == othernormal[1] &&
148
m_normal[2] == othernormal[2] &&
149
m_rgba == otherrgba) ;
153
135
short RAS_TexVert::getFlag() const