00001 /*****************************************************************************
00002 * SGL: A Scene Graph Library
00003 *
00004 * Copyright (C) 1997-2001 Scott McMillan All Rights Reserved.
00005 *
00006 * This library is free software; you can redistribute it and/or
00007 * modify it under the terms of the GNU Library General Public
00008 * License as published by the Free Software Foundation; either
00009 * version 2 of the License, or (at your option) any later version.
00010 *
00011 * This library is distributed in the hope that it will be useful,
00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00014 * Library General Public License for more details.
00015 *
00016 * You should have received a copy of the GNU Library General Public
00017 * License along with this library; if not, write to the Free
00018 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00019 *****************************************************************************
00020 * File: sglu.h
00021 * Created: 11 November 1998
00022 * Summary: SGL Utility library...miscellaneous objects and functions.
00023 *****************************************************************************/
00024
00025 #ifndef __SGLU_H
00026 #define __SGLU_H
00027
00028 #if defined(WIN32) && defined(_DLL)
00029 // The next define will come from the makefile for archive objects.
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
1.2.6 written by Dimitri van Heesch,
© 1997-2001