diff options
Diffstat (limited to 'debian/fireflies/fireflies-2.08/libgfx/include')
31 files changed, 3271 insertions, 0 deletions
diff --git a/debian/fireflies/fireflies-2.08/libgfx/include/gfx/arcball.h b/debian/fireflies/fireflies-2.08/libgfx/include/gfx/arcball.h new file mode 100644 index 00000000..3b1ff00e --- /dev/null +++ b/debian/fireflies/fireflies-2.08/libgfx/include/gfx/arcball.h @@ -0,0 +1,55 @@ +#ifndef GFXARCBALL_INCLUDED // -*- C++ -*- +#define GFXARCBALL_INCLUDED +#if !defined(__GNUC__) +# pragma once +#endif + +/************************************************************************ + + Arcball rotation control. + + $Id: arcball.h 427 2004-09-27 04:45:31Z garland $ + + ************************************************************************/ + +#include "baseball.h" + +namespace gfx +{ + +class Arcball : public Baseball +{ +private: + Vec2 ball_ctr; + double ball_radius; + + Quat q_now, q_down, q_drag; // Quaternions describing rotation + Vec3 v_from, v_to; // + + bool is_dragging; + +protected: + Vec3 proj_to_sphere(const Vec2&); + void update(); + + +public: + Arcball(); + + virtual void update_animation(); + virtual bool mouse_down(int *where, int which); + virtual bool mouse_up(int *where, int which); + virtual bool mouse_drag(int *where, int *last, int which); + + virtual void apply_transform(); + virtual void get_transform(Vec3 & c, Vec3 &t, Quat & q); + virtual void set_transform(const Vec3 & c, const Vec3 & t, const Quat & q); + + virtual void write(std::ostream&); + virtual void read(std::istream&); +}; + +} // namespace gfx + +// GFXARCBALL_INCLUDED +#endif diff --git a/debian/fireflies/fireflies-2.08/libgfx/include/gfx/array.h b/debian/fireflies/fireflies-2.08/libgfx/include/gfx/array.h new file mode 100644 index 00000000..66189e4b --- /dev/null +++ b/debian/fireflies/fireflies-2.08/libgfx/include/gfx/array.h @@ -0,0 +1,70 @@ +#ifndef GFXARRAY_INCLUDED // -*- C++ -*- +#define GFXARRAY_INCLUDED +#if !defined(__GNUC__) +# pragma once +#endif + +/************************************************************************ + + These array classes extend the STL vector<> template to provide + convenient 2-D and 3-D arrays. + + NOTE: This package used to provide array<T> and varray<T> templates + that were alternatives to the STL vector<T> template. Its purpose was + to support some legacy code written in the days when few compilers + understood STL. Now that STL support is common, that code has been + removed. + + $Id: array.h 427 2004-09-27 04:45:31Z garland $ + + ************************************************************************/ + +#include "gfx.h" +#include <vector> + +namespace gfx +{ + +template<class T> +class array2 : public std::vector<T> +{ +private: + int W, H; + +protected: + array2() { } + +public: + array2(int w, int h) : std::vector<T>(w*h), W(w), H(h) { } + + T& operator()(int i, int j) { return (*this)[j*W+i]; } + const T& operator()(int i, int j) const { return (*this)[j*W+i]; } + + int width() const { return W; } + int height() const { return H; } +}; + +template<class T> +class array3 : public std::vector<T> +{ +private: + int W, H, D; + +protected: + array3() { } + +public: + array3(int w, int h, int d) : std::vector<T>(w*h*d), W(w), H(h), D(d) { } + + T& operator()(int i, int j, int k) { return (*this)[k*W*H + j*W+i]; } + const T& operator()(int i,int j,int k) const {return (*this)[k*W*H+j*W+i];} + + int width() const { return W; } + int height() const { return H; } + int depth() const { return D; } +}; + +} // namespace gfx + +// GFXARRAY_INCLUDED +#endif diff --git a/debian/fireflies/fireflies-2.08/libgfx/include/gfx/baseball.h b/debian/fireflies/fireflies-2.08/libgfx/include/gfx/baseball.h new file mode 100644 index 00000000..6e10d647 --- /dev/null +++ b/debian/fireflies/fireflies-2.08/libgfx/include/gfx/baseball.h @@ -0,0 +1,55 @@ +#ifndef GFXBASEBALL_INCLUDED // -*- C++ -*- +#define GFXBASEBALL_INCLUDED +#if !defined(__GNUC__) +# pragma once +#endif + +/************************************************************************ + + Common base class for ball-based rotators (e.g., Trackball & Arcball). + + $Id: baseball.h 443 2005-06-14 00:53:40Z garland $ + + ************************************************************************/ + +#include "quat.h" + +namespace gfx +{ + +class Baseball +{ +public: + Vec3 ctr; // Describes bounding sphere of object + double radius; // + + Quat curquat; // Current rotation of object + Vec3 trans; // Current translation of object + +public: + Baseball(); + virtual ~Baseball() {} + + // Required initialization method + template<class T> + void bounding_sphere(const TVec3<T>& v, T r) { ctr=v; radius=r; } + + // Standard event interface provide by all Ball controllers + virtual void update_animation() = 0; + virtual bool mouse_down(int *where, int which) = 0; + virtual bool mouse_up(int *where, int which) = 0; + virtual bool mouse_drag(int *where, int *last, int which) = 0; + + // Interface for use during drawing to apply appropriate transformation + virtual void apply_transform(); + virtual void unapply_transform(); + + // Interface for reading/writing transform + virtual void write(std::ostream&); + virtual void read(std::istream&); +}; + +} // namespace gfx + +// GFXBASEBALL_INCLUDED +#endif diff --git a/debian/fireflies/fireflies-2.08/libgfx/include/gfx/color.h b/debian/fireflies/fireflies-2.08/libgfx/include/gfx/color.h new file mode 100644 index 00000000..6b86e6e6 --- /dev/null +++ b/debian/fireflies/fireflies-2.08/libgfx/include/gfx/color.h @@ -0,0 +1,48 @@ +#ifndef GFXCOLOR_INCLUDED // -*- C++ -*- +#define GFXCOLOR_INCLUDED +#if !defined(__GNUC__) +# pragma once +#endif + +/************************************************************************ + + Simple color manipulations + + $Id$ + + ************************************************************************/ + +#include "vec3.h" + +namespace gfx +{ + + // RGB colors have components R,G,B in [0,1] + typedef Vec3f rgbColor; + + // HSV colors should have components: + // H in [0,360] + // S in [0,1] + // V in [0,1] + typedef Vec3f hsvColor; + + typedef Vec3f yiqColor; + + typedef Vec3f xyzColor; + typedef Vec2f xyChromaticity; + + extern hsvColor RGBtoHSV(const rgbColor& rgb); + extern rgbColor HSVtoRGB(const hsvColor& hsv); + + extern float rgb_luminance_ntsc(const rgbColor& rgb); + extern float rgb_luminance_alt(const rgbColor& rgb); + + extern yiqColor RGBtoYIQ(const rgbColor& rgb); + + extern xyzColor RGBtoXYZ(const rgbColor& rgb); + extern rgbColor XYZtoRGB(const xyzColor& xyz); + extern xyChromaticity xyz_chromaticity(const xyzColor& xyz); +} + +// GFXCOLOR_INCLUDED +#endif diff --git a/debian/fireflies/fireflies-2.08/libgfx/include/gfx/config-osx.h b/debian/fireflies/fireflies-2.08/libgfx/include/gfx/config-osx.h new file mode 100644 index 00000000..b8081979 --- /dev/null +++ b/debian/fireflies/fireflies-2.08/libgfx/include/gfx/config-osx.h @@ -0,0 +1,86 @@ +/************************************************************************ + + Configuration header for Mac OS X. Manually derived from config.h + generated by autoconf on OS X Tiger (10.4). + + ************************************************************************/ + +/* Define this if your compiler doesn't support the new C++ 'bool' type */ +#define HAVE_BOOL 1 + +/* Define if your system supports rint() */ +#define HAVE_RINT 1 + +/* Define if your system supports getrusage() */ +#define HAVE_GETRUSAGE 1 + +/* Define if your system does not support getrusage() but supports times() */ +#define HAVE_TIMES 1 + +/* Define if your system supports random() as opposed to just rand() */ +/* #undef HAVE_RANDOM */ + +/* Define if the STL hash_map template is available */ +/* #undef HAVE_HASH_MAP */ + +/* Define if the STL hash_set template is available */ +/* #undef HAVE_HASH_SET */ + +/* GCC v3 puts hash_map and hash_set in an 'ext' directory */ +#define HAVE_EXT_HASH_MAP 1 +#define HAVE_EXT_HASH_SET 1 + +/* Define if the STL valarray template is available */ +#define HAVE_VALARRAY 1 + +/* Define if the ANSI standard <sstream> is available */ +#define HAVE_SSTREAM 1 + +/* Define if the pre-ANSI <strstream> is available */ +#define HAVE_STRSTREAM 1 + +/* Define if the gzstream library (a zlib wrapper) is available */ +/* #undef HAVE_GZSTREAM */ + +/* ***** GUI & Image configuration section ***** */ + +/* Define if the FLTK GUI toolkit is available */ +#define HAVE_FLTK 1 + +/* Define if FLTK OpenGL support is available */ +#define HAVE_FLTK_GL 1 + +/* Define if Sam Leffler's libtiff is available */ +#define HAVE_LIBTIFF 1 + +/* Define the libtiff LZW is available */ +/* #undef HAVE_LIBTIFF_LZW */ + +/* Define if libpng is available */ +#define HAVE_LIBPNG 1 + +/* Define if the Independent JPEG Group's libjpeg is available */ +#define HAVE_LIBJPEG 1 + +/* ***** OpenGL configuration section ***** */ + +/* Define to the name of OpenGL implementation (e.g., "OpenGL" or "Mesa") */ +#define HAVE_OPENGL "OpenGL" + +/* Define if glPolygonOffsetEXT is available */ +/* #undef HAVE_POLYOFFSET_EXT */ + +/* Define if glPolygonOffset is available */ +#define HAVE_POLYOFFSET 1 + +/* Define if <GL/glext.h> header is available */ +/* #undef HAVE_GL_GLEXT_H */ + +/* Define if <GL/glxext.h> header is available */ +/* #undef HAVE_GL_GLXEXT_H */ + +/* Define if <GL/wglext.h> header is available */ +/* #undef HAVE_GL_WGLEXT_H */ + +/* Define if <OpenGL/glext.h> header is available (for Apple) */ +#define HAVE_OPENGL_GLEXT_H 1 diff --git a/debian/fireflies/fireflies-2.08/libgfx/include/gfx/config-vc.h b/debian/fireflies/fireflies-2.08/libgfx/include/gfx/config-vc.h new file mode 100644 index 00000000..ed327937 --- /dev/null +++ b/debian/fireflies/fireflies-2.08/libgfx/include/gfx/config-vc.h @@ -0,0 +1,85 @@ +/************************************************************************ + + Visual C++ 5/6 configuration header. + Manually generated from config.h.in. + + ************************************************************************/ + +/* Define this if your compiler doesn't support the new C++ 'bool' type */ +#define HAVE_BOOL 1 + +/* Define if your system supports rint() */ +/* #define HAVE_RINT 1 */ + +/* Define if your system supports getrusage() */ +/* #undef HAVE_GETRUSAGE */ + +/* Define if your system does not support getrusage() but supports times() */ +/* #undef HAVE_TIMES */ + +/* Define if your system supports random() as opposed to just rand() */ +/* #undef HAVE_RANDOM */ + +/* Define if the STL hash_map template is available */ +/* #undef HAVE_HASH_MAP */ + +/* Define if the STL hash_set template is available */ +/*#undef HAVE_HASH_SET */ + +/* GCC v3 puts hash_map and hash_set in an 'ext' directory */ +/* #undef HAVE_EXT_HASH_MAP */ +/* #undef HAVE_EXT_HASH_SET */ + +/* Define if the STL valarray template is available */ +#define HAVE_VALARRAY 1 + +/* Define if the ANSI standard <sstream> is available */ +#define HAVE_SSTREAM 1 + +/* Define if the pre-ANSI <strstream> is available */ +/* #undef HAVE_STRSTREAM */ + +/* Define if the FLTK GUI toolkit is available */ +#define HAVE_FLTK 1 + +/* Define if FLTK OpenGL support is available */ +#define HAVE_FLTK_GL 1 + +/* Define if Sam Leffler's libtiff is available */ +#define HAVE_LIBTIFF 1 + +/* Define if libpng is available */ +#define HAVE_LIBPNG 1 + +/* Define if the Independent JPEG Group's libjpeg is available */ +#define HAVE_LIBJPEG 1 + +/* ***** OpenGL configuration section ***** */ + +/* Define to the name of OpenGL implementation (e.g., "OpenGL" or "Mesa") */ +#define HAVE_OPENGL "OpenGL" + +/* Define if glPolygonOffsetEXT is available */ +/* #undef HAVE_POLYOFFSET_EXT */ + +/* Define if glPolygonOffset is available */ +#define HAVE_POLYOFFSET 1 + +/* Define if <GL/glext.h> header is available */ +#define HAVE_GL_GLEXT_H 1 + +/* Define if <GL/glxext.h> header is available */ +/* #undef HAVE_GL_GLXEXT_H */ + +/* Define if <GL/wglext.h> header is available */ +#define HAVE_GL_WGLEXT_H 1 + +/* Visual C++ gets confused by too many casting and [] operators */ +#define HAVE_CASTING_LIMITS 1 + +#if defined(_DEBUG) && defined(_MSC_VER) +// STL makes Visual C++ complain about identifiers longer than 255 +// characters. Unfortunately, this may limit the debugability of +// code that uses STL. +#pragma warning (disable : 4786) +#endif diff --git a/debian/fireflies/fireflies-2.08/libgfx/include/gfx/config.h.in b/debian/fireflies/fireflies-2.08/libgfx/include/gfx/config.h.in new file mode 100644 index 00000000..0adb4ea7 --- /dev/null +++ b/debian/fireflies/fireflies-2.08/libgfx/include/gfx/config.h.in @@ -0,0 +1,81 @@ +/* This -*- C -*- file is meant to be processed by the configure script */ + +/* Define this if your compiler doesn't support the new C++ 'bool' type */ +#undef HAVE_BOOL + +/* Define if your system supports rint() */ +#undef HAVE_RINT + +/* Define if your system supports getrusage() */ +#undef HAVE_GETRUSAGE + +/* Define if your system does not support getrusage() but supports times() */ +#undef HAVE_TIMES + +/* Define if your system supports random() as opposed to just rand() */ +#undef HAVE_RANDOM + +/* Define if the STL hash_map template is available */ +#undef HAVE_HASH_MAP + +/* Define if the STL hash_set template is available */ +#undef HAVE_HASH_SET + +/* GCC v3 puts hash_map and hash_set in an 'ext' directory */ +#undef HAVE_EXT_HASH_MAP +#undef HAVE_EXT_HASH_SET + +/* Define if the STL valarray template is available */ +#undef HAVE_VALARRAY + +/* Define if the ANSI standard <sstream> is available */ +#undef HAVE_SSTREAM + +/* Define if the pre-ANSI <strstream> is available */ +#undef HAVE_STRSTREAM + +/* Define if the gzstream library (a zlib wrapper) is available */ +#undef HAVE_GZSTREAM + +/* ***** GUI & Image configuration section ***** */ + +/* Define if the FLTK GUI toolkit is available */ +#undef HAVE_FLTK + +/* Define if FLTK OpenGL support is available */ +#undef HAVE_FLTK_GL + +/* Define if Sam Leffler's libtiff is available */ +#undef HAVE_LIBTIFF + +/* Define the libtiff LZW is available */ +#undef HAVE_LIBTIFF_LZW + +/* Define if libpng is available */ +#undef HAVE_LIBPNG + +/* Define if the Independent JPEG Group's libjpeg is available */ +#undef HAVE_LIBJPEG + +/* ***** OpenGL configuration section ***** */ + +/* Define to the name of OpenGL implementation (e.g., "OpenGL" or "Mesa") */ +#undef HAVE_OPENGL + +/* Define if glPolygonOffsetEXT is available */ +#undef HAVE_POLYOFFSET_EXT + +/* Define if glPolygonOffset is available */ +#undef HAVE_POLYOFFSET + +/* Define if <GL/glext.h> header is available */ +#undef HAVE_GL_GLEXT_H + +/* Define if <GL/glxext.h> header is available */ +#undef HAVE_GL_GLXEXT_H + +/* Define if <GL/wglext.h> header is available */ +#undef HAVE_GL_WGLEXT_H + +/* Define if <OpenGL/glext.h> header is available (for Apple) */ +#undef HAVE_OPENGL_GLEXT_H diff --git a/debian/fireflies/fireflies-2.08/libgfx/include/gfx/geom3d.h b/debian/fireflies/fireflies-2.08/libgfx/include/gfx/geom3d.h new file mode 100644 index 00000000..817bb6f2 --- /dev/null +++ b/debian/fireflies/fireflies-2.08/libgfx/include/gfx/geom3d.h @@ -0,0 +1,133 @@ +#ifndef GFXGEOM3D_INCLUDED +#define GFXGEOM3D_INCLUDED +#if !defined(__GNUC__) +# pragma once +#endif + +/************************************************************************ + + Handy 3D geometrical primitives + + $Id: geom3d.h 432 2004-11-02 22:55:41Z garland $ + + ************************************************************************/ + +#include "vec3.h" + +namespace gfx +{ + +// +// Computing properties of triangles +// + +template<class Vec> +inline Vec triangle_raw_normal(const Vec& v1, const Vec& v2, const Vec& v3) +{ + return cross(v2-v1, v3-v1); +} + +template<class Vec> +inline typename Vec::value_type + triangle_area(const Vec& v1,const Vec& v2,const Vec& v3) +{ + return 0.5 * norm(triangle_raw_normal(v1, v2, v3)); +} + +template<class Vec> +inline Vec triangle_normal(const Vec& v1, const Vec& v2, const Vec& v3) +{ + Vec n = triangle_raw_normal(v1, v2, v3); + unitize(n); + return n; +} + +template<class Vec, class Plane> +inline Plane triangle_plane(const Vec& v1, const Vec& v2, const Vec& v3) +{ + Vec n = triangle_normal(v1, v2, v3); + return Plane(n, -(n*v1)); +} + +template<class Vec, class Plane> +inline Plane triangle_raw_plane(const Vec& v1, const Vec& v2, const Vec& v3) +{ + Vec n = triangle_raw_normal(v1, v2, v3); + return Plane(n, -(n*v1)); +} + +template< class Vec> +inline typename Vec::value_type + triangle_compactness(const Vec& v1, const Vec& v2, const Vec& v3) +{ + const double FOUR_ROOT3 = 6.928203230275509; + + return FOUR_ROOT3 * triangle_area(v1, v2, v3) / + ( norm2(v2 - v1) + norm2(v3 - v2) + norm2(v1 - v3) ); +} + +// +// Operations with axis-aligned bounding boxes +// + +template<class Vec, class List> +void update_bbox(Vec& min, Vec& max, const List& items) +{ + typedef typename List::const_iterator iterator; + + for(iterator i=items.begin(); i!=items.end(); i++) + { + const Vec& v = *i; + for(int j=0; j<Vec::dim(); j++) + { + if( v[j] < min[j] ) min[j] = v[j]; + if( v[j] > max[j] ) max[j] = v[j]; + } + } +} + +template<class Vec, class List> +void compute_bbox(Vec& min, Vec& max, const List& items) +{ + if( items.size()==0 ) min = max = 0; + else min = max = items[0]; + + update_bbox(min, max, items); +} + +template<class Vec> +bool is_inside_bbox(const Vec& p, const Vec& min, Vec& max) +{ + for(int i=0; i<Vec::dim(); i++) + if( p[i]<min[i] || p[i]>max[i] ) + return false; + + return true; +} + +template<class Vec> +Vec clamp_to_bbox(Vec p, const Vec& min, const Vec& max) +{ + for(int i=0; i<Vec::dim(); i++) + { + if (p[i]<min[i]) p[i]=min[i]; + else if (p[i]>max[i]) p[i]=max[i]; + } + + return p; +} + +// +// Computing properties of tetrahedra +// + +extern double tetrahedron_determinant(const Vec3& v0, const Vec3& v1, + const Vec3& v2, const Vec3& v3); + +extern double tetrahedron_volume(const Vec3& v0, const Vec3& v1, + const Vec3& v2, const Vec3& v3); + +} // namespace gfx + +// GFXGEOM3D_INCLUDED +#endif diff --git a/debian/fireflies/fireflies-2.08/libgfx/include/gfx/geom4d.h b/debian/fireflies/fireflies-2.08/libgfx/include/gfx/geom4d.h new file mode 100644 index 00000000..47007c02 --- /dev/null +++ b/debian/fireflies/fireflies-2.08/libgfx/include/gfx/geom4d.h @@ -0,0 +1,36 @@ +#ifndef GFXGEOM4D_INCLUDED +#define GFXGEOM4D_INCLUDED +#if !defined(__GNUC__) +# pragma once +#endif + +/************************************************************************ + + Handy 4D geometrical primitives + + $Id: geom4d.h 427 2004-09-27 04:45:31Z garland $ + + ************************************************************************/ + +namespace gfx +{ + +template<class Vec> +inline Vec tet_raw_normal(const Vec& v1, const Vec& v2, const Vec& v3, const Vec& v4) +{ + return cross(v2-v1, v3-v1, v4-v1); +} + + +template<class Vec> +inline Vec tet_normal(const Vec& v1, const Vec& v2, const Vec& v3, const Vec& v4) +{ + Vec n = tet_raw_normal(v1, v2, v3, v4); + unitize(n); + return n; +} + +} + +// GFXGEOM4D_INCLUDED +#endif diff --git a/debian/fireflies/fireflies-2.08/libgfx/include/gfx/gfx.h b/debian/fireflies/fireflies-2.08/libgfx/include/gfx/gfx.h new file mode 100644 index 00000000..69d5a0bd --- /dev/null +++ b/debian/fireflies/fireflies-2.08/libgfx/include/gfx/gfx.h @@ -0,0 +1,105 @@ +#ifndef GFX_INCLUDED // -*- C++ -*- +#define GFX_INCLUDED +#if !defined(__GNUC__) +# pragma once +#endif + +/************************************************************************ + + Main header file for the libgfx graphics library. + + $Id: gfx.h 455 2005-08-17 18:10:25Z garland $ + + ************************************************************************/ + +#if defined(HAVE_CONFIG_H) +# include "config.h" +#elif defined(_MSC_VER) +# include "config-vc.h" +#elif defined(__APPLE__) +# include "config-osx.h" +#endif + +#include <cstdlib> +#include <cmath> +#include <climits> +#include <iostream> + +//////////////////////////////////////////////////////////////////////// +// +// Standards notwithstanding, not all platforms define exactly the +// same things in their header files. We try to compensate here. +// + +#if !defined(HAVE_BOOL) +typedef int bool; +const bool false = 0; +const bool true = 1; +#endif + +// Microsoft doesn't define std::min() & std::max() because it conflicts with +// <windef.h>, and their _MIN/_MAX macro workarounds don't add the std:: +// namespace qualification. These macros provide a uniform way of getting +// around this problem. +// +#if defined(_MSC_VER) +# define MIN(a,b) std::_cpp_min(a,b) +# define MAX(a,b) std::_cpp_max(a,b) +#else +# if defined(__CYGWIN__) +# define NOMINMAX +# endif +# define MIN(a,b) std::min(a,b) +# define MAX(a,b) std::max(a,b) +#endif + +#ifndef M_PI +# define M_PI 3.14159265358979323846264338327950288419716939937510582097494459 +#endif + +#if !defined(HUGE) && defined(HUGE_VAL) +# define HUGE HUGE_VAL +#endif + +#if !defined(HAVE_RINT) +inline double rint(double x) { return floor(x + 0.5); } +#endif + +//////////////////////////////////////////////////////////////////////// +// +// +// +namespace gfx +{ + +#if defined(HAVE_RANDOM) + inline double random1() { return (double)random() / (double)LONG_MAX; } + inline char random_byte() { return (char)(random() & 0xff); } +#else + inline double random1() { return (double)rand() / (double)RAND_MAX; } + inline char random_byte() { return (char)(rand() & 0xff); } +#endif + +const double FEQ_EPS = 1e-6; +const double FEQ_EPS2 = 1e-12; + +inline bool FEQ(double a, double b, double e=FEQ_EPS) {return fabs(a-b)<e;} +inline bool FEQ2(double a, double b, double e=FEQ_EPS2) {return fabs(a-b)<e;} + + +//////////////////////////////////////////////////////////////////////// +// +// +// + +#define TIMING(t, cmd) { t=get_cpu_time(); cmd; t=get_cpu_time() - t; } +extern double get_cpu_time(); + +} // namespace gfx + +#ifndef GFX_NAMESPACE +using namespace gfx; +#endif + +// GFX_INCLUDED +#endif diff --git a/debian/fireflies/fireflies-2.08/libgfx/include/gfx/gl.h b/debian/fireflies/fireflies-2.08/libgfx/include/gfx/gl.h new file mode 100644 index 00000000..c8fe3bcb --- /dev/null +++ b/debian/fireflies/fireflies-2.08/libgfx/include/gfx/gl.h @@ -0,0 +1,32 @@ +#ifndef GFXGL_INCLUDED // -*- C++ -*- +#define GFXGL_INCLUDED +#if !defined(__GNUC__) +# pragma once +#endif + +/************************************************************************ + + Include standard OpenGL headers. This process is complicated by the + fact that the Win32 OpenGL headers require that <windows.h> be + included before they are. + + $Id: gl.h 292 2002-01-24 17:43:59Z garland $ + + ************************************************************************/ + +#include "gfx.h" + +#if defined(WIN32) +# include <windows.h> +#endif + +#if defined(__APPLE__) +# include <OpenGL/gl.h> +# include <OpenGL/glu.h> +#else +# include <GL/gl.h> +# include <GL/glu.h> +#endif + +// GFXGL_INCLUDED +#endif diff --git a/debian/fireflies/fireflies-2.08/libgfx/include/gfx/glext.h b/debian/fireflies/fireflies-2.08/libgfx/include/gfx/glext.h new file mode 100644 index 00000000..c5c99ca1 --- /dev/null +++ b/debian/fireflies/fireflies-2.08/libgfx/include/gfx/glext.h @@ -0,0 +1,30 @@ +#ifndef GFXGLEXT_INCLUDED // -*- C++ -*- +#define GFXGLEXT_INCLUDED +#if !defined(__GNUC__) +# pragma once +#endif + +/************************************************************************ + + Include the standard OpenGL Extension headers, if available. + + $Id: glext.h 273 2001-10-15 16:57:23Z garland $ + + ************************************************************************/ + +#include "gl.h" + +#if defined(HAVE_GL_GLEXT_H) +# include <GL/glext.h> +#endif + +#if defined(HAVE_GL_GLXEXT_H) +# include <GL/glxext.h> +#endif + +#if defined(HAVE_GL_WGLEXT_H) +# include <GL/wglext.h> +#endif + +// GFXGLEXT_INCLUDED +#endif diff --git a/debian/fireflies/fireflies-2.08/libgfx/include/gfx/gltools.h b/debian/fireflies/fireflies-2.08/libgfx/include/gfx/gltools.h new file mode 100644 index 00000000..a5422f9e --- /dev/null +++ b/debian/fireflies/fireflies-2.08/libgfx/include/gfx/gltools.h @@ -0,0 +1,37 @@ +#ifndef GFXGLTOOLS_INCLUDED // -*- C++ -*- +#define GFXGLTOOLS_INCLUDED +#if !defined(__GNUC__) +# pragma once +#endif + +/************************************************************************ + + Handy functions for common OpenGL tasks + + $Id: gltools.h 445 2005-06-18 02:40:45Z garland $ + + ************************************************************************/ + +#include "gl.h" +#include "vec3.h" + +namespace gfx +{ + +extern GLuint opengl_pick_nil; +extern GLuint opengl_pick_zmax; + +extern void begin_opengl_pick(int *ctr, double radius, GLuint *buf, int size); +extern GLuint complete_opengl_pick(GLuint *buffer); + +extern void check_opengl_errors(const char *msg=NULL); + +extern void camera_lookat(const Vec3& min, const Vec3& max, double aspect); +extern void ortho_camera_lookat(const Vec3& min, const Vec3& max,double aspect); + +extern int unproject_pixel(int *pixel, double *world, double z=0.0); + +} + +// GFXGLTOOLS_INCLUDED +#endif diff --git a/debian/fireflies/fireflies-2.08/libgfx/include/gfx/gui.h b/debian/fireflies/fireflies-2.08/libgfx/include/gfx/gui.h new file mode 100644 index 00000000..da8285ac --- /dev/null +++ b/debian/fireflies/fireflies-2.08/libgfx/include/gfx/gui.h @@ -0,0 +1,186 @@ +#ifndef GFXGUI_INCLUDED // -*- C++ -*- +#define GFXGUI_INCLUDED +#if !defined(__GNUC__) +# pragma once +#endif + +/************************************************************************ + + Minimalist GUI framework. + + This package implements a baseline GUI framework for use in + GFX-based applications. Only a very specific kind of interface is + supported: one where the application window consists primarily of an + OpenGL drawing canvas. + + $Id: gui.h 443 2005-06-14 00:53:40Z garland $ + + ************************************************************************/ + +#include "gl.h" + +#include <FL/Fl.H> +#include <FL/Fl_Window.H> +#include <FL/Fl_Menu_Bar.H> +#include <FL/Fl_Gl_Window.H> +#include <FL/Fl_Output.H> + +namespace gfx +{ + +class MxGUI; + +class MxGLCanvas : public Fl_Gl_Window +{ +private: + int last_click[2]; + MxGUI *app; + +public: + // Override selected FLTK window methods + // + virtual void draw(); + virtual int handle(int event); + virtual void resize(int x, int y, int w, int h); + +public: + MxGLCanvas(int x, int y, int w, int h, const char *label=NULL); + void attach_app(MxGUI *a); +}; + +class MxGUI +{ +private: + int w_offset, h_offset; + Fl_Window *create_window(int xw=640, int yw=480, int pad=5); + +public: + // This is the public interface of MxGUI available to the application. + // + Fl_Window *toplevel; + MxGLCanvas *canvas; + Fl_Output *status_line; + Fl_Menu_Bar *menu_bar; + Fl_Menu_Item *menu_layout; + float default_fps, target_fps; + + static MxGUI *current; // There should only be one. + + MxGUI(); + virtual ~MxGUI() {} + + virtual void initialize(int argc, char **argv, + Fl_Menu_Item *layout=NULL, + int xw=640, int yw=480); + virtual int run(); + + int status(const char *fmt, ...); + void animate(bool will); + bool snapshot_to_file(int format, const char *filenamep=NULL); + void resize_canvas(int width, int height); + void lock_size(); + void unlock_size(); + + void title(const char *l) { toplevel->label(l); } + + // Menu construction and standard callbacks + int add_menu(const std::string&, int key, Fl_Callback *cb, int flags=0); + int add_toggle_menu(const std::string&, int key, bool& val, int flags=0); + static void cb_toggle(Fl_Menu_ *m, bool *flag); + +public: + // + // Callback functions that get executed in response to menu commands. + virtual void cb_new(); + virtual void cb_exit(); + virtual void cb_snapshot(int); + virtual void cb_animate(Fl_Menu_ *m); + virtual void cb_fps(); + virtual void cb_vga_size(int width); // uses 4:3 aspect ratio + virtual void cb_hdtv_size(int width); // uses 16:9 aspect ratio + virtual void cb_dv_size(int width); // uses 3:2 aspect ratio + + virtual void cb_save_view_to_file(); + virtual void cb_load_view_from_file(); + virtual bool save_view_to_file(); + virtual bool load_view_from_file(); + +public: + // + // Applications are customized by overriding the following methods. + + // Override these methods to control the contents of the GL canvas + virtual void setup_for_drawing(); + virtual void draw_contents(); + virtual void update_animation(); + + // Override these methods to receive events from the GL canvas + virtual bool mouse_down(int *where, int which); + virtual bool mouse_up(int *where, int which); + virtual bool mouse_drag(int *where, int *last, int which); + virtual bool key_press(int key); + + // Override these methods to get command line arguments + virtual int cmdline_option(int argc, char **argv, int& index); + virtual void cmdline_file(const char *file); + + // Override these methods to add custom interface elements + virtual void add_upper_controls(int& yfill, const int pad) {} + virtual void add_lower_controls(int& yfill, const int pad) {} + + // Override this method to free memory, close files, etc. + virtual void cleanup_for_exit() {} +}; + +//////////////////////////////////////////////////////////////////////// +// +// This template makes it easier to create FLTK-compliant callbacks. +// In particular, its purpose is to construct static thunks for +// calling member functions of MxGUI-derived classes. +// + +template<class Gui> +struct MxBinder +{ + typedef void (Gui::*GuiCommand)(); + typedef void (Gui::*GuiCommand1)(int); + typedef void (Gui::*GuiCommand2)(Fl_Menu_ *); + + template<GuiCommand cmd> + static void to(Fl_Widget *, void *data) + { + Gui *gui = static_cast<Gui*>(data); + (gui->*cmd)(); + gui->canvas->redraw(); + } + + template<GuiCommand2 cmd> + static void to_menu(Fl_Widget *w, void *data) + { + Gui *gui = static_cast<Gui*>(data); + (gui->*cmd)(static_cast<Fl_Menu_ *>(w)); + gui->canvas->redraw(); + } + + template<GuiCommand1 cmd, int i> + static void to_arg(Fl_Widget *, void *data) + { + Gui *gui = static_cast<Gui*>(data); + (gui->*cmd)(i); + gui->canvas->redraw(); + } +}; + +//////////////////////////////////////////////////////////////////////// +// +// These macros make static FLTK menu definitions look a little nicer. +// + +#define MXGUI_BEGIN_MENU(name) {name, 0, 0, 0, FL_SUBMENU}, +#define MXGUI_END_MENU {0}, +#define MXGUI_FINISH_MENUBAR {0} + +} // namespace gfx + +// GFXGUI_INCLUDED +#endif diff --git a/debian/fireflies/fireflies-2.08/libgfx/include/gfx/intvec.h b/debian/fireflies/fireflies-2.08/libgfx/include/gfx/intvec.h new file mode 100644 index 00000000..f6cf4d05 --- /dev/null +++ b/debian/fireflies/fireflies-2.08/libgfx/include/gfx/intvec.h @@ -0,0 +1,97 @@ +#ifndef GFXINTVEC_INCLUDED // -*- C++ -*- +#define GFXINTVEC_INCLUDED +#if !defined(__GNUC__) +# pragma once +#endif + +/************************************************************************ + + Generic class for representing packed integer vectors. + + For signed types (e.g., short) the elements of the vector are + assumed to fall in the range [-1, 1]. For unsigned types the + elements of the vector are assumed to fall in the range [0, 1]. + + Note that ANSI C defines the maximum values of integer types in + <limits.h>. + + $Id: intvec.h 427 2004-09-27 04:45:31Z garland $ + + ************************************************************************/ + +#include "gfx.h" + +namespace gfx +{ + +template<class T, int T_MAX, int N> +class IntVec +{ +private: + T data[N]; + + // These are the routines used by all other methods to convert + // between the internal integral representation and the external + // floating point representation. + // + static inline T _fromflt(double x) + { return (T)rint((x>1.0f?1.0f:x)*(double)T_MAX); } + static inline double _toflt(T s) { return (double)s/(double)T_MAX; } + +protected: + operator T*() { return data; } + operator const T*() const { return data; } + +public: + IntVec() { *this = 0.0; } + + double operator[](int i) const { return _toflt(data[i]); } + void set(int i, double x) { data[i] = _fromflt(x); } + + IntVec<T, T_MAX, N>& operator=(const IntVec<T, T_MAX, N>& v) + { for(int i=0; i<N; i++) data[i]=v.data[i]; return *this; } + + double operator=(double x) + { T y = _fromflt(x); for(int i=0; i<N; i++) data[i] = y; return x; } + + const T *raw_data() const { return data; } +}; + + +//////////////////////////////////////////////////////////////////////// +// +// 3-D vectors are particularly common in graphics applications. +// RGB colors and normals are common examples of data types for which +// we might want to use packed integer representation. Therefore we +// make a special derived class to make it easy to define such types. +// +// Example: To define an RGB 3-vector represented as 3 components +// whose values range from [0 .. 255], we could use the +// declaration: +// +// typedef IntVec3<unsigned char, UCHAR_MAX> byteColor; +// + +#include "vec3.h" + +template<class T, int T_MAX> +class IntVec3 : public IntVec<T, T_MAX, 3> +{ +public: + IntVec3() { *this = 0.0; } + IntVec3(double x, double y, double z) { pack(Vec3(x, y, z)); } + template<class U> IntVec3(const TVec3<U>& v) { pack(v[0], v[1], v[2]); } + + Vec3 unpack() const { return Vec3((*this)[0],(*this)[1],(*this)[2]); } + void pack(const Vec3& v) + { this->set(0, v[0]); this->set(1, v[1]); this->set(2, v[2]); } + void pack(double x, double y, double z) + { this->set(0,x); this->set(1,y); this->set(2,z); } + + IntVec3<T,T_MAX>& operator=(const Vec3& v) { pack(v); return *this; } +}; + +} // namespace gfx + +// GFXINTVEC_INCLUDED +#endif diff --git a/debian/fireflies/fireflies-2.08/libgfx/include/gfx/mat2.h b/debian/fireflies/fireflies-2.08/libgfx/include/gfx/mat2.h new file mode 100644 index 00000000..d4331e89 --- /dev/null +++ b/debian/fireflies/fireflies-2.08/libgfx/include/gfx/mat2.h @@ -0,0 +1,158 @@ +#ifndef GFXMAT2_INCLUDED // -*- C++ -*- +#define GFXMAT2_INCLUDED +#if !defined(__GNUC__) +# pragma once +#endif + +/************************************************************************ + + 2x2 Matrix class + + $Id: mat2.h 427 2004-09-27 04:45:31Z garland $ + + ************************************************************************/ + +#include "vec2.h" + +namespace gfx +{ + +class Mat2 +{ +private: + Vec2 row[2]; + +public: + // Standard constructors + // + Mat2() { *this = 0.0; } + Mat2(double a, double b, double c, double d) + { row[0][0]=a; row[0][1]=b; row[1][0]=c; row[1][1]=d; } + Mat2(const Vec2 &r0,const Vec2 &r1) { row[0]=r0; row[1]=r1; } + Mat2(const Mat2 &m) { *this = m; } + + // Descriptive interface + // + typedef double value_type; + typedef Vec2 vector_type; + typedef Mat2 inverse_type; + static int dim() { return 2; } + + // Access methods note: A(i, j) == row i, col j + // + double& operator()(int i, int j) { return row[i][j]; } + double operator()(int i, int j) const { return row[i][j]; } + Vec2& operator[](int i) { return row[i]; } + const Vec2& operator[](int i) const { return row[i]; } + inline Vec2 col(int i) const {return Vec2(row[0][i],row[1][i]);} + + operator double*() { return row[0]; } + operator const double*() { return row[0]; } + operator const double*() const { return row[0]; } + + + // Assignment methods + // + inline Mat2& operator=(const Mat2& m); + inline Mat2& operator=(double s); + + inline Mat2& operator+=(const Mat2& m); + inline Mat2& operator-=(const Mat2& m); + inline Mat2& operator*=(double s); + inline Mat2& operator/=(double s); + + + // Construction of standard matrices + // + static Mat2 I(); + static Mat2 outer_product(const Vec2 &u, const Vec2 &v) + { return Mat2(u[0]*v[0], u[0]*v[1], u[1]*v[0], u[1]*v[1]); } + static Mat2 outer_product(const Vec2 &u) { return outer_product(u,u); } + + Mat2 &diag(double d); + Mat2 &ident() { return diag(1.0); } +}; + +//////////////////////////////////////////////////////////////////////// +// +// Method definitions +// + +inline Mat2& Mat2::operator=(const Mat2& m) + { row[0]=m[0]; row[1]=m[1]; return *this; } + +inline Mat2& Mat2::operator=(double s) + { row[0]=s; row[1]=s; return *this; } + +inline Mat2& Mat2::operator+=(const Mat2& m) + { row[0] += m.row[0]; row[1] += m.row[1]; return *this;} + +inline Mat2& Mat2::operator-=(const Mat2& m) + { row[0] -= m.row[0]; row[1] -= m.row[1]; return *this; } + +inline Mat2& Mat2::operator*=(double s) + { row[0] *= s; row[1] *= s; return *this; } + +inline Mat2& Mat2::operator/=(double s) + { row[0] /= s; row[1] /= s; return *this; } + +//////////////////////////////////////////////////////////////////////// +// +// Operator definitions +// + +inline Mat2 operator+(const Mat2 &n, const Mat2 &m) + { return Mat2(n[0]+m[0], n[1]+m[1]); } + +inline Mat2 operator-(const Mat2 &n, const Mat2 &m) + { return Mat2(n[0]-m[0], n[1]-m[1]); } + +inline Mat2 operator-(const Mat2 &m) + { return Mat2(-m[0], -m[1]); } + +inline Mat2 operator*(double s, const Mat2 &m) + { return Mat2(m[0]*s, m[1]*s); } +inline Mat2 operator*(const Mat2 &m, double s) + { return s*m; } + +inline Mat2 operator/(const Mat2 &m, double s) + { return Mat2(m[0]/s, m[1]/s); } + +inline Vec2 operator*(const Mat2 &m, const Vec2 &v) + { return Vec2(m[0]*v, m[1]*v); } + +extern Mat2 operator*(const Mat2 &n, const Mat2 &m); + +inline std::ostream &operator<<(std::ostream &out, const Mat2& M) + { return out << M[0] << std::endl << M[1]; } + +inline std::istream &operator>>(std::istream &in, Mat2& M) + { return in >> M[0] >> M[1]; } + +//////////////////////////////////////////////////////////////////////// +// +// Misc. function definitions +// + +inline double det(const Mat2 &m) + { return m(0,0)*m(1,1) - m(0,1)*m(1,0); } + +inline double trace(const Mat2 &m) + { return m(0,0) + m(1,1); } + +inline Mat2 transpose(const Mat2 &m) + { return Mat2(m.col(0), m.col(1)); } + +inline Mat2 adjoint(const Mat2 &m) + { return Mat2(perp(m[1]), -perp(m[0])); } + +extern double invert(Mat2 &m_inv, const Mat2 &m); + +extern bool eigenvalues(const Mat2&, Vec2& evals); +extern bool eigenvectors(const Mat2&, const Vec2& evals, Vec2 evecs[2]); +extern bool eigen(const Mat2&, Vec2& evals, Vec2 evecs[2]); + +} // namespace gfx + +// GFXMAT2_INCLUDED +#endif diff --git a/debian/fireflies/fireflies-2.08/libgfx/include/gfx/mat3.h b/debian/fireflies/fireflies-2.08/libgfx/include/gfx/mat3.h new file mode 100644 index 00000000..d898a964 --- /dev/null +++ b/debian/fireflies/fireflies-2.08/libgfx/include/gfx/mat3.h @@ -0,0 +1,157 @@ +#ifndef GFXMAT3_INCLUDED // -*- C++ -*- +#define GFXMAT3_INCLUDED +#if !defined(__GNUC__) +# pragma once +#endif + +/************************************************************************ + + 3x3 Matrix class + + $Id: mat3.h 427 2004-09-27 04:45:31Z garland $ + + ************************************************************************/ + +#include "vec3.h" + +namespace gfx +{ + +class Mat3 +{ +private: + Vec3 row[3]; + +public: + // Standard constructors + // + Mat3() { *this = 0.0; } + Mat3(const Vec3& r0,const Vec3& r1,const Vec3& r2) + { row[0]=r0; row[1]=r1; row[2]=r2; } + Mat3(const Mat3& m) { *this = m; } + + // Descriptive interface + // + typedef double value_type; + typedef Vec3 vector_type; + typedef Mat3 inverse_type; + static int dim() { return 3; } + + // Access methods + // + double& operator()(int i, int j) { return row[i][j]; } + double operator()(int i, int j) const { return row[i][j]; } + Vec3& operator[](int i) { return row[i]; } + const Vec3& operator[](int i) const { return row[i]; } + inline Vec3 col(int i) const {return Vec3(row[0][i],row[1][i],row[2][i]);} + + operator double*() { return row[0]; } + operator const double*() { return row[0]; } + operator const double*() const { return row[0]; } + + + // Assignment methods + // + inline Mat3& operator=(const Mat3& m); + inline Mat3& operator=(double s); + + inline Mat3& operator+=(const Mat3& m); + inline Mat3& operator-=(const Mat3& m); + inline Mat3& operator*=(double s); + inline Mat3& operator/=(double s); + + + // Construction of standard matrices + // + static Mat3 I(); + static Mat3 outer_product(const Vec3& u, const Vec3& v); + static Mat3 outer_product(const Vec3& v); + + Mat3 &diag(double d); + Mat3 &ident() { return diag(1.0); } + + +}; + +//////////////////////////////////////////////////////////////////////// +// +// Methods definitions +// + +inline Mat3& Mat3::operator=(const Mat3& m) + { row[0] = m[0]; row[1] = m[1]; row[2] = m[2]; return *this; } + +inline Mat3& Mat3::operator=(double s) + { row[0]=s; row[1]=s; row[2]=s; return *this; } + +inline Mat3& Mat3::operator+=(const Mat3& m) + { row[0] += m[0]; row[1] += m[1]; row[2] += m[2]; return *this; } + +inline Mat3& Mat3::operator-=(const Mat3& m) + { row[0] -= m[0]; row[1] -= m[1]; row[2] -= m[2]; return *this; } + +inline Mat3& Mat3::operator*=(double s) + { row[0] *= s; row[1] *= s; row[2] *= s; return *this; } + +inline Mat3& Mat3::operator/=(double s) + { row[0] /= s; row[1] /= s; row[2] /= s; return *this; } + +//////////////////////////////////////////////////////////////////////// +// +// Operator definitions +// + +inline Mat3 operator+(const Mat3& n, const Mat3& m) + { return Mat3(n[0]+m[0], n[1]+m[1], n[2]+m[2]); } + +inline Mat3 operator-(const Mat3& n, const Mat3& m) + { return Mat3(n[0]-m[0], n[1]-m[1], n[2]-m[2]); } + +inline Mat3 operator-(const Mat3& m) + { return Mat3(-m[0], -m[1], -m[2]); } + +inline Mat3 operator*(double s, const Mat3& m) + { return Mat3(m[0]*s, m[1]*s, m[2]*s); } +inline Mat3 operator*(const Mat3& m, double s) + { return s*m; } + +inline Mat3 operator/(const Mat3& m, double s) + { return Mat3(m[0]/s, m[1]/s, m[2]/s); } + +inline Vec3 operator*(const Mat3& m, const Vec3& v) + { return Vec3(m[0]*v, m[1]*v, m[2]*v); } + +extern Mat3 operator*(const Mat3& n, const Mat3& m); + +inline std::ostream &operator<<(std::ostream &out, const Mat3& M) + { return out << M[0] << std::endl << M[1] << std::endl << M[2]; } + +inline std::istream &operator>>(std::istream &in, Mat3& M) + { return in >> M[0] >> M[1] >> M[2]; } + +//////////////////////////////////////////////////////////////////////// +// +// Misc. function definitions +// + +inline double det(const Mat3& m) { return m[0] * (m[1] ^ m[2]); } + +inline double trace(const Mat3& m) { return m(0,0) + m(1,1) + m(2,2); } + +inline Mat3 transpose(const Mat3& m) + { return Mat3(m.col(0), m.col(1), m.col(2)); } + +extern Mat3 adjoint(const Mat3& m); + +extern double invert(Mat3& m_inv, const Mat3& m); + +inline Mat3 row_extend(const Vec3& v) { return Mat3(v, v, v); } + +extern Mat3 diag(const Vec3& v); + +extern bool eigen(const Mat3& m, Vec3& eig_vals, Vec3 eig_vecs[3]); + +} // namespace gfx + +// GFXMAT3_INCLUDED +#endif diff --git a/debian/fireflies/fireflies-2.08/libgfx/include/gfx/mat4.h b/debian/fireflies/fireflies-2.08/libgfx/include/gfx/mat4.h new file mode 100644 index 00000000..dfb36da4 --- /dev/null +++ b/debian/fireflies/fireflies-2.08/libgfx/include/gfx/mat4.h @@ -0,0 +1,194 @@ +#ifndef GFXMAT4_INCLUDED // -*- C++ -*- +#define GFXMAT4_INCLUDED +#if !defined(__GNUC__) +# pragma once +#endif + +/************************************************************************ + + 4x4 Matrix class + + $Id: mat4.h 427 2004-09-27 04:45:31Z garland $ + + ************************************************************************/ + +#include "vec4.h" + +namespace gfx +{ + +class Mat4 +{ +private: + Vec4 row[4]; + +public: + // Standard constructors + // + Mat4() { *this = 0.0; } + Mat4(const Vec4& r0,const Vec4& r1,const Vec4& r2,const Vec4& r3) + { row[0]=r0; row[1]=r1; row[2]=r2; row[3]=r3; } + Mat4(const Mat4& m) { *this = m; } + + // Descriptive interface + // + typedef double value_type; + typedef Vec4 vector_type; + typedef Mat4 inverse_type; + static int dim() { return 4; } + + // Access methods + // + double& operator()(int i, int j) { return row[i][j]; } + double operator()(int i, int j) const { return row[i][j]; } + Vec4& operator[](int i) { return row[i]; } + const Vec4& operator[](int i) const { return row[i]; } + inline Vec4 col(int i) const + { return Vec4(row[0][i],row[1][i],row[2][i],row[3][i]); } + + operator double*() { return row[0]; } + operator const double*() { return row[0]; } + operator const double*() const { return row[0]; } + + // Assignment methods + // + inline Mat4& operator=(const Mat4& m); + inline Mat4& operator=(double s); + + inline Mat4& operator+=(const Mat4& m); + inline Mat4& operator-=(const Mat4& m); + inline Mat4& operator*=(double s); + inline Mat4& operator/=(double s); + + static Mat4 I(); +}; + +//////////////////////////////////////////////////////////////////////// +// +// Method definitions +// + +inline Mat4& Mat4::operator=(const Mat4& m) +{ + row[0] = m[0]; row[1] = m[1]; row[2] = m[2]; row[3] = m[3]; + return *this; +} + +inline Mat4& Mat4::operator=(double s) +{ + row[0]=s; row[1]=s; row[2]=s; row[3]=s; + return *this; +} + +inline Mat4& Mat4::operator+=(const Mat4& m) +{ + row[0] += m[0]; row[1] += m[1]; row[2] += m[2]; row[3] += m[3]; + return *this; +} + +inline Mat4& Mat4::operator-=(const Mat4& m) +{ + row[0] -= m[0]; row[1] -= m[1]; row[2] -= m[2]; row[3] -= m[3]; + return *this; +} + +inline Mat4& Mat4::operator*=(double s) +{ + row[0] *= s; row[1] *= s; row[2] *= s; row[3] *= s; + return *this; +} + +inline Mat4& Mat4::operator/=(double s) +{ + row[0] /= s; row[1] /= s; row[2] /= s; row[3] /= s; + return *this; +} + +//////////////////////////////////////////////////////////////////////// +// +// Operator definitions +// + +inline Mat4 operator+(const Mat4& n, const Mat4& m) + { return Mat4(n[0]+m[0], n[1]+m[1], n[2]+m[2], n[3]+m[3]); } + +inline Mat4 operator-(const Mat4& n, const Mat4& m) + { return Mat4(n[0]-m[0], n[1]-m[1], n[2]-m[2], n[3]-m[3]); } + +inline Mat4 operator-(const Mat4& n) + { return Mat4(-n[0], -n[1], -n[2], -n[3]); } + +inline Mat4 operator*(double s, const Mat4& m) + { return Mat4(m[0]*s, m[1]*s, m[2]*s, m[3]*s); } +inline Mat4 operator*(const Mat4& m, double s) + { return s*m; } + +inline Mat4 operator/(const Mat4& m, double s) + { return Mat4(m[0]/s, m[1]/s, m[2]/s, m[3]/s); } + +inline Vec4 operator*(const Mat4& m, const Vec4& v) + { return Vec4(m[0]*v, m[1]*v, m[2]*v, m[3]*v); } + +extern Mat4 operator*(const Mat4& n, const Mat4& m); + +// +// Transform a homogeneous 3-vector and reproject into normal 3-space +// +inline Vec3 operator*(const Mat4& m, const Vec3& v) +{ + Vec4 u=Vec4(v,1); + double w=m[3]*u; + + if(w==0.0) return Vec3(m[0]*u, m[1]*u, m[2]*u); + else return Vec3(m[0]*u/w, m[1]*u/w, m[2]*u/w); +} + +inline std::ostream &operator<<(std::ostream &out, const Mat4& M) + { return out<<M[0]<<std::endl<<M[1]<<std::endl<<M[2]<<std::endl<<M[3]; } + +inline std::istream &operator>>(std::istream &in, Mat4& M) + { return in >> M[0] >> M[1] >> M[2] >> M[3]; } + +//////////////////////////////////////////////////////////////////////// +// +// Transformations +// + +extern Mat4 translation_matrix(const Vec3& delta); + +extern Mat4 scaling_matrix(const Vec3& scale); + +extern Mat4 rotation_matrix_rad(double theta, const Vec3& axis); + +inline Mat4 rotation_matrix_deg(double theta, const Vec3& axis) + { return rotation_matrix_rad(theta*M_PI/180.0, axis); } + +extern Mat4 perspective_matrix(double fovy, double aspect, + double zmin=0.0, double zmax=0.0); + +extern Mat4 lookat_matrix(const Vec3& from, const Vec3& at, const Vec3& up); + +extern Mat4 viewport_matrix(double w, double h); + +//////////////////////////////////////////////////////////////////////// +// +// Misc. function definitions +// + +inline double det(const Mat4& m) { return m[0] * cross(m[1], m[2], m[3]); } + +inline double trace(const Mat4& m) { return m(0,0)+m(1,1)+m(2,2)+m(3,3); } + +inline Mat4 transpose(const Mat4& m) + { return Mat4(m.col(0), m.col(1), m.col(2), m.col(3)); } + +extern Mat4 adjoint(const Mat4& m); +extern double invert(Mat4& m_inv, const Mat4& m); +extern double invert_cramer(Mat4& m_inv, const Mat4& m); + +extern bool eigen(const Mat4& m, Vec4& eig_vals, Vec4 eig_vecs[4]); + +} // namespace gfx + +// GFXMAT4_INCLUDED +#endif diff --git a/debian/fireflies/fireflies-2.08/libgfx/include/gfx/quat.h b/debian/fireflies/fireflies-2.08/libgfx/include/gfx/quat.h new file mode 100644 index 00000000..172a8b30 --- /dev/null +++ b/debian/fireflies/fireflies-2.08/libgfx/include/gfx/quat.h @@ -0,0 +1,118 @@ +#ifndef GFXQUAT_INCLUDED // -*- C++ -*- +#define GFXQUAT_INCLUDED +#if !defined(__GNUC__) +# pragma once +#endif + +/************************************************************************ + + Quaternion class + + $Id: quat.h 440 2005-02-23 05:14:13Z garland $ + + ************************************************************************/ + +#include "mat4.h" + +namespace gfx +{ + +class Quat +{ +private: + Vec3 v; // Vector component + double s; // Scalar component + +public: + Quat() { v=0.0; s=1.0; } + Quat(double x, double y, double z, double w) { v[0]=x;v[1]=y;v[2]=z; s=w; } + Quat(const Vec3& a, double b) { v=a; s=b; } + Quat(const Quat& q) { *this=q; } + + // Access methods + const Vec3& vector() const { return v; } + Vec3& vector() { return v; } + double scalar() const { return s; } + double& scalar() { return s; } + + // Assignment and in-place arithmetic methods + Quat& operator=(const Quat& q); + Quat& operator+=(const Quat& q); + Quat& operator-=(const Quat& q); + Quat& operator=(double d); + Quat& operator*=(double d); + Quat& operator/=(double d); + + // Construction of standard quaternions + static Quat ident(); +}; + +//////////////////////////////////////////////////////////////////////// +// +// Implementation of Quat methods +// + +inline Quat& Quat::operator=(const Quat& q) { v=q.v; s=q.s; return *this; } +inline Quat& Quat::operator+=(const Quat& q) { v+=q.v; s+=q.s; return *this; } +inline Quat& Quat::operator-=(const Quat& q) { v-=q.v; s-=q.s; return *this; } + +inline Quat& Quat::operator=(double d) { v=d; s=d; return *this; } +inline Quat& Quat::operator*=(double d) { v*=d; s*=d; return *this; } +inline Quat& Quat::operator/=(double d) { v/=d; s/=d; return *this; } + +inline Quat Quat::ident() { return Quat(0, 0, 0, 1); } + +//////////////////////////////////////////////////////////////////////// +// +// Standard arithmetic operators on quaternions +// + +inline Quat operator+(const Quat& q, const Quat& r) + { return Quat(q.vector()+r.vector(), q.scalar()+r.scalar()); } + +inline Quat operator*(const Quat& q, const Quat& r) +{ + return Quat(cross(q.vector(),r.vector()) + + r.scalar()*q.vector() + + q.scalar()*r.vector(), + q.scalar()*r.scalar() - q.vector()*r.vector()); +} + +inline Quat operator*(const Quat& q, double s) + { return Quat(q.vector()*s, q.scalar()*s); } +inline Quat operator*(double s, const Quat& q) + { return Quat(q.vector()*s, q.scalar()*s); } + +inline Quat operator/(const Quat& q, double s) + { return Quat(q.vector()/s, q.scalar()/s); } + +inline std::ostream &operator<<(std::ostream &out, const Quat& q) + { return out << q.vector() << " " << q.scalar(); } + +inline std::istream &operator>>(std::istream &in, Quat& q) + { return in >> q.vector() >> q.scalar(); } + + +//////////////////////////////////////////////////////////////////////// +// +// Standard functions on quaternions +// + +inline double norm(const Quat& q) + { return q.scalar()*q.scalar() + q.vector()*q.vector(); } + +inline Quat conjugate(const Quat& q) { return Quat(-q.vector(), q.scalar()); } +inline Quat inverse(const Quat& q) { return conjugate(q)/norm(q); } +inline Quat& unitize(Quat& q) { q /= sqrt(norm(q)); return q; } + +extern Quat exp(const Quat& q); +extern Quat log(const Quat& q); +extern Quat axis_to_quat(const Vec3& a, double phi); +extern Mat4 quat_to_matrix(const Quat& q); +extern Mat4 unit_quat_to_matrix(const Quat& q); +extern Quat slerp(const Quat& from, const Quat& to, double t); + +} // namespace gfx + +// GFXQUAT_INCLUDED +#endif diff --git a/debian/fireflies/fireflies-2.08/libgfx/include/gfx/raster.h b/debian/fireflies/fireflies-2.08/libgfx/include/gfx/raster.h new file mode 100644 index 00000000..4d4b2336 --- /dev/null +++ b/debian/fireflies/fireflies-2.08/libgfx/include/gfx/raster.h @@ -0,0 +1,171 @@ +#ifndef GFXRASTER_INCLUDED // -*- C++ -*- +#define GFXRASTER_INCLUDED +#if !defined(__GNUC__) +# pragma once +#endif + +/************************************************************************ + + Raster image support. + + $Id: raster.h 427 2004-09-27 04:45:31Z garland $ + + ************************************************************************/ + +#include "gfx.h" +#include "vec2.h" + +namespace gfx +{ + +typedef TVec2<short> PixelAddress; + +template<class T> +class Raster +{ +private: + T *data; + int W, H, nchan; + +public: + Raster(int w, int h, int c) + { + W=w; H=h; nchan=c; + data = new T[length()]; + } + virtual ~Raster() { delete[] data; } + + int width() const { return W; } + int height() const { return H; } + int channels() const { return nchan; } + int length() const { return W*H*nchan; } + + T& operator[](int i) { return data[i]; } + T operator[](int i) const { return data[i]; } + + virtual T *pixel(int i, int j) { return data + (j*W+i)*nchan; } + virtual const T *pixel(int i, int j) const { return data + (j*W+i)*nchan; } + T *pixel(const PixelAddress &a) { return pixel(a[0], a[1]); } + const T *pixel(const PixelAddress &a) const { return pixel(a[0], a[1]); } + + T *head() { return data; } + const T *head() const { return data; } + + void reverse(int start=0, int end=-1); + void hflip(); + void vflip(); + + bool is_valid_address(const PixelAddress& a) const + { + return is_valid_address(a[0], a[1]); + } + + virtual bool is_valid_address(int x, int y) const + { + return ( (x >= 0) && (x < W) && (y >= 0) && (y < H) ); + } +}; + + +class FloatRaster; +class ByteRaster : public Raster<unsigned char> +{ +public: + ByteRaster(int w, int h, int c) : Raster<unsigned char>(w,h,c) {} + ByteRaster(const ByteRaster& img); + ByteRaster(const FloatRaster& img); +}; + + +class FloatRaster : public Raster<float> +{ +public: + FloatRaster(int w, int h, int c) : Raster<float>(w,h,c) {} + FloatRaster(const FloatRaster &img); + FloatRaster(const ByteRaster &img); +}; + + +//////////////////////////////////////////////////////////////////////// +// +// Templated raster methods +// + +template<class T> +inline void Raster<T>::reverse(int start, int end) +{ + if(end<0 || end>=length()) end = length() - channels(); + + int i=start, j=end; + + while(i<j) + { + for(int k=0; k<channels(); k++) + { + T tmp = (*this)[i+k]; + (*this)[i+k] = (*this)[j+k]; + (*this)[j+k] = tmp; + } + i += channels(); + j -= channels(); + } +} + +template<class T> +inline void Raster<T>::hflip() +{ + int i = 0; + int j = channels()*(width()-1); + + while( i<length() ) + { + reverse(i, i+j); + i += j + channels(); + } +} + +template<class T> +inline void Raster<T>::vflip() +{ + reverse(); + hflip(); +} + + +//////////////////////////////////////////////////////////////////////// +// +// Supported external image file formats. +// + +enum { IMG_PNM=0, IMG_PNG=1, IMG_TIFF=2, IMG_JPEG=3, IMG_LIMIT=4 }; + +extern const char *image_type_name(int type); +extern const char *image_type_ext(int type); +extern int infer_image_type(const char *filename); + +// Image I/O based on filename extensions +extern bool write_image(const char *filename, const ByteRaster&, int type=-1); +extern ByteRaster *read_image(const char *filename, int type=-1); + +// PNM support provided by libgfx (always available) +extern bool will_write_raw_pnm; +extern bool write_pnm_image(const char *filename, const ByteRaster&); +extern ByteRaster *read_pnm_image(const char *filename); + +// TIFF support provided through libtiff (if available). +extern bool write_tiff_image(const char *filename, const ByteRaster&); +extern ByteRaster *read_tiff_image(const char *filename); + +// PNG support provided through libpng (if available). +extern bool write_png_image(const char *filename, const ByteRaster&); +extern ByteRaster *read_png_image(const char *filename); + +// JPEG support provided through libjpeg (if available) +extern int jpeg_output_quality; +extern bool write_jpeg_image(const char *filename, const ByteRaster&); +extern ByteRaster *read_jpeg_image(const char *filename); + +} // namespace gfx + +// GFXRASTER_INCLUDED +#endif diff --git a/debian/fireflies/fireflies-2.08/libgfx/include/gfx/script.h b/debian/fireflies/fireflies-2.08/libgfx/include/gfx/script.h new file mode 100644 index 00000000..c38cba1a --- /dev/null +++ b/debian/fireflies/fireflies-2.08/libgfx/include/gfx/script.h @@ -0,0 +1,182 @@ +#ifndef GFXSCRIPT_INCLUDED // -*- C++ -*- +#define GFXSCRIPT_INCLUDED +#if !defined(__GNUC__) +# pragma once +#endif + +/************************************************************************ + + Simple low-level file format scripting support. + + This is the THIRD major revision of this code. It represents a + significant departure from the previous scripting structure. + + $Id: script.h 443 2005-06-14 00:53:40Z garland $ + + ************************************************************************/ + +#include "gfx.h" +#include <vector> +#include <string> +#include <map> +//#include <hash_map> + +namespace gfx +{ + +// Define a set of exceptions that can occur during script parsing +// + namespace script + { + struct Error + { + std::string msg; + Error(const std::string& m) : msg(m) {} + }; + + struct SyntaxError : public Error + { SyntaxError(const std::string& m) : Error(m) {} }; + + struct NameError : public Error + { NameError(const std::string& m) : Error(m) {} }; + + struct IOError : public Error + { IOError(const std::string& m) : Error(m) {} }; + } + + +// These return codes are deprecated and will be going away in the near +// future. Start using the exceptions defined above instead. +enum { + SCRIPT_OK = 0, + SCRIPT_ERR_UNDEF, + SCRIPT_ERR_SYNTAX, + SCRIPT_ERR_UNSUPPORTED, + SCRIPT_ERR_NOFILE, + SCRIPT_END +}; + +class CmdLine +{ +public: + typedef std::string::size_type index_type; + typedef std::pair<index_type, index_type> range_type; + + const std::string &line; + range_type op; + std::vector<range_type> tokens; + + std::string substr(const range_type& r) const + { return line.substr(r.first, r.second-r.first);} + + std::string token_to_string(int i) const; + double token_to_double(int i) const; + float token_to_float(int i) const; + int token_to_int(int i) const; + std::string rest_to_string(int i) const; + + + CmdLine(const std::string &l) : line(l) { } + + std::string opname() const { return substr(op); } + int argcount() const { return tokens.size(); } + std::string argline() const; + + int collect_as_strings(std::vector<std::string> &v, int offset=0) const; + int collect_as_numbers(std::vector<double> &v, int offset=0) const; + int collect_as_numbers(std::vector<int> &v, int offset=0) const; + + int collect_as_numbers(double *v, int size, int offset=0) const; + int collect_as_numbers(float *v, int size, int offset=0) const; + int collect_as_numbers(int *v, int size, int offset=0) const; +}; + +typedef int (*CmdHandler)(const CmdLine&); + +struct CmdObject +{ + virtual ~CmdObject() {} + virtual int operator()(const CmdLine& cmd) = 0; +}; + +struct CmdFunction : public CmdObject +{ + CmdHandler fn; + CmdFunction(CmdHandler f) { fn=f; } + virtual int operator()(const CmdLine& cmd) { return (*fn)(cmd); } +}; + +template<class T> struct CmdMethod : public CmdObject +{ + typedef int (T::*member_handler)(const CmdLine&); + T *self; + member_handler fn; + + CmdMethod(T &obj, member_handler p) { self=&obj; fn=p; } + virtual int operator()(const CmdLine& cmd) { return (self->*fn)(cmd); } +}; + +template<class T> struct CmdMethod2 : public CmdObject +{ + typedef void (T::*member_handler)(const CmdLine&); + T *self; + member_handler fn; + + CmdMethod2(T &obj, member_handler p) { self=&obj; fn=p; } + virtual int operator()(const CmdLine& cmd) + { + (self->*fn)(cmd); + return SCRIPT_OK; + } +}; + +//typedef std::hash_map< std::string, CmdHandler > CmdTable; +typedef std::map< std::string, CmdObject* > CmdTable; + +class CmdEnv +{ +private: + CmdTable script_commands; + + int script_include(const CmdLine&); + int script_ignore(const CmdLine&); + int script_end(const CmdLine&); + int script_eval(const CmdLine&); + + std::vector<CmdEnv*> scopes; + +public: + CmdEnv(); + virtual ~CmdEnv(); + + void register_command(const std::string& name, CmdObject *fn); + CmdObject *lookup_command(const std::string& name); + + void register_command(const std::string& name, CmdHandler proc); + + template<class T> inline void register_method(const std::string& name, + T *obj, + int (T::*fn)(const CmdLine&)) + { register_command(name, new CmdMethod<T>(*obj, fn)); } + + template<class T> inline void register_method(const std::string& name, + T *obj, + void (T::*fn)(const CmdLine&)) + { register_command(name, new CmdMethod2<T>(*obj, fn)); } + + void ignore_command(const std::string& name); + + void register_vocabulary(const std::string& name, CmdEnv *env); + void begin_scope(CmdEnv *subenv); + void end_scope(); + + int do_line(const std::string& line); + int do_stream(std::istream& in); + int do_file(const std::string& filename); + int do_string(const std::string& line); +}; + +} // namespace gfx + +// GFXSCRIPT_INCLUDED +#endif diff --git a/debian/fireflies/fireflies-2.08/libgfx/include/gfx/symmat2.h b/debian/fireflies/fireflies-2.08/libgfx/include/gfx/symmat2.h new file mode 100644 index 00000000..db58c19c --- /dev/null +++ b/debian/fireflies/fireflies-2.08/libgfx/include/gfx/symmat2.h @@ -0,0 +1,134 @@ +#ifndef GFXSYMMAT2_INCLUDED // -*- C++ -*- +#define GFXSYMMAT2_INCLUDED +#if !defined(__GNUC__) +# pragma once +#endif + +/************************************************************************ + + Symmetric 2x2 Matrix class + + ************************************************************************/ + +#include "mat2.h" + +namespace gfx +{ + +class SymMat2 +{ +private: + double elt[3]; + + inline int index(int i, int j) const + { + // if n=dim(), and if i<=j: + // index = ( n*(n+1)/2 - (n-i)*(n-i+1)/2 ) + (j-i) + // + if( i<=j ) return 3 - (2-i)*(3-i)/2 + (j-i); + else return 3 - (2-j)*(3-j)/2 + (i-j); + } + +public: + // Standard constructors + // + SymMat2(double s=0.0) { *this = s; } + SymMat2(const SymMat2& m) { *this = m; } + + double& operator()(int i, int j) { return elt[index(i,j)]; } + double operator()(int i, int j) const { return elt[index(i,j)]; } + + static int size() { return 3; } + static int dim() { return 2; } + typedef Vec2 vector_type; + typedef Mat2 inverse_type; + typedef double value_type; + + operator double*() { return elt; } + operator const double*() { return elt; } + operator const double*() const { return elt; } + + inline Vec2 row(int i) const; + inline Vec2 col(int j) const; + Mat2 fullmatrix() const; + + inline SymMat2& operator=(const SymMat2& m); + inline SymMat2& operator=(double s); + + inline SymMat2& operator+=(const SymMat2& m); + inline SymMat2& operator-=(const SymMat2& m); + inline SymMat2& operator*=(double s); + inline SymMat2& operator/=(double s); + + static SymMat2 I(); + static SymMat2 outer_product(const Vec2& v); +}; + +//////////////////////////////////////////////////////////////////////// +// +// Methods definitions +// + +inline Vec2 SymMat2::row(int i) const + { return Vec2((*this)(i, 0), (*this)(i, 1)); } + +inline Vec2 SymMat2::col(int j) const + { return Vec2((*this)(0, j), (*this)(1, j)); } + +inline SymMat2& SymMat2::operator=(const SymMat2& m) + { for(int i=0; i<size(); i++) elt[i]=m.elt[i]; return *this; } + +inline SymMat2& SymMat2::operator=(double s) + { for(int i=0; i<size(); i++) elt[i]=s; return *this; } + +inline SymMat2& SymMat2::operator+=(const SymMat2& m) + { for(int i=0; i<size(); i++) elt[i]+=m.elt[i]; return *this; } + +inline SymMat2& SymMat2::operator-=(const SymMat2& m) + { for(int i=0; i<size(); i++) elt[i]-=m.elt[i]; return *this; } + +inline SymMat2& SymMat2::operator*=(double s) + { for(int i=0; i<size(); i++) elt[i]*=s; return *this; } + +inline SymMat2& SymMat2::operator/=(double s) + { for(int i=0; i<size(); i++) elt[i]/=s; return *this; } + +//////////////////////////////////////////////////////////////////////// +// +// Operator definitions +// + +inline SymMat2 operator+(SymMat2 n, const SymMat2& m) { n += m; return n; } +inline SymMat2 operator-(SymMat2 n, const SymMat2& m) { n -= m; return n; } + +inline SymMat2 operator*(double s, SymMat2 m) { m*=s; return m; } +inline SymMat2 operator*(SymMat2 m, double s) { m*=s; return m; } +inline SymMat2 operator/(SymMat2 m, double s) { m/=s; return m; } + +inline Vec2 operator*(const SymMat2& m, const Vec2& v) + { return Vec2(m.row(0)*v, m.row(1)*v); } + +extern SymMat2 operator*(const SymMat2& n, const SymMat2& m); + +extern std::ostream &operator<<(std::ostream &out, const SymMat2& M); + + +//////////////////////////////////////////////////////////////////////// +// +// Misc. function definitions +// + +inline double det(const SymMat2& m) { return m(0,0)*m(1,1) - 2*m(0,1); } + +inline double trace(const SymMat2& m) { return m(0,0) + m(1,1); } + +inline SymMat2 transpose(const SymMat2& m) { return m; } + +extern double invert(Mat2& m_inv, const SymMat2& m); + +extern bool eigen(const SymMat2& m, Vec2& eig_vals, Vec2 eig_vecs[2]); + +} // namespace gfx + +// GFXSYMMAT2_INCLUDED +#endif diff --git a/debian/fireflies/fireflies-2.08/libgfx/include/gfx/symmat3.h b/debian/fireflies/fireflies-2.08/libgfx/include/gfx/symmat3.h new file mode 100644 index 00000000..ec5e181f --- /dev/null +++ b/debian/fireflies/fireflies-2.08/libgfx/include/gfx/symmat3.h @@ -0,0 +1,136 @@ +#ifndef GFXSYMMAT3_INCLUDED // -*- C++ -*- +#define GFXSYMMAT3_INCLUDED +#if !defined(__GNUC__) +# pragma once +#endif + +/************************************************************************ + + Symmetric 3x3 Matrix class + + $Id: symmat3.h 427 2004-09-27 04:45:31Z garland $ + + ************************************************************************/ + +#include "mat3.h" + +namespace gfx +{ + +class SymMat3 +{ +private: + double elt[6]; + + inline int index(int i, int j) const + { + // if n=dim(), and if i<=j: + // index = ( n*(n+1)/2 - (n-i)*(n-i+1)/2 ) + (j-i) + // + if( i<=j ) return 6 - (3-i)*(4-i)/2 + (j-i); + else return 6 - (3-j)*(4-j)/2 + (i-j); + } + +public: + // Standard constructors + // + SymMat3(double s=0.0) { *this = s; } + SymMat3(const SymMat3& m) { *this = m; } + + double& operator()(int i, int j) { return elt[index(i,j)]; } + double operator()(int i, int j) const { return elt[index(i,j)]; } + + static int size() { return 6; } + static int dim() { return 3; } + typedef Vec3 vector_type; + typedef Mat3 inverse_type; + typedef double value_type; + + operator double*() { return elt; } + operator const double*() { return elt; } + operator const double*() const { return elt; } + + inline Vec3 row(int i) const; + inline Vec3 col(int j) const; + Mat3 fullmatrix() const; + + inline SymMat3& operator=(const SymMat3& m); + inline SymMat3& operator=(double s); + + inline SymMat3& operator+=(const SymMat3& m); + inline SymMat3& operator-=(const SymMat3& m); + inline SymMat3& operator*=(double s); + inline SymMat3& operator/=(double s); + + static SymMat3 I(); + static SymMat3 outer_product(const Vec3& v); +}; + +//////////////////////////////////////////////////////////////////////// +// +// Methods definitions +// + +inline Vec3 SymMat3::row(int i) const + { return Vec3((*this)(i, 0), (*this)(i, 1), (*this)(i, 2)); } + +inline Vec3 SymMat3::col(int j) const + { return Vec3((*this)(0, j), (*this)(1, j), (*this)(2, j)); } + +inline SymMat3& SymMat3::operator=(const SymMat3& m) + { for(int i=0; i<size(); i++) elt[i]=m.elt[i]; return *this; } + +inline SymMat3& SymMat3::operator=(double s) + { for(int i=0; i<size(); i++) elt[i]=s; return *this; } + +inline SymMat3& SymMat3::operator+=(const SymMat3& m) + { for(int i=0; i<size(); i++) elt[i]+=m.elt[i]; return *this; } + +inline SymMat3& SymMat3::operator-=(const SymMat3& m) + { for(int i=0; i<size(); i++) elt[i]-=m.elt[i]; return *this; } + +inline SymMat3& SymMat3::operator*=(double s) + { for(int i=0; i<size(); i++) elt[i]*=s; return *this; } + +inline SymMat3& SymMat3::operator/=(double s) + { for(int i=0; i<size(); i++) elt[i]/=s; return *this; } + +//////////////////////////////////////////////////////////////////////// +// +// Operator definitions +// + +inline SymMat3 operator+(SymMat3 n, const SymMat3& m) { n += m; return n; } +inline SymMat3 operator-(SymMat3 n, const SymMat3& m) { n -= m; return n; } + +inline SymMat3 operator*(double s, SymMat3 m) { m*=s; return m; } +inline SymMat3 operator*(SymMat3 m, double s) { m*=s; return m; } +inline SymMat3 operator/(SymMat3 m, double s) { m/=s; return m; } + +inline Vec3 operator*(const SymMat3& m, const Vec3& v) + { return Vec3(m.row(0)*v, m.row(1)*v, m.row(2)*v); } + +extern SymMat3 operator*(const SymMat3& n, const SymMat3& m); + +extern std::ostream &operator<<(std::ostream &out, const SymMat3& M); + + +//////////////////////////////////////////////////////////////////////// +// +// Misc. function definitions +// + +inline double det(const SymMat3& m) { return m.row(0) * (m.row(1)^m.row(2)); } + +inline double trace(const SymMat3& m) { return m(0,0) + m(1,1) + m(2,2); } + +inline SymMat3 transpose(const SymMat3& m) { return m; } + +extern double invert(Mat3& m_inv, const SymMat3& m); + +extern bool eigen(const SymMat3& m, Vec3& eig_vals, Vec3 eig_vecs[3]); + +} // namespace gfx + +// GFXSYMMAT3_INCLUDED +#endif diff --git a/debian/fireflies/fireflies-2.08/libgfx/include/gfx/symmat4.h b/debian/fireflies/fireflies-2.08/libgfx/include/gfx/symmat4.h new file mode 100644 index 00000000..e33ac14d --- /dev/null +++ b/debian/fireflies/fireflies-2.08/libgfx/include/gfx/symmat4.h @@ -0,0 +1,145 @@ +#ifndef GFXSYMMAT4_INCLUDED // C++ +#define GFXSYMMAT4_INCLUDED +#if !defined(__GNUC__) +# pragma once +#endif +/************************************************************************ + + 4X4 Symmetric Matrix class + + $Id: symmat4.h 441 2005-05-03 18:05:36Z garland $ + + ************************************************************************/ + +#include "mat4.h" + +namespace gfx +{ + +class SymMat4 +{ +public: + double elt[10]; + + inline int index(int i, int j) const + { + // if n=dim(), and if i<=j: + // index = ( n*(n+1)/2 - (n-i)*(n-i+1)/2 ) + (j-i) + // + if (i<=j) return (10 - (4-i)*(5-i)/2 + (j-i)); + else return (10 - (4-j)*(5-j)/2 + (i-j)); + } + +public: + // Standard constructors + // + SymMat4(double s=0.0) { *this = 0.0; } + SymMat4(const SymMat4 &m) {*this=m;} + + + // Descriptive interface + // + typedef double value_type; + typedef Vec4 vector_type; + typedef Mat4 inverse_type; + static int dim() { return 4; } + static int size() {return 10;} + + + // Access methods + // + double& operator()(int i, int j) { return elt[index(i,j)]; } + double operator()(int i, int j) const { return elt[index(i,j)]; } + + inline Vec4 row(int i) const; + inline Vec4 col(int i) const; + Mat4 fullmatrix() const; + + operator double*() { return elt; } + operator const double*() { return elt; } + operator const double*() const { return elt; } + + // Assignment methods + // + inline SymMat4& operator=(const SymMat4& m); + inline SymMat4& operator=(double s); + + inline SymMat4& operator+=(const SymMat4& m); + inline SymMat4& operator-=(const SymMat4& m); + inline SymMat4& operator*=(double s); + inline SymMat4& operator/=(double s); + + static SymMat4 I(); + static SymMat4 outer_product(const Vec4& v); +}; + +//////////////////////////////////////////////////////////////////////// +// +// Method definitions +// +inline Vec4 SymMat4::row(int i) const + { return Vec4((*this)(i,0), (*this)(i,1), (*this)(i,2), (*this)(i,3)); } + +inline Vec4 SymMat4::col(int j) const + { return Vec4((*this)(0,j), (*this)(1,j), (*this)(2,j), (*this)(3,j)); } + +inline SymMat4& SymMat4::operator=(const SymMat4& m) + { for(int i=0; i<size(); i++) elt[i] = m.elt[i]; return *this; } + +inline SymMat4& SymMat4::operator=(double s) + { for(int i=0; i<size(); i++) elt[i] = s; return *this; } + +inline SymMat4& SymMat4::operator+=(const SymMat4& m) + { for(int i=0; i<size(); i++) elt[i]+=m.elt[i]; return *this; } + +inline SymMat4& SymMat4::operator-=(const SymMat4& m) + { for(int i=0; i<size(); i++) elt[i]-=m.elt[i]; return *this; } + +inline SymMat4& SymMat4::operator*=(double s) + { for(int i=0; i<size(); i++) elt[i] *= s; return *this; } + +inline SymMat4& SymMat4::operator/=(double s) + { for(int i=0; i<size(); i++) elt[i] /= s; return *this; } + +//////////////////////////////////////////////////////////////////////// +// +// Operator definitions +// + +inline SymMat4 operator+(SymMat4 n, const SymMat4& m) { n += m; return n; } +inline SymMat4 operator-(SymMat4 n, const SymMat4& m) { n -= m; return n; } + +inline SymMat4 operator*(double s, SymMat4 m) { m*=s; return m; } +inline SymMat4 operator*(SymMat4 m, double s) { m*=s; return m; } +inline SymMat4 operator/(SymMat4 m, double s) { m/=s; return m; } + +inline SymMat4 operator-(const SymMat4& m) +{ + SymMat4 temp; + for(int i=0; i<m.size(); i++) temp.elt[i]= -m.elt[i]; + return temp; +} + +inline Vec4 operator*(const SymMat4& m, const Vec4& v) + { return Vec4(m.row(0)*v, m.row(1)*v, m.row(2)*v, m.row(3)*v); } + +extern SymMat4 operator*(const SymMat4& n, const SymMat4& m); + + +//////////////////////////////////////////////////////////////////////// +// +// Misc. function definitions +// + +inline double trace(const SymMat4& m) { return m(0,0)+m(1,1)+m(2,2)+m(3,3); } + +inline SymMat4 transpose(const SymMat4& m) { return m; } + +extern double invert(Mat4& m_inv, const SymMat4& m); + +extern bool eigen(const SymMat4& m, Vec4& eig_vals, Vec4 eig_vecs[4]); + +} // namespace gfx + +// GFXSYMMAT4_INCLUDED +#endif diff --git a/debian/fireflies/fireflies-2.08/libgfx/include/gfx/trackball.h b/debian/fireflies/fireflies-2.08/libgfx/include/gfx/trackball.h new file mode 100644 index 00000000..1432ed71 --- /dev/null +++ b/debian/fireflies/fireflies-2.08/libgfx/include/gfx/trackball.h @@ -0,0 +1,39 @@ +#ifndef GFXTRACKBALL_INCLUDED // -*- C++ -*- +#define GFXTRACKBALL_INCLUDED +#if !defined(__GNUC__) +# pragma once +#endif + +/************************************************************************ + + Virtual trackball rotation control. + + $Id: trackball.h 427 2004-09-27 04:45:31Z garland $ + + ************************************************************************/ + +#include "baseball.h" + +namespace gfx +{ + +extern void trackball(Quat& q, float p1x, float p1y, float p2x, float p2y); + +class Trackball : public Baseball +{ +public: + Quat lastquat; + +public: + Trackball(); + + virtual void update_animation(); + virtual bool mouse_down(int *where, int which); + virtual bool mouse_up(int *where, int which); + virtual bool mouse_drag(int *where, int *last, int which); +}; + +} // namespace gfx + +// GFXTRACKBALL_INCLUDED +#endif diff --git a/debian/fireflies/fireflies-2.08/libgfx/include/gfx/vec2.h b/debian/fireflies/fireflies-2.08/libgfx/include/gfx/vec2.h new file mode 100644 index 00000000..11b7ac7f --- /dev/null +++ b/debian/fireflies/fireflies-2.08/libgfx/include/gfx/vec2.h @@ -0,0 +1,158 @@ +#ifndef GFXVEC2_INCLUDED // -*- C++ -*- +#define GFXVEC2_INCLUDED +#if !defined(__GNUC__) +# pragma once +#endif + +/************************************************************************ + + 2D Vector class + + $Id: vec2.h 427 2004-09-27 04:45:31Z garland $ + + ************************************************************************/ + +#include "gfx.h" + +namespace gfx +{ + +template<class T> +class TVec2 { +private: + T elt[2]; + +public: + // Standard constructors + // + TVec2(T s=0) { *this = s; } + TVec2(T x, T y) { elt[0]=x; elt[1]=y; } + + // Copy constructors & assignment operators + template<class U> TVec2(const TVec2<U>& v) { *this = v; } + template<class U> TVec2(const U v[2]) { elt[0]=v[0]; elt[1]=v[1]; } + template<class U> TVec2& operator=(const TVec2<U>& v) + { elt[0]=v[0]; elt[1]=v[1]; return *this; } + TVec2& operator=(T s) { elt[0]=elt[1]=s; return *this; } + + + // Descriptive interface + // + typedef T value_type; + static int dim() { return 2; } + + + // Access methods + // + operator T*() { return elt; } + operator const T*() const { return elt; } + +#ifndef HAVE_CASTING_LIMITS + T& operator[](int i) { return elt[i]; } + T operator[](int i) const { return elt[i]; } + operator const T*() { return elt; } +#endif + + // In-place arithmetic methods + // + inline TVec2& operator+=(const TVec2& v); + inline TVec2& operator-=(const TVec2& v); + inline TVec2& operator*=(T s); + inline TVec2& operator/=(T s); +}; + +//////////////////////////////////////////////////////////////////////// +// +// Method definitions +// +template<class T> inline TVec2<T>& TVec2<T>::operator+=(const TVec2<T>& v) + { elt[0] += v[0]; elt[1] += v[1]; return *this; } + +template<class T> inline TVec2<T>& TVec2<T>::operator-=(const TVec2<T>& v) + { elt[0] -= v[0]; elt[1] -= v[1]; return *this; } + +template<class T> inline TVec2<T>& TVec2<T>::operator*=(T s) + { elt[0] *= s; elt[1] *= s; return *this; } + +template<class T> inline TVec2<T>& TVec2<T>::operator/=(T s) + { elt[0] /= s; elt[1] /= s; return *this; } + +//////////////////////////////////////////////////////////////////////// +// +// Operator defintions +// + +template<class T> +inline TVec2<T> operator+(const TVec2<T> &u, const TVec2<T> &v) + { return TVec2<T>(u[0]+v[0], u[1]+v[1]); } + +template<class T> +inline TVec2<T> operator-(const TVec2<T> &u, const TVec2<T> &v) + { return TVec2<T>(u[0]-v[0], u[1]-v[1]); } + +template<class T> inline TVec2<T> operator-(const TVec2<T> &v) + { return TVec2<T>(-v[0], -v[1]); } + +#if _MSC_VER>=1200 +// Normally, we use the <class T, class N> construct below to allow the scalar +// argument to be different than the template type. This, for example, allows +// the user to write things like v/2. Unfortunately, Microsoft VC6.0 (aka +// v1200) gets confused by this. We used to include explicit versions for the +// case of int's, but this was causing silent (and incorrect) coercion of +// floats to ints. +// + + template<class T> inline TVec2<T> operator*(T s, const TVec2<T> &v) + { return TVec2<T>(v[0]*s, v[1]*s); } + template<class T> inline TVec2<T> operator*(const TVec2<T> &v, T s) + { return s*v; } + + template<class T> inline TVec2<T> operator/(const TVec2<T> &v, T s) + { return TVec2<T>(v[0]/s, v[1]/s); } + +#else + template<class T, class N> inline TVec2<T> operator*(N s, const TVec2<T> &v) + { return TVec2<T>(v[0]*s, v[1]*s); } + template<class T, class N> inline TVec2<T> operator*(const TVec2<T> &v, N s) + { return s*v; } + + template<class T, class N> inline TVec2<T> operator/(const TVec2<T> &v, N s) + { return TVec2<T>(v[0]/s, v[1]/s); } +#endif + +template<class T> inline T operator*(const TVec2<T> &u, const TVec2<T>& v) + { return u[0]*v[0] + u[1]*v[1]; } + +template<class T> inline TVec2<T> perp(const TVec2<T> &v) + { return TVec2<T>(v[1], -v[0]); } + +template<class T> +inline std::ostream &operator<<(std::ostream &out, const TVec2<T> &v) + { return out << v[0] << " " << v[1]; } + +template<class T> +inline std::istream &operator>>(std::istream &in, TVec2<T>& v) + { return in >> v[0] >> v[1]; } + + +//////////////////////////////////////////////////////////////////////// +// +// Misc. function definitions +// + +template<class T> inline T norm2(const TVec2<T>& v) { return v*v; } +template<class T> inline T norm(const TVec2<T>& v) { return sqrt(norm2(v)); } + +template<class T> inline void unitize(TVec2<T>& v) +{ + T l = norm2(v); + if( l!=1.0 && l!=0.0 ) v /= sqrt(l); +} + +typedef TVec2<double> Vec2; +typedef TVec2<float> Vec2f; + +} // namespace gfx + +// GFXVEC2_INCLUDED +#endif diff --git a/debian/fireflies/fireflies-2.08/libgfx/include/gfx/vec3.h b/debian/fireflies/fireflies-2.08/libgfx/include/gfx/vec3.h new file mode 100644 index 00000000..22d37394 --- /dev/null +++ b/debian/fireflies/fireflies-2.08/libgfx/include/gfx/vec3.h @@ -0,0 +1,184 @@ +#ifndef GFXVEC3_INCLUDED // -*- C++ -*- +#define GFXVEC3_INCLUDED +#if !defined(__GNUC__) +# pragma once +#endif + +/************************************************************************ + + 3D Vector class + + $Id: vec3.h 427 2004-09-27 04:45:31Z garland $ + + ************************************************************************/ + +#include "vec2.h" + +namespace gfx +{ + +template<class T> +class TVec3 { +private: + T elt[3]; + +public: + // Standard constructors + // + TVec3(T s=0) { *this = s; } + TVec3(T x, T y, T z) { elt[0]=x; elt[1]=y; elt[2]=z; } + + // Copy constructors & assignment operators + template<class U> TVec3(const TVec3<U>& v) { *this = v; } +#ifndef STDMIX_INCLUDED + // This is now a standard constructor, except when compiling legacy MixKit + // code. + template<class U> TVec3(const U v[3]) + { elt[0]=v[0]; elt[1]=v[1]; elt[2]=v[2]; } +#else + // For MixKit code, we need these constructors instead. + // They SHOULD NOT be used in new code. + TVec3(const float *v) { elt[0]=v[0]; elt[1]=v[1]; elt[2]=v[2]; } + TVec3(const double *v) { elt[0]=v[0]; elt[1]=v[1]; elt[2]=v[2]; } +#endif + template<class U> TVec3& operator=(const TVec3<U>& v) + { elt[0]=v[0]; elt[1]=v[1]; elt[2]=v[2]; return *this; } + TVec3& operator=(T s) { elt[0]=elt[1]=elt[2]=s; return *this; } + + // Descriptive interface + // + typedef T value_type; + static int dim() { return 3; } + + + // Access methods + // + operator T*() { return elt; } + operator const T*() const { return elt; } + +#ifndef HAVE_CASTING_LIMITS + T& operator[](int i) { return elt[i]; } + T operator[](int i) const { return elt[i]; } + operator const T*() { return elt; } +#endif + + + // Assignment and in-place arithmetic methods + // + inline TVec3& operator+=(const TVec3& v); + inline TVec3& operator-=(const TVec3& v); + inline TVec3& operator*=(T s); + inline TVec3& operator/=(T s); +}; + +//////////////////////////////////////////////////////////////////////// +// +// Method definitions +// + +template<class T> inline TVec3<T>& TVec3<T>::operator+=(const TVec3<T>& v) + { elt[0] += v[0]; elt[1] += v[1]; elt[2] += v[2]; return *this; } + +template<class T> inline TVec3<T>& TVec3<T>::operator-=(const TVec3<T>& v) + { elt[0] -= v[0]; elt[1] -= v[1]; elt[2] -= v[2]; return *this; } + +template<class T> inline TVec3<T>& TVec3<T>::operator*=(T s) + { elt[0] *= s; elt[1] *= s; elt[2] *= s; return *this; } + +template<class T> inline TVec3<T>& TVec3<T>::operator/=(T s) + { elt[0] /= s; elt[1] /= s; elt[2] /= s; return *this; } + + +//////////////////////////////////////////////////////////////////////// +// +// Operator definitions +// + +template<class T> +inline TVec3<T> operator+(const TVec3<T> &u, const TVec3<T>& v) + { return TVec3<T>(u[0]+v[0], u[1]+v[1], u[2]+v[2]); } + +template<class T> +inline TVec3<T> operator-(const TVec3<T> &u, const TVec3<T>& v) + { return TVec3<T>(u[0]-v[0], u[1]-v[1], u[2]-v[2]); } + +template<class T> inline TVec3<T> operator-(const TVec3<T> &v) + { return TVec3<T>(-v[0], -v[1], -v[2]); } + +#if _MSC_VER>=1200 +// Normally, we use the <class T, class N> construct below to allow the scalar +// argument to be different than the template type. This, for example, allows +// the user to write things like v/2. Unfortunately, Microsoft VC6.0 (aka +// v1200) gets confused by this. We used to include explicit versions for the +// case of int's, but this was causing silent (and incorrect) coercion of +// floats to ints. +// + template<class T> inline TVec3<T> operator*(T s, const TVec3<T> &v) + { return TVec3<T>(v[0]*s, v[1]*s, v[2]*s); } + template<class T> inline TVec3<T> operator*(const TVec3<T> &v, T s) + { return s*v; } + + template<class T> inline TVec3<T> operator/(const TVec3<T> &v, T s) + { return TVec3<T>(v[0]/s, v[1]/s, v[2]/s); } +#else + template<class T, class N> inline TVec3<T> operator*(N s, const TVec3<T> &v) + { return TVec3<T>(v[0]*s, v[1]*s, v[2]*s); } + template<class T, class N> inline TVec3<T> operator*(const TVec3<T> &v, N s) + { return s*v; } + + template<class T, class N> inline TVec3<T> operator/(const TVec3<T> &v, N s) + { return TVec3<T>(v[0]/s, v[1]/s, v[2]/s); } +#endif + +template<class T> inline T operator*(const TVec3<T> &u, const TVec3<T>& v) + { return u[0]*v[0] + u[1]*v[1] + u[2]*v[2]; } + +template<class T> inline TVec3<T> cross(const TVec3<T>& u, const TVec3<T>& v) +{ + return TVec3<T>( u[1]*v[2] - v[1]*u[2], + -u[0]*v[2] + v[0]*u[2], + u[0]*v[1] - v[0]*u[1] ); +} + +template<class T> +inline TVec3<T> operator^(const TVec3<T>& u, const TVec3<T>& v) + { return cross(u, v); } + + +template<class T> +inline std::ostream &operator<<(std::ostream &out, const TVec3<T>& v) + { return out << v[0] << " " << v[1] << " " << v[2]; } + +template<class T> +inline std::istream &operator>>(std::istream &in, TVec3<T>& v) + { return in >> v[0] >> v[1] >> v[2]; } + +//////////////////////////////////////////////////////////////////////// +// +// Misc. function definitions +// + +template<class T> inline T norm2(const TVec3<T>& v) { return v*v; } +template<class T> inline T norm(const TVec3<T>& v) { return sqrt(norm2(v)); } + +template<class T> inline void unitize(TVec3<T>& v) +{ + T l = norm2(v); + if( l!=1.0 && l!=0.0 ) v /= sqrt(l); +} + +template<class T> inline TVec2<T> proj(const TVec3<T>& v) +{ + TVec2<T> u(v[0], v[1]); + if( v[2]!=1.0 && v[2]!=0.0 ) + u /= v[2]; + return u; +} + +typedef TVec3<double> Vec3; +typedef TVec3<float> Vec3f; + +} // namespace gfx + +// GFXVEC3_INCLUDED +#endif diff --git a/debian/fireflies/fireflies-2.08/libgfx/include/gfx/vec4.h b/debian/fireflies/fireflies-2.08/libgfx/include/gfx/vec4.h new file mode 100644 index 00000000..8875074e --- /dev/null +++ b/debian/fireflies/fireflies-2.08/libgfx/include/gfx/vec4.h @@ -0,0 +1,183 @@ +#ifndef GFXVEC4_INCLUDED // -*- C++ -*- +#define GFXVEC4_INCLUDED +#if !defined(__GNUC__) +# pragma once +#endif + +/************************************************************************ + + 4D Vector class + + $Id: vec4.h 427 2004-09-27 04:45:31Z garland $ + + ************************************************************************/ + +#include "vec3.h" + +namespace gfx +{ + +template<class T> +class TVec4 { +private: + T elt[4]; + +public: + // Standard constructors + // + TVec4(T s=0) { *this = s; } + TVec4(T x, T y, T z, T w) { elt[0]=x; elt[1]=y; elt[2]=z; elt[3]=w; } + + // Copy constructors & assignment operators + template<class U> TVec4(const TVec4<U>& v) { *this = v; } + template<class U> TVec4(const TVec3<U>& v,T w) + { elt[0]=v[0]; elt[1]=v[1]; elt[2]=v[2]; elt[3]=w; } + template<class U> TVec4(const U v[4]) + { elt[0]=v[0]; elt[1]=v[1]; elt[2]=v[2]; elt[3]=v[3]; } + template<class U> TVec4& operator=(const TVec4<U>& v) + { elt[0]=v[0]; elt[1]=v[1]; elt[2]=v[2]; elt[3]=v[3]; return *this; } + TVec4& operator=(T s) { elt[0]=elt[1]=elt[2]=elt[3]=s; return *this; } + + + // Descriptive interface + // + typedef T value_type; + static int dim() { return 4; } + + + // Access methods + // + operator T*() { return elt; } + operator const T*() const { return elt; } + +#ifndef HAVE_CASTING_LIMITS + T& operator[](int i) { return elt[i]; } + T operator[](int i) const { return elt[i]; } + operator const T*() { return elt; } +#endif + + // Assignment and in-place arithmetic methods + // + inline TVec4& operator+=(const TVec4& v); + inline TVec4& operator-=(const TVec4& v); + inline TVec4& operator*=(T s); + inline TVec4& operator/=(T s); +}; + +//////////////////////////////////////////////////////////////////////// +// +// Method definitions +// + +template<class T> inline TVec4<T>& TVec4<T>::operator+=(const TVec4<T>& v) + { elt[0]+=v[0]; elt[1]+=v[1]; elt[2]+=v[2]; elt[3]+=v[3]; return *this;} + +template<class T> inline TVec4<T>& TVec4<T>::operator-=(const TVec4<T>& v) + { elt[0]-=v[0]; elt[1]-=v[1]; elt[2]-=v[2]; elt[3]-=v[3]; return *this;} + +template<class T> inline TVec4<T>& TVec4<T>::operator*=(T s) + { elt[0] *= s; elt[1] *= s; elt[2] *= s; elt[3] *= s; return *this; } + +template<class T> inline TVec4<T>& TVec4<T>::operator/=(T s) + { elt[0] /= s; elt[1] /= s; elt[2] /= s; elt[3] /= s; return *this; } + + +//////////////////////////////////////////////////////////////////////// +// +// Operator definitions +// + +template<class T> +inline TVec4<T> operator+(const TVec4<T> &u, const TVec4<T> &v) + { return TVec4<T>(u[0]+v[0], u[1]+v[1], u[2]+v[2], u[3]+v[3]); } + +template<class T> +inline TVec4<T> operator-(const TVec4<T> &u, const TVec4<T>& v) + { return TVec4<T>(u[0]-v[0], u[1]-v[1], u[2]-v[2], u[3]-v[3]); } + +template<class T> inline TVec4<T> operator-(const TVec4<T> &u) + { return TVec4<T>(-u[0], -u[1], -u[2], -u[3]); } + +#if _MSC_VER>=1200 +// Normally, we use the <class T, class N> construct below to allow the scalar +// argument to be different than the template type. This, for example, allows +// the user to write things like v/2. Unfortunately, Microsoft VC6.0 (aka +// v1200) gets confused by this. We used to include explicit versions for the +// case of int's, but this was causing silent (and incorrect) coercion of +// floats to ints. +// + template<class T> inline TVec4<T> operator*(T s, const TVec4<T> &v) + { return TVec4<T>(v[0]*s, v[1]*s, v[2]*s, v[3]*s); } + template<class T> inline TVec4<T> operator*(const TVec4<T> &v, T s) + { return s*v; } + + template<class T> inline TVec4<T> operator/(const TVec4<T> &v, T s) + { return TVec4<T>(v[0]/s, v[1]/s, v[2]/s, v[3]/s); } +#else + template<class T, class N> inline TVec4<T> operator*(N s, const TVec4<T> &v) + { return TVec4<T>(v[0]*s, v[1]*s, v[2]*s, v[3]*s); } + template<class T, class N> inline TVec4<T> operator*(const TVec4<T> &v, N s) + { return s*v; } + + template<class T, class N> inline TVec4<T> operator/(const TVec4<T> &v, N s) + { return TVec4<T>(v[0]/s, v[1]/s, v[2]/s, v[3]/s); } +#endif + +template<class T> inline T operator*(const TVec4<T> &u, const TVec4<T> &v) + { return u[0]*v[0] + u[1]*v[1] + u[2]*v[2] + u[3]*v[3]; } + +template<class T> +inline std::ostream &operator<<(std::ostream &out, const TVec4<T>& v) + { return out <<v[0] <<" " <<v[1] <<" " <<v[2] <<" " <<v[3]; } + +template<class T> +inline std::istream &operator>>(std::istream &in, TVec4<T>& v) + { return in >> v[0] >> v[1] >> v[2] >> v[3]; } + +//////////////////////////////////////////////////////////////////////// +// +// Misc. function definitions +// + +template<class T> +inline TVec4<T> cross(const TVec4<T>& a, const TVec4<T>& b, const TVec4<T>& c) +{ + // Code adapted from VecLib4d.c in Graphics Gems V + + T d1 = (b[2] * c[3]) - (b[3] * c[2]); + T d2 = (b[1] * c[3]) - (b[3] * c[1]); + T d3 = (b[1] * c[2]) - (b[2] * c[1]); + T d4 = (b[0] * c[3]) - (b[3] * c[0]); + T d5 = (b[0] * c[2]) - (b[2] * c[0]); + T d6 = (b[0] * c[1]) - (b[1] * c[0]); + + return TVec4<T>(- a[1] * d1 + a[2] * d2 - a[3] * d3, + a[0] * d1 - a[2] * d4 + a[3] * d5, + - a[0] * d2 + a[1] * d4 - a[3] * d6, + a[0] * d3 - a[1] * d5 + a[2] * d6); +} + +template<class T> inline T norm2(const TVec4<T>& v) { return v*v; } +template<class T> inline T norm(const TVec4<T>& v) { return sqrt(norm2(v)); } + +template<class T> inline void unitize(TVec4<T>& v) +{ + T l = norm2(v); + if( l!=1.0 && l!=0.0 ) v /= sqrt(l); +} + +template<class T> inline TVec3<T> proj(const TVec4<T>& v) +{ + TVec3<T> u(v[0], v[1], v[2]); + if( v[3]!=1.0 && v[3]!=0.0 ) + u /= v[3]; + return u; +} + +typedef TVec4<double> Vec4; +typedef TVec4<float> Vec4f; + +} // namespace gfx + +// GFXVEC4_INCLUDED +#endif diff --git a/debian/fireflies/fireflies-2.08/libgfx/include/gfx/win/gui-mfc.h b/debian/fireflies/fireflies-2.08/libgfx/include/gfx/win/gui-mfc.h new file mode 100644 index 00000000..134916bd --- /dev/null +++ b/debian/fireflies/fireflies-2.08/libgfx/include/gfx/win/gui-mfc.h @@ -0,0 +1,120 @@ +#ifndef GFXGUIMFC_INCLUDED // -*- C++ -*- +#define GFXGUIMFC_INCLUDED +#if !defined(__GNUC__) +# pragma once +#endif + +/************************************************************************ + + Minimalist GUI framework built using MFC. + + This package mimics the baseline GUI framework originally implemented + on top of FLTK in <gui.h>. It remains incomplete, and does not + support all the features provided by the FLTK-based version. + + At this point, the two GUI implementations are close to + source-compatible, but not quite. The main difference is in the + startup issues -- main() vs. InitInstance(). + + $Id: gui-mfc.h 427 2004-09-27 04:45:31Z garland $ + + ************************************************************************/ + +#include "mfc.h" +#include "../gl.h" + +namespace gfx +{ + + +class Canvas : public CFrameWnd +{ +private: + int last_click[2]; + +public: + Canvas(); + + CStatusBar *status_line; + +private: + int pixfmt; + HGLRC glcontext; + +protected: + inline void make_current(HDC dc) { wglMakeCurrent(dc, glcontext); } + inline void finish(HDC dc) { SwapBuffers(dc); } + + void immediate_redraw(); + + int decode_mouse_button(UINT flags, int which=0); + void do_mouse_down(int which, UINT flags, CPoint where); + void do_mouse_up(int which, UINT flags, CPoint where); + void do_mouse_move(UINT flags, CPoint where); + +public: + void post_redraw(); + +protected: + // + // Override selected MFC virtual functions + // + BOOL PreCreateWindow(CREATESTRUCT &cs); + +protected: + // + // Define MFC event handlers + // + afx_msg int OnCreate(LPCREATESTRUCT lpcs); + afx_msg void OnDestroy(); + afx_msg void OnSize(UINT type, int width, int height); + + afx_msg void OnActivate(UINT state, CWnd *other, BOOL is_minimized); + afx_msg void OnPaint(); + afx_msg BOOL OnEraseBkgnd(CDC *dc); + + afx_msg void OnLButtonDown(UINT flags, CPoint point); + afx_msg void OnLButtonUp(UINT flags, CPoint point); + afx_msg void OnRButtonDown(UINT flags, CPoint point); + afx_msg void OnRButtonUp(UINT flags, CPoint point); + afx_msg void OnMButtonDown(UINT flags, CPoint point); + afx_msg void OnMButtonUp(UINT flags, CPoint point); + afx_msg void OnMouseMove(UINT flags, CPoint point); + afx_msg void OnChar(UINT ch, UINT repcount, UINT flags); + + DECLARE_MESSAGE_MAP() +}; + + +class MfcGUI : public CWinApp +{ +private: + UINT timer_id; + +public: + MfcGUI(); + + virtual BOOL InitInstance(); + + Canvas *canvas; + float default_fps, target_fps; + + void status(const char *format, ...); + + void animate(bool will=true); + +public: + + virtual void update_animation(); + virtual void setup_for_drawing(); + virtual void draw_contents(); + virtual bool mouse_down(int *where, int which); + virtual bool mouse_up(int *where, int which); + virtual bool mouse_drag(int *where, int *last, int which); + virtual bool key_press(int key); +}; + +} // namespace gfx + +// GFXGUIMFC_INCLUDED +#endif diff --git a/debian/fireflies/fireflies-2.08/libgfx/include/gfx/win/mfc.h b/debian/fireflies/fireflies-2.08/libgfx/include/gfx/win/mfc.h new file mode 100644 index 00000000..9feb045f --- /dev/null +++ b/debian/fireflies/fireflies-2.08/libgfx/include/gfx/win/mfc.h @@ -0,0 +1,30 @@ +#ifndef GFXMFC_INCLUDED // -*- C++ -*- +#define GFXMFC_INCLUDED +#if !defined(__GNUC__) +# pragma once +#endif + +/************************************************************************ + + Support code for using MFC. At the moment, this just makes sure that + we include the right headers. + + $Id: mfc.h 425 2004-09-27 03:40:06Z garland $ + + ************************************************************************/ + +#ifndef _MBCS +#define _MBCS +#endif + +#ifndef _AFXDLL +#define _AFXDLL +#endif + +#include <afxwin.h> +#include <afxext.h> + +#include "wintools.h" + +// GFXMFC_INCLUDED +#endif diff --git a/debian/fireflies/fireflies-2.08/libgfx/include/gfx/win/wintools.h b/debian/fireflies/fireflies-2.08/libgfx/include/gfx/win/wintools.h new file mode 100644 index 00000000..2fd683ed --- /dev/null +++ b/debian/fireflies/fireflies-2.08/libgfx/include/gfx/win/wintools.h @@ -0,0 +1,26 @@ +#ifndef GFXWINTOOLS_INCLUDED // -*- C++ -*- +#define GFXWINTOOLS_INCLUDED +#if !defined(__GNUC__) +# pragma once +#endif + +/************************************************************************ + + Support code for handling various tasks under Win32 + + $Id: wintools.h 427 2004-09-27 04:45:31Z garland $ + + ************************************************************************/ + +#include <windows.h> + +namespace gfx +{ + +extern HGLRC create_glcontext(HDC dc); +extern int set_pixel_format(HDC dc); + +} // namespace gfx + +// GFXWINTOOLS_INCLUDED +#endif |