[Jahshaka-cvs] SF.net SVN: editopia:[172] cinesuite/cineplay-cinecode/trunk/src
Status: Beta
Brought to you by:
jahshaka
From: <tim...@us...> - 2008-08-08 08:03:12
|
Revision: 172 http://editopia.svn.sourceforge.net/editopia/?rev=172&view=rev Author: timdewhirst Date: 2008-08-08 08:03:08 +0000 (Fri, 08 Aug 2008) Log Message: ----------- cinesuite - add of geometry and lerp classes Modified Paths: -------------- cinesuite/cineplay-cinecode/trunk/src/common.pri Added Paths: ----------- cinesuite/cineplay-cinecode/trunk/src/Geometry.hpp cinesuite/cineplay-cinecode/trunk/src/Lerp.hpp Added: cinesuite/cineplay-cinecode/trunk/src/Geometry.hpp =================================================================== --- cinesuite/cineplay-cinecode/trunk/src/Geometry.hpp (rev 0) +++ cinesuite/cineplay-cinecode/trunk/src/Geometry.hpp 2008-08-08 08:03:08 UTC (rev 172) @@ -0,0 +1,76 @@ +/* -*- mode: C++; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*- */ + +// This file is part of Cineplay +// +// Cineplay is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// Cineplay is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see <http://www.gnu.org/licenses/>. +// +// Copyright (C) 2008 Audiotube Ltd. +// For more information, see http://www.audiotube.com + +#pragma once + +// std +#include <list> +#include <iostream> + +/// Basic 3D point class +struct point3 +{ + point3() + : x( 0 ), y( 0 ), z( 0 ) + {} + + point3( double x_, double y_, double z_ ) + : x( x_ ), y( y_ ), z( z_ ) + {} + + point3( const point3& rhs ) + : x( rhs.x ), y( rhs.y ), z( rhs.z ) + {} + + const point3& operator=( const point3& rhs ) + { + x = rhs.x; y = rhs.y; z = rhs.z; + return *this; + } + + double x, y, z; +}; + +static std::ostream& operator<<( std::ostream& os, const point3& p ) +{ + os << "(" << p.x << ", " << p.y << ", " << p.z << ")"; + return os; +} + +/// An ordered set of points in 3D space. The convention +/// is that these follow a right handed system with normal +/// towards the observer starting in quadrant 1 i.e. for a +/// square (0, 0), (1, 0), (1, 1), (0, 1) we would have: +/// - a == (1, 1) +/// - b == (0, 1) +/// - c == (0, 0) +/// - d == (1, 0) +struct quad3 +{ + point3 a, b, c, d; +}; + +static std::ostream& operator<<( std::ostream& os, const quad3& q ) +{ + os << "[" << q.a << ", " << q.b << ", " << q.c << ", " << q.d << "]"; + return os; +} + +typedef std::list< quad3 > quad3_list; Added: cinesuite/cineplay-cinecode/trunk/src/Lerp.hpp =================================================================== --- cinesuite/cineplay-cinecode/trunk/src/Lerp.hpp (rev 0) +++ cinesuite/cineplay-cinecode/trunk/src/Lerp.hpp 2008-08-08 08:03:08 UTC (rev 172) @@ -0,0 +1,52 @@ +/* -*- mode: C++; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*- */ + +// This file is part of Cineplay +// +// Cineplay is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// Cineplay is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see <http://www.gnu.org/licenses/>. +// +// Copyright (C) 2008 Audiotube Ltd. +// For more information, see http://www.audiotube.com + +#pragma once + +#include "Geometry.hpp" + +// return a value linearly interpolated between start, end +// according to value \a p [0:1] +template < class T > +T Lerp( const T& start, const T& end, double p ) +{ + T diff = end - start; + return start + p*diff; +} + +template <> +point3 Lerp( const point3& start, const point3& end, double p ) +{ + return point3( Lerp( start.x, end.x, p ), + Lerp( start.y, end.y, p ), + Lerp( start.z, end.z, p ) ); +} + +template <> +quad3 Lerp( const quad3& start, const quad3& end, double p ) +{ + quad3 result; + result.a = Lerp( start.a, end.a, p ); + result.b = Lerp( start.b, end.b, p ); + result.c = Lerp( start.c, end.c, p ); + result.d = Lerp( start.d, end.d, p ); + + return result; +} Modified: cinesuite/cineplay-cinecode/trunk/src/common.pri =================================================================== --- cinesuite/cineplay-cinecode/trunk/src/common.pri 2008-07-29 23:22:37 UTC (rev 171) +++ cinesuite/cineplay-cinecode/trunk/src/common.pri 2008-08-08 08:03:08 UTC (rev 172) @@ -50,7 +50,9 @@ PlayerMultiplexer.hpp \ LogMessageHandler.h \ ScrollViewResizer.h \ - GridLayoutCallback.h + GridLayoutCallback.h \ + Geometry.hpp \ + Lerp.hpp SOURCES += \ AddFavouriteDlg.cpp \ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |