From 183f0f0b905715f0d89b38174fdfd44641c1a79c Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Wed, 12 Aug 2009 12:03:18 +0000 Subject: src/model filenames cleanup, parse .map texture coordinates, early loading of material textures --- src/model/face.cc | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 src/model/face.cc (limited to 'src/model/face.cc') diff --git a/src/model/face.cc b/src/model/face.cc new file mode 100644 index 0000000..c6c3269 --- /dev/null +++ b/src/model/face.cc @@ -0,0 +1,43 @@ +/* + model/face.cc + This file is part of the Osirion project and is distributed under + the terms of the GNU General Public License version 2 +*/ + +#include + +#include "model/face.h" + +namespace model +{ + +using math::Vector3f; +/* + * all points p(x, y, z) on the plane satisfy the general equation + * x*a() + y*b() + z*c() + d() = 0 + */ + +Face::Face(Vector3f const & point0, Vector3f const &point1, Vector3f const &point2) +{ + face_detail = false; + face_surface_flags = 0; + face_material = 0; + + face_point[0] = point0; + face_point[1] = point1; + face_point[2] = point2; + + face_normal = crossproduct((face_point[1] - face_point[0]) , (face_point[2] - face_point[0])); + pd = -1 * (face_normal.x * face_point[0].x + face_normal.y * face_point[0].y + face_normal.z * face_point[0].z); +} + +Face::Face(Face const & other) +{ + for (size_t i=0; i < 3; i++) + this->face_point[i] = other.face_point[i]; + + face_normal = crossproduct((face_point[1] - face_point[0]) , (face_point[2] - face_point[0])); + pd = -1 * (face_normal.x * face_point[0].x + face_normal.y * face_point[0].y + face_normal.z * face_point[0].z); +} + +} -- cgit v1.2.3