goat3dgfx

changeset 23:0ac499409edd

added misisng header file in goat3dgfx.h added contains() function in geom
author John Tsiombikas <nuclear@member.fsf.org>
date Tue, 25 Feb 2014 23:47:48 +0200
parents 92bfb0206969
children dc5918c62a64 6236080aaea4
files Makefile.in configure goat3dgfx.pc.in src/geom.cc src/geom.h src/goat3dgfx.h
diffstat 6 files changed, 58 insertions(+), 2 deletions(-) [+]
line diff
     1.1 --- a/Makefile.in	Sat Dec 28 06:48:23 2013 +0200
     1.2 +++ b/Makefile.in	Tue Feb 25 23:47:48 2014 +0200
     1.3 @@ -9,6 +9,8 @@
     1.4  name = goat3dgfx
     1.5  lib_a = lib$(name).a
     1.6  
     1.7 +pcfile = $(name).pc
     1.8 +
     1.9  so_major = 0
    1.10  so_minor = 1
    1.11  
    1.12 @@ -26,7 +28,7 @@
    1.13  inc = -Isrc -Isrc/vr
    1.14  warn = -Wall
    1.15  
    1.16 -libs_ldflags = -limago -lanim -lpsys -lvmath
    1.17 +libs_ldflags = -limago -lanim -lpsys -lvmath -lresman
    1.18  
    1.19  CFLAGS = -pedantic $(warn) $(dbg) $(pic) $(opt) $(inc) $(cfg_cflags) $(libs_cflags)
    1.20  CXXFLAGS =  $(CFLAGS)
    1.21 @@ -69,6 +71,8 @@
    1.22  		ln -s $(lib_so) $(soname) && \
    1.23  		ln -s $(soname) $(devlink) || \
    1.24  		true
    1.25 +	mkdir -p $(DESTDIR)$(PREFIX)/share/pkgconfig
    1.26 +	cp $(pcfile) $(DESTDIR)$(PREFIX)/share/pkgconfig/$(pcfile)
    1.27  
    1.28  .PHONY: uninstall
    1.29  uninstall:
    1.30 @@ -80,3 +84,4 @@
    1.31  		rm -f $(DESTDIR)$(PREFIX)/lib/$(soname) && \
    1.32  		rm -f $(DESTDIR)$(PREFIX)/lib/$(devlink) || \
    1.33  		true
    1.34 +	rm -f $(DESTDIR)$(PREFIX)/share/pkgconfig/$(pcfile)
     2.1 --- a/configure	Sat Dec 28 06:48:23 2013 +0200
     2.2 +++ b/configure	Tue Feb 25 23:47:48 2014 +0200
     2.3 @@ -5,7 +5,7 @@
     2.4  dbg=true
     2.5  vr=true
     2.6  
     2.7 -for arg; do
     2.8 +for arg in $#; do
     2.9  	case "$arg" in
    2.10  	--prefix=*)
    2.11  		value=`echo $arg | sed 's/--prefix=//'`
    2.12 @@ -204,6 +204,25 @@
    2.13  	cat Makefile.in >>Makefile
    2.14  }
    2.15  
    2.16 +gen_pkgconfig()
    2.17 +{
    2.18 +	pcfile=goat3dgfx.pc
    2.19 +	echo "generating: $pcfile ..."
    2.20 +	begin_emit $pcfile
    2.21 +
    2.22 +	emit "prefix=$prefix"
    2.23 +	emit "ver=0.1"
    2.24 +
    2.25 +	if [ `uname -s` = Darwin ]; then
    2.26 +		emit 'libgl=-framework OpenGL -framework GLUT -lGLEW'
    2.27 +	else
    2.28 +		emit 'libgl=-lGL -lGLU -lglut -lGLEW'
    2.29 +	fi
    2.30 +	emit 'libovr='
    2.31 +
    2.32 +	cat ${pcfile}.in >>$pcfile
    2.33 +}
    2.34 +
    2.35  check_opengl
    2.36  check_glut
    2.37  check_glew
    2.38 @@ -211,3 +230,4 @@
    2.39  
    2.40  gen_makefile
    2.41  gen_config
    2.42 +gen_pkgconfig
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/goat3dgfx.pc.in	Tue Feb 25 23:47:48 2014 +0200
     3.3 @@ -0,0 +1,8 @@
     3.4 +libdir=${prefix}/lib
     3.5 +incdir=${prefix}/include/goat3dgfx
     3.6 +
     3.7 +Name: goat3dgfx
     3.8 +Description: Mutant Stargoat 3D graphics engine
     3.9 +Version: ${ver}
    3.10 +Cflags: -I${incdir}
    3.11 +Libs: -L${libdir} ${libgl} ${libovr} -lgoat3dgfx -lvmath -limago -lpsys -lvmath -lresman -lm
     4.1 --- a/src/geom.cc	Sat Dec 28 06:48:23 2013 +0200
     4.2 +++ b/src/geom.cc	Tue Feb 25 23:47:48 2014 +0200
     4.3 @@ -49,6 +49,12 @@
     4.4  	error_log("Sphere::intersection undefined\n");
     4.5  }
     4.6  
     4.7 +bool Sphere::contains(const Vector3 &pt) const
     4.8 +{
     4.9 +	float dist_sq = (pt - center).length_sq();
    4.10 +	return dist_sq <= radius * radius;
    4.11 +}
    4.12 +
    4.13  bool Sphere::intersect(const Ray &ray, HitPoint *hit) const
    4.14  {
    4.15  	float a = dot_product(ray.dir, ray.dir);
    4.16 @@ -136,6 +142,13 @@
    4.17  	}
    4.18  }
    4.19  
    4.20 +bool AABox::contains(const Vector3 &pt) const
    4.21 +{
    4.22 +	return pt.x >= min.x && pt.x <= max.x &&
    4.23 +		pt.y >= min.y && pt.y <= max.y &&
    4.24 +		pt.z >= min.z && pt.z <= max.z;
    4.25 +}
    4.26 +
    4.27  bool AABox::intersect(const Ray &ray, HitPoint *hit) const
    4.28  {
    4.29  	Vector3 param[2] = {min, max};
    4.30 @@ -235,6 +248,11 @@
    4.31  	error_log("Plane::set_intersection undefined\n");
    4.32  }
    4.33  
    4.34 +bool Plane::contains(const Vector3 &pt) const
    4.35 +{
    4.36 +	return false;	// TODO: maybe define containment as half-space containment?
    4.37 +}
    4.38 +
    4.39  bool Plane::intersect(const Ray &ray, HitPoint *hit) const
    4.40  {
    4.41  	float ndotdir = dot_product(normal, ray.dir);
     5.1 --- a/src/geom.h	Sat Dec 28 06:48:23 2013 +0200
     5.2 +++ b/src/geom.h	Tue Feb 25 23:47:48 2014 +0200
     5.3 @@ -21,6 +21,7 @@
     5.4  	virtual void set_union(const GeomObject *obj1, const GeomObject *obj2) = 0;
     5.5  	virtual void set_intersection(const GeomObject *obj1, const GeomObject *obj2) = 0;
     5.6  
     5.7 +	virtual bool contains(const Vector3 &pt) const = 0;
     5.8  	virtual bool intersect(const Ray &ray, HitPoint *hit = 0) const = 0;
     5.9  };
    5.10  
    5.11 @@ -35,6 +36,7 @@
    5.12  	void set_union(const GeomObject *obj1, const GeomObject *obj2);
    5.13  	void set_intersection(const GeomObject *obj1, const GeomObject *obj2);
    5.14  
    5.15 +	bool contains(const Vector3 &pt) const;
    5.16  	bool intersect(const Ray &ray, HitPoint *hit = 0) const;
    5.17  };
    5.18  
    5.19 @@ -48,6 +50,7 @@
    5.20  	void set_union(const GeomObject *obj1, const GeomObject *obj2);
    5.21  	void set_intersection(const GeomObject *obj1, const GeomObject *obj2);
    5.22  
    5.23 +	bool contains(const Vector3 &pt) const;
    5.24  	bool intersect(const Ray &ray, HitPoint *hit = 0) const;
    5.25  };
    5.26  
    5.27 @@ -63,6 +66,7 @@
    5.28  	void set_union(const GeomObject *obj1, const GeomObject *obj2);
    5.29  	void set_intersection(const GeomObject *obj1, const GeomObject *obj2);
    5.30  
    5.31 +	bool contains(const Vector3 &pt) const;
    5.32  	bool intersect(const Ray &ray, HitPoint *hit = 0) const;
    5.33  };
    5.34  
     6.1 --- a/src/goat3dgfx.h	Sat Dec 28 06:48:23 2013 +0200
     6.2 +++ b/src/goat3dgfx.h	Tue Feb 25 23:47:48 2014 +0200
     6.3 @@ -2,6 +2,7 @@
     6.4  #define GOAT3DGFX_H_
     6.5  
     6.6  #include <goat3dgfx/assload.h>
     6.7 +#include <goat3dgfx/camera.h>
     6.8  #include <goat3dgfx/curve.h>
     6.9  #include <goat3dgfx/curveload.h>
    6.10  #include <goat3dgfx/datapath.h>