indent classes, align by spaces
This commit is contained in:
@@ -41,35 +41,35 @@ class VolumeTest
|
||||
public:
|
||||
|
||||
/// \brief Returns true if \p point intersects volume.
|
||||
virtual bool TestPoint( const Vector3& point ) const = 0;
|
||||
virtual bool TestPoint( const Vector3& point ) const = 0;
|
||||
/// \brief Returns true if \p segment intersects volume.
|
||||
virtual bool TestLine( const Segment& segment ) const = 0;
|
||||
virtual bool TestLine( const Segment& segment ) const = 0;
|
||||
/// \brief Returns true if \p plane faces towards volume.
|
||||
virtual bool TestPlane( const Plane3& plane ) const = 0;
|
||||
virtual bool TestPlane( const Plane3& plane ) const = 0;
|
||||
/// \brief Returns true if \p plane transformed by \p localToWorld faces the viewer.
|
||||
virtual bool TestPlane( const Plane3& plane, const Matrix4& localToWorld ) const = 0;
|
||||
virtual bool TestPlane( const Plane3& plane, const Matrix4& localToWorld ) const = 0;
|
||||
/// \brief Returns the intersection of \p aabb and volume.
|
||||
virtual VolumeIntersectionValue TestAABB( const AABB& aabb ) const = 0;
|
||||
virtual VolumeIntersectionValue TestAABB( const AABB& aabb ) const = 0;
|
||||
/// \brief Returns the intersection of \p aabb transformed by \p localToWorld and volume.
|
||||
virtual VolumeIntersectionValue TestAABB( const AABB& aabb, const Matrix4& localToWorld ) const = 0;
|
||||
virtual VolumeIntersectionValue TestAABB( const AABB& aabb, const Matrix4& localToWorld ) const = 0;
|
||||
|
||||
virtual bool fill() const = 0;
|
||||
virtual bool fill() const = 0;
|
||||
|
||||
virtual const Matrix4& GetViewport() const = 0;
|
||||
virtual const Matrix4& GetProjection() const = 0;
|
||||
virtual const Matrix4& GetModelview() const = 0;
|
||||
virtual const Matrix4& GetViewport() const = 0;
|
||||
virtual const Matrix4& GetProjection() const = 0;
|
||||
virtual const Matrix4& GetModelview() const = 0;
|
||||
|
||||
virtual const Matrix4& GetViewMatrix() const = 0; //viewproj
|
||||
virtual const Vector3& getViewer() const = 0;
|
||||
virtual const Vector3& getViewDir() const = 0;
|
||||
virtual const Matrix4& GetViewMatrix() const = 0; //viewproj
|
||||
virtual const Vector3& getViewer() const = 0;
|
||||
virtual const Vector3& getViewDir() const = 0;
|
||||
};
|
||||
|
||||
class Cullable
|
||||
{
|
||||
public:
|
||||
STRING_CONSTANT( Name, "Cullable" );
|
||||
STRING_CONSTANT( Name, "Cullable" );
|
||||
|
||||
virtual VolumeIntersectionValue intersectVolume( const VolumeTest& test, const Matrix4& localToWorld ) const = 0;
|
||||
virtual VolumeIntersectionValue intersectVolume( const VolumeTest& test, const Matrix4& localToWorld ) const = 0;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -29,9 +29,9 @@ class Matrix4;
|
||||
class Editable
|
||||
{
|
||||
public:
|
||||
STRING_CONSTANT( Name, "Editable" );
|
||||
STRING_CONSTANT( Name, "Editable" );
|
||||
|
||||
virtual const Matrix4& getLocalPivot() const = 0;
|
||||
virtual const Matrix4& getLocalPivot() const = 0;
|
||||
};
|
||||
|
||||
inline Editable* Node_getEditable( scene::Node& node ){
|
||||
@@ -41,9 +41,9 @@ inline Editable* Node_getEditable( scene::Node& node ){
|
||||
class Snappable
|
||||
{
|
||||
public:
|
||||
STRING_CONSTANT( Name, "Snappable" );
|
||||
STRING_CONSTANT( Name, "Snappable" );
|
||||
|
||||
virtual void snapto( float snap ) = 0;
|
||||
virtual void snapto( float snap ) = 0;
|
||||
};
|
||||
|
||||
inline Snappable* Node_getSnappable( scene::Node& node ){
|
||||
|
||||
@@ -32,16 +32,16 @@ class ArchiveFile
|
||||
{
|
||||
public:
|
||||
/// \brief Destroys the file object.
|
||||
virtual void release() = 0;
|
||||
virtual void release() = 0;
|
||||
/// \brief Returns the size of the file data in bytes.
|
||||
virtual std::size_t size() const = 0;
|
||||
virtual std::size_t size() const = 0;
|
||||
/// \brief Returns the path to this file (relative to the filesystem root)
|
||||
virtual const char* getName() const = 0;
|
||||
virtual const char* getName() const = 0;
|
||||
/// \brief Returns the stream associated with this file.
|
||||
/// Subsequent calls return the same stream.
|
||||
/// The stream may be read forwards until it is exhausted.
|
||||
/// The stream remains valid for the lifetime of the file.
|
||||
virtual InputStream& getInputStream() = 0;
|
||||
virtual InputStream& getInputStream() = 0;
|
||||
};
|
||||
|
||||
class TextInputStream;
|
||||
@@ -51,23 +51,23 @@ class ArchiveTextFile
|
||||
{
|
||||
public:
|
||||
/// \brief Destroys the file object.
|
||||
virtual void release() = 0;
|
||||
virtual void release() = 0;
|
||||
/// \brief Returns the stream associated with this file.
|
||||
/// Subsequent calls return the same stream.
|
||||
/// The stream may be read forwards until it is exhausted.
|
||||
/// The stream remains valid for the lifetime of the file.
|
||||
virtual TextInputStream& getInputStream() = 0;
|
||||
virtual TextInputStream& getInputStream() = 0;
|
||||
};
|
||||
|
||||
class ScopedArchiveFile
|
||||
{
|
||||
ArchiveFile& m_file;
|
||||
ArchiveFile& m_file;
|
||||
public:
|
||||
ScopedArchiveFile( ArchiveFile& file ) : m_file( file ){
|
||||
}
|
||||
~ScopedArchiveFile(){
|
||||
m_file.release();
|
||||
}
|
||||
ScopedArchiveFile( ArchiveFile& file ) : m_file( file ){
|
||||
}
|
||||
~ScopedArchiveFile(){
|
||||
m_file.release();
|
||||
}
|
||||
};
|
||||
|
||||
class CustomArchiveVisitor;
|
||||
@@ -76,33 +76,33 @@ class Archive
|
||||
{
|
||||
public:
|
||||
|
||||
class Visitor
|
||||
{
|
||||
public:
|
||||
virtual void visit( const char* name ) = 0;
|
||||
};
|
||||
class Visitor
|
||||
{
|
||||
public:
|
||||
virtual void visit( const char* name ) = 0;
|
||||
};
|
||||
|
||||
typedef CustomArchiveVisitor VisitorFunc;
|
||||
typedef CustomArchiveVisitor VisitorFunc;
|
||||
|
||||
enum EMode
|
||||
{
|
||||
eFiles = 0x01,
|
||||
eDirectories = 0x02,
|
||||
eFilesAndDirectories = 0x03,
|
||||
};
|
||||
enum EMode
|
||||
{
|
||||
eFiles = 0x01,
|
||||
eDirectories = 0x02,
|
||||
eFilesAndDirectories = 0x03,
|
||||
};
|
||||
|
||||
/// \brief Destroys the archive object.
|
||||
/// Any unreleased file object associated with the archive remains valid. */
|
||||
virtual void release() = 0;
|
||||
virtual void release() = 0;
|
||||
/// \brief Returns a new object associated with the file identified by \p name, or 0 if the file cannot be opened.
|
||||
/// Name comparisons are case-insensitive.
|
||||
virtual ArchiveFile* openFile( const char* name ) = 0;
|
||||
virtual ArchiveFile* openFile( const char* name ) = 0;
|
||||
/// \brief Returns a new object associated with the file identified by \p name, or 0 if the file cannot be opened.
|
||||
/// Name comparisons are case-insensitive.
|
||||
virtual ArchiveTextFile* openTextFile( const char* name ) = 0;
|
||||
virtual ArchiveTextFile* openTextFile( const char* name ) = 0;
|
||||
/// Returns true if the file identified by \p name can be opened.
|
||||
/// Name comparisons are case-insensitive.
|
||||
virtual bool containsFile( const char* name ) = 0;
|
||||
virtual bool containsFile( const char* name ) = 0;
|
||||
/// \brief Performs a depth-first traversal of the archive tree starting at \p root.
|
||||
/// Traverses the entire tree if \p root is "".
|
||||
/// When a file is encountered, calls \c visitor.file passing the file name.
|
||||
@@ -110,32 +110,32 @@ virtual bool containsFile( const char* name ) = 0;
|
||||
/// Skips the directory if \c visitor.directory returned true.
|
||||
/// Root comparisons are case-insensitive.
|
||||
/// Names are mixed-case.
|
||||
virtual void forEachFile( VisitorFunc visitor, const char* root ) = 0;
|
||||
virtual void forEachFile( VisitorFunc visitor, const char* root ) = 0;
|
||||
};
|
||||
|
||||
class CustomArchiveVisitor
|
||||
{
|
||||
Archive::Visitor* m_visitor;
|
||||
Archive::EMode m_mode;
|
||||
std::size_t m_depth;
|
||||
Archive::Visitor* m_visitor;
|
||||
Archive::EMode m_mode;
|
||||
std::size_t m_depth;
|
||||
public:
|
||||
CustomArchiveVisitor( Archive::Visitor& visitor, Archive::EMode mode, std::size_t depth )
|
||||
: m_visitor( &visitor ), m_mode( mode ), m_depth( depth ){
|
||||
}
|
||||
void file( const char* name ){
|
||||
if ( ( m_mode & Archive::eFiles ) != 0 ) {
|
||||
m_visitor->visit( name );
|
||||
CustomArchiveVisitor( Archive::Visitor& visitor, Archive::EMode mode, std::size_t depth )
|
||||
: m_visitor( &visitor ), m_mode( mode ), m_depth( depth ){
|
||||
}
|
||||
}
|
||||
bool directory( const char* name, std::size_t depth ){
|
||||
if ( ( m_mode & Archive::eDirectories ) != 0 ) {
|
||||
m_visitor->visit( name );
|
||||
void file( const char* name ){
|
||||
if ( ( m_mode & Archive::eFiles ) != 0 ) {
|
||||
m_visitor->visit( name );
|
||||
}
|
||||
}
|
||||
if ( depth == m_depth ) {
|
||||
return true;
|
||||
bool directory( const char* name, std::size_t depth ){
|
||||
if ( ( m_mode & Archive::eDirectories ) != 0 ) {
|
||||
m_visitor->visit( name );
|
||||
}
|
||||
if ( depth == m_depth ) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
typedef Archive* ( *PFN_OPENARCHIVE )( const char* name );
|
||||
@@ -143,10 +143,10 @@ typedef Archive* ( *PFN_OPENARCHIVE )( const char* name );
|
||||
class _QERArchiveTable
|
||||
{
|
||||
public:
|
||||
INTEGER_CONSTANT( Version, 1 );
|
||||
STRING_CONSTANT( Name, "archive" );
|
||||
INTEGER_CONSTANT( Version, 1 );
|
||||
STRING_CONSTANT( Name, "archive" );
|
||||
|
||||
PFN_OPENARCHIVE m_pfnOpenArchive;
|
||||
PFN_OPENARCHIVE m_pfnOpenArchive;
|
||||
};
|
||||
|
||||
template<typename Type>
|
||||
|
||||
@@ -49,63 +49,63 @@ class Node;
|
||||
class IBrushFace
|
||||
{
|
||||
public:
|
||||
virtual const char* GetShader() const = 0;
|
||||
virtual void SetShader( const char* name ) = 0;
|
||||
virtual const TextureProjection& GetTexdef() const = 0;
|
||||
virtual void GetTexdef( TextureProjection& projection ) const = 0;
|
||||
virtual void SetTexdef( const TextureProjection& projection ) = 0;
|
||||
virtual void GetFlags( ContentsFlagsValue& flags ) const = 0;
|
||||
virtual void SetFlags( const ContentsFlagsValue& flags ) = 0;
|
||||
virtual void ShiftTexdef( float s, float t ) = 0;
|
||||
virtual void ScaleTexdef( float s, float t ) = 0;
|
||||
virtual void RotateTexdef( float angle ) = 0;
|
||||
virtual void FitTexture( float s_repeat, float t_repeat ) = 0;
|
||||
virtual bool isDetail() const = 0;
|
||||
virtual void setDetail( bool detail ) = 0;
|
||||
virtual const char* GetShader() const = 0;
|
||||
virtual void SetShader( const char* name ) = 0;
|
||||
virtual const TextureProjection& GetTexdef() const = 0;
|
||||
virtual void GetTexdef( TextureProjection& projection ) const = 0;
|
||||
virtual void SetTexdef( const TextureProjection& projection ) = 0;
|
||||
virtual void GetFlags( ContentsFlagsValue& flags ) const = 0;
|
||||
virtual void SetFlags( const ContentsFlagsValue& flags ) = 0;
|
||||
virtual void ShiftTexdef( float s, float t ) = 0;
|
||||
virtual void ScaleTexdef( float s, float t ) = 0;
|
||||
virtual void RotateTexdef( float angle ) = 0;
|
||||
virtual void FitTexture( float s_repeat, float t_repeat ) = 0;
|
||||
virtual bool isDetail() const = 0;
|
||||
virtual void setDetail( bool detail ) = 0;
|
||||
};
|
||||
|
||||
class IBrush
|
||||
{
|
||||
public:
|
||||
STRING_CONSTANT( Name, "IBrush" );
|
||||
virtual void reserve( std::size_t count ) = 0;
|
||||
virtual void clear() = 0;
|
||||
virtual void copy( const IBrush& other ) = 0;
|
||||
virtual IBrushFace* addPlane( const Vector3& p0, const Vector3& p1, const Vector3& p2, const char* shader, const TextureProjection& projection ) = 0;
|
||||
virtual const AABB& localAABB() const = 0;
|
||||
virtual void removeEmptyFaces() = 0;
|
||||
STRING_CONSTANT( Name, "IBrush" );
|
||||
virtual void reserve( std::size_t count ) = 0;
|
||||
virtual void clear() = 0;
|
||||
virtual void copy( const IBrush& other ) = 0;
|
||||
virtual IBrushFace* addPlane( const Vector3& p0, const Vector3& p1, const Vector3& p2, const char* shader, const TextureProjection& projection ) = 0;
|
||||
virtual const AABB& localAABB() const = 0;
|
||||
virtual void removeEmptyFaces() = 0;
|
||||
};
|
||||
|
||||
class IBrushFaceInstance
|
||||
{
|
||||
public:
|
||||
virtual IBrushFace& getFace() = 0;
|
||||
virtual const IBrushFace& getFace() const = 0;
|
||||
virtual bool isSelected() const = 0;
|
||||
virtual void setSelected( SelectionSystem::EComponentMode mode, bool select ) const = 0;
|
||||
virtual IBrushFace& getFace() = 0;
|
||||
virtual const IBrushFace& getFace() const = 0;
|
||||
virtual bool isSelected() const = 0;
|
||||
virtual void setSelected( SelectionSystem::EComponentMode mode, bool select ) const = 0;
|
||||
};
|
||||
|
||||
class IBrushInstance
|
||||
{
|
||||
public:
|
||||
STRING_CONSTANT( Name, "IBrushInstance" );
|
||||
virtual void forEachFaceInstance( const BrushInstanceVisitor& visitor ) = 0;
|
||||
STRING_CONSTANT( Name, "IBrushInstance" );
|
||||
virtual void forEachFaceInstance( const BrushInstanceVisitor& visitor ) = 0;
|
||||
};
|
||||
#endif
|
||||
|
||||
class _QERFaceData
|
||||
{
|
||||
public:
|
||||
_QERFaceData() : m_shader( "" ), contents( 0 ), flags( 0 ), value( 0 ){
|
||||
}
|
||||
Vector3 m_p0;
|
||||
Vector3 m_p1;
|
||||
Vector3 m_p2;
|
||||
texdef_t m_texdef;
|
||||
const char* m_shader;
|
||||
int contents;
|
||||
int flags;
|
||||
int value;
|
||||
_QERFaceData() : m_shader( "" ), contents( 0 ), flags( 0 ), value( 0 ){
|
||||
}
|
||||
Vector3 m_p0;
|
||||
Vector3 m_p1;
|
||||
Vector3 m_p2;
|
||||
texdef_t m_texdef;
|
||||
const char* m_shader;
|
||||
int contents;
|
||||
int flags;
|
||||
int value;
|
||||
};
|
||||
|
||||
typedef Callback1<const _QERFaceData&> BrushFaceDataCallback;
|
||||
@@ -113,13 +113,13 @@ typedef Callback1<const _QERFaceData&> BrushFaceDataCallback;
|
||||
class BrushCreator
|
||||
{
|
||||
public:
|
||||
INTEGER_CONSTANT( Version, 1 );
|
||||
STRING_CONSTANT( Name, "brush" );
|
||||
virtual scene::Node& createBrush() = 0;
|
||||
virtual EBrushType getFormat() const = 0;
|
||||
virtual void toggleFormat( EBrushType type ) const = 0;
|
||||
virtual void Brush_forEachFace( scene::Node& brush, const BrushFaceDataCallback& callback ) = 0;
|
||||
virtual bool Brush_addFace( scene::Node& brush, const _QERFaceData& faceData ) = 0;
|
||||
INTEGER_CONSTANT( Version, 1 );
|
||||
STRING_CONSTANT( Name, "brush" );
|
||||
virtual scene::Node& createBrush() = 0;
|
||||
virtual EBrushType getFormat() const = 0;
|
||||
virtual void toggleFormat( EBrushType type ) const = 0;
|
||||
virtual void Brush_forEachFace( scene::Node& brush, const BrushFaceDataCallback& callback ) = 0;
|
||||
virtual bool Brush_addFace( scene::Node& brush, const _QERFaceData& faceData ) = 0;
|
||||
};
|
||||
|
||||
#include "modulesystem.h"
|
||||
|
||||
@@ -36,15 +36,15 @@ class Matrix4;
|
||||
class CameraView
|
||||
{
|
||||
public:
|
||||
virtual void setModelview( const Matrix4& modelview ) = 0;
|
||||
virtual void setFieldOfView( float fieldOfView ) = 0;
|
||||
virtual void setModelview( const Matrix4& modelview ) = 0;
|
||||
virtual void setFieldOfView( float fieldOfView ) = 0;
|
||||
};
|
||||
|
||||
class CameraModel
|
||||
{
|
||||
public:
|
||||
STRING_CONSTANT( Name, "CameraModel" );
|
||||
virtual void setCameraView( CameraView* view, const Callback& disconnect ) = 0;
|
||||
STRING_CONSTANT( Name, "CameraModel" );
|
||||
virtual void setCameraView( CameraView* view, const Callback& disconnect ) = 0;
|
||||
};
|
||||
|
||||
template<typename Element> class BasicVector3;
|
||||
|
||||
@@ -27,8 +27,8 @@
|
||||
class StreamBase
|
||||
{
|
||||
public:
|
||||
typedef std::size_t size_type;
|
||||
typedef unsigned char byte_type;
|
||||
typedef std::size_t size_type;
|
||||
typedef unsigned char byte_type;
|
||||
};
|
||||
|
||||
/// \brief A read-only byte-stream.
|
||||
@@ -37,7 +37,7 @@ class InputStream : public StreamBase
|
||||
public:
|
||||
/// \brief Attempts to read the next \p length bytes from the stream to \p buffer.
|
||||
/// Returns the number of bytes actually stored in \p buffer.
|
||||
virtual size_type read( byte_type* buffer, size_type length ) = 0;
|
||||
virtual size_type read( byte_type* buffer, size_type length ) = 0;
|
||||
};
|
||||
|
||||
/// \brief A write-only byte-stream.
|
||||
@@ -46,28 +46,28 @@ class OutputStream : public StreamBase
|
||||
public:
|
||||
/// \brief Attempts to write \p length bytes to the stream from \p buffer.
|
||||
/// Returns the number of bytes actually read from \p buffer.
|
||||
virtual size_type write( const byte_type* buffer, size_type length ) = 0;
|
||||
virtual size_type write( const byte_type* buffer, size_type length ) = 0;
|
||||
};
|
||||
|
||||
class SeekableStream
|
||||
{
|
||||
public:
|
||||
typedef int offset_type;
|
||||
typedef std::size_t position_type;
|
||||
typedef int offset_type;
|
||||
typedef std::size_t position_type;
|
||||
|
||||
enum seekdir
|
||||
{
|
||||
beg,
|
||||
cur,
|
||||
end,
|
||||
};
|
||||
enum seekdir
|
||||
{
|
||||
beg,
|
||||
cur,
|
||||
end,
|
||||
};
|
||||
|
||||
/// \brief Sets the current \p position of the stream relative to the start.
|
||||
virtual position_type seek( position_type position ) = 0;
|
||||
virtual position_type seek( position_type position ) = 0;
|
||||
/// \brief Sets the current \p position of the stream relative to either the start, end or current position.
|
||||
virtual position_type seek( offset_type offset, seekdir direction ) = 0;
|
||||
virtual position_type seek( offset_type offset, seekdir direction ) = 0;
|
||||
/// \brief Returns the current position of the stream.
|
||||
virtual position_type tell() const = 0;
|
||||
virtual position_type tell() const = 0;
|
||||
};
|
||||
|
||||
/// \brief A seekable read-only byte-stream.
|
||||
|
||||
@@ -45,9 +45,9 @@ class ListAttributeType;
|
||||
class EntityClassCollector
|
||||
{
|
||||
public:
|
||||
virtual void insert( EntityClass* eclass ) = 0;
|
||||
virtual void insert( const char* name, const ListAttributeType& list ){
|
||||
}
|
||||
virtual void insert( EntityClass* eclass ) = 0;
|
||||
virtual void insert( const char* name, const ListAttributeType& list ){
|
||||
}
|
||||
};
|
||||
|
||||
struct EntityClassScanner
|
||||
@@ -81,7 +81,7 @@ typedef ModulesRef<EntityClassScanner> EClassModulesRef;
|
||||
class EntityClassVisitor
|
||||
{
|
||||
public:
|
||||
virtual void visit( EntityClass* eclass ) = 0;
|
||||
virtual void visit( EntityClass* eclass ) = 0;
|
||||
};
|
||||
|
||||
class ModuleObserver;
|
||||
|
||||
@@ -34,53 +34,53 @@ typedef Callback1<const char*> KeyObserver;
|
||||
class EntityKeyValue
|
||||
{
|
||||
public:
|
||||
virtual const char* c_str() const = 0;
|
||||
virtual void assign( const char* other ) = 0;
|
||||
virtual void attach( const KeyObserver& observer ) = 0;
|
||||
virtual void detach( const KeyObserver& observer ) = 0;
|
||||
virtual const char* c_str() const = 0;
|
||||
virtual void assign( const char* other ) = 0;
|
||||
virtual void attach( const KeyObserver& observer ) = 0;
|
||||
virtual void detach( const KeyObserver& observer ) = 0;
|
||||
};
|
||||
|
||||
class Entity
|
||||
{
|
||||
public:
|
||||
STRING_CONSTANT( Name, "Entity" );
|
||||
STRING_CONSTANT( Name, "Entity" );
|
||||
|
||||
class Observer
|
||||
{
|
||||
public:
|
||||
virtual void insert( const char* key, EntityKeyValue& value ) = 0;
|
||||
virtual void erase( const char* key, EntityKeyValue& value ) = 0;
|
||||
virtual void clear() { };
|
||||
};
|
||||
class Observer
|
||||
{
|
||||
public:
|
||||
virtual void insert( const char* key, EntityKeyValue& value ) = 0;
|
||||
virtual void erase( const char* key, EntityKeyValue& value ) = 0;
|
||||
virtual void clear() { };
|
||||
};
|
||||
|
||||
class Visitor
|
||||
{
|
||||
public:
|
||||
virtual void visit( const char* key, const char* value ) = 0;
|
||||
};
|
||||
class Visitor
|
||||
{
|
||||
public:
|
||||
virtual void visit( const char* key, const char* value ) = 0;
|
||||
};
|
||||
|
||||
virtual const EntityClass& getEntityClass() const = 0;
|
||||
virtual void forEachKeyValue( Visitor& visitor ) const = 0;
|
||||
virtual void setKeyValue( const char* key, const char* value ) = 0;
|
||||
virtual const char* getKeyValue( const char* key ) const = 0;
|
||||
virtual bool isContainer() const = 0;
|
||||
virtual void attach( Observer& observer ) = 0;
|
||||
virtual void detach( Observer& observer ) = 0;
|
||||
virtual const EntityClass& getEntityClass() const = 0;
|
||||
virtual void forEachKeyValue( Visitor& visitor ) const = 0;
|
||||
virtual void setKeyValue( const char* key, const char* value ) = 0;
|
||||
virtual const char* getKeyValue( const char* key ) const = 0;
|
||||
virtual bool isContainer() const = 0;
|
||||
virtual void attach( Observer& observer ) = 0;
|
||||
virtual void detach( Observer& observer ) = 0;
|
||||
};
|
||||
|
||||
class EntityCopyingVisitor : public Entity::Visitor
|
||||
{
|
||||
Entity& m_entity;
|
||||
Entity& m_entity;
|
||||
public:
|
||||
EntityCopyingVisitor( Entity& entity )
|
||||
: m_entity( entity ){
|
||||
}
|
||||
|
||||
void visit( const char* key, const char* value ){
|
||||
if ( !string_equal( key, "classname" ) ) {
|
||||
m_entity.setKeyValue( key, value );
|
||||
EntityCopyingVisitor( Entity& entity )
|
||||
: m_entity( entity ){
|
||||
}
|
||||
|
||||
void visit( const char* key, const char* value ){
|
||||
if ( !string_equal( key, "classname" ) ) {
|
||||
m_entity.setKeyValue( key, value );
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
inline Entity* Node_getEntity( scene::Node& node ){
|
||||
@@ -110,36 +110,36 @@ class Counter;
|
||||
class EntityCreator
|
||||
{
|
||||
public:
|
||||
INTEGER_CONSTANT( Version, 2 );
|
||||
STRING_CONSTANT( Name, "entity" );
|
||||
INTEGER_CONSTANT( Version, 2 );
|
||||
STRING_CONSTANT( Name, "entity" );
|
||||
|
||||
virtual scene::Node& createEntity( EntityClass* eclass ) = 0;
|
||||
virtual scene::Node& createEntity( EntityClass* eclass ) = 0;
|
||||
|
||||
typedef void ( *KeyValueChangedFunc )();
|
||||
virtual void setKeyValueChangedFunc( KeyValueChangedFunc func ) = 0;
|
||||
typedef void ( *KeyValueChangedFunc )();
|
||||
virtual void setKeyValueChangedFunc( KeyValueChangedFunc func ) = 0;
|
||||
|
||||
virtual void setCounter( Counter* counter ) = 0;
|
||||
virtual void setCounter( Counter* counter ) = 0;
|
||||
|
||||
virtual void connectEntities( const scene::Path& e1, const scene::Path& e2, int index ) = 0;
|
||||
virtual void connectEntities( const scene::Path& e1, const scene::Path& e2, int index ) = 0;
|
||||
|
||||
virtual void setLightRadii( bool lightRadii ) = 0;
|
||||
virtual bool getLightRadii() = 0;
|
||||
virtual void setShowNames( bool showNames ) = 0;
|
||||
virtual bool getShowNames() = 0;
|
||||
virtual void setShowBboxes( bool showBboxes ) = 0;
|
||||
virtual bool getShowBboxes() = 0;
|
||||
virtual void setShowConnections( bool showConnections ) = 0;
|
||||
virtual bool getShowConnections() = 0;
|
||||
virtual void setShowNamesDist( int dist ) = 0;
|
||||
virtual int getShowNamesDist() = 0;
|
||||
virtual void setShowNamesRatio( int ratio ) = 0;
|
||||
virtual int getShowNamesRatio() = 0;
|
||||
virtual void setShowTargetNames( bool showNames ) = 0;
|
||||
virtual bool getShowTargetNames() = 0;
|
||||
virtual void setShowAngles( bool showAngles ) = 0;
|
||||
virtual bool getShowAngles() = 0;
|
||||
virtual void setLightRadii( bool lightRadii ) = 0;
|
||||
virtual bool getLightRadii() = 0;
|
||||
virtual void setShowNames( bool showNames ) = 0;
|
||||
virtual bool getShowNames() = 0;
|
||||
virtual void setShowBboxes( bool showBboxes ) = 0;
|
||||
virtual bool getShowBboxes() = 0;
|
||||
virtual void setShowConnections( bool showConnections ) = 0;
|
||||
virtual bool getShowConnections() = 0;
|
||||
virtual void setShowNamesDist( int dist ) = 0;
|
||||
virtual int getShowNamesDist() = 0;
|
||||
virtual void setShowNamesRatio( int ratio ) = 0;
|
||||
virtual int getShowNamesRatio() = 0;
|
||||
virtual void setShowTargetNames( bool showNames ) = 0;
|
||||
virtual bool getShowTargetNames() = 0;
|
||||
virtual void setShowAngles( bool showAngles ) = 0;
|
||||
virtual bool getShowAngles() = 0;
|
||||
|
||||
virtual void printStatistics() const = 0;
|
||||
virtual void printStatistics() const = 0;
|
||||
};
|
||||
|
||||
#include "modulesystem.h"
|
||||
|
||||
@@ -41,65 +41,65 @@ typedef struct _GSList GSList;
|
||||
class VirtualFileSystem
|
||||
{
|
||||
public:
|
||||
INTEGER_CONSTANT( Version, 1 );
|
||||
STRING_CONSTANT( Name, "VFS" );
|
||||
INTEGER_CONSTANT( Version, 1 );
|
||||
STRING_CONSTANT( Name, "VFS" );
|
||||
|
||||
/// \brief Adds a root search \p path.
|
||||
/// Called before \c initialise.
|
||||
virtual void initDirectory( const char *path ) = 0;
|
||||
virtual void initDirectory( const char *path ) = 0;
|
||||
/// \brief Initialises the filesystem.
|
||||
/// Called after all root search paths have been added.
|
||||
virtual void initialise() = 0;
|
||||
virtual void initialise() = 0;
|
||||
/// \brief Shuts down the filesystem.
|
||||
virtual void shutdown() = 0;
|
||||
virtual void shutdown() = 0;
|
||||
|
||||
/// \brief Returns the file identified by \p filename opened in binary mode, or 0 if not found.
|
||||
/// The caller must \c release() the file returned if it is not 0.
|
||||
virtual ArchiveFile* openFile( const char* filename ) = 0;
|
||||
virtual ArchiveFile* openFile( const char* filename ) = 0;
|
||||
/// \brief Returns the file identified by \p filename opened in text mode, or 0 if not found.
|
||||
/// The caller must \c release() the file returned if it is not 0.
|
||||
virtual ArchiveTextFile* openTextFile( const char* filename ) = 0;
|
||||
virtual ArchiveTextFile* openTextFile( const char* filename ) = 0;
|
||||
|
||||
/// \brief Opens the file identified by \p filename and reads it into \p buffer, or sets *\p buffer to 0 if not found.
|
||||
/// Returns the size of the buffer allocated, or undefined value if *\p buffer is 0;
|
||||
/// The caller must free the allocated buffer by calling \c freeFile
|
||||
/// \deprecated Deprecated - use \c openFile.
|
||||
virtual std::size_t loadFile( const char *filename, void **buffer ) = 0;
|
||||
virtual std::size_t loadFile( const char *filename, void **buffer ) = 0;
|
||||
/// \brief Frees the buffer returned by \c loadFile.
|
||||
/// \deprecated Deprecated.
|
||||
virtual void freeFile( void *p ) = 0;
|
||||
virtual void freeFile( void *p ) = 0;
|
||||
|
||||
/// \brief Calls \p callback for each directory under \p basedir.
|
||||
virtual void forEachDirectory( const char* basedir, const FileNameCallback& callback, std::size_t depth = 1 ) = 0;
|
||||
virtual void forEachDirectory( const char* basedir, const FileNameCallback& callback, std::size_t depth = 1 ) = 0;
|
||||
/// \brief Calls \p callback for each file under \p basedir matching \p extension.
|
||||
/// Use "*" as \p extension to match all file extensions.
|
||||
virtual void forEachFile( const char* basedir, const char* extension, const FileNameCallback& callback, std::size_t depth = 1 ) = 0;
|
||||
virtual void forEachFile( const char* basedir, const char* extension, const FileNameCallback& callback, std::size_t depth = 1 ) = 0;
|
||||
|
||||
/// \brief Returns a list containing the relative names of all the directories under \p basedir.
|
||||
/// The caller must free the returned list by calling \c clearFileDirList;
|
||||
/// \deprecated Deprecated - use \c forEachDirectory.
|
||||
virtual GSList* getDirList( const char *basedir ) = 0;
|
||||
virtual GSList* getDirList( const char *basedir ) = 0;
|
||||
/// \brief Returns a list containing the relative names of the files under \p basedir (\p extension can be "*" for all files).
|
||||
/// The caller must free the returned list by calling \c clearFileDirList.
|
||||
/// \deprecated Deprecated - use \c forEachFile.
|
||||
virtual GSList* getFileList( const char *basedir, const char *extension ) = 0;
|
||||
virtual GSList* getFileList( const char *basedir, const char *extension ) = 0;
|
||||
/// \brief Frees the \p list returned from \c getDirList or \c getFileList.
|
||||
/// \deprecated Deprecated.
|
||||
virtual void clearFileDirList( GSList **list ) = 0;
|
||||
virtual void clearFileDirList( GSList **list ) = 0;
|
||||
|
||||
/// \brief Returns the absolute filename for a relative \p name, or "" if not found.
|
||||
virtual const char* findFile( const char* name ) = 0;
|
||||
virtual const char* findFile( const char* name ) = 0;
|
||||
/// \brief Returns the filesystem root for an absolute \p name, or "" if not found.
|
||||
/// This can be used to convert an absolute name to a relative name.
|
||||
virtual const char* findRoot( const char* name ) = 0;
|
||||
virtual const char* findRoot( const char* name ) = 0;
|
||||
|
||||
/// \brief Attach an \p observer whose realise() and unrealise() methods will be called when the filesystem is initialised or shut down.
|
||||
virtual void attach( ModuleObserver& observer ) = 0;
|
||||
virtual void attach( ModuleObserver& observer ) = 0;
|
||||
/// \brief Detach an \p observer previously-attached by calling \c attach.
|
||||
virtual void detach( ModuleObserver& observer ) = 0;
|
||||
virtual void detach( ModuleObserver& observer ) = 0;
|
||||
|
||||
virtual Archive* getArchive( const char* archiveName, bool pakonly = true ) = 0;
|
||||
virtual void forEachArchive( const ArchiveNameCallback& callback, bool pakonly = true, bool reverse = false ) = 0;
|
||||
virtual Archive* getArchive( const char* archiveName, bool pakonly = true ) = 0;
|
||||
virtual void forEachArchive( const ArchiveNameCallback& callback, bool pakonly = true, bool reverse = false ) = 0;
|
||||
};
|
||||
|
||||
#include "modulesystem.h"
|
||||
|
||||
@@ -27,34 +27,34 @@
|
||||
class filetype_t
|
||||
{
|
||||
public:
|
||||
filetype_t()
|
||||
: name( "" ), pattern( "" ){
|
||||
}
|
||||
filetype_t( const char* _name, const char* _pattern, bool _can_load = true, bool _can_import = true, bool _can_save = true )
|
||||
: name( _name ), pattern( _pattern ), can_load( _can_load ), can_import( _can_import ), can_save( _can_save ){
|
||||
}
|
||||
const char* name;
|
||||
const char* pattern;
|
||||
bool can_load;
|
||||
bool can_import;
|
||||
bool can_save;
|
||||
filetype_t()
|
||||
: name( "" ), pattern( "" ){
|
||||
}
|
||||
filetype_t( const char* _name, const char* _pattern, bool _can_load = true, bool _can_import = true, bool _can_save = true )
|
||||
: name( _name ), pattern( _pattern ), can_load( _can_load ), can_import( _can_import ), can_save( _can_save ){
|
||||
}
|
||||
const char* name;
|
||||
const char* pattern;
|
||||
bool can_load;
|
||||
bool can_import;
|
||||
bool can_save;
|
||||
};
|
||||
|
||||
|
||||
class IFileTypeList
|
||||
{
|
||||
public:
|
||||
virtual void addType( const char* moduleName, filetype_t type ) = 0;
|
||||
virtual void addType( const char* moduleName, filetype_t type ) = 0;
|
||||
};
|
||||
|
||||
class IFileTypeRegistry
|
||||
{
|
||||
public:
|
||||
INTEGER_CONSTANT( Version, 1 );
|
||||
STRING_CONSTANT( Name, "filetypes" );
|
||||
INTEGER_CONSTANT( Version, 1 );
|
||||
STRING_CONSTANT( Name, "filetypes" );
|
||||
|
||||
virtual void addType( const char* moduleType, const char* moduleName, filetype_t type ) = 0;
|
||||
virtual void getTypeList( const char* moduleType, IFileTypeList* typelist, bool want_load = false, bool want_import = false, bool want_save = false ) = 0;
|
||||
virtual void addType( const char* moduleType, const char* moduleName, filetype_t type ) = 0;
|
||||
virtual void getTypeList( const char* moduleType, IFileTypeList* typelist, bool want_load = false, bool want_import = false, bool want_save = false ) = 0;
|
||||
};
|
||||
|
||||
#include "modulesystem.h"
|
||||
|
||||
@@ -54,23 +54,23 @@ enum
|
||||
class Filter
|
||||
{
|
||||
public:
|
||||
virtual void setActive( bool active ) = 0;
|
||||
virtual void setActive( bool active ) = 0;
|
||||
};
|
||||
|
||||
class Filterable
|
||||
{
|
||||
public:
|
||||
virtual void updateFiltered() = 0;
|
||||
virtual void updateFiltered() = 0;
|
||||
};
|
||||
|
||||
class FilterSystem
|
||||
{
|
||||
public:
|
||||
INTEGER_CONSTANT( Version, 1 );
|
||||
STRING_CONSTANT( Name, "filters" );
|
||||
virtual void addFilter( Filter& filter, int mask ) = 0;
|
||||
virtual void registerFilterable( Filterable& filterable ) = 0;
|
||||
virtual void unregisterFilterable( Filterable& filterable ) = 0;
|
||||
INTEGER_CONSTANT( Version, 1 );
|
||||
STRING_CONSTANT( Name, "filters" );
|
||||
virtual void addFilter( Filter& filter, int mask ) = 0;
|
||||
virtual void registerFilterable( Filterable& filterable ) = 0;
|
||||
virtual void unregisterFilterable( Filterable& filterable ) = 0;
|
||||
};
|
||||
|
||||
#include "modulesystem.h"
|
||||
|
||||
@@ -31,84 +31,84 @@ class Matrix4;
|
||||
class GLProgram
|
||||
{
|
||||
public:
|
||||
virtual void enable() = 0;
|
||||
virtual void disable() = 0;
|
||||
virtual void setParameters( const Vector3& viewer, const Matrix4& localToWorld, const Vector3& origin, const Vector3& colour, const Matrix4& world2light ) = 0;
|
||||
virtual void enable() = 0;
|
||||
virtual void disable() = 0;
|
||||
virtual void setParameters( const Vector3& viewer, const Matrix4& localToWorld, const Vector3& origin, const Vector3& colour, const Matrix4& world2light ) = 0;
|
||||
};
|
||||
|
||||
class OpenGLFogState
|
||||
{
|
||||
public:
|
||||
OpenGLFogState() : mode( GL_EXP ), density( 0 ), start( 0 ), end( 0 ), index( 0 ), colour( 1, 1, 1, 1 ){
|
||||
}
|
||||
GLenum mode;
|
||||
GLfloat density;
|
||||
GLfloat start;
|
||||
GLfloat end;
|
||||
GLint index;
|
||||
Vector4 colour;
|
||||
OpenGLFogState() : mode( GL_EXP ), density( 0 ), start( 0 ), end( 0 ), index( 0 ), colour( 1, 1, 1, 1 ){
|
||||
}
|
||||
GLenum mode;
|
||||
GLfloat density;
|
||||
GLfloat start;
|
||||
GLfloat end;
|
||||
GLint index;
|
||||
Vector4 colour;
|
||||
};
|
||||
|
||||
//! A collection of opengl state information.
|
||||
class OpenGLState
|
||||
{
|
||||
public:
|
||||
enum ESort
|
||||
{
|
||||
eSortFirst = 0,
|
||||
eSortOpaque = 1,
|
||||
eSortMultiFirst = 2,
|
||||
eSortMultiLast = 1023,
|
||||
eSortOverbrighten = 1024,
|
||||
eSortFullbright = 1025,
|
||||
eSortTranslucent = 1026,
|
||||
eSortHighlight = 1027,
|
||||
eSortOverlayFirst = 1028,
|
||||
eSortOverlayLast = 2047,
|
||||
eSortText = 2048,
|
||||
eSortControlFirst = 2050,
|
||||
eSortControlLast = 3071,
|
||||
eSortGUI0 = 3072,
|
||||
eSortGUI1 = 3073,
|
||||
eSortLast = 4096,
|
||||
};
|
||||
enum ESort
|
||||
{
|
||||
eSortFirst = 0,
|
||||
eSortOpaque = 1,
|
||||
eSortMultiFirst = 2,
|
||||
eSortMultiLast = 1023,
|
||||
eSortOverbrighten = 1024,
|
||||
eSortFullbright = 1025,
|
||||
eSortTranslucent = 1026,
|
||||
eSortHighlight = 1027,
|
||||
eSortOverlayFirst = 1028,
|
||||
eSortOverlayLast = 2047,
|
||||
eSortText = 2048,
|
||||
eSortControlFirst = 2050,
|
||||
eSortControlLast = 3071,
|
||||
eSortGUI0 = 3072,
|
||||
eSortGUI1 = 3073,
|
||||
eSortLast = 4096,
|
||||
};
|
||||
|
||||
unsigned int m_state;
|
||||
std::size_t m_sort;
|
||||
GLint m_texture;
|
||||
GLint m_texture1;
|
||||
GLint m_texture2;
|
||||
GLint m_texture3;
|
||||
GLint m_texture4;
|
||||
GLint m_texture5;
|
||||
GLint m_texture6;
|
||||
GLint m_texture7;
|
||||
Vector4 m_colour;
|
||||
GLenum m_blend_src, m_blend_dst;
|
||||
GLenum m_depthfunc;
|
||||
GLenum m_alphafunc;
|
||||
GLfloat m_alpharef;
|
||||
GLfloat m_linewidth;
|
||||
GLfloat m_pointsize;
|
||||
GLint m_linestipple_factor;
|
||||
GLushort m_linestipple_pattern;
|
||||
OpenGLFogState m_fog;
|
||||
GLProgram* m_program;
|
||||
unsigned int m_state;
|
||||
std::size_t m_sort;
|
||||
GLint m_texture;
|
||||
GLint m_texture1;
|
||||
GLint m_texture2;
|
||||
GLint m_texture3;
|
||||
GLint m_texture4;
|
||||
GLint m_texture5;
|
||||
GLint m_texture6;
|
||||
GLint m_texture7;
|
||||
Vector4 m_colour;
|
||||
GLenum m_blend_src, m_blend_dst;
|
||||
GLenum m_depthfunc;
|
||||
GLenum m_alphafunc;
|
||||
GLfloat m_alpharef;
|
||||
GLfloat m_linewidth;
|
||||
GLfloat m_pointsize;
|
||||
GLint m_linestipple_factor;
|
||||
GLushort m_linestipple_pattern;
|
||||
OpenGLFogState m_fog;
|
||||
GLProgram* m_program;
|
||||
|
||||
OpenGLState() : m_program( 0 ){
|
||||
}
|
||||
OpenGLState() : m_program( 0 ){
|
||||
}
|
||||
};
|
||||
|
||||
class OpenGLStateLibrary
|
||||
{
|
||||
public:
|
||||
INTEGER_CONSTANT( Version, 1 );
|
||||
STRING_CONSTANT( Name, "openglshaderlibrary" );
|
||||
INTEGER_CONSTANT( Version, 1 );
|
||||
STRING_CONSTANT( Name, "openglshaderlibrary" );
|
||||
|
||||
virtual void getDefaultState( OpenGLState& state ) const = 0;
|
||||
virtual void getDefaultState( OpenGLState& state ) const = 0;
|
||||
|
||||
virtual void insert( const char* name, const OpenGLState& state ) = 0;
|
||||
virtual void erase( const char* name ) = 0;
|
||||
virtual void insert( const char* name, const OpenGLState& state ) = 0;
|
||||
virtual void erase( const char* name ) = 0;
|
||||
};
|
||||
|
||||
#include "modulesystem.h"
|
||||
|
||||
@@ -29,20 +29,20 @@ typedef unsigned char byte;
|
||||
class Image
|
||||
{
|
||||
public:
|
||||
virtual void release() = 0;
|
||||
virtual byte* getRGBAPixels() const = 0;
|
||||
virtual unsigned int getWidth() const = 0;
|
||||
virtual unsigned int getHeight() const = 0;
|
||||
virtual void release() = 0;
|
||||
virtual byte* getRGBAPixels() const = 0;
|
||||
virtual unsigned int getWidth() const = 0;
|
||||
virtual unsigned int getHeight() const = 0;
|
||||
|
||||
virtual int getSurfaceFlags() const {
|
||||
return 0;
|
||||
}
|
||||
virtual int getContentFlags() const {
|
||||
return 0;
|
||||
}
|
||||
virtual int getValue() const {
|
||||
return 0;
|
||||
}
|
||||
virtual int getSurfaceFlags() const {
|
||||
return 0;
|
||||
}
|
||||
virtual int getContentFlags() const {
|
||||
return 0;
|
||||
}
|
||||
virtual int getValue() const {
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
class ArchiveFile;
|
||||
|
||||
@@ -31,18 +31,18 @@ class TokenWriter;
|
||||
class MapImporter
|
||||
{
|
||||
public:
|
||||
STRING_CONSTANT( Name, "MapImporter" );
|
||||
STRING_CONSTANT( Name, "MapImporter" );
|
||||
|
||||
virtual bool importTokens( Tokeniser& tokeniser ) = 0;
|
||||
virtual bool importTokens( Tokeniser& tokeniser ) = 0;
|
||||
};
|
||||
|
||||
/// \brief A node whose state can be exported to a token stream.
|
||||
class MapExporter
|
||||
{
|
||||
public:
|
||||
STRING_CONSTANT( Name, "MapExporter" );
|
||||
STRING_CONSTANT( Name, "MapExporter" );
|
||||
|
||||
virtual void exportTokens( TokenWriter& writer ) const = 0;
|
||||
virtual void exportTokens( TokenWriter& writer ) const = 0;
|
||||
};
|
||||
|
||||
#include "iscenegraph.h"
|
||||
@@ -59,13 +59,13 @@ typedef void ( *GraphTraversalFunc )( scene::Node& root, const scene::Traversabl
|
||||
class MapFormat
|
||||
{
|
||||
public:
|
||||
INTEGER_CONSTANT( Version, 2 );
|
||||
STRING_CONSTANT( Name, "map" );
|
||||
INTEGER_CONSTANT( Version, 2 );
|
||||
STRING_CONSTANT( Name, "map" );
|
||||
|
||||
/// \brief Read a map graph into \p root from \p outputStream, using \p entityTable to create entities.
|
||||
virtual void readGraph( scene::Node& root, TextInputStream& inputStream, EntityCreator& entityTable ) const = 0;
|
||||
virtual void readGraph( scene::Node& root, TextInputStream& inputStream, EntityCreator& entityTable ) const = 0;
|
||||
/// \brief Write the map graph obtained by applying \p traverse to \p root into \p outputStream.
|
||||
virtual void writeGraph( scene::Node& root, GraphTraversalFunc traverse, TextOutputStream& outputStream ) const = 0;
|
||||
virtual void writeGraph( scene::Node& root, GraphTraversalFunc traverse, TextOutputStream& outputStream ) const = 0;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -34,9 +34,9 @@ class ArchiveFile;
|
||||
class ModelLoader
|
||||
{
|
||||
public:
|
||||
INTEGER_CONSTANT( Version, 1 );
|
||||
STRING_CONSTANT( Name, "model" );
|
||||
virtual scene::Node& loadModel( ArchiveFile& file ) = 0;
|
||||
INTEGER_CONSTANT( Version, 1 );
|
||||
STRING_CONSTANT( Name, "model" );
|
||||
virtual scene::Node& loadModel( ArchiveFile& file ) = 0;
|
||||
};
|
||||
|
||||
template<typename Type>
|
||||
|
||||
294
include/ipatch.h
294
include/ipatch.h
@@ -33,187 +33,187 @@ class Node;
|
||||
template<typename Element>
|
||||
class ArrayReference
|
||||
{
|
||||
std::size_t m_size;
|
||||
Element* m_data;
|
||||
std::size_t m_size;
|
||||
Element* m_data;
|
||||
public:
|
||||
typedef Element value_type;
|
||||
typedef value_type* iterator;
|
||||
typedef const value_type* const_iterator;
|
||||
typedef Element value_type;
|
||||
typedef value_type* iterator;
|
||||
typedef const value_type* const_iterator;
|
||||
|
||||
ArrayReference()
|
||||
: m_size( 0 ), m_data( 0 ){
|
||||
}
|
||||
ArrayReference( std::size_t size, Element* data )
|
||||
: m_size( size ), m_data( data ){
|
||||
}
|
||||
ArrayReference()
|
||||
: m_size( 0 ), m_data( 0 ){
|
||||
}
|
||||
ArrayReference( std::size_t size, Element* data )
|
||||
: m_size( size ), m_data( data ){
|
||||
}
|
||||
|
||||
iterator begin(){
|
||||
return m_data;
|
||||
}
|
||||
const_iterator begin() const {
|
||||
return m_data;
|
||||
}
|
||||
iterator end(){
|
||||
return m_data + m_size;
|
||||
}
|
||||
const_iterator end() const {
|
||||
return m_data + m_size;
|
||||
}
|
||||
iterator begin(){
|
||||
return m_data;
|
||||
}
|
||||
const_iterator begin() const {
|
||||
return m_data;
|
||||
}
|
||||
iterator end(){
|
||||
return m_data + m_size;
|
||||
}
|
||||
const_iterator end() const {
|
||||
return m_data + m_size;
|
||||
}
|
||||
|
||||
value_type& operator[]( std::size_t index ){
|
||||
value_type& operator[]( std::size_t index ){
|
||||
#if defined( _DEBUG )
|
||||
ASSERT_MESSAGE( index < size(), "array index out of bounds" );
|
||||
ASSERT_MESSAGE( index < size(), "array index out of bounds" );
|
||||
#endif
|
||||
return m_data[index];
|
||||
}
|
||||
const value_type& operator[]( std::size_t index ) const {
|
||||
return m_data[index];
|
||||
}
|
||||
const value_type& operator[]( std::size_t index ) const {
|
||||
#if defined( _DEBUG )
|
||||
ASSERT_MESSAGE( index < size(), "array index out of bounds" );
|
||||
ASSERT_MESSAGE( index < size(), "array index out of bounds" );
|
||||
#endif
|
||||
return m_data[index];
|
||||
}
|
||||
value_type* data(){
|
||||
return m_data;
|
||||
}
|
||||
const value_type* data() const {
|
||||
return m_data;
|
||||
}
|
||||
std::size_t size() const {
|
||||
return m_size;
|
||||
}
|
||||
bool empty() const {
|
||||
return m_size == 0;
|
||||
}
|
||||
return m_data[index];
|
||||
}
|
||||
value_type* data(){
|
||||
return m_data;
|
||||
}
|
||||
const value_type* data() const {
|
||||
return m_data;
|
||||
}
|
||||
std::size_t size() const {
|
||||
return m_size;
|
||||
}
|
||||
bool empty() const {
|
||||
return m_size == 0;
|
||||
}
|
||||
};
|
||||
|
||||
#if 0
|
||||
template<typename Element>
|
||||
class MatrixIterator
|
||||
{
|
||||
Element* m_position;
|
||||
Element* m_position;
|
||||
|
||||
void increment(){
|
||||
++m_position;
|
||||
}
|
||||
void increment(){
|
||||
++m_position;
|
||||
}
|
||||
|
||||
public:
|
||||
typedef std::bidirectional_iterator_tag iterator_category;
|
||||
typedef std::ptrdiff_t difference_type;
|
||||
typedef difference_type distance_type;
|
||||
typedef KeyValue<Key, Value> value_type;
|
||||
typedef value_type* pointer;
|
||||
typedef value_type& reference;
|
||||
typedef std::bidirectional_iterator_tag iterator_category;
|
||||
typedef std::ptrdiff_t difference_type;
|
||||
typedef difference_type distance_type;
|
||||
typedef KeyValue<Key, Value> value_type;
|
||||
typedef value_type* pointer;
|
||||
typedef value_type& reference;
|
||||
|
||||
MatrixIterator( Element* position ) : m_position( position ){
|
||||
}
|
||||
MatrixIterator( Element* position ) : m_position( position ){
|
||||
}
|
||||
|
||||
Element* position(){
|
||||
return m_position;
|
||||
}
|
||||
Element* position(){
|
||||
return m_position;
|
||||
}
|
||||
|
||||
bool operator==( const MatrixIterator& other ) const {
|
||||
return m_position == other.m_position;
|
||||
}
|
||||
bool operator!=( const MatrixIterator& other ) const {
|
||||
return !operator==( other );
|
||||
}
|
||||
MatrixIterator& operator++(){
|
||||
increment();
|
||||
return *this;
|
||||
}
|
||||
MatrixIterator operator++( int ){
|
||||
MatrixIterator tmp = *this;
|
||||
increment();
|
||||
return tmp;
|
||||
}
|
||||
value_type& operator*() const {
|
||||
return m_position->m_value;
|
||||
}
|
||||
value_type* operator->() const {
|
||||
return &( operator*() );
|
||||
}
|
||||
bool operator==( const MatrixIterator& other ) const {
|
||||
return m_position == other.m_position;
|
||||
}
|
||||
bool operator!=( const MatrixIterator& other ) const {
|
||||
return !operator==( other );
|
||||
}
|
||||
MatrixIterator& operator++(){
|
||||
increment();
|
||||
return *this;
|
||||
}
|
||||
MatrixIterator operator++( int ){
|
||||
MatrixIterator tmp = *this;
|
||||
increment();
|
||||
return tmp;
|
||||
}
|
||||
value_type& operator*() const {
|
||||
return m_position->m_value;
|
||||
}
|
||||
value_type* operator->() const {
|
||||
return &( operator*() );
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
template<typename Element>
|
||||
class Matrix
|
||||
{
|
||||
std::size_t m_x, m_y;
|
||||
Element* m_data;
|
||||
std::size_t m_x, m_y;
|
||||
Element* m_data;
|
||||
public:
|
||||
typedef Element value_type;
|
||||
typedef value_type* iterator;
|
||||
typedef const value_type* const_iterator;
|
||||
typedef Element value_type;
|
||||
typedef value_type* iterator;
|
||||
typedef const value_type* const_iterator;
|
||||
|
||||
Matrix()
|
||||
: m_x( 0 ), m_y( 0 ), m_data( 0 ){
|
||||
}
|
||||
Matrix( std::size_t x, std::size_t y, Element* data )
|
||||
: m_x( x ), m_y( y ), m_data( data ){
|
||||
}
|
||||
Matrix()
|
||||
: m_x( 0 ), m_y( 0 ), m_data( 0 ){
|
||||
}
|
||||
Matrix( std::size_t x, std::size_t y, Element* data )
|
||||
: m_x( x ), m_y( y ), m_data( data ){
|
||||
}
|
||||
|
||||
iterator begin(){
|
||||
return m_data;
|
||||
}
|
||||
const_iterator begin() const {
|
||||
return m_data;
|
||||
}
|
||||
iterator end(){
|
||||
return m_data + size();
|
||||
}
|
||||
const_iterator end() const {
|
||||
return m_data + size();
|
||||
}
|
||||
iterator begin(){
|
||||
return m_data;
|
||||
}
|
||||
const_iterator begin() const {
|
||||
return m_data;
|
||||
}
|
||||
iterator end(){
|
||||
return m_data + size();
|
||||
}
|
||||
const_iterator end() const {
|
||||
return m_data + size();
|
||||
}
|
||||
|
||||
value_type& operator[]( std::size_t index ){
|
||||
value_type& operator[]( std::size_t index ){
|
||||
#if defined( _DEBUG )
|
||||
ASSERT_MESSAGE( index < size(), "array index out of bounds" );
|
||||
ASSERT_MESSAGE( index < size(), "array index out of bounds" );
|
||||
#endif
|
||||
return m_data[index];
|
||||
}
|
||||
const value_type& operator[]( std::size_t index ) const {
|
||||
return m_data[index];
|
||||
}
|
||||
const value_type& operator[]( std::size_t index ) const {
|
||||
#if defined( _DEBUG )
|
||||
ASSERT_MESSAGE( index < size(), "array index out of bounds" );
|
||||
ASSERT_MESSAGE( index < size(), "array index out of bounds" );
|
||||
#endif
|
||||
return m_data[index];
|
||||
}
|
||||
value_type& operator()( std::size_t x, std::size_t y ){
|
||||
return m_data[index];
|
||||
}
|
||||
value_type& operator()( std::size_t x, std::size_t y ){
|
||||
#if defined( _DEBUG )
|
||||
ASSERT_MESSAGE( x < m_x && y < m_y, "array index out of bounds" );
|
||||
ASSERT_MESSAGE( x < m_x && y < m_y, "array index out of bounds" );
|
||||
#endif
|
||||
return m_data[x * m_y + y];
|
||||
}
|
||||
const value_type& operator()( std::size_t x, std::size_t y ) const {
|
||||
return m_data[x * m_y + y];
|
||||
}
|
||||
const value_type& operator()( std::size_t x, std::size_t y ) const {
|
||||
#if defined( _DEBUG )
|
||||
ASSERT_MESSAGE( x < m_x && y < m_y, "array index out of bounds" );
|
||||
ASSERT_MESSAGE( x < m_x && y < m_y, "array index out of bounds" );
|
||||
#endif
|
||||
return m_data[x * m_y + y];
|
||||
}
|
||||
value_type* data(){
|
||||
return m_data;
|
||||
}
|
||||
const value_type* data() const {
|
||||
return m_data;
|
||||
}
|
||||
std::size_t x() const {
|
||||
return m_x;
|
||||
}
|
||||
std::size_t y() const {
|
||||
return m_y;
|
||||
}
|
||||
std::size_t size() const {
|
||||
return m_x * m_y;
|
||||
}
|
||||
bool empty() const {
|
||||
return m_x == 0;
|
||||
}
|
||||
return m_data[x * m_y + y];
|
||||
}
|
||||
value_type* data(){
|
||||
return m_data;
|
||||
}
|
||||
const value_type* data() const {
|
||||
return m_data;
|
||||
}
|
||||
std::size_t x() const {
|
||||
return m_x;
|
||||
}
|
||||
std::size_t y() const {
|
||||
return m_y;
|
||||
}
|
||||
std::size_t size() const {
|
||||
return m_x * m_y;
|
||||
}
|
||||
bool empty() const {
|
||||
return m_x == 0;
|
||||
}
|
||||
};
|
||||
|
||||
class PatchControl
|
||||
{
|
||||
public:
|
||||
Vector3 m_vertex;
|
||||
Vector2 m_texcoord;
|
||||
Vector3 m_vertex;
|
||||
Vector2 m_texcoord;
|
||||
};
|
||||
|
||||
typedef Matrix<PatchControl> PatchControlMatrix;
|
||||
@@ -222,15 +222,15 @@ typedef Matrix<PatchControl> PatchControlMatrix;
|
||||
class PatchCreator
|
||||
{
|
||||
public:
|
||||
INTEGER_CONSTANT( Version, 1 );
|
||||
STRING_CONSTANT( Name, "patch" );
|
||||
virtual scene::Node& createPatch() = 0;
|
||||
virtual void Patch_undoSave( scene::Node& patch ) const = 0;
|
||||
virtual void Patch_resize( scene::Node& patch, std::size_t width, std::size_t height ) const = 0;
|
||||
virtual PatchControlMatrix Patch_getControlPoints( scene::Node& patch ) const = 0;
|
||||
virtual void Patch_controlPointsChanged( scene::Node& patch ) const = 0;
|
||||
virtual const char* Patch_getShader( scene::Node& patch ) const = 0;
|
||||
virtual void Patch_setShader( scene::Node& patch, const char* shader ) const = 0;
|
||||
INTEGER_CONSTANT( Version, 1 );
|
||||
STRING_CONSTANT( Name, "patch" );
|
||||
virtual scene::Node& createPatch() = 0;
|
||||
virtual void Patch_undoSave( scene::Node& patch ) const = 0;
|
||||
virtual void Patch_resize( scene::Node& patch, std::size_t width, std::size_t height ) const = 0;
|
||||
virtual PatchControlMatrix Patch_getControlPoints( scene::Node& patch ) const = 0;
|
||||
virtual void Patch_controlPointsChanged( scene::Node& patch ) const = 0;
|
||||
virtual const char* Patch_getShader( scene::Node& patch ) const = 0;
|
||||
virtual void Patch_setShader( scene::Node& patch, const char* shader ) const = 0;
|
||||
};
|
||||
|
||||
#include "modulesystem.h"
|
||||
|
||||
@@ -34,16 +34,16 @@ class ModuleObserver;
|
||||
class Resource
|
||||
{
|
||||
public:
|
||||
virtual bool load() = 0;
|
||||
virtual bool save() = 0;
|
||||
virtual void flush() = 0;
|
||||
virtual void refresh() = 0;
|
||||
virtual scene::Node* getNode() = 0;
|
||||
virtual void setNode( scene::Node* node ) = 0;
|
||||
virtual void attach( ModuleObserver& observer ) = 0;
|
||||
virtual void detach( ModuleObserver& observer ) = 0;
|
||||
virtual void realise() = 0;
|
||||
virtual void unrealise() = 0;
|
||||
virtual bool load() = 0;
|
||||
virtual bool save() = 0;
|
||||
virtual void flush() = 0;
|
||||
virtual void refresh() = 0;
|
||||
virtual scene::Node* getNode() = 0;
|
||||
virtual void setNode( scene::Node* node ) = 0;
|
||||
virtual void attach( ModuleObserver& observer ) = 0;
|
||||
virtual void detach( ModuleObserver& observer ) = 0;
|
||||
virtual void realise() = 0;
|
||||
virtual void unrealise() = 0;
|
||||
};
|
||||
|
||||
class EntityCreator;
|
||||
@@ -51,13 +51,13 @@ class EntityCreator;
|
||||
class ReferenceCache
|
||||
{
|
||||
public:
|
||||
INTEGER_CONSTANT( Version, 1 );
|
||||
STRING_CONSTANT( Name, "reference" );
|
||||
INTEGER_CONSTANT( Version, 1 );
|
||||
STRING_CONSTANT( Name, "reference" );
|
||||
|
||||
virtual Resource* capture( const char* path ) = 0;
|
||||
virtual void release( const char* path ) = 0;
|
||||
virtual Resource* capture( const char* path ) = 0;
|
||||
virtual void release( const char* path ) = 0;
|
||||
|
||||
virtual void setEntityCreator( EntityCreator& entityCreator ) = 0;
|
||||
virtual void setEntityCreator( EntityCreator& entityCreator ) = 0;
|
||||
};
|
||||
|
||||
#include "modulesystem.h"
|
||||
|
||||
@@ -66,24 +66,24 @@ class Shader;
|
||||
class RendererLight
|
||||
{
|
||||
public:
|
||||
virtual Shader* getShader() const = 0;
|
||||
virtual const AABB& aabb() const = 0;
|
||||
virtual bool testAABB( const AABB& other ) const = 0;
|
||||
virtual const Matrix4& rotation() const = 0;
|
||||
virtual const Vector3& offset() const = 0;
|
||||
virtual const Vector3& colour() const = 0;
|
||||
virtual bool isProjected() const = 0;
|
||||
virtual const Matrix4& projection() const = 0;
|
||||
virtual Shader* getShader() const = 0;
|
||||
virtual const AABB& aabb() const = 0;
|
||||
virtual bool testAABB( const AABB& other ) const = 0;
|
||||
virtual const Matrix4& rotation() const = 0;
|
||||
virtual const Vector3& offset() const = 0;
|
||||
virtual const Vector3& colour() const = 0;
|
||||
virtual bool isProjected() const = 0;
|
||||
virtual const Matrix4& projection() const = 0;
|
||||
};
|
||||
|
||||
class LightCullable
|
||||
{
|
||||
public:
|
||||
virtual bool testLight( const RendererLight& light ) const = 0;
|
||||
virtual void insertLight( const RendererLight& light ){
|
||||
}
|
||||
virtual void clearLights(){
|
||||
}
|
||||
virtual bool testLight( const RendererLight& light ) const = 0;
|
||||
virtual void insertLight( const RendererLight& light ){
|
||||
}
|
||||
virtual void clearLights(){
|
||||
}
|
||||
};
|
||||
|
||||
class Renderable;
|
||||
@@ -94,9 +94,9 @@ typedef Callback1<const RendererLight&> RendererLightCallback;
|
||||
class LightList
|
||||
{
|
||||
public:
|
||||
virtual void evaluateLights() const = 0;
|
||||
virtual void lightsChanged() const = 0;
|
||||
virtual void forEachLight( const RendererLightCallback& callback ) const = 0;
|
||||
virtual void evaluateLights() const = 0;
|
||||
virtual void lightsChanged() const = 0;
|
||||
virtual void forEachLight( const RendererLightCallback& callback ) const = 0;
|
||||
};
|
||||
|
||||
const int c_attr_TexCoord0 = 1;
|
||||
@@ -106,7 +106,7 @@ const int c_attr_Binormal = 4;
|
||||
class OpenGLRenderable
|
||||
{
|
||||
public:
|
||||
virtual void render( RenderStateFlags state ) const = 0;
|
||||
virtual void render( RenderStateFlags state ) const = 0;
|
||||
};
|
||||
|
||||
class Matrix4;
|
||||
@@ -116,42 +116,42 @@ class ModuleObserver;
|
||||
class Shader
|
||||
{
|
||||
public:
|
||||
virtual void addRenderable( const OpenGLRenderable& renderable, const Matrix4& modelview, const LightList* lights = 0 ) = 0;
|
||||
virtual void incrementUsed() = 0;
|
||||
virtual void decrementUsed() = 0;
|
||||
virtual void attach( ModuleObserver& observer ) = 0;
|
||||
virtual void detach( ModuleObserver& observer ) = 0;
|
||||
virtual qtexture_t& getTexture() const = 0;
|
||||
virtual unsigned int getFlags() const = 0;
|
||||
virtual void addRenderable( const OpenGLRenderable& renderable, const Matrix4& modelview, const LightList* lights = 0 ) = 0;
|
||||
virtual void incrementUsed() = 0;
|
||||
virtual void decrementUsed() = 0;
|
||||
virtual void attach( ModuleObserver& observer ) = 0;
|
||||
virtual void detach( ModuleObserver& observer ) = 0;
|
||||
virtual qtexture_t& getTexture() const = 0;
|
||||
virtual unsigned int getFlags() const = 0;
|
||||
};
|
||||
|
||||
class ShaderCache
|
||||
{
|
||||
public:
|
||||
INTEGER_CONSTANT( Version, 1 );
|
||||
STRING_CONSTANT( Name, "renderstate" );
|
||||
INTEGER_CONSTANT( Version, 1 );
|
||||
STRING_CONSTANT( Name, "renderstate" );
|
||||
|
||||
virtual Shader* capture( const char* name ) = 0;
|
||||
virtual void release( const char* name ) = 0;
|
||||
/*! Render all Shader objects. */
|
||||
virtual void render( RenderStateFlags globalstate, const Matrix4& modelview, const Matrix4& projection, const Vector3& viewer = Vector3( 0, 0, 0 ) ) = 0;
|
||||
virtual Shader* capture( const char* name ) = 0;
|
||||
virtual void release( const char* name ) = 0;
|
||||
/*! Render all Shader objects. */
|
||||
virtual void render( RenderStateFlags globalstate, const Matrix4& modelview, const Matrix4& projection, const Vector3& viewer = Vector3( 0, 0, 0 ) ) = 0;
|
||||
|
||||
virtual void realise() = 0;
|
||||
virtual void unrealise() = 0;
|
||||
virtual void realise() = 0;
|
||||
virtual void unrealise() = 0;
|
||||
|
||||
virtual bool lightingSupported() const = 0;
|
||||
virtual bool useShaderLanguage() const = 0;
|
||||
virtual bool lightingSupported() const = 0;
|
||||
virtual bool useShaderLanguage() const = 0;
|
||||
|
||||
virtual const LightList& attach( LightCullable& cullable ) = 0;
|
||||
virtual void detach( LightCullable& cullable ) = 0;
|
||||
virtual void changed( LightCullable& cullable ) = 0;
|
||||
virtual void attach( RendererLight& light ) = 0;
|
||||
virtual void detach( RendererLight& light ) = 0;
|
||||
virtual void changed( RendererLight& light ) = 0;
|
||||
virtual const LightList& attach( LightCullable& cullable ) = 0;
|
||||
virtual void detach( LightCullable& cullable ) = 0;
|
||||
virtual void changed( LightCullable& cullable ) = 0;
|
||||
virtual void attach( RendererLight& light ) = 0;
|
||||
virtual void detach( RendererLight& light ) = 0;
|
||||
virtual void changed( RendererLight& light ) = 0;
|
||||
|
||||
virtual void attachRenderable( const Renderable& renderable ) = 0;
|
||||
virtual void detachRenderable( const Renderable& renderable ) = 0;
|
||||
virtual void forEachRenderable( const RenderableCallback& callback ) const = 0;
|
||||
virtual void attachRenderable( const Renderable& renderable ) = 0;
|
||||
virtual void detachRenderable( const Renderable& renderable ) = 0;
|
||||
virtual void forEachRenderable( const RenderableCallback& callback ) const = 0;
|
||||
};
|
||||
|
||||
#include "modulesystem.h"
|
||||
|
||||
@@ -70,121 +70,121 @@ typedef Stack<NodeReference> Path;
|
||||
class Graph
|
||||
{
|
||||
public:
|
||||
INTEGER_CONSTANT( Version, 1 );
|
||||
STRING_CONSTANT( Name, "scenegraph" );
|
||||
INTEGER_CONSTANT( Version, 1 );
|
||||
STRING_CONSTANT( Name, "scenegraph" );
|
||||
|
||||
class Walker
|
||||
{
|
||||
public:
|
||||
class Walker
|
||||
{
|
||||
public:
|
||||
/// \brief Called before traversing the first child-instance of 'instance'. If the return value is false, the children of the current instance are not traversed.
|
||||
virtual bool pre( const Path& path, Instance& instance ) const = 0;
|
||||
virtual bool pre( const Path& path, Instance& instance ) const = 0;
|
||||
/// \brief Called after traversing the last child-instance of 'instance'.
|
||||
virtual void post( const Path& path, Instance& instance ) const {
|
||||
}
|
||||
};
|
||||
virtual void post( const Path& path, Instance& instance ) const {
|
||||
}
|
||||
};
|
||||
|
||||
/// \brief Returns the root-node of the graph.
|
||||
virtual Node& root() = 0;
|
||||
virtual Node& root() = 0;
|
||||
/// \brief Sets the root-node of the graph to be 'node'.
|
||||
virtual void insert_root( Node& root ) = 0;
|
||||
virtual void insert_root( Node& root ) = 0;
|
||||
/// \brief Clears the root-node of the graph.
|
||||
virtual void erase_root() = 0;
|
||||
virtual void erase_root() = 0;
|
||||
/// \brief Traverses all nodes in the graph depth-first, starting from the root node.
|
||||
virtual void traverse( const Walker& walker ) = 0;
|
||||
virtual void traverse( const Walker& walker ) = 0;
|
||||
/// \brief Traverses all nodes in the graph depth-first, starting from 'start'.
|
||||
virtual void traverse_subgraph( const Walker& walker, const Path& start ) = 0;
|
||||
virtual void traverse_subgraph( const Walker& walker, const Path& start ) = 0;
|
||||
/// \brief Returns the instance at the location identified by 'path', or 0 if it does not exist.
|
||||
virtual scene::Instance* find( const Path& path ) = 0;
|
||||
virtual scene::Instance* find( const Path& path ) = 0;
|
||||
|
||||
/// \brief Invokes all scene-changed callbacks. Called when any part of the scene changes the way it will appear when the scene is rendered.
|
||||
/// \todo Move to a separate class.
|
||||
virtual void sceneChanged() = 0;
|
||||
virtual void sceneChanged() = 0;
|
||||
/// \brief Add a \p callback to be invoked when the scene changes.
|
||||
/// \todo Move to a separate class.
|
||||
virtual void addSceneChangedCallback( const SignalHandler& handler ) = 0;
|
||||
virtual void addSceneChangedCallback( const SignalHandler& handler ) = 0;
|
||||
|
||||
/// \brief Invokes all bounds-changed callbacks. Called when the bounds of any instance in the scene change.
|
||||
/// \todo Move to a separate class.
|
||||
virtual void boundsChanged() = 0;
|
||||
virtual void boundsChanged() = 0;
|
||||
/// \brief Add a \p callback to be invoked when the bounds of any instance in the scene change.
|
||||
virtual SignalHandlerId addBoundsChangedCallback( const SignalHandler& boundsChanged ) = 0;
|
||||
virtual SignalHandlerId addBoundsChangedCallback( const SignalHandler& boundsChanged ) = 0;
|
||||
/// \brief Remove a \p callback to be invoked when the bounds of any instance in the scene change.
|
||||
virtual void removeBoundsChangedCallback( SignalHandlerId id ) = 0;
|
||||
virtual void removeBoundsChangedCallback( SignalHandlerId id ) = 0;
|
||||
|
||||
virtual TypeId getNodeTypeId( const char* name ) = 0;
|
||||
virtual TypeId getInstanceTypeId( const char* name ) = 0;
|
||||
virtual TypeId getNodeTypeId( const char* name ) = 0;
|
||||
virtual TypeId getInstanceTypeId( const char* name ) = 0;
|
||||
};
|
||||
|
||||
class Traversable
|
||||
{
|
||||
public:
|
||||
STRING_CONSTANT( Name, "scene::Traversable" );
|
||||
STRING_CONSTANT( Name, "scene::Traversable" );
|
||||
|
||||
class Observer
|
||||
{
|
||||
public:
|
||||
class Observer
|
||||
{
|
||||
public:
|
||||
/// \brief Called when a node is added to the container.
|
||||
virtual void insert( Node& node ) = 0;
|
||||
virtual void insert( Node& node ) = 0;
|
||||
/// \brief Called when a node is removed from the container.
|
||||
virtual void erase( Node& node ) = 0;
|
||||
};
|
||||
virtual void erase( Node& node ) = 0;
|
||||
};
|
||||
|
||||
class Walker
|
||||
{
|
||||
public:
|
||||
class Walker
|
||||
{
|
||||
public:
|
||||
/// \brief Called before traversing the first child-node of 'node'. If the return value is false, the children of the current node are not traversed.
|
||||
virtual bool pre( Node& node ) const = 0;
|
||||
virtual bool pre( Node& node ) const = 0;
|
||||
/// \brief Called after traversing the last child-node of 'node'.
|
||||
virtual void post( Node& node ) const {
|
||||
}
|
||||
};
|
||||
virtual void post( Node& node ) const {
|
||||
}
|
||||
};
|
||||
/// \brief Adds a node to the container.
|
||||
virtual void insert( Node& node ) = 0;
|
||||
virtual void insert( Node& node ) = 0;
|
||||
/// \brief Removes a node from the container.
|
||||
virtual void erase( Node& node ) = 0;
|
||||
virtual void erase( Node& node ) = 0;
|
||||
/// \brief Traverses the subgraphs rooted at each node in the container, depth-first.
|
||||
virtual void traverse( const Walker& walker ) = 0;
|
||||
virtual void traverse( const Walker& walker ) = 0;
|
||||
/// \brief Returns true if the container contains no nodes.
|
||||
virtual bool empty() const = 0;
|
||||
virtual bool empty() const = 0;
|
||||
};
|
||||
|
||||
class Instantiable
|
||||
{
|
||||
public:
|
||||
STRING_CONSTANT( Name, "scene::Instantiable" );
|
||||
STRING_CONSTANT( Name, "scene::Instantiable" );
|
||||
|
||||
class Observer
|
||||
{
|
||||
public:
|
||||
class Observer
|
||||
{
|
||||
public:
|
||||
/// \brief Called when an instance is added to the container.
|
||||
virtual void insert( scene::Instance* instance ) = 0;
|
||||
virtual void insert( scene::Instance* instance ) = 0;
|
||||
/// \brief Called when an instance is removed from the container.
|
||||
virtual void erase( scene::Instance* instance ) = 0;
|
||||
};
|
||||
virtual void erase( scene::Instance* instance ) = 0;
|
||||
};
|
||||
|
||||
class Visitor
|
||||
{
|
||||
public:
|
||||
virtual void visit( Instance& instance ) const = 0;
|
||||
};
|
||||
class Visitor
|
||||
{
|
||||
public:
|
||||
virtual void visit( Instance& instance ) const = 0;
|
||||
};
|
||||
|
||||
/// \brief Returns a new instance uniquely identified by 'path'.
|
||||
virtual scene::Instance* create( const scene::Path& path, scene::Instance* parent ) = 0;
|
||||
virtual scene::Instance* create( const scene::Path& path, scene::Instance* parent ) = 0;
|
||||
/// \brief Calls Visitor::visit(instance) for each instance in the container.
|
||||
virtual void forEachInstance( const Visitor& visitor ) = 0;
|
||||
virtual void forEachInstance( const Visitor& visitor ) = 0;
|
||||
/// \brief Adds an instance to the container.
|
||||
virtual void insert( Observer* observer, const Path& path, scene::Instance* instance ) = 0;
|
||||
virtual void insert( Observer* observer, const Path& path, scene::Instance* instance ) = 0;
|
||||
/// \brief Returns an instance removed from the container.
|
||||
virtual scene::Instance* erase( Observer* observer, const Path& path ) = 0;
|
||||
virtual scene::Instance* erase( Observer* observer, const Path& path ) = 0;
|
||||
};
|
||||
|
||||
class Cloneable
|
||||
{
|
||||
public:
|
||||
STRING_CONSTANT( Name, "scene::Cloneable" );
|
||||
STRING_CONSTANT( Name, "scene::Cloneable" );
|
||||
|
||||
/// \brief Returns a copy of itself.
|
||||
virtual scene::Node& clone() const = 0;
|
||||
virtual scene::Node& clone() const = 0;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -33,13 +33,13 @@
|
||||
class Tokeniser
|
||||
{
|
||||
public:
|
||||
virtual void release() = 0;
|
||||
virtual void nextLine() = 0;
|
||||
virtual const char* getToken() = 0;
|
||||
virtual void ungetToken() = 0;
|
||||
virtual std::size_t getLine() const = 0;
|
||||
virtual std::size_t getColumn() const = 0;
|
||||
virtual bool bufferContains( const char* str ) = 0;
|
||||
virtual void release() = 0;
|
||||
virtual void nextLine() = 0;
|
||||
virtual const char* getToken() = 0;
|
||||
virtual void ungetToken() = 0;
|
||||
virtual std::size_t getLine() const = 0;
|
||||
virtual std::size_t getColumn() const = 0;
|
||||
virtual bool bufferContains( const char* str ) = 0;
|
||||
};
|
||||
|
||||
class TextInputStream;
|
||||
@@ -47,13 +47,13 @@ class TextInputStream;
|
||||
class TokenWriter
|
||||
{
|
||||
public:
|
||||
virtual void release() = 0;
|
||||
virtual void nextLine() = 0;
|
||||
virtual void writeToken( const char* token ) = 0;
|
||||
virtual void writeString( const char* string ) = 0;
|
||||
virtual void writeInteger( int i ) = 0;
|
||||
virtual void writeUnsigned( std::size_t i ) = 0;
|
||||
virtual void writeFloat( double f ) = 0;
|
||||
virtual void release() = 0;
|
||||
virtual void nextLine() = 0;
|
||||
virtual void writeToken( const char* token ) = 0;
|
||||
virtual void writeString( const char* string ) = 0;
|
||||
virtual void writeInteger( int i ) = 0;
|
||||
virtual void writeUnsigned( std::size_t i ) = 0;
|
||||
virtual void writeFloat( double f ) = 0;
|
||||
};
|
||||
|
||||
class TextOutputStream;
|
||||
|
||||
@@ -33,10 +33,10 @@ class View;
|
||||
class Selectable
|
||||
{
|
||||
public:
|
||||
STRING_CONSTANT( Name, "Selectable" );
|
||||
STRING_CONSTANT( Name, "Selectable" );
|
||||
|
||||
virtual void setSelected( bool select ) = 0;
|
||||
virtual bool isSelected() const = 0;
|
||||
virtual void setSelected( bool select ) = 0;
|
||||
virtual bool isSelected() const = 0;
|
||||
};
|
||||
|
||||
namespace scene
|
||||
@@ -47,7 +47,7 @@ class Instance;
|
||||
class InstanceSelectionObserver
|
||||
{
|
||||
public:
|
||||
virtual void onSelectedChanged( scene::Instance& instance ) = 0;
|
||||
virtual void onSelectedChanged( scene::Instance& instance ) = 0;
|
||||
};
|
||||
|
||||
template<typename Element> class BasicVector3;
|
||||
@@ -64,76 +64,76 @@ typedef SignalHandler1<const Selectable&> SelectionChangeHandler;
|
||||
class SelectionSystem
|
||||
{
|
||||
public:
|
||||
INTEGER_CONSTANT( Version, 1 );
|
||||
STRING_CONSTANT( Name, "selection" );
|
||||
INTEGER_CONSTANT( Version, 1 );
|
||||
STRING_CONSTANT( Name, "selection" );
|
||||
|
||||
enum EMode
|
||||
{
|
||||
eEntity,
|
||||
ePrimitive,
|
||||
eComponent,
|
||||
};
|
||||
enum EMode
|
||||
{
|
||||
eEntity,
|
||||
ePrimitive,
|
||||
eComponent,
|
||||
};
|
||||
|
||||
enum EComponentMode
|
||||
{
|
||||
eDefault,
|
||||
eVertex,
|
||||
eEdge,
|
||||
eFace,
|
||||
};
|
||||
enum EComponentMode
|
||||
{
|
||||
eDefault,
|
||||
eVertex,
|
||||
eEdge,
|
||||
eFace,
|
||||
};
|
||||
|
||||
enum EManipulatorMode
|
||||
{
|
||||
eTranslate,
|
||||
eRotate,
|
||||
eScale,
|
||||
eSkew,
|
||||
eDrag,
|
||||
eClip,
|
||||
eBuild,
|
||||
eUV,
|
||||
};
|
||||
enum EManipulatorMode
|
||||
{
|
||||
eTranslate,
|
||||
eRotate,
|
||||
eScale,
|
||||
eSkew,
|
||||
eDrag,
|
||||
eClip,
|
||||
eBuild,
|
||||
eUV,
|
||||
};
|
||||
|
||||
virtual void SetMode( EMode mode ) = 0;
|
||||
virtual EMode Mode() const = 0;
|
||||
virtual void SetComponentMode( EComponentMode mode ) = 0;
|
||||
virtual EComponentMode ComponentMode() const = 0;
|
||||
virtual void SetManipulatorMode( EManipulatorMode mode ) = 0;
|
||||
virtual EManipulatorMode ManipulatorMode() const = 0;
|
||||
virtual void SetMode( EMode mode ) = 0;
|
||||
virtual EMode Mode() const = 0;
|
||||
virtual void SetComponentMode( EComponentMode mode ) = 0;
|
||||
virtual EComponentMode ComponentMode() const = 0;
|
||||
virtual void SetManipulatorMode( EManipulatorMode mode ) = 0;
|
||||
virtual EManipulatorMode ManipulatorMode() const = 0;
|
||||
|
||||
virtual SelectionChangeCallback getObserver( EMode mode ) = 0;
|
||||
virtual std::size_t countSelected() const = 0;
|
||||
virtual std::size_t countSelectedComponents() const = 0;
|
||||
virtual void countSelectedStuff( std::size_t& brushes, std::size_t& patches, std::size_t& entities ) const = 0;
|
||||
virtual void onSelectedChanged( scene::Instance& instance, const Selectable& selectable ) = 0;
|
||||
virtual void onComponentSelection( scene::Instance& instance, const Selectable& selectable ) = 0;
|
||||
virtual scene::Instance& firstSelected() const = 0;
|
||||
virtual scene::Instance& ultimateSelected() const = 0;
|
||||
virtual scene::Instance& penultimateSelected() const = 0;
|
||||
virtual void setSelectedAll( bool selected ) = 0;
|
||||
virtual void setSelectedAllComponents( bool selected ) = 0;
|
||||
virtual SelectionChangeCallback getObserver( EMode mode ) = 0;
|
||||
virtual std::size_t countSelected() const = 0;
|
||||
virtual std::size_t countSelectedComponents() const = 0;
|
||||
virtual void countSelectedStuff( std::size_t& brushes, std::size_t& patches, std::size_t& entities ) const = 0;
|
||||
virtual void onSelectedChanged( scene::Instance& instance, const Selectable& selectable ) = 0;
|
||||
virtual void onComponentSelection( scene::Instance& instance, const Selectable& selectable ) = 0;
|
||||
virtual scene::Instance& firstSelected() const = 0;
|
||||
virtual scene::Instance& ultimateSelected() const = 0;
|
||||
virtual scene::Instance& penultimateSelected() const = 0;
|
||||
virtual void setSelectedAll( bool selected ) = 0;
|
||||
virtual void setSelectedAllComponents( bool selected ) = 0;
|
||||
|
||||
class Visitor
|
||||
{
|
||||
public:
|
||||
virtual void visit( scene::Instance& instance ) const = 0;
|
||||
};
|
||||
virtual void foreachSelected( const Visitor& visitor ) const = 0;
|
||||
virtual void foreachSelectedComponent( const Visitor& visitor ) const = 0;
|
||||
class Visitor
|
||||
{
|
||||
public:
|
||||
virtual void visit( scene::Instance& instance ) const = 0;
|
||||
};
|
||||
virtual void foreachSelected( const Visitor& visitor ) const = 0;
|
||||
virtual void foreachSelectedComponent( const Visitor& visitor ) const = 0;
|
||||
|
||||
virtual void addSelectionChangeCallback( const SelectionChangeHandler& handler ) = 0;
|
||||
virtual void addSelectionChangeCallback( const SelectionChangeHandler& handler ) = 0;
|
||||
|
||||
virtual void NudgeManipulator( const Vector3& nudge, const Vector3& view ) = 0;
|
||||
virtual void NudgeManipulator( const Vector3& nudge, const Vector3& view ) = 0;
|
||||
|
||||
virtual void translateSelected( const Vector3& translation ) = 0;
|
||||
virtual void rotateSelected( const Quaternion& rotation, bool snapOrigin = false ) = 0;
|
||||
virtual void scaleSelected( const Vector3& scaling, bool snapOrigin = false ) = 0;
|
||||
virtual void repeatTransforms( const Callback& clone ) = 0;
|
||||
virtual void translateSelected( const Vector3& translation ) = 0;
|
||||
virtual void rotateSelected( const Quaternion& rotation, bool snapOrigin = false ) = 0;
|
||||
virtual void scaleSelected( const Vector3& scaling, bool snapOrigin = false ) = 0;
|
||||
virtual void repeatTransforms( const Callback& clone ) = 0;
|
||||
|
||||
virtual void pivotChanged() const = 0;
|
||||
virtual void setCustomTransformOrigin( const Vector3& origin, const bool set[3] ) const = 0;
|
||||
virtual void pivotChanged() const = 0;
|
||||
virtual void setCustomTransformOrigin( const Vector3& origin, const bool set[3] ) const = 0;
|
||||
|
||||
virtual const AABB& getBoundsSelected() const = 0; /* object bounds */
|
||||
virtual const AABB& getBoundsSelected() const = 0; /* object bounds */
|
||||
};
|
||||
|
||||
#include "modulesystem.h"
|
||||
|
||||
@@ -58,19 +58,19 @@ const BlendFactor BLEND_SRC_ALPHA_SATURATE = 10;
|
||||
class BlendFunc
|
||||
{
|
||||
public:
|
||||
BlendFunc( BlendFactor src, BlendFactor dst ) : m_src( src ), m_dst( dst ){
|
||||
}
|
||||
BlendFactor m_src;
|
||||
BlendFactor m_dst;
|
||||
BlendFunc( BlendFactor src, BlendFactor dst ) : m_src( src ), m_dst( dst ){
|
||||
}
|
||||
BlendFactor m_src;
|
||||
BlendFactor m_dst;
|
||||
};
|
||||
|
||||
class ShaderLayer
|
||||
{
|
||||
public:
|
||||
virtual qtexture_t* texture() const = 0;
|
||||
virtual BlendFunc blendFunc() const = 0;
|
||||
virtual bool clampToBorder() const = 0;
|
||||
virtual float alphaTest() const = 0;
|
||||
virtual qtexture_t* texture() const = 0;
|
||||
virtual BlendFunc blendFunc() const = 0;
|
||||
virtual bool clampToBorder() const = 0;
|
||||
virtual float alphaTest() const = 0;
|
||||
};
|
||||
|
||||
typedef Callback1<const ShaderLayer&> ShaderLayerCallback;
|
||||
@@ -79,51 +79,51 @@ typedef Callback1<const ShaderLayer&> ShaderLayerCallback;
|
||||
class IShader
|
||||
{
|
||||
public:
|
||||
enum EAlphaFunc
|
||||
{
|
||||
eAlways,
|
||||
eEqual,
|
||||
eLess,
|
||||
eGreater,
|
||||
eLEqual,
|
||||
eGEqual,
|
||||
};
|
||||
enum ECull
|
||||
{
|
||||
eCullNone,
|
||||
eCullBack,
|
||||
};
|
||||
enum EAlphaFunc
|
||||
{
|
||||
eAlways,
|
||||
eEqual,
|
||||
eLess,
|
||||
eGreater,
|
||||
eLEqual,
|
||||
eGEqual,
|
||||
};
|
||||
enum ECull
|
||||
{
|
||||
eCullNone,
|
||||
eCullBack,
|
||||
};
|
||||
// Increment the number of references to this object
|
||||
virtual void IncRef() = 0;
|
||||
virtual void IncRef() = 0;
|
||||
// Decrement the reference count
|
||||
virtual void DecRef() = 0;
|
||||
virtual void DecRef() = 0;
|
||||
// get/set the qtexture_t* Radiant uses to represent this shader object
|
||||
virtual qtexture_t* getTexture() const = 0;
|
||||
virtual qtexture_t* getDiffuse() const = 0;
|
||||
virtual qtexture_t* getBump() const = 0;
|
||||
virtual qtexture_t* getSpecular() const = 0;
|
||||
virtual qtexture_t* getTexture() const = 0;
|
||||
virtual qtexture_t* getDiffuse() const = 0;
|
||||
virtual qtexture_t* getBump() const = 0;
|
||||
virtual qtexture_t* getSpecular() const = 0;
|
||||
// get shader name
|
||||
virtual const char* getName() const = 0;
|
||||
virtual bool IsInUse() const = 0;
|
||||
virtual void SetInUse( bool bInUse ) = 0;
|
||||
virtual const char* getName() const = 0;
|
||||
virtual bool IsInUse() const = 0;
|
||||
virtual void SetInUse( bool bInUse ) = 0;
|
||||
// get the editor flags (QER_NOCARVE QER_TRANS)
|
||||
virtual int getFlags() const = 0;
|
||||
virtual int getFlags() const = 0;
|
||||
// get the transparency value
|
||||
virtual float getTrans() const = 0;
|
||||
virtual float getTrans() const = 0;
|
||||
// test if it's a true shader, or a default shader created to wrap around a texture
|
||||
virtual bool IsDefault() const = 0;
|
||||
virtual bool IsDefault() const = 0;
|
||||
// get the alphaFunc
|
||||
virtual void getAlphaFunc( EAlphaFunc *func, float *ref ) = 0;
|
||||
virtual BlendFunc getBlendFunc() const = 0;
|
||||
virtual void getAlphaFunc( EAlphaFunc *func, float *ref ) = 0;
|
||||
virtual BlendFunc getBlendFunc() const = 0;
|
||||
// get the cull type
|
||||
virtual ECull getCull() = 0;
|
||||
virtual ECull getCull() = 0;
|
||||
// get shader file name (ie the file where this one is defined)
|
||||
virtual const char* getShaderFileName() const = 0;
|
||||
virtual const char* getShaderFileName() const = 0;
|
||||
|
||||
virtual const ShaderLayer* firstLayer() const = 0;
|
||||
virtual void forEachLayer( const ShaderLayerCallback& layer ) const = 0;
|
||||
virtual const ShaderLayer* firstLayer() const = 0;
|
||||
virtual void forEachLayer( const ShaderLayerCallback& layer ) const = 0;
|
||||
|
||||
virtual qtexture_t* lightFalloffImage() const = 0;
|
||||
virtual qtexture_t* lightFalloffImage() const = 0;
|
||||
};
|
||||
|
||||
typedef struct _GSList GSList;
|
||||
@@ -134,34 +134,34 @@ class ModuleObserver;
|
||||
class ShaderSystem
|
||||
{
|
||||
public:
|
||||
INTEGER_CONSTANT( Version, 1 );
|
||||
STRING_CONSTANT( Name, "shaders" );
|
||||
INTEGER_CONSTANT( Version, 1 );
|
||||
STRING_CONSTANT( Name, "shaders" );
|
||||
// NOTE: shader and texture names used must be full path.
|
||||
// Shaders usable as textures have prefix equal to getTexturePrefix()
|
||||
|
||||
virtual void realise() = 0;
|
||||
virtual void unrealise() = 0;
|
||||
virtual void refresh() = 0;
|
||||
virtual void realise() = 0;
|
||||
virtual void unrealise() = 0;
|
||||
virtual void refresh() = 0;
|
||||
// activate the shader for a given name and return it
|
||||
// will return the default shader if name is not found
|
||||
virtual IShader* getShaderForName( const char* name ) = 0;
|
||||
virtual IShader* getShaderForName( const char* name ) = 0;
|
||||
|
||||
virtual void foreachShaderName( const ShaderNameCallback& callback ) = 0;
|
||||
virtual void foreachShaderName( const ShaderNameCallback& callback ) = 0;
|
||||
|
||||
// iterate over the list of active shaders
|
||||
virtual void beginActiveShadersIterator() = 0;
|
||||
virtual bool endActiveShadersIterator() = 0;
|
||||
virtual IShader* dereferenceActiveShadersIterator() = 0;
|
||||
virtual void incrementActiveShadersIterator() = 0;
|
||||
virtual void beginActiveShadersIterator() = 0;
|
||||
virtual bool endActiveShadersIterator() = 0;
|
||||
virtual IShader* dereferenceActiveShadersIterator() = 0;
|
||||
virtual void incrementActiveShadersIterator() = 0;
|
||||
|
||||
virtual void setActiveShadersChangedNotify( const Callback& notify ) = 0;
|
||||
virtual void setActiveShadersChangedNotify( const Callback& notify ) = 0;
|
||||
|
||||
virtual void attach( ModuleObserver& observer ) = 0;
|
||||
virtual void detach( ModuleObserver& observer ) = 0;
|
||||
virtual void attach( ModuleObserver& observer ) = 0;
|
||||
virtual void detach( ModuleObserver& observer ) = 0;
|
||||
|
||||
virtual void setLightingEnabled( bool enabled ) = 0;
|
||||
virtual void setLightingEnabled( bool enabled ) = 0;
|
||||
|
||||
virtual const char* getTexturePrefix() const = 0;
|
||||
virtual const char* getTexturePrefix() const = 0;
|
||||
};
|
||||
|
||||
#include "modulesystem.h"
|
||||
|
||||
@@ -25,17 +25,17 @@
|
||||
class texdef_t
|
||||
{
|
||||
public:
|
||||
float shift[2];
|
||||
float rotate;
|
||||
float scale[2];
|
||||
float shift[2];
|
||||
float rotate;
|
||||
float scale[2];
|
||||
|
||||
texdef_t(){
|
||||
shift[0] = 0;
|
||||
shift[1] = 0;
|
||||
rotate = 0;
|
||||
scale[0] = 1;
|
||||
scale[1] = 1;
|
||||
}
|
||||
texdef_t(){
|
||||
shift[0] = 0;
|
||||
shift[1] = 0;
|
||||
rotate = 0;
|
||||
scale[0] = 1;
|
||||
scale[1] = 1;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -34,7 +34,7 @@ class TextInputStream
|
||||
public:
|
||||
/// \brief Attempts to read the next \p length characters from the stream to \p buffer.
|
||||
/// Returns the number of characters actually stored in \p buffer.
|
||||
virtual std::size_t read( char* buffer, std::size_t length ) = 0;
|
||||
virtual std::size_t read( char* buffer, std::size_t length ) = 0;
|
||||
};
|
||||
|
||||
/// \brief A write-only character-stream.
|
||||
@@ -43,7 +43,7 @@ class TextOutputStream
|
||||
public:
|
||||
/// \brief Attempts to write \p length characters to the stream from \p buffer.
|
||||
/// Returns the number of characters actually read from \p buffer.
|
||||
virtual std::size_t write( const char* buffer, std::size_t length ) = 0;
|
||||
virtual std::size_t write( const char* buffer, std::size_t length ) = 0;
|
||||
};
|
||||
|
||||
/// \brief Calls the overloaded function ostream_write() to perform text formatting specific to the type being written.
|
||||
@@ -68,25 +68,25 @@ inline TextOutputStream& operator<<( TextOutputStream& ostream, const T& t ){
|
||||
class NullOutputStream : public TextOutputStream
|
||||
{
|
||||
public:
|
||||
std::size_t write( const char*, std::size_t length ){
|
||||
return length;
|
||||
}
|
||||
std::size_t write( const char*, std::size_t length ){
|
||||
return length;
|
||||
}
|
||||
};
|
||||
|
||||
class OutputStreamHolder
|
||||
{
|
||||
NullOutputStream m_nullOutputStream;
|
||||
TextOutputStream* m_outputStream;
|
||||
NullOutputStream m_nullOutputStream;
|
||||
TextOutputStream* m_outputStream;
|
||||
public:
|
||||
OutputStreamHolder()
|
||||
: m_outputStream( &m_nullOutputStream ){
|
||||
}
|
||||
void setOutputStream( TextOutputStream& outputStream ){
|
||||
m_outputStream = &outputStream;
|
||||
}
|
||||
TextOutputStream& getOutputStream(){
|
||||
return *m_outputStream;
|
||||
}
|
||||
OutputStreamHolder()
|
||||
: m_outputStream( &m_nullOutputStream ){
|
||||
}
|
||||
void setOutputStream( TextOutputStream& outputStream ){
|
||||
m_outputStream = &outputStream;
|
||||
}
|
||||
TextOutputStream& getOutputStream(){
|
||||
return *m_outputStream;
|
||||
}
|
||||
};
|
||||
|
||||
typedef Static<OutputStreamHolder> GlobalOutputStream;
|
||||
|
||||
@@ -29,16 +29,16 @@ struct qtexture_t;
|
||||
|
||||
class LoadImageCallback
|
||||
{
|
||||
typedef Image* ( *LoadFunc )( void* environment, const char* name );
|
||||
typedef Image* ( *LoadFunc )( void* environment, const char* name );
|
||||
public:
|
||||
void* m_environment;
|
||||
LoadFunc m_func;
|
||||
void* m_environment;
|
||||
LoadFunc m_func;
|
||||
|
||||
LoadImageCallback( void* environment, LoadFunc func ) : m_environment( environment ), m_func( func ){
|
||||
}
|
||||
Image* loadImage( const char* name ) const {
|
||||
return m_func( m_environment, name );
|
||||
}
|
||||
LoadImageCallback( void* environment, LoadFunc func ) : m_environment( environment ), m_func( func ){
|
||||
}
|
||||
Image* loadImage( const char* name ) const {
|
||||
return m_func( m_environment, name );
|
||||
}
|
||||
};
|
||||
|
||||
inline bool operator==( const LoadImageCallback& self, const LoadImageCallback& other ){
|
||||
@@ -46,28 +46,28 @@ inline bool operator==( const LoadImageCallback& self, const LoadImageCallback&
|
||||
}
|
||||
inline bool operator<( const LoadImageCallback& self, const LoadImageCallback& other ){
|
||||
return self.m_environment < other.m_environment ||
|
||||
( !( other.m_environment < self.m_environment ) && self.m_func < other.m_func );
|
||||
( !( other.m_environment < self.m_environment ) && self.m_func < other.m_func );
|
||||
}
|
||||
|
||||
class TexturesCacheObserver
|
||||
{
|
||||
public:
|
||||
virtual void unrealise() = 0;
|
||||
virtual void realise() = 0;
|
||||
virtual void unrealise() = 0;
|
||||
virtual void realise() = 0;
|
||||
};
|
||||
|
||||
class TexturesCache
|
||||
{
|
||||
public:
|
||||
INTEGER_CONSTANT( Version, 1 );
|
||||
STRING_CONSTANT( Name, "textures" );
|
||||
virtual LoadImageCallback defaultLoader() const = 0;
|
||||
virtual Image* loadImage( const char* name ) = 0;
|
||||
virtual qtexture_t* capture( const char* name ) = 0;
|
||||
virtual qtexture_t* capture( const LoadImageCallback& load, const char* name ) = 0;
|
||||
virtual void release( qtexture_t* texture ) = 0;
|
||||
virtual void attach( TexturesCacheObserver& observer ) = 0;
|
||||
virtual void detach( TexturesCacheObserver& observer ) = 0;
|
||||
INTEGER_CONSTANT( Version, 1 );
|
||||
STRING_CONSTANT( Name, "textures" );
|
||||
virtual LoadImageCallback defaultLoader() const = 0;
|
||||
virtual Image* loadImage( const char* name ) = 0;
|
||||
virtual qtexture_t* capture( const char* name ) = 0;
|
||||
virtual qtexture_t* capture( const LoadImageCallback& load, const char* name ) = 0;
|
||||
virtual void release( qtexture_t* texture ) = 0;
|
||||
virtual void attach( TexturesCacheObserver& observer ) = 0;
|
||||
virtual void detach( TexturesCacheObserver& observer ) = 0;
|
||||
};
|
||||
|
||||
#include "modulesystem.h"
|
||||
|
||||
@@ -28,19 +28,19 @@
|
||||
class IToolbarButton
|
||||
{
|
||||
public:
|
||||
enum EType
|
||||
{
|
||||
eSpace,
|
||||
eButton,
|
||||
eToggleButton,
|
||||
eRadioButton,
|
||||
};
|
||||
enum EType
|
||||
{
|
||||
eSpace,
|
||||
eButton,
|
||||
eToggleButton,
|
||||
eRadioButton,
|
||||
};
|
||||
|
||||
virtual const char* getImage() const = 0;
|
||||
virtual const char* getText() const = 0;
|
||||
virtual const char* getTooltip() const = 0;
|
||||
virtual EType getType() const = 0;
|
||||
virtual void activate() const = 0;
|
||||
virtual const char* getImage() const = 0;
|
||||
virtual const char* getText() const = 0;
|
||||
virtual const char* getTooltip() const = 0;
|
||||
virtual EType getType() const = 0;
|
||||
virtual void activate() const = 0;
|
||||
};
|
||||
|
||||
typedef std::size_t ( *PFN_TOOLBARBUTTONCOUNT )();
|
||||
|
||||
@@ -32,60 +32,60 @@
|
||||
class UndoMemento
|
||||
{
|
||||
public:
|
||||
virtual void release() = 0;
|
||||
virtual ~UndoMemento() {
|
||||
}
|
||||
virtual void release() = 0;
|
||||
virtual ~UndoMemento() {
|
||||
}
|
||||
};
|
||||
|
||||
class Undoable
|
||||
{
|
||||
public:
|
||||
virtual UndoMemento* exportState() const = 0;
|
||||
virtual void importState( const UndoMemento* state ) = 0;
|
||||
virtual ~Undoable() {
|
||||
}
|
||||
virtual UndoMemento* exportState() const = 0;
|
||||
virtual void importState( const UndoMemento* state ) = 0;
|
||||
virtual ~Undoable() {
|
||||
}
|
||||
};
|
||||
|
||||
class UndoObserver
|
||||
{
|
||||
public:
|
||||
virtual void save( Undoable* undoable ) = 0;
|
||||
virtual ~UndoObserver() {
|
||||
}
|
||||
virtual void save( Undoable* undoable ) = 0;
|
||||
virtual ~UndoObserver() {
|
||||
}
|
||||
};
|
||||
|
||||
class UndoTracker
|
||||
{
|
||||
public:
|
||||
virtual void clear() = 0;
|
||||
virtual void begin() = 0;
|
||||
virtual void undo() = 0;
|
||||
virtual void redo() = 0;
|
||||
virtual ~UndoTracker() {
|
||||
}
|
||||
virtual void clear() = 0;
|
||||
virtual void begin() = 0;
|
||||
virtual void undo() = 0;
|
||||
virtual void redo() = 0;
|
||||
virtual ~UndoTracker() {
|
||||
}
|
||||
};
|
||||
|
||||
class UndoSystem
|
||||
{
|
||||
public:
|
||||
INTEGER_CONSTANT( Version, 1 );
|
||||
STRING_CONSTANT( Name, "undo" );
|
||||
INTEGER_CONSTANT( Version, 1 );
|
||||
STRING_CONSTANT( Name, "undo" );
|
||||
|
||||
virtual UndoObserver* observer( Undoable* undoable ) = 0;
|
||||
virtual void release( Undoable* undoable ) = 0;
|
||||
virtual UndoObserver* observer( Undoable* undoable ) = 0;
|
||||
virtual void release( Undoable* undoable ) = 0;
|
||||
|
||||
virtual std::size_t size() const = 0;
|
||||
virtual void start() = 0;
|
||||
virtual void finish( const char* command ) = 0;
|
||||
virtual void undo() = 0;
|
||||
virtual void redo() = 0;
|
||||
virtual void clear() = 0;
|
||||
virtual std::size_t size() const = 0;
|
||||
virtual void start() = 0;
|
||||
virtual void finish( const char* command ) = 0;
|
||||
virtual void undo() = 0;
|
||||
virtual void redo() = 0;
|
||||
virtual void clear() = 0;
|
||||
|
||||
virtual void trackerAttach( UndoTracker& tracker ) = 0;
|
||||
virtual void trackerDetach( UndoTracker& tracker ) = 0;
|
||||
virtual void trackerAttach( UndoTracker& tracker ) = 0;
|
||||
virtual void trackerDetach( UndoTracker& tracker ) = 0;
|
||||
|
||||
virtual ~UndoSystem() {
|
||||
}
|
||||
virtual ~UndoSystem() {
|
||||
}
|
||||
};
|
||||
|
||||
#include "modulesystem.h"
|
||||
@@ -104,14 +104,14 @@ inline UndoSystem& GlobalUndoSystem(){
|
||||
|
||||
class UndoableCommand
|
||||
{
|
||||
const char* m_command;
|
||||
const char* m_command;
|
||||
public:
|
||||
UndoableCommand( const char* command ) : m_command( command ){
|
||||
GlobalUndoSystem().start();
|
||||
}
|
||||
~UndoableCommand(){
|
||||
GlobalUndoSystem().finish( m_command );
|
||||
}
|
||||
UndoableCommand( const char* command ) : m_command( command ){
|
||||
GlobalUndoSystem().start();
|
||||
}
|
||||
~UndoableCommand(){
|
||||
GlobalUndoSystem().finish( m_command );
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -38,13 +38,13 @@ const std::size_t VARIABLE_IS_NOT_USED MAPFILE_MAX_CHANGES = std::numeric_limits
|
||||
class MapFile
|
||||
{
|
||||
public:
|
||||
STRING_CONSTANT( Name, "MapFile" );
|
||||
STRING_CONSTANT( Name, "MapFile" );
|
||||
|
||||
virtual void save() = 0;
|
||||
virtual bool saved() const = 0;
|
||||
virtual void changed() = 0;
|
||||
virtual void setChangedCallback( const Callback& changed ) = 0;
|
||||
virtual std::size_t changes() const = 0;
|
||||
virtual void save() = 0;
|
||||
virtual bool saved() const = 0;
|
||||
virtual void changed() = 0;
|
||||
virtual void setChangedCallback( const Callback& changed ) = 0;
|
||||
virtual std::size_t changes() const = 0;
|
||||
};
|
||||
|
||||
#include "scenelib.h"
|
||||
|
||||
@@ -28,10 +28,10 @@
|
||||
class SkinRemap
|
||||
{
|
||||
public:
|
||||
const char* m_from;
|
||||
const char* m_to;
|
||||
SkinRemap( const char* from, const char* to ) : m_from( from ), m_to( to ){
|
||||
}
|
||||
const char* m_from;
|
||||
const char* m_to;
|
||||
SkinRemap( const char* from, const char* to ) : m_from( from ), m_to( to ){
|
||||
}
|
||||
};
|
||||
|
||||
typedef Callback1<SkinRemap> SkinRemapCallback;
|
||||
@@ -40,36 +40,36 @@ class ModuleObserver;
|
||||
class ModelSkin
|
||||
{
|
||||
public:
|
||||
STRING_CONSTANT( Name, "ModelSkin" );
|
||||
STRING_CONSTANT( Name, "ModelSkin" );
|
||||
/// \brief Attach an \p observer whose realise() and unrealise() methods will be called when the skin is loaded or unloaded.
|
||||
virtual void attach( ModuleObserver& observer ) = 0;
|
||||
virtual void attach( ModuleObserver& observer ) = 0;
|
||||
/// \brief Detach an \p observer previously-attached by calling \c attach.
|
||||
virtual void detach( ModuleObserver& observer ) = 0;
|
||||
virtual void detach( ModuleObserver& observer ) = 0;
|
||||
/// \brief Returns true if this skin is currently loaded.
|
||||
virtual bool realised() const = 0;
|
||||
virtual bool realised() const = 0;
|
||||
/// \brief Returns the shader identifier that \p name remaps to, or "" if not found or not realised.
|
||||
virtual const char* getRemap( const char* name ) const = 0;
|
||||
virtual const char* getRemap( const char* name ) const = 0;
|
||||
/// \brief Calls \p callback for each remap pair. Has no effect if not realised.
|
||||
virtual void forEachRemap( const SkinRemapCallback& callback ) const = 0;
|
||||
virtual void forEachRemap( const SkinRemapCallback& callback ) const = 0;
|
||||
};
|
||||
|
||||
class SkinnedModel
|
||||
{
|
||||
public:
|
||||
STRING_CONSTANT( Name, "SkinnedModel" );
|
||||
STRING_CONSTANT( Name, "SkinnedModel" );
|
||||
/// \brief Instructs the skinned model to update its skin.
|
||||
virtual void skinChanged() = 0;
|
||||
virtual void skinChanged() = 0;
|
||||
};
|
||||
|
||||
class ModelSkinCache
|
||||
{
|
||||
public:
|
||||
INTEGER_CONSTANT( Version, 1 );
|
||||
STRING_CONSTANT( Name, "modelskin" );
|
||||
INTEGER_CONSTANT( Version, 1 );
|
||||
STRING_CONSTANT( Name, "modelskin" );
|
||||
/// \brief Increments the reference count of and returns a reference to the skin uniquely identified by 'name'.
|
||||
virtual ModelSkin& capture( const char* name ) = 0;
|
||||
virtual ModelSkin& capture( const char* name ) = 0;
|
||||
/// \brief Decrements the reference-count of the skin uniquely identified by 'name'.
|
||||
virtual void release( const char* name ) = 0;
|
||||
virtual void release( const char* name ) = 0;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -25,8 +25,8 @@
|
||||
class ModuleObserver
|
||||
{
|
||||
public:
|
||||
virtual void unrealise() = 0;
|
||||
virtual void realise() = 0;
|
||||
virtual void unrealise() = 0;
|
||||
virtual void realise() = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -42,9 +42,9 @@
|
||||
class Module
|
||||
{
|
||||
public:
|
||||
virtual void capture() = 0;
|
||||
virtual void release() = 0;
|
||||
virtual void* getTable() = 0;
|
||||
virtual void capture() = 0;
|
||||
virtual void release() = 0;
|
||||
virtual void* getTable() = 0;
|
||||
};
|
||||
|
||||
inline void* Module_getTable( Module& module ){
|
||||
@@ -57,38 +57,38 @@ class DebugMessageHandler;
|
||||
class ModuleServer
|
||||
{
|
||||
public:
|
||||
class Visitor
|
||||
{
|
||||
public:
|
||||
virtual void visit( const char* name, Module& module ) const = 0;
|
||||
};
|
||||
class Visitor
|
||||
{
|
||||
public:
|
||||
virtual void visit( const char* name, Module& module ) const = 0;
|
||||
};
|
||||
|
||||
virtual void setError( bool error ) = 0;
|
||||
virtual bool getError() const = 0;
|
||||
virtual void setError( bool error ) = 0;
|
||||
virtual bool getError() const = 0;
|
||||
|
||||
virtual TextOutputStream& getOutputStream() = 0;
|
||||
virtual TextOutputStream& getWarningStream() = 0;
|
||||
virtual TextOutputStream& getErrorStream() = 0;
|
||||
virtual DebugMessageHandler& getDebugMessageHandler() = 0;
|
||||
virtual TextOutputStream& getOutputStream() = 0;
|
||||
virtual TextOutputStream& getWarningStream() = 0;
|
||||
virtual TextOutputStream& getErrorStream() = 0;
|
||||
virtual DebugMessageHandler& getDebugMessageHandler() = 0;
|
||||
|
||||
virtual void registerModule( const char* type, int version, const char* name, Module& module ) = 0;
|
||||
virtual Module* findModule( const char* type, int version, const char* name ) const = 0;
|
||||
virtual void foreachModule( const char* type, int version, const Visitor& visitor ) = 0;
|
||||
virtual void registerModule( const char* type, int version, const char* name, Module& module ) = 0;
|
||||
virtual Module* findModule( const char* type, int version, const char* name ) const = 0;
|
||||
virtual void foreachModule( const char* type, int version, const Visitor& visitor ) = 0;
|
||||
};
|
||||
|
||||
class ModuleServerHolder
|
||||
{
|
||||
ModuleServer* m_server;
|
||||
ModuleServer* m_server;
|
||||
public:
|
||||
ModuleServerHolder()
|
||||
: m_server( 0 ){
|
||||
}
|
||||
void set( ModuleServer& server ){
|
||||
m_server = &server;
|
||||
}
|
||||
ModuleServer& get(){
|
||||
return *m_server;
|
||||
}
|
||||
ModuleServerHolder()
|
||||
: m_server( 0 ){
|
||||
}
|
||||
void set( ModuleServer& server ){
|
||||
m_server = &server;
|
||||
}
|
||||
ModuleServer& get(){
|
||||
return *m_server;
|
||||
}
|
||||
};
|
||||
|
||||
typedef Static<ModuleServerHolder> GlobalModuleServer;
|
||||
@@ -112,104 +112,104 @@ template<typename Type>
|
||||
class Modules
|
||||
{
|
||||
public:
|
||||
class Visitor
|
||||
{
|
||||
public:
|
||||
virtual void visit( const char* name, const Type& table ) const = 0;
|
||||
};
|
||||
class Visitor
|
||||
{
|
||||
public:
|
||||
virtual void visit( const char* name, const Type& table ) const = 0;
|
||||
};
|
||||
|
||||
virtual Type* findModule( const char* name ) = 0;
|
||||
virtual void foreachModule( const Visitor& visitor ) = 0;
|
||||
virtual Type* findModule( const char* name ) = 0;
|
||||
virtual void foreachModule( const Visitor& visitor ) = 0;
|
||||
};
|
||||
|
||||
template<typename Type>
|
||||
class ModuleRef
|
||||
{
|
||||
Module* m_module;
|
||||
Type* m_table;
|
||||
Module* m_module;
|
||||
Type* m_table;
|
||||
public:
|
||||
ModuleRef( const char* name ) : m_table( 0 ){
|
||||
if ( !globalModuleServer().getError() ) {
|
||||
m_module = globalModuleServer().findModule( typename Type::Name(), typename Type::Version(), name );
|
||||
if ( m_module == 0 ) {
|
||||
globalModuleServer().setError( true );
|
||||
globalErrorStream() << "ModuleRef::initialise: type=" << makeQuoted( typename Type::Name() ) << " version=" << makeQuoted( typename Type::Version() ) << " name=" << makeQuoted( name ) << " - not found\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
m_module->capture();
|
||||
if ( !globalModuleServer().getError() ) {
|
||||
m_table = static_cast<Type*>( m_module->getTable() );
|
||||
ModuleRef( const char* name ) : m_table( 0 ){
|
||||
if ( !globalModuleServer().getError() ) {
|
||||
m_module = globalModuleServer().findModule( typename Type::Name(), typename Type::Version(), name );
|
||||
if ( m_module == 0 ) {
|
||||
globalModuleServer().setError( true );
|
||||
globalErrorStream() << "ModuleRef::initialise: type=" << makeQuoted( typename Type::Name() ) << " version=" << makeQuoted( typename Type::Version() ) << " name=" << makeQuoted( name ) << " - not found\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
m_module->capture();
|
||||
if ( !globalModuleServer().getError() ) {
|
||||
m_table = static_cast<Type*>( m_module->getTable() );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
~ModuleRef(){
|
||||
if ( m_module != 0 ) {
|
||||
m_module->release();
|
||||
~ModuleRef(){
|
||||
if ( m_module != 0 ) {
|
||||
m_module->release();
|
||||
}
|
||||
}
|
||||
}
|
||||
Type* getTable(){
|
||||
Type* getTable(){
|
||||
#if defined( _DEBUG )
|
||||
ASSERT_MESSAGE( m_table != 0, "ModuleRef::getTable: type=" << makeQuoted( typename Type::Name() ) << " version=" << makeQuoted( typename Type::Version() ) << " - module-reference used without being initialised" );
|
||||
ASSERT_MESSAGE( m_table != 0, "ModuleRef::getTable: type=" << makeQuoted( typename Type::Name() ) << " version=" << makeQuoted( typename Type::Version() ) << " - module-reference used without being initialised" );
|
||||
#endif
|
||||
return m_table;
|
||||
}
|
||||
return m_table;
|
||||
}
|
||||
};
|
||||
|
||||
template<typename Type>
|
||||
class SingletonModuleRef
|
||||
{
|
||||
Module* m_module;
|
||||
Type* m_table;
|
||||
Module* m_module;
|
||||
Type* m_table;
|
||||
public:
|
||||
|
||||
SingletonModuleRef()
|
||||
: m_module( 0 ), m_table( 0 ){
|
||||
}
|
||||
|
||||
bool initialised() const {
|
||||
return m_module != 0;
|
||||
}
|
||||
|
||||
void initialise( const char* name ){
|
||||
m_module = globalModuleServer().findModule( typename Type::Name(), typename Type::Version(), name );
|
||||
if ( m_module == 0 ) {
|
||||
globalModuleServer().setError( true );
|
||||
globalErrorStream() << "SingletonModuleRef::initialise: type=" << makeQuoted( typename Type::Name() ) << " version=" << makeQuoted( typename Type::Version() ) << " name=" << makeQuoted( name ) << " - not found\n";
|
||||
SingletonModuleRef()
|
||||
: m_module( 0 ), m_table( 0 ){
|
||||
}
|
||||
}
|
||||
|
||||
Type* getTable(){
|
||||
bool initialised() const {
|
||||
return m_module != 0;
|
||||
}
|
||||
|
||||
void initialise( const char* name ){
|
||||
m_module = globalModuleServer().findModule( typename Type::Name(), typename Type::Version(), name );
|
||||
if ( m_module == 0 ) {
|
||||
globalModuleServer().setError( true );
|
||||
globalErrorStream() << "SingletonModuleRef::initialise: type=" << makeQuoted( typename Type::Name() ) << " version=" << makeQuoted( typename Type::Version() ) << " name=" << makeQuoted( name ) << " - not found\n";
|
||||
}
|
||||
}
|
||||
|
||||
Type* getTable(){
|
||||
#if defined( _DEBUG )
|
||||
ASSERT_MESSAGE( m_table != 0, "SingletonModuleRef::getTable: type=" << makeQuoted( typename Type::Name() ) << " version=" << makeQuoted( typename Type::Version() ) << " - module-reference used without being initialised" );
|
||||
ASSERT_MESSAGE( m_table != 0, "SingletonModuleRef::getTable: type=" << makeQuoted( typename Type::Name() ) << " version=" << makeQuoted( typename Type::Version() ) << " - module-reference used without being initialised" );
|
||||
#endif
|
||||
return m_table;
|
||||
}
|
||||
void capture(){
|
||||
if ( initialised() ) {
|
||||
m_module->capture();
|
||||
m_table = static_cast<Type*>( m_module->getTable() );
|
||||
return m_table;
|
||||
}
|
||||
}
|
||||
void release(){
|
||||
if ( initialised() ) {
|
||||
m_module->release();
|
||||
void capture(){
|
||||
if ( initialised() ) {
|
||||
m_module->capture();
|
||||
m_table = static_cast<Type*>( m_module->getTable() );
|
||||
}
|
||||
}
|
||||
void release(){
|
||||
if ( initialised() ) {
|
||||
m_module->release();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template<typename Type>
|
||||
class GlobalModule
|
||||
{
|
||||
static SingletonModuleRef<Type> m_instance;
|
||||
static SingletonModuleRef<Type> m_instance;
|
||||
public:
|
||||
static SingletonModuleRef<Type>& instance(){
|
||||
return m_instance;
|
||||
}
|
||||
static Type& getTable(){
|
||||
return *m_instance.getTable();
|
||||
}
|
||||
static SingletonModuleRef<Type>& instance(){
|
||||
return m_instance;
|
||||
}
|
||||
static Type& getTable(){
|
||||
return *m_instance.getTable();
|
||||
}
|
||||
};
|
||||
|
||||
template<class Type>
|
||||
@@ -220,18 +220,18 @@ template<typename Type>
|
||||
class GlobalModuleRef
|
||||
{
|
||||
public:
|
||||
GlobalModuleRef( const char* name = "*" ){
|
||||
if ( !globalModuleServer().getError() ) {
|
||||
GlobalModule<Type>::instance().initialise( name );
|
||||
GlobalModuleRef( const char* name = "*" ){
|
||||
if ( !globalModuleServer().getError() ) {
|
||||
GlobalModule<Type>::instance().initialise( name );
|
||||
}
|
||||
GlobalModule<Type>::instance().capture();
|
||||
}
|
||||
~GlobalModuleRef(){
|
||||
GlobalModule<Type>::instance().release();
|
||||
}
|
||||
Type& getTable(){
|
||||
return GlobalModule<Type>::getTable();
|
||||
}
|
||||
GlobalModule<Type>::instance().capture();
|
||||
}
|
||||
~GlobalModuleRef(){
|
||||
GlobalModule<Type>::instance().release();
|
||||
}
|
||||
Type& getTable(){
|
||||
return GlobalModule<Type>::getTable();
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -30,11 +30,11 @@ typedef Callback1<const char*> NameCallback;
|
||||
class Nameable
|
||||
{
|
||||
public:
|
||||
STRING_CONSTANT( Name, "Nameable" );
|
||||
STRING_CONSTANT( Name, "Nameable" );
|
||||
|
||||
virtual const char* name() const = 0;
|
||||
virtual void attach( const NameCallback& callback ) = 0;
|
||||
virtual void detach( const NameCallback& callback ) = 0;
|
||||
virtual const char* name() const = 0;
|
||||
virtual void attach( const NameCallback& callback ) = 0;
|
||||
virtual void detach( const NameCallback& callback ) = 0;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -31,19 +31,19 @@ typedef Callback1<const NameCallback&> NameCallbackCallback;
|
||||
class Namespace
|
||||
{
|
||||
public:
|
||||
INTEGER_CONSTANT( Version, 1 );
|
||||
STRING_CONSTANT( Name, "namespace" );
|
||||
virtual void attach( const NameCallback& setName, const NameCallbackCallback& attachObserver ) = 0;
|
||||
virtual void detach( const NameCallback& setName, const NameCallbackCallback& detachObserver ) = 0;
|
||||
virtual void makeUnique( const char* name, const NameCallback& setName ) const = 0;
|
||||
INTEGER_CONSTANT( Version, 1 );
|
||||
STRING_CONSTANT( Name, "namespace" );
|
||||
virtual void attach( const NameCallback& setName, const NameCallbackCallback& attachObserver ) = 0;
|
||||
virtual void detach( const NameCallback& setName, const NameCallbackCallback& detachObserver ) = 0;
|
||||
virtual void makeUnique( const char* name, const NameCallback& setName ) const = 0;
|
||||
};
|
||||
|
||||
class Namespaced
|
||||
{
|
||||
public:
|
||||
STRING_CONSTANT( Name, "Namespaced" );
|
||||
STRING_CONSTANT( Name, "Namespaced" );
|
||||
|
||||
virtual void setNamespace( Namespace& space ) = 0;
|
||||
virtual void setNamespace( Namespace& space ) = 0;
|
||||
};
|
||||
|
||||
#include "modulesystem.h"
|
||||
|
||||
@@ -58,28 +58,28 @@ void SavePrefs( PreferenceDictionary& preferences, const char* filename ){
|
||||
class StringPreference
|
||||
{
|
||||
public:
|
||||
class Observer
|
||||
{
|
||||
public:
|
||||
virtual void onChanged() = 0;
|
||||
};
|
||||
class Observer
|
||||
{
|
||||
public:
|
||||
virtual void onChanged() = 0;
|
||||
};
|
||||
|
||||
private:
|
||||
CopiedString m_string;
|
||||
Observer& m_observer;
|
||||
CopiedString m_string;
|
||||
Observer& m_observer;
|
||||
public:
|
||||
StringPreference( Observer& observer )
|
||||
: m_observer( observer ){
|
||||
}
|
||||
void importString( const char* value ){
|
||||
m_string = value;
|
||||
m_observer.onChanged();
|
||||
}
|
||||
typedef MemberCaller1<StringPreference, const char*, &StringPreference::importString> ImportStringCaller;
|
||||
void exportString( StringImportCallback& importer ){
|
||||
importer( m_string.c_str() );
|
||||
}
|
||||
typedef MemberCaller1<StringPreference, StringImportCallback&, &StringPreference::exportString> ExportStringCaller;
|
||||
StringPreference( Observer& observer )
|
||||
: m_observer( observer ){
|
||||
}
|
||||
void importString( const char* value ){
|
||||
m_string = value;
|
||||
m_observer.onChanged();
|
||||
}
|
||||
typedef MemberCaller1<StringPreference, const char*, &StringPreference::importString> ImportStringCaller;
|
||||
void exportString( StringImportCallback& importer ){
|
||||
importer( m_string.c_str() );
|
||||
}
|
||||
typedef MemberCaller1<StringPreference, StringImportCallback&, &StringPreference::exportString> ExportStringCaller;
|
||||
};
|
||||
|
||||
inline void int_export( int i, StringImportCallback& importer ){
|
||||
@@ -95,79 +95,79 @@ inline int int_import( const char* value ){
|
||||
class IntPreference
|
||||
{
|
||||
public:
|
||||
class Observer
|
||||
{
|
||||
public:
|
||||
virtual void onChanged() = 0;
|
||||
};
|
||||
class Observer
|
||||
{
|
||||
public:
|
||||
virtual void onChanged() = 0;
|
||||
};
|
||||
|
||||
private:
|
||||
int m_int;
|
||||
Observer& m_observer;
|
||||
int m_int;
|
||||
Observer& m_observer;
|
||||
public:
|
||||
|
||||
IntPreference( Observer& observer )
|
||||
: m_observer( observer ){
|
||||
}
|
||||
void importString( const char* value ){
|
||||
m_int = int_import( value );
|
||||
m_observer.onChanged();
|
||||
}
|
||||
typedef MemberCaller1<IntPreference, const char*, &IntPreference::importString> ImportStringCaller;
|
||||
void exportString( StringImportCallback& importer ){
|
||||
int_export( m_int, importer );
|
||||
}
|
||||
typedef MemberCaller1<IntPreference, StringImportCallback&, &IntPreference::exportString> ExportStringCaller;
|
||||
IntPreference( Observer& observer )
|
||||
: m_observer( observer ){
|
||||
}
|
||||
void importString( const char* value ){
|
||||
m_int = int_import( value );
|
||||
m_observer.onChanged();
|
||||
}
|
||||
typedef MemberCaller1<IntPreference, const char*, &IntPreference::importString> ImportStringCaller;
|
||||
void exportString( StringImportCallback& importer ){
|
||||
int_export( m_int, importer );
|
||||
}
|
||||
typedef MemberCaller1<IntPreference, StringImportCallback&, &IntPreference::exportString> ExportStringCaller;
|
||||
};
|
||||
|
||||
class IntPreferenceImporter
|
||||
{
|
||||
int& m_i;
|
||||
int& m_i;
|
||||
public:
|
||||
|
||||
IntPreferenceImporter( int& i )
|
||||
: m_i( i ){
|
||||
}
|
||||
void importString( const char* value ){
|
||||
m_i = int_import( value );
|
||||
}
|
||||
IntPreferenceImporter( int& i )
|
||||
: m_i( i ){
|
||||
}
|
||||
void importString( const char* value ){
|
||||
m_i = int_import( value );
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class TestPrefs
|
||||
{
|
||||
public:
|
||||
TestPrefs(){
|
||||
PreferenceDictionary preferences;
|
||||
TestPrefs(){
|
||||
PreferenceDictionary preferences;
|
||||
|
||||
class StringObserver : public StringPreference::Observer
|
||||
{
|
||||
public:
|
||||
void onChanged(){
|
||||
int bleh = 0;
|
||||
}
|
||||
} string_observer;
|
||||
StringPreference string1( string_observer );
|
||||
string1.importString( "twenty-three" );
|
||||
|
||||
class IntObserver : public IntPreference::Observer
|
||||
{
|
||||
public:
|
||||
void onChanged(){
|
||||
int bleh = 0;
|
||||
}
|
||||
|
||||
} int_observer;
|
||||
IntPreference int1( int_observer );
|
||||
int1.importString( "23" );
|
||||
|
||||
preferences.registerPreference( "string1", StringPreference::ImportStringCaller( string1 ), StringPreference::ExportStringCaller( string1 ) );
|
||||
preferences.registerPreference( "int1", IntPreference::ImportStringCaller( int1 ), IntPreference::ExportStringCaller( int1 ) );
|
||||
|
||||
LoadPrefs( preferences, "test.pref" );
|
||||
SavePrefs( preferences, "test.pref" );
|
||||
|
||||
class StringObserver : public StringPreference::Observer
|
||||
{
|
||||
public:
|
||||
void onChanged(){
|
||||
int bleh = 0;
|
||||
}
|
||||
} string_observer;
|
||||
StringPreference string1( string_observer );
|
||||
string1.importString( "twenty-three" );
|
||||
|
||||
class IntObserver : public IntPreference::Observer
|
||||
{
|
||||
public:
|
||||
void onChanged(){
|
||||
int bleh = 0;
|
||||
}
|
||||
|
||||
} int_observer;
|
||||
IntPreference int1( int_observer );
|
||||
int1.importString( "23" );
|
||||
|
||||
preferences.registerPreference( "string1", StringPreference::ImportStringCaller( string1 ), StringPreference::ExportStringCaller( string1 ) );
|
||||
preferences.registerPreference( "int1", IntPreference::ImportStringCaller( int1 ), IntPreference::ExportStringCaller( int1 ) );
|
||||
|
||||
LoadPrefs( preferences, "test.pref" );
|
||||
SavePrefs( preferences, "test.pref" );
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
#if 0
|
||||
|
||||
@@ -31,10 +31,10 @@ typedef Callback1<const StringImportCallback&> StringExportCallback;
|
||||
class PreferenceSystem
|
||||
{
|
||||
public:
|
||||
INTEGER_CONSTANT( Version, 1 );
|
||||
STRING_CONSTANT( Name, "preferences" );
|
||||
INTEGER_CONSTANT( Version, 1 );
|
||||
STRING_CONSTANT( Name, "preferences" );
|
||||
|
||||
virtual void registerPreference( const char* name, const StringImportCallback& importer, const StringExportCallback& exporter ) = 0;
|
||||
virtual void registerPreference( const char* name, const StringImportCallback& importer, const StringExportCallback& exporter ) = 0;
|
||||
};
|
||||
|
||||
#include "modulesystem.h"
|
||||
|
||||
@@ -81,7 +81,7 @@ typedef char* ( *PFN_QERAPP_DIRDIALOG )( GtkWidget *parent, const char* title /*
|
||||
template<typename Element> class BasicVector3;
|
||||
typedef BasicVector3<float> Vector3;
|
||||
typedef bool ( *PFN_QERAPP_COLORDIALOG )( GtkWidget *parent, Vector3& color,
|
||||
const char* title /* = "Choose Color"*/ );
|
||||
const char* title /* = "Choose Color"*/ );
|
||||
|
||||
// load a .bmp file and create a GtkImage widget from it
|
||||
// NOTE: 'filename' is relative to <radiant_path>/plugins/bitmaps/
|
||||
|
||||
@@ -32,29 +32,29 @@ class Matrix4;
|
||||
class Renderer
|
||||
{
|
||||
public:
|
||||
enum EHighlightMode
|
||||
{
|
||||
eFace = 1 << 0,
|
||||
/*! Full highlighting. */
|
||||
ePrimitive = 1 << 1,
|
||||
ePrimitiveWire = 1 << 2, //always draw wire for primitives
|
||||
eFaceWire = 1 << 3, //wire for selected faces
|
||||
};
|
||||
enum EHighlightMode
|
||||
{
|
||||
eFace = 1 << 0,
|
||||
/*! Full highlighting. */
|
||||
ePrimitive = 1 << 1,
|
||||
ePrimitiveWire = 1 << 2, //always draw wire for primitives
|
||||
eFaceWire = 1 << 3, //wire for selected faces
|
||||
};
|
||||
|
||||
enum EStyle
|
||||
{
|
||||
eWireframeOnly,
|
||||
eFullMaterials,
|
||||
};
|
||||
enum EStyle
|
||||
{
|
||||
eWireframeOnly,
|
||||
eFullMaterials,
|
||||
};
|
||||
|
||||
virtual void PushState() = 0;
|
||||
virtual void PopState() = 0;
|
||||
virtual void SetState( Shader* state, EStyle mode ) = 0;
|
||||
virtual EStyle getStyle() const = 0;
|
||||
virtual void Highlight( EHighlightMode mode, bool bEnable = true ) = 0;
|
||||
virtual void setLights( const LightList& lights ){
|
||||
}
|
||||
virtual void addRenderable( const OpenGLRenderable& renderable, const Matrix4& world ) = 0;
|
||||
virtual void PushState() = 0;
|
||||
virtual void PopState() = 0;
|
||||
virtual void SetState( Shader* state, EStyle mode ) = 0;
|
||||
virtual EStyle getStyle() const = 0;
|
||||
virtual void Highlight( EHighlightMode mode, bool bEnable = true ) = 0;
|
||||
virtual void setLights( const LightList& lights ){
|
||||
}
|
||||
virtual void addRenderable( const OpenGLRenderable& renderable, const Matrix4& world ) = 0;
|
||||
};
|
||||
|
||||
class VolumeTest;
|
||||
@@ -62,14 +62,14 @@ class VolumeTest;
|
||||
class Renderable
|
||||
{
|
||||
public:
|
||||
STRING_CONSTANT( Name, "Renderable" );
|
||||
STRING_CONSTANT( Name, "Renderable" );
|
||||
|
||||
virtual void renderSolid( Renderer& renderer, const VolumeTest& volume ) const = 0;
|
||||
virtual void renderWireframe( Renderer& renderer, const VolumeTest& volume ) const = 0;
|
||||
virtual void renderComponents( Renderer&, const VolumeTest& ) const {
|
||||
}
|
||||
virtual void viewChanged() const {
|
||||
}
|
||||
virtual void renderSolid( Renderer& renderer, const VolumeTest& volume ) const = 0;
|
||||
virtual void renderWireframe( Renderer& renderer, const VolumeTest& volume ) const = 0;
|
||||
virtual void renderComponents( Renderer&, const VolumeTest& ) const {
|
||||
}
|
||||
virtual void viewChanged() const {
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -30,65 +30,65 @@
|
||||
|
||||
class SelectionIntersection
|
||||
{
|
||||
float m_depth;
|
||||
float m_distance;
|
||||
float m_depth2;
|
||||
bool m_indirect;
|
||||
float m_depth;
|
||||
float m_distance;
|
||||
float m_depth2;
|
||||
bool m_indirect;
|
||||
public:
|
||||
SelectionIntersection() : m_depth( 1 ), m_distance( 2 ), m_depth2( -1 ), m_indirect( true ){
|
||||
}
|
||||
SelectionIntersection( float depth, float distance ) : m_depth( depth ), m_distance( distance ), m_depth2( -1 ), m_indirect( distance != 0.f ){
|
||||
}
|
||||
SelectionIntersection( float depth, float distance, float depth2 ) : m_depth( depth ), m_distance( distance ), m_depth2( depth2 ), m_indirect( distance != 0.f ){
|
||||
}
|
||||
bool operator<( const SelectionIntersection& other ) const {
|
||||
if( m_indirect != other.m_indirect ){
|
||||
return other.m_indirect; //m_distance < other.m_distance;
|
||||
SelectionIntersection() : m_depth( 1 ), m_distance( 2 ), m_depth2( -1 ), m_indirect( true ){
|
||||
}
|
||||
else if( m_indirect && other.m_indirect ){
|
||||
if( fabs( m_distance - other.m_distance ) > 1e-3f /*0.00002f*/ ){
|
||||
return m_distance < other.m_distance;
|
||||
SelectionIntersection( float depth, float distance ) : m_depth( depth ), m_distance( distance ), m_depth2( -1 ), m_indirect( distance != 0.f ){
|
||||
}
|
||||
SelectionIntersection( float depth, float distance, float depth2 ) : m_depth( depth ), m_distance( distance ), m_depth2( depth2 ), m_indirect( distance != 0.f ){
|
||||
}
|
||||
bool operator<( const SelectionIntersection& other ) const {
|
||||
if( m_indirect != other.m_indirect ){
|
||||
return other.m_indirect; //m_distance < other.m_distance;
|
||||
}
|
||||
else if( fabs( m_depth - other.m_depth ) > 1e-6f ){
|
||||
else if( m_indirect && other.m_indirect ){
|
||||
if( fabs( m_distance - other.m_distance ) > 1e-3f /*0.00002f*/ ){
|
||||
return m_distance < other.m_distance;
|
||||
}
|
||||
else if( fabs( m_depth - other.m_depth ) > 1e-6f ){
|
||||
return m_depth < other.m_depth;
|
||||
}
|
||||
else{
|
||||
return m_depth2 > other.m_depth2;
|
||||
}
|
||||
}
|
||||
else if( m_depth != other.m_depth ){
|
||||
return m_depth < other.m_depth;
|
||||
}
|
||||
else{
|
||||
return m_depth2 > other.m_depth2;
|
||||
}
|
||||
}
|
||||
else if( m_depth != other.m_depth ){
|
||||
return m_depth < other.m_depth;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool equalEpsilon( const SelectionIntersection& other, float distanceEpsilon, float depthEpsilon ) const {
|
||||
if( m_indirect != other.m_indirect ){
|
||||
return false;
|
||||
}
|
||||
else if( m_indirect && other.m_indirect ){
|
||||
bool equalEpsilon( const SelectionIntersection& other, float distanceEpsilon, float depthEpsilon ) const {
|
||||
if( m_indirect != other.m_indirect ){
|
||||
return false;
|
||||
}
|
||||
else if( m_indirect && other.m_indirect ){
|
||||
#if 1
|
||||
return float_equal_epsilon( m_distance, other.m_distance, distanceEpsilon )
|
||||
&& float_equal_epsilon( m_depth, other.m_depth, depthEpsilon )
|
||||
&& float_equal_epsilon( m_depth2, other.m_depth2, 3e-7f );
|
||||
return float_equal_epsilon( m_distance, other.m_distance, distanceEpsilon )
|
||||
&& float_equal_epsilon( m_depth, other.m_depth, depthEpsilon )
|
||||
&& float_equal_epsilon( m_depth2, other.m_depth2, 3e-7f );
|
||||
#else
|
||||
return ( m_distance == other.m_distance )
|
||||
&& ( m_depth == other.m_depth )
|
||||
&& ( m_depth2 == other.m_depth2 );
|
||||
return ( m_distance == other.m_distance )
|
||||
&& ( m_depth == other.m_depth )
|
||||
&& ( m_depth2 == other.m_depth2 );
|
||||
#endif
|
||||
}
|
||||
return float_equal_epsilon( m_distance, other.m_distance, distanceEpsilon )
|
||||
&& float_equal_epsilon( m_depth, other.m_depth, depthEpsilon )
|
||||
&& float_equal_epsilon( m_depth2, other.m_depth2, depthEpsilon );
|
||||
}
|
||||
float depth() const {
|
||||
return m_depth;
|
||||
}
|
||||
float distance() const {
|
||||
return m_distance;
|
||||
}
|
||||
bool valid() const {
|
||||
return depth() < 1;
|
||||
}
|
||||
return float_equal_epsilon( m_distance, other.m_distance, distanceEpsilon )
|
||||
&& float_equal_epsilon( m_depth, other.m_depth, depthEpsilon )
|
||||
&& float_equal_epsilon( m_depth2, other.m_depth2, depthEpsilon );
|
||||
}
|
||||
float depth() const {
|
||||
return m_depth;
|
||||
}
|
||||
float distance() const {
|
||||
return m_distance;
|
||||
}
|
||||
bool valid() const {
|
||||
return depth() < 1;
|
||||
}
|
||||
};
|
||||
|
||||
// returns true if self is closer than other
|
||||
@@ -108,119 +108,119 @@ inline void assign_if_closer( SelectionIntersection& best, const SelectionInters
|
||||
|
||||
class VertexPointer
|
||||
{
|
||||
typedef const unsigned char* byte_pointer;
|
||||
typedef const unsigned char* byte_pointer;
|
||||
public:
|
||||
typedef float elem_type;
|
||||
typedef const elem_type* pointer;
|
||||
typedef const elem_type& reference;
|
||||
typedef float elem_type;
|
||||
typedef const elem_type* pointer;
|
||||
typedef const elem_type& reference;
|
||||
|
||||
class iterator
|
||||
{
|
||||
public:
|
||||
iterator() {}
|
||||
iterator( byte_pointer vertices, std::size_t stride )
|
||||
: m_iter( vertices ), m_stride( stride ) {}
|
||||
class iterator
|
||||
{
|
||||
public:
|
||||
iterator() {}
|
||||
iterator( byte_pointer vertices, std::size_t stride )
|
||||
: m_iter( vertices ), m_stride( stride ) {}
|
||||
|
||||
bool operator==( const iterator& other ) const {
|
||||
return m_iter == other.m_iter;
|
||||
}
|
||||
bool operator!=( const iterator& other ) const {
|
||||
return !operator==( other );
|
||||
}
|
||||
bool operator==( const iterator& other ) const {
|
||||
return m_iter == other.m_iter;
|
||||
}
|
||||
bool operator!=( const iterator& other ) const {
|
||||
return !operator==( other );
|
||||
}
|
||||
|
||||
iterator operator+( std::size_t i ){
|
||||
return iterator( m_iter + i * m_stride, m_stride );
|
||||
}
|
||||
iterator operator+=( std::size_t i ){
|
||||
m_iter += i * m_stride;
|
||||
return *this;
|
||||
}
|
||||
iterator& operator++(){
|
||||
m_iter += m_stride;
|
||||
return *this;
|
||||
}
|
||||
iterator operator++( int ){
|
||||
iterator tmp = *this;
|
||||
m_iter += m_stride;
|
||||
return tmp;
|
||||
}
|
||||
reference operator*() const {
|
||||
return *reinterpret_cast<pointer>( m_iter );
|
||||
}
|
||||
private:
|
||||
byte_pointer m_iter;
|
||||
std::size_t m_stride;
|
||||
};
|
||||
iterator operator+( std::size_t i ){
|
||||
return iterator( m_iter + i * m_stride, m_stride );
|
||||
}
|
||||
iterator operator+=( std::size_t i ){
|
||||
m_iter += i * m_stride;
|
||||
return *this;
|
||||
}
|
||||
iterator& operator++(){
|
||||
m_iter += m_stride;
|
||||
return *this;
|
||||
}
|
||||
iterator operator++( int ){
|
||||
iterator tmp = *this;
|
||||
m_iter += m_stride;
|
||||
return tmp;
|
||||
}
|
||||
reference operator*() const {
|
||||
return *reinterpret_cast<pointer>( m_iter );
|
||||
}
|
||||
private:
|
||||
byte_pointer m_iter;
|
||||
std::size_t m_stride;
|
||||
};
|
||||
|
||||
VertexPointer( pointer vertices, std::size_t stride )
|
||||
: m_vertices( reinterpret_cast<byte_pointer>( vertices ) ), m_stride( stride ) {}
|
||||
VertexPointer( pointer vertices, std::size_t stride )
|
||||
: m_vertices( reinterpret_cast<byte_pointer>( vertices ) ), m_stride( stride ) {}
|
||||
|
||||
iterator begin() const {
|
||||
return iterator( m_vertices, m_stride );
|
||||
}
|
||||
iterator begin() const {
|
||||
return iterator( m_vertices, m_stride );
|
||||
}
|
||||
|
||||
reference operator[]( std::size_t i ) const {
|
||||
return *reinterpret_cast<pointer>( m_vertices + m_stride * i );
|
||||
}
|
||||
reference operator[]( std::size_t i ) const {
|
||||
return *reinterpret_cast<pointer>( m_vertices + m_stride * i );
|
||||
}
|
||||
|
||||
private:
|
||||
byte_pointer m_vertices;
|
||||
std::size_t m_stride;
|
||||
byte_pointer m_vertices;
|
||||
std::size_t m_stride;
|
||||
};
|
||||
|
||||
class IndexPointer
|
||||
{
|
||||
public:
|
||||
typedef unsigned int index_type;
|
||||
typedef const index_type* pointer;
|
||||
typedef unsigned int index_type;
|
||||
typedef const index_type* pointer;
|
||||
|
||||
class iterator
|
||||
{
|
||||
public:
|
||||
iterator( pointer iter ) : m_iter( iter ) {}
|
||||
class iterator
|
||||
{
|
||||
public:
|
||||
iterator( pointer iter ) : m_iter( iter ) {}
|
||||
|
||||
bool operator==( const iterator& other ) const {
|
||||
return m_iter == other.m_iter;
|
||||
}
|
||||
bool operator!=( const iterator& other ) const {
|
||||
return !operator==( other );
|
||||
}
|
||||
bool operator==( const iterator& other ) const {
|
||||
return m_iter == other.m_iter;
|
||||
}
|
||||
bool operator!=( const iterator& other ) const {
|
||||
return !operator==( other );
|
||||
}
|
||||
|
||||
iterator operator+( std::size_t i ){
|
||||
return m_iter + i;
|
||||
}
|
||||
iterator operator+=( std::size_t i ){
|
||||
return m_iter += i;
|
||||
}
|
||||
iterator operator++(){
|
||||
return ++m_iter;
|
||||
}
|
||||
iterator operator++( int ){
|
||||
return m_iter++;
|
||||
}
|
||||
const index_type& operator*() const {
|
||||
return *m_iter;
|
||||
}
|
||||
private:
|
||||
void increment(){
|
||||
++m_iter;
|
||||
}
|
||||
pointer m_iter;
|
||||
};
|
||||
iterator operator+( std::size_t i ){
|
||||
return m_iter + i;
|
||||
}
|
||||
iterator operator+=( std::size_t i ){
|
||||
return m_iter += i;
|
||||
}
|
||||
iterator operator++(){
|
||||
return ++m_iter;
|
||||
}
|
||||
iterator operator++( int ){
|
||||
return m_iter++;
|
||||
}
|
||||
const index_type& operator*() const {
|
||||
return *m_iter;
|
||||
}
|
||||
private:
|
||||
void increment(){
|
||||
++m_iter;
|
||||
}
|
||||
pointer m_iter;
|
||||
};
|
||||
|
||||
IndexPointer( pointer indices, std::size_t count )
|
||||
: m_indices( indices ), m_finish( indices + count ) {}
|
||||
IndexPointer( pointer indices, std::size_t count )
|
||||
: m_indices( indices ), m_finish( indices + count ) {}
|
||||
|
||||
iterator begin() const {
|
||||
return m_indices;
|
||||
}
|
||||
iterator end() const {
|
||||
return m_finish;
|
||||
}
|
||||
iterator begin() const {
|
||||
return m_indices;
|
||||
}
|
||||
iterator end() const {
|
||||
return m_finish;
|
||||
}
|
||||
|
||||
private:
|
||||
pointer m_indices;
|
||||
pointer m_finish;
|
||||
pointer m_indices;
|
||||
pointer m_finish;
|
||||
};
|
||||
|
||||
class Matrix4;
|
||||
@@ -229,19 +229,19 @@ class VolumeTest;
|
||||
class SelectionTest
|
||||
{
|
||||
public:
|
||||
virtual void BeginMesh( const Matrix4& localToWorld, bool twoSided = false ) = 0;
|
||||
virtual const VolumeTest& getVolume() const = 0;
|
||||
//virtual const Vector3& getNear() const = 0;
|
||||
//virtual const Vector3& getFar() const = 0;
|
||||
virtual const Matrix4& getScreen2world() const = 0;
|
||||
virtual void TestPoint( const Vector3& point, SelectionIntersection& best ) = 0;
|
||||
virtual void TestPolygon( const VertexPointer& vertices, std::size_t count, SelectionIntersection& best, const DoubleVector3 planepoints[3] ) = 0;
|
||||
virtual void TestLineLoop( const VertexPointer& vertices, std::size_t count, SelectionIntersection& best ) = 0;
|
||||
virtual void TestLineStrip( const VertexPointer& vertices, std::size_t count, SelectionIntersection& best ) = 0;
|
||||
virtual void TestLines( const VertexPointer& vertices, std::size_t count, SelectionIntersection& best ) = 0;
|
||||
virtual void TestTriangles( const VertexPointer& vertices, const IndexPointer& indices, SelectionIntersection& best ) = 0;
|
||||
virtual void TestQuads( const VertexPointer& vertices, const IndexPointer& indices, SelectionIntersection& best ) = 0;
|
||||
virtual void TestQuadStrip( const VertexPointer& vertices, const IndexPointer& indices, SelectionIntersection& best ) = 0;
|
||||
virtual void BeginMesh( const Matrix4& localToWorld, bool twoSided = false ) = 0;
|
||||
virtual const VolumeTest& getVolume() const = 0;
|
||||
// virtual const Vector3& getNear() const = 0;
|
||||
// virtual const Vector3& getFar() const = 0;
|
||||
virtual const Matrix4& getScreen2world() const = 0;
|
||||
virtual void TestPoint( const Vector3& point, SelectionIntersection& best ) = 0;
|
||||
virtual void TestPolygon( const VertexPointer& vertices, std::size_t count, SelectionIntersection& best, const DoubleVector3 planepoints[3] ) = 0;
|
||||
virtual void TestLineLoop( const VertexPointer& vertices, std::size_t count, SelectionIntersection& best ) = 0;
|
||||
virtual void TestLineStrip( const VertexPointer& vertices, std::size_t count, SelectionIntersection& best ) = 0;
|
||||
virtual void TestLines( const VertexPointer& vertices, std::size_t count, SelectionIntersection& best ) = 0;
|
||||
virtual void TestTriangles( const VertexPointer& vertices, const IndexPointer& indices, SelectionIntersection& best ) = 0;
|
||||
virtual void TestQuads( const VertexPointer& vertices, const IndexPointer& indices, SelectionIntersection& best ) = 0;
|
||||
virtual void TestQuadStrip( const VertexPointer& vertices, const IndexPointer& indices, SelectionIntersection& best ) = 0;
|
||||
};
|
||||
|
||||
class Selectable;
|
||||
@@ -249,9 +249,9 @@ class Selectable;
|
||||
class Selector
|
||||
{
|
||||
public:
|
||||
virtual void pushSelectable( Selectable& selectable ) = 0;
|
||||
virtual void popSelectable() = 0;
|
||||
virtual void addIntersection( const SelectionIntersection& intersection ) = 0;
|
||||
virtual void pushSelectable( Selectable& selectable ) = 0;
|
||||
virtual void popSelectable() = 0;
|
||||
virtual void addIntersection( const SelectionIntersection& intersection ) = 0;
|
||||
};
|
||||
|
||||
inline void Selector_add( Selector& selector, Selectable& selectable ){
|
||||
@@ -271,9 +271,9 @@ class VolumeTest;
|
||||
class SelectionTestable
|
||||
{
|
||||
public:
|
||||
STRING_CONSTANT( Name, "SelectionTestable" );
|
||||
STRING_CONSTANT( Name, "SelectionTestable" );
|
||||
|
||||
virtual void testSelect( Selector& selector, SelectionTest& test ) = 0;
|
||||
virtual void testSelect( Selector& selector, SelectionTest& test ) = 0;
|
||||
};
|
||||
|
||||
inline SelectionTestable* Instance_getSelectionTestable( scene::Instance& instance ){
|
||||
@@ -288,22 +288,22 @@ typedef Callback1<const Plane3&> PlaneCallback;
|
||||
class SelectedPlanes
|
||||
{
|
||||
public:
|
||||
virtual bool contains( const Plane3& plane ) const = 0;
|
||||
virtual bool contains( const Plane3& plane ) const = 0;
|
||||
};
|
||||
|
||||
/// \todo Support localToWorld.
|
||||
class PlaneSelectable
|
||||
{
|
||||
public:
|
||||
STRING_CONSTANT( Name, "PlaneSelectable" );
|
||||
STRING_CONSTANT( Name, "PlaneSelectable" );
|
||||
|
||||
virtual void selectPlanes( Selector& selector, SelectionTest& test, const PlaneCallback& selectedPlaneCallback ) = 0;
|
||||
virtual void selectReversedPlanes( Selector& selector, const SelectedPlanes& selectedPlanes ) = 0;
|
||||
virtual void selectPlanes( Selector& selector, SelectionTest& test, const PlaneCallback& selectedPlaneCallback ) = 0;
|
||||
virtual void selectReversedPlanes( Selector& selector, const SelectedPlanes& selectedPlanes ) = 0;
|
||||
|
||||
virtual void bestPlaneDirect( SelectionTest& test, Plane3& plane, SelectionIntersection& intersection ) const = 0;
|
||||
virtual void bestPlaneIndirect( SelectionTest& test, Plane3& plane, Vector3& intersection, float& dist ) const = 0;
|
||||
virtual void selectByPlane( const Plane3& plane ) = 0;
|
||||
virtual void gatherPolygonsByPlane( const Plane3& plane, std::vector<std::vector<Vector3>>& polygons ) const = 0;
|
||||
virtual void bestPlaneDirect( SelectionTest& test, Plane3& plane, SelectionIntersection& intersection ) const = 0;
|
||||
virtual void bestPlaneIndirect( SelectionTest& test, Plane3& plane, Vector3& intersection, float& dist ) const = 0;
|
||||
virtual void selectByPlane( const Plane3& plane ) = 0;
|
||||
virtual void gatherPolygonsByPlane( const Plane3& plane, std::vector<std::vector<Vector3>>& polygons ) const = 0;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -79,13 +79,13 @@ typedef Vector2 WindowVector;
|
||||
class WindowObserver
|
||||
{
|
||||
public:
|
||||
virtual void release() = 0;
|
||||
virtual void onSizeChanged( int width, int height ) = 0;
|
||||
virtual void onMouseDown( const WindowVector& position, ButtonIdentifier button, ModifierFlags modifiers ) = 0;
|
||||
virtual void onMouseUp( const WindowVector& position, ButtonIdentifier button, ModifierFlags modifiers ) = 0;
|
||||
virtual void onMouseMotion( const WindowVector& position, ModifierFlags modifiers ) = 0;
|
||||
virtual void onModifierDown( ModifierFlags modifier ) = 0;
|
||||
virtual void onModifierUp( ModifierFlags modifier ) = 0;
|
||||
virtual void release() = 0;
|
||||
virtual void onSizeChanged( int width, int height ) = 0;
|
||||
virtual void onMouseDown( const WindowVector& position, ButtonIdentifier button, ModifierFlags modifiers ) = 0;
|
||||
virtual void onMouseUp( const WindowVector& position, ButtonIdentifier button, ModifierFlags modifiers ) = 0;
|
||||
virtual void onMouseMotion( const WindowVector& position, ModifierFlags modifiers ) = 0;
|
||||
virtual void onModifierDown( ModifierFlags modifier ) = 0;
|
||||
virtual void onModifierUp( ModifierFlags modifier ) = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user