Commit 19061d0d authored by Jan Möbius's avatar Jan Möbius

Added SkyDome to staging



git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free-Staging@16390 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 3c6703d1
/*===========================================================================*\
* *
* OpenFlipper *
* Copyright (C) 2001-2011 by Computer Graphics Group, RWTH Aachen *
* www.openflipper.org *
* *
*--------------------------------------------------------------------------- *
* This file is part of OpenFlipper. *
* *
* OpenFlipper is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 3 of *
* the License, or (at your option) any later version with the *
* following exceptions: *
* *
* If other files instantiate templates or use macros *
* or inline functions from this file, or you compile this file and *
* link it with other files to produce an executable, this file does *
* not by itself cause the resulting executable to be covered by the *
* GNU Lesser General Public License. This exception does not however *
* invalidate any other reasons why the executable file might be *
* covered by the GNU Lesser General Public License. *
* *
* OpenFlipper is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU LesserGeneral Public *
* License along with OpenFlipper. If not, *
* see <http://www.gnu.org/licenses/>. *
* *
\*===========================================================================*/
/*===========================================================================*\
* *
* $Revision: 15085 $ *
* $LastChangedBy: moebius $ *
* $Date: 2012-07-25 08:57:39 +0200 (Mi, 25 Jul 2012) $ *
* *
\*===========================================================================*/
//=============================================================================
//
// Plugin Functions for SkyDomes
//
//=============================================================================
#include <OpenFlipper/common/Types.hh>
#include "SkyDomeObject.hh"
#include "PluginFunctionsSkyDome.hh"
#include <OpenFlipper/BasePlugin/PluginFunctions.hh>
#include "SkyDome.hh"
namespace PluginFunctions {
// ===============================================================================
// Get objects
// ===============================================================================
bool getObject( int _identifier , SkyDomeObject*& _object ) {
if ( _identifier == -1 ) {
_object = 0;
return false;
}
// Get object by using the map accelerated plugin function
BaseObjectData* object = 0;
PluginFunctions::getObject(_identifier,object);
_object = dynamic_cast< SkyDomeObject* >(object);
return ( _object != 0 );
}
SkyDomeObject* skyDomeObject( int _objectId ) {
if ( _objectId == -1 ) {
return 0;
}
// Get object by using the map accelerated plugin function
BaseObjectData* object = 0;
PluginFunctions::getObject(_objectId,object);
SkyDomeObject* skyDomeObject = dynamic_cast< SkyDomeObject* >(object);
return skyDomeObject;
}
// ===============================================================================
// Getting data from objects and casting between them
// ===============================================================================
SkyDomeNode* skyDomeNode( BaseObjectData* _object ) {
if ( _object->dataType(DATA_SKYDOME) ) {
SkyDomeObject* object = dynamic_cast< SkyDomeObject* >(_object);
return object->skyDomeNode();
} else
return 0;
}
SkyDomeObject* skyDomeObject( BaseObjectData* _object ) {
if ( ! _object->dataType(DATA_SKYDOME) )
return 0;
return dynamic_cast< SkyDomeObject* >( _object );
}
}
/*===========================================================================*\
* *
* OpenFlipper *
* Copyright (C) 2001-2011 by Computer Graphics Group, RWTH Aachen *
* www.openflipper.org *
* *
*--------------------------------------------------------------------------- *
* This file is part of OpenFlipper. *
* *
* OpenFlipper is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 3 of *
* the License, or (at your option) any later version with the *
* following exceptions: *
* *
* If other files instantiate templates or use macros *
* or inline functions from this file, or you compile this file and *
* link it with other files to produce an executable, this file does *
* not by itself cause the resulting executable to be covered by the *
* GNU Lesser General Public License. This exception does not however *
* invalidate any other reasons why the executable file might be *
* covered by the GNU Lesser General Public License. *
* *
* OpenFlipper is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU LesserGeneral Public *
* License along with OpenFlipper. If not, *
* see <http://www.gnu.org/licenses/>. *
* *
\*===========================================================================*/
/*===========================================================================*\
* *
* $Revision: 13743 $ *
* $LastChangedBy: moebius $ *
* $Date: 2012-02-10 08:41:26 +0100 (Fr, 10 Feb 2012) $ *
* *
\*===========================================================================*/
//=============================================================================
//
// Standard Functions
//
//=============================================================================
/**
* \file PluginFunctionsSkyDome.hh
* This file contains functions which can be used by plugins to access SkyDomes in the framework.
*/
#pragma once
#include <ObjectTypes/SkyDome/SkyDomeObject.hh>
#include <OpenFlipper/common/Types.hh>
/** The Namespace PluginFunctions contains functions for all plugins. */
namespace PluginFunctions {
/** This functions returns the object with the given id if it is a SkyDomeObject.
* See get_object( int _identifier , BaseObject*& _object ) for more details.
*/
DLLEXPORT
bool getObject( int _identifier , SkyDomeObject*& _object );
/** \brief Get a SkyDomeNode from an object.
*
* @param _object The object should be of type BaseDataObject. If the content is a SkyDome, a
* SkyDomeNode will be returned. Otherwise a NULL pointer is returned.
*/
DLLEXPORT
SkyDomeNode* skyDomeNode( BaseObjectData* _object );
/** \brief Cast an BaseObject to a SkyDomeObject if possible
*
* @param _object The object should be of type BaseDataObject. If the content is a SkyDome, a
* a SkyDomeObject is returned. Otherwise a NULL pointer is returned.
*/
DLLEXPORT
SkyDomeObject* skyDomeObject( BaseObjectData* _object );
/** \brief Get a SkyDomeObject from id if possible
*
* @param _objectId If the content is a SkyDome, a SkyDomeObject is returned. Otherwise a NULL pointer is returned.
*/
DLLEXPORT
SkyDomeObject* skyDomeObject( int _objectId );
}
/*===========================================================================*\
* *
* OpenFlipper *
* Copyright (C) 2001-2011 by Computer Graphics Group, RWTH Aachen *
* www.openflipper.org *
* *
*--------------------------------------------------------------------------- *
* This file is part of OpenFlipper. *
* *
* OpenFlipper is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 3 of *
* the License, or (at your option) any later version with the *
* following exceptions: *
* *
* If other files instantiate templates or use macros *
* or inline functions from this file, or you compile this file and *
* link it with other files to produce an executable, this file does *
* not by itself cause the resulting executable to be covered by the *
* GNU Lesser General Public License. This exception does not however *
* invalidate any other reasons why the executable file might be *
* covered by the GNU Lesser General Public License. *
* *
* OpenFlipper is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU LesserGeneral Public *
* License along with OpenFlipper. If not, *
* see <http://www.gnu.org/licenses/>. *
* *
\*===========================================================================*/
/*===========================================================================*\
* *
* $Revision: 13620 $ *
* $LastChangedBy: moebius $ *
* $Date: 2012-02-01 14:51:25 +0100 (Mi, 01 Feb 2012) $ *
* *
\*===========================================================================*/
/**
* \file SkyDome.h
* This File contains all required includes for using SkyDome
*/
#pragma once
//== INCLUDES =================================================================
/** \def DATA_SkyDome
* Use this macro to reference Sky Domes
*/
#define DATA_SKYDOME typeId("SkyDome")
#include <ObjectTypes/SkyDome/SkyDomeType.hh>
#include <ObjectTypes/SkyDome/SkyDomeObject.hh>
#include <ObjectTypes/SkyDome/PluginFunctionsSkyDome.hh>
//=============================================================================
This diff is collapsed.
/*===========================================================================*\
* *
* OpenFlipper *
* Copyright (C) 2001-2011 by Computer Graphics Group, RWTH Aachen *
* www.openflipper.org *
* *
*--------------------------------------------------------------------------- *
* This file is part of OpenFlipper. *
* *
* OpenFlipper is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 3 of *
* the License, or (at your option) any later version with the *
* following exceptions: *
* *
* If other files instantiate templates or use macros *
* or inline functions from this file, or you compile this file and *
* link it with other files to produce an executable, this file does *
* not by itself cause the resulting executable to be covered by the *
* GNU Lesser General Public License. This exception does not however *
* invalidate any other reasons why the executable file might be *
* covered by the GNU Lesser General Public License. *
* *
* OpenFlipper is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU LesserGeneral Public *
* License along with OpenFlipper. If not, *
* see <http://www.gnu.org/licenses/>. *
* *
\*===========================================================================*/
/*===========================================================================*\
* *
* $Revision: 10745 $ *
* $LastChangedBy: moebius $ *
* $Date: 2011-01-26 10:23:50 +0100 (Mi, 26 Jan 2011) $ *
* *
\*===========================================================================*/
#ifndef SKYDOME_NODE_HH
#define SKYDOME_NODE_HH
//== INCLUDES =================================================================
#include <ObjectTypes/SkyDome/SkyDomeType.hh>
#include <ACG/Scenegraph/BaseNode.hh>
#include <ACG/Scenegraph/DrawModes.hh>
#include <OpenFlipper/common/GlobalDefines.hh>
#include <ACG/GL/VertexDeclaration.hh>
#include <ACG/GL/IRenderer.hh>
#include <ACG/GL/GLPrimitives.hh>
#include <ObjectTypes/SkyDome/SkyDomeType.hh>
//== NAMESPACES ===============================================================
//== CLASS DEFINITION =========================================================
class DLLEXPORT SkyDomeNode : public ACG::SceneGraph::BaseNode
{
public:
/** \brief Construct a SkyDome rendering node
*
* @param _parent The parent node in the scenegraph
* @param _name The name of the new node (visible in the scenegraph dialogs)
* @param _dome A pointer to an existing SkyDome object
*/
SkyDomeNode(SkyDome& _dome, BaseNode *_parent = 0, std::string _name = "<PlaneNode>");
/// destructor
~SkyDomeNode();
/// static name of this class
ACG_CLASSNAME(SkyDomeNode);
/// return available draw modes
ACG::SceneGraph::DrawModes::DrawMode availableDrawModes() const;
/// update bounding box
void boundingBox(ACG::Vec3d & _bbMin, ACG::Vec3d & _bbMax);
/// draw SkyDome
void draw(ACG::GLState & _state, const ACG::SceneGraph::DrawModes::DrawMode & _drawMode);
/// draw SkyDome for object picking
void pick(ACG::GLState & _state, ACG::SceneGraph::PickTarget _target);
/// Get the currently rendered plane
SkyDome& getSkyDome();
/// Set a new plane for rendering
void setSkyDome(SkyDome _dome);
/** \brief Add the objects to the given renderer
*
* @param _renderer The renderer which will be used. Add your geometry into this class
* @param _state The current GL State when this object is called
* @param _drawMode The active draw mode
* @param _mat Current material
*/
void getRenderObjects(ACG::IRenderer* _renderer, ACG::GLState& _state , const ACG::SceneGraph::DrawModes::DrawMode& _drawMode , const ACG::SceneGraph::Material* _mat);
private:
void drawSkyDome(ACG::GLState & _state);
void drawSkyDomePick(ACG::GLState & _state);
SkyDome& dome_;
/// VBO used to render the dome
unsigned int vbo_;
ACG::VertexDeclaration vertexDecl_;
};
#endif // SKYDOME_NODE_HH
/*===========================================================================*\
* *
* OpenFlipper *
* Copyright (C) 2001-2011 by Computer Graphics Group, RWTH Aachen *
* www.openflipper.org *
* *
*--------------------------------------------------------------------------- *
* This file is part of OpenFlipper. *
* *
* OpenFlipper is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 3 of *
* the License, or (at your option) any later version with the *
* following exceptions: *
* *
* If other files instantiate templates or use macros *
* or inline functions from this file, or you compile this file and *
* link it with other files to produce an executable, this file does *
* not by itself cause the resulting executable to be covered by the *
* GNU Lesser General Public License. This exception does not however *
* invalidate any other reasons why the executable file might be *
* covered by the GNU Lesser General Public License. *
* *
* OpenFlipper is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU LesserGeneral Public *
* License along with OpenFlipper. If not, *
* see <http://www.gnu.org/licenses/>. *
* *
\*===========================================================================*/
/*===========================================================================*\
* *
* $Revision: 10745 $ *
* $LastChangedBy: moebius $ *
* $Date: 2011-01-26 10:23:50 +0100 (Mi, 26. Jan 2011) $ *
* *
\*===========================================================================*/
//=============================================================================
//
// SkyDome Object
//
//=============================================================================
//== INCLUDES =================================================================
#include <OpenFlipper/common/Types.hh>
#include "SkyDomeObject.hh"
#include "SkyDome.hh"
//== DEFINES ==================================================================
//== TYPEDEFS =================================================================
//== CLASS DEFINITION =========================================================
/** Constructor for SkyDome Objects. This object class gets a Separator Node giving
* the root node to which it should be connected. The plane is generated internally
* and all nodes for visualization will be added below the scenegraph node.\n
* You don't need to create an object of this type manually. Use
* PluginFunctions::addSkyDome instead. ( see Types.hh::DataType )
*/
SkyDomeObject::SkyDomeObject( ) :
BaseObjectData( ),
skyDomeNode_(NULL)
{
setDataType(DATA_SKYDOME);
init();
}
//=============================================================================
/**
* Copy Constructor - generates a copy of the given object
*/
SkyDomeObject::SkyDomeObject(SkyDomeObject & _object) :
BaseObjectData(_object)
{
init( &_object.skyDome_ );
setName( name() );
}
/** Destructor for SkyDome Objects. The destructor deletes the Line and all
* Scenegraph nodes associated with the SkyDome or the object.
*/
SkyDomeObject::~SkyDomeObject()
{
// Delete the data attached to this object ( this will remove all perObject data)
// Not the best way to do it but it will work.
// This is only necessary if people use references to the plane below and
// they do something with the plane in the destructor of their
// perObjectData.
deleteData();
// No need to delete the scenegraph Nodes as this will be managed by base plugin
skyDomeNode_ = NULL;
}
/** Cleanup Function for SkyDome Objects. Deletes the contents of the whole object and
* calls SkyDomeObject::init afterwards.
*/
void SkyDomeObject::cleanup() {
BaseObjectData::cleanup();
skyDomeNode_ = NULL;
setDataType(DATA_SKYDOME);
init();
}
/**
* Generate a copy
*/
BaseObject* SkyDomeObject::copy() {
SkyDomeObject* object = new SkyDomeObject(*this);
return dynamic_cast< BaseObject* >(object);
}
/** This function initializes the plane object. It creates the scenegraph nodes.
*/
void SkyDomeObject::init( SkyDome* _skyDome) {
if ( materialNode() == NULL)
std::cerr << "Error when creating SkyDome Object! materialNode is NULL!" << std::endl;
skyDomeNode_ = new SkyDomeNode( skyDome_, materialNode() , "NEW SkyDomeNode" );
if (_skyDome){
skyDome_ = *_skyDome;
} else {
// Leave at default values
}
}
// ===============================================================================
// Name/Path Handling
// ===============================================================================
/** Set the name of an object. All Scenegraph nodes are renamed too. It also calls
* BaseObjectData::setName.
*/
void SkyDomeObject::setName( QString _name ) {
BaseObjectData::setName(_name);
std::string nodename = std::string("SkyDomeNode for SkyDome " + _name.toUtf8() );
skyDomeNode_->name( nodename );
}
// ===============================================================================
// Visualization
// ===============================================================================
SkyDomeNode* SkyDomeObject::skyDomeNode() {
return skyDomeNode_;
}
// ===============================================================================
// Object information
// ===============================================================================
/** Returns a string containing all information about the current object. This also
* includes the information provided by BaseObjectData::getObjectinfo
*
* @return String containing the object information
*/
QString SkyDomeObject::getObjectinfo() {
QString output;
output += "========================================================================\n";
output += BaseObjectData::getObjectinfo();
if ( dataType( DATA_SKYDOME ) )
output += "Object Contains SkyDome : ";
output += " Horizontal FOV: ( " + QString::number(skyDome_.horizontalFOV()) + ")";
output += "========================================================================\n";
return output;
}
SkyDome& SkyDomeObject::getSkyDome() {
return skyDome_;
}
// ===============================================================================
// Picking
// ===============================================================================
/** Given an node index from PluginFunctions::scenegraphPick this function can be used to
* check if the planeNode of the object has been picked.
*
* @param _node_idx Index of the picked plane node
* @return if the planeNode of this object is the picking target.
*/
bool SkyDomeObject::picked( uint _node_idx ) {
return ( _node_idx == skyDomeNode_->id() );
}
//
//void SkyDomeObject::enablePicking( bool _enable ) {
// SkyDomeNode_->enablePicking( _enable );
//}
//
//bool SkyDomeObject::pickingEnabled() {
// return SkyDomeNode_->pickingEnabled();
//}
//=============================================================================
/*===========================================================================*\
* *
* OpenFlipper *
* Copyright (C) 2001-2011 by Computer Graphics Group, RWTH Aachen *
* www.openflipper.org *
* *
*--------------------------------------------------------------------------- *
* This file is part of OpenFlipper. *
* *
* OpenFlipper is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 3 of *
* the License, or (at your option) any later version with the *
* following exceptions: *
* *
* If other files instantiate templates or use macros *
* or inline functions from this file, or you compile this file and *
* link it with other files to produce an executable, this file does *
* not by itself cause the resulting executable to be covered by the *
* GNU Lesser General Public License. This exception does not however *
* invalidate any other reasons why the executable file might be *