00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef __SGLU_H
00026 #define __SGLU_H
00027
00028 #if defined(WIN32) && defined(_DLL)
00029
00030 #ifdef sglu_DLL_FILE
00031 #define SGLU_DLL_API __declspec(dllexport)
00032 #else
00033 #define SGLU_DLL_API __declspec(dllimport)
00034 #endif
00035 #else
00036 #define SGLU_DLL_API
00037 #endif
00038
00039 #include <sgl.h>
00040 #include <sglNode.hpp>
00041
00042
00043 inline void cross(float a[3], float b[3], float c[3])
00044 {
00045 c[0] = a[1]*b[2] - a[2]*b[1];
00046 c[1] = a[2]*b[0] - a[0]*b[2];
00047 c[2] = a[0]*b[1] - a[1]*b[0];
00048 }
00049
00050
00051 inline float normalize(float v[3])
00052 {
00053 float norm = sqrt(v[0]*v[0] + v[1]*v[1] + v[2]*v[2]);
00054
00055 if (norm > 0.0)
00056 {
00057 v[0] /= norm;
00058 v[1] /= norm;
00059 v[2] /= norm;
00060 }
00061
00062 return norm;
00063 }
00064
00065
00066 inline void compute_face_normal(float v0[3], float v1[3], float v2[3],
00067 float normal[3])
00068 {
00069 float a[3], b[3];
00070 register int i;
00071
00072 for (i=0; i<3; i++)
00073 {
00074 a[i] = v1[i] - v0[i];
00075 b[i] = v2[i] - v0[i];
00076 }
00077
00078 cross(a, b, normal);
00079 normalize(normal);
00080
00081 }
00082
00083
00084
00085 SGLU_DLL_API void sgluOutputTree(sglNode *root,
00086 ostream &ostrm,
00087 unsigned int indent_spaces);
00088 SGLU_DLL_API void sgluOutputPath(sglNode *end_point,
00089 ostream &ostrm,
00090 unsigned int indent_spaces);
00091
00097 SGLU_DLL_API void sgluBindTextures(sglNode *root);
00098
00107 SGLU_DLL_API sglObject *sgluFindObject(const string &name, sglObject *root);
00108
00109 #endif