00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
#ifndef OPENCAL_TRIANGLE_H
00012
#define OPENCAL_TRIANGLE_H
00013
00014
00015
#include <OpenCAL/global.h>
00016
00017
#include <OpenCAL/Vector3.h>
00018
using OpenCAL::Utils::Vector3;
00019
#include <OpenCAL/Material.h>
00020
using OpenCAL::Utils::Material;
00021
#include <OpenCAL/Texture.h>
00022
using OpenCAL::Utils::Texture;
00023
00024
00025
namespace OpenCAL
00026 {
00027
00028
class Vertex;
00029
00033 class OPENCAL_API Triangle
00034 {
00035
protected:
00036
00037
Vertex *m_vertices[3];
00038 Vector3 m_normal;
00039
bool m_normalValid;
00040 Material *m_material;
00041
00042
public:
00043
00044
00045 Triangle(
Vertex *a,
Vertex *b,
Vertex *c);
00046
virtual ~Triangle();
00047
00048
00049
Vertex *getVertex(
unsigned int i) {
return m_vertices[i]; }
00050
const Vertex *getVertex(
unsigned int i)
const {
return m_vertices[i]; }
00051
const Vector3 &getNormal();
00052
bool isNormalValid()
const {
return m_normalValid; }
00053
const Material *getMaterial()
const {
return m_material; }
00054 Material *getMaterial() {
return m_material; }
00055
bool hasMaterial()
const {
return (m_material != 0); }
00056
00057
00058
void setMaterial(Material *material) { m_material = material; }
00059
00060
00061
void invalidateNormal() { m_normalValid =
false; }
00062
void calculateNormal();
00063
float getArea()
const;
00064 Vector3 getMidpoint()
const;
00065 };
00066 }
00067
00068
#endif // OPENCAL_TRIANGLE_H