diff --git a/common/BaseObjectData.cc b/common/BaseObjectData.cc
index b4b59e999e643165d8437847e665ffb4dd9a09fc..c7f35c8c3b7b562f9ad8eec2a1a56713f96d6cb3 100644
--- a/common/BaseObjectData.cc
+++ b/common/BaseObjectData.cc
@@ -12,12 +12,12 @@
// 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.
-//
+//
// 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 Lesser General Public License
// along with OpenFlipper. If not, see .
//
@@ -50,11 +50,11 @@
//== TYPEDEFS =================================================================
//== CLASS DEFINITION =========================================================
-
+
BaseObjectData::BaseObjectData( SeparatorNode* _rootNode ) :
BaseObject(),
path_("."),
- rootNode_(_rootNode),
+ rootNode_(_rootNode),
separatorNode_(0),
manipulatorNode_(0),
materialNode_(0)
@@ -66,12 +66,12 @@ BaseObjectData::~BaseObjectData() {
if ( separatorNode_ != 0 ) {
separatorNode_->delete_subtree();
}
-
+
}
void BaseObjectData::cleanup() {
path_ = ".";
-
+
// Delete everything below the seperator node on top of the object. This will remove the complete subtree.
if ( separatorNode_ == 0 )
std::cerr << "cleanup : separatorNode_ is already 0" << std::endl;
@@ -80,12 +80,12 @@ void BaseObjectData::cleanup() {
separatorNode_ = 0;
manipulatorNode_ = 0;
materialNode_ = 0;
-
+
additionalNodes_.clear();
}
-
+
BaseObject::cleanup();
-
+
BaseObjectData::init();
}
@@ -93,14 +93,14 @@ void BaseObjectData::init() {
// Create seperatorNode for Object only if it does not exist.
if ( separatorNode_ == 0 )
separatorNode_ = new SeparatorNode((BaseNode*)rootNode_,"NEW Object");
- else
+ else
std::cerr << "Separator Node already exists. this should not happen!" << std::endl;
-
+
if ( manipulatorNode_ == 0 ) {
manipulatorNode_ = new ManipulatorNode(baseNode(),"NEW ManipulatorNode");
manipulatorNode_->set_status( ACG::SceneGraph::ManipulatorNode::HideNode );
}
- else
+ else
std::cerr << "Manipulator Node already exists. this should not happen!" << std::endl;
if ( materialNode_ == 0 )
materialNode_ = new MaterialNode(manipulatorNode(), "New Material");
@@ -119,13 +119,13 @@ void BaseObjectData::setFromFileName(QString _filename ) {
void BaseObjectData::setName( QString _name ) {
BaseObject::setName( _name );
-
+
std::string nodename = std::string("SeparatorNode for object " + _name.toUtf8());
separatorNode_->name( nodename );
-
+
nodename = std::string("ManipulatorNode for object " + _name.toUtf8());
manipulatorNode_->name( nodename );
-
+
nodename = std::string(_name.toUtf8() + "'s Material" );
materialNode_->name( nodename );
}
@@ -136,7 +136,7 @@ QString BaseObjectData::path(){
}
void BaseObjectData::path(QString _path ) {
- path_ = _path;
+ path_ = _path;
}
// ===============================================================================
@@ -144,29 +144,33 @@ void BaseObjectData::path(QString _path ) {
// ===============================================================================
void BaseObjectData::show() {
- separatorNode_->set_status( ACG::SceneGraph::BaseNode::Active );
+ separatorNode_->set_status( ACG::SceneGraph::BaseNode::Active );
visible_ = true;
}
void BaseObjectData::hide() {
- separatorNode_->set_status( ACG::SceneGraph::BaseNode::HideSubtree );
+ separatorNode_->set_status( ACG::SceneGraph::BaseNode::HideSubtree );
visible_ = false;
}
SeparatorNode* BaseObjectData::baseNode() {
- return separatorNode_;
+ return separatorNode_;
}
ManipulatorNode* BaseObjectData::manipulatorNode() {
- return manipulatorNode_;
+ return manipulatorNode_;
+}
+
+ACG::SceneGraph::ShaderNode* BaseObjectData::shaderNode() {
+ return 0;
}
MaterialNode* BaseObjectData::materialNode() {
- return materialNode_;
+ return materialNode_;
}
void BaseObjectData::setBaseColor(ACG::Vec4f _color) {
- materialNode_->set_base_color(_color);
+ materialNode_->set_base_color(_color);
}
bool BaseObjectData::manipPlaced() {
@@ -188,11 +192,11 @@ void BaseObjectData::getBoundingBox(ACG::Vec3d& bbmin, ACG::Vec3d& bbmax){
}
// ===============================================================================
-// Picking
+// Picking
// ===============================================================================
bool BaseObjectData::picked( uint /* _node_idx */ ) {
- return false;
+ return false;
}
void BaseObjectData::enablePicking( bool /*_enable*/ ) {
@@ -219,14 +223,14 @@ bool BaseObjectData::hasAdditionalNode(QString _pluginName, QString _nodeName ,
QString index;
index.setNum(_id);
QString searchname = _pluginName+"#"+_nodeName+"#"+index;
-
+
for ( uint i =0 ; i < additionalNodes_.size() ; ++i ) {
if (additionalNodes_[i].second == searchname )
return true;
}
-
+
return false;
}
-
+
//=============================================================================
diff --git a/common/BaseObjectData.hh b/common/BaseObjectData.hh
index dbd9608874d3df5099e977de7af8ce2e80288cbe..e79de2f753b35eb0d59bebbc60410e7ddb34a763 100644
--- a/common/BaseObjectData.hh
+++ b/common/BaseObjectData.hh
@@ -12,12 +12,12 @@
// 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.
-//
+//
// 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 Lesser General Public License
// along with OpenFlipper. If not, see .
//
@@ -39,7 +39,7 @@
//=============================================================================
/**
- * \file BaseObjectData.hh
+ * \file BaseObjectData.hh
* This File contains the Basic object class for all Objects which show content vi
* the Scenegraph.
*/
@@ -48,7 +48,7 @@
#ifndef BASEOBJECTDATA_HH
#define BASEOBJECTDATA_HH
-
+
#ifdef WIN32
#define DLLEXPORT __declspec(dllexport)
#else
@@ -61,6 +61,7 @@
#include
#include
#include
+#include
#include
#include
@@ -89,121 +90,128 @@ class DLLEXPORT BaseObjectData : public BaseObject
///destructor
virtual ~BaseObjectData();
-
+
protected:
/** This function creates the scenegraph nodes */
virtual void init();
-
- /** @} */
-
+
+ /** @} */
+
//===========================================================================
/** @name Data
* @{ */
- //===========================================================================
-
- public:
+ //===========================================================================
+
+ public:
/** Clean all data structures of the object
- *
+ *
* */
virtual void cleanup();
-
- /** @} */
-
+
+ /** @} */
+
//===========================================================================
/** @name Name and Path handling
* @{ */
- //===========================================================================
-
- public:
-
+ //===========================================================================
+
+ public:
+
/** Set the object name from a filename. The function will set the name of the
* object to the filename. At the same time the path is set to the one given in
* the parameter
- *
+ *
* @param _filename path to the file.
*/
void setFromFileName(QString _filename );
-
+
/// set the name of the object. ( If you overwrite it, call BaseObjectData::setName(_name ) it in your funtion first)
virtual void setName( QString _name );
-
+
/// return the path to the object ( defaults to "." if unset )
QString path();
-
+
/// set the path to the object.
void path(QString _path);
-
+
private:
-
+
/// path to the file from which the object is loaded ( defaults to "." )
QString path_;
-
- /** @} */
-
-
-
+
+ /** @} */
+
+
+
//===========================================================================
/** @name Object visualization
* @{ */
- //===========================================================================
-
+ //===========================================================================
+
public :
/// Sets the whole Scenegraph subtree of this node to visible
void show();
-
+
/// Sets the whole Scenegraph subtree of this node to invisible
void hide();
-
+
/** get the base node of this object (Use this node to add custom Nodes to the Object
* which should not be transformed with the manipulator of the Object)
*/
SeparatorNode* baseNode();
-
+
/** get the ManipulatorNode node of this object (Use this node to add custom Nodes to the Object
* which should be transformed with the manipulator of the Object)
*/
ManipulatorNode* manipulatorNode();
-
+
+ /** Return pointer to the shader node
+ * If you want to support shaders, you have to add a shader node into your scenegraph structure
+ * above your object to be rendered. If you do not have a shader, just ignore this function
+ * and it will return a 0 pointer.
+ */
+ virtual ACG::SceneGraph::ShaderNode* shaderNode();
+
/// get a pointer to the materialnode
MaterialNode* materialNode();
-
+
/// Set the color of the object
void setBaseColor(ACG::Vec4f _color);
-
+
/// Check if the manipulator has been placed
bool manipPlaced();
-
+
/// set the manipulator place status
void manipPlaced( bool _placed );
/// get the bounding box of the object
void getBoundingBox(ACG::Vec3d& bbmin, ACG::Vec3d& bbmax);
-
+
private :
-
+
bool manipPlaced_;
-
+
/// rootNode of global Scenegraph structure
SeparatorNode* rootNode_;
-
+
/// Separator at top of Scenegraph structure used for this Object
SeparatorNode* separatorNode_;
-
- /// Manipulator used for this Object
+
+ /// Manipulator used for this Object
ManipulatorNode* manipulatorNode_;
-
+
/// Scenegraph Material Node for the object
MaterialNode* materialNode_;
-
- /** @} */
-
-
+
+ /** @} */
+
+
//===========================================================================
/** @name Picking
* @{ */
- //===========================================================================
-
+ //===========================================================================
+
public :
/// detect if the node has been picked
virtual bool picked( uint _node_idx );
@@ -219,87 +227,87 @@ class DLLEXPORT BaseObjectData : public BaseObject
* this function.
*/
virtual bool pickingEnabled();
-
- /** @} */
-
+
+ /** @} */
+
//===========================================================================
/** @name Content
* @{ */
//===========================================================================
-
+
public:
/// This function is called to update the object
virtual void update();
-
- /** @} */
-
+
+ /** @} */
+
//===========================================================================
/** @name Additional nodes
* @{ */
- //===========================================================================
+ //===========================================================================
public:
/** \brief add an additional node to the object
- *
- * This function can be used to store an additional Scenegraph node. If you add nodes there, you do not
+ *
+ * This function can be used to store an additional Scenegraph node. If you add nodes there, you do not
* need to keep track of deleted, added objects, as this will be done in the main application.
* You have to create the node yourself as this function does not know the type. You should add the
- * new node below the manipulatorNode if you want that it moves with the rest of the data. Otherwise
+ * new node below the manipulatorNode if you want that it moves with the rest of the data. Otherwise
* add it below the seperatorNode of the object.
- *
+ *
* @param _node Node to add
* @param _pluginName Name of the current plugin
- * @param _nodeName Name of the New Node
+ * @param _nodeName Name of the New Node
* @param _id extra index, if there will be multiple nodes with this name( defaults to 0)
* @return true if successfull
*/
- template< typename NodeT >
+ template< typename NodeT >
bool addAdditionalNode(NodeT* _node , QString _pluginName, QString _nodeName , int _id = 0);
-
+
/** \brief check if an object has the additional node
- *
+ *
* If you store additional Scenegraph nodes with the objects you can check if they
* exist with this function.
- *
+ *
* @param _pluginName Name of the current plugin
- * @param _nodeName Name of the Node
+ * @param _nodeName Name of the Node
* @param _id extra index, if there are multiple nodes with this name( defaults to 0)
* @return true if found
*/
- bool hasAdditionalNode(QString _pluginName, QString _nodeName , int _id = 0);
-
+ bool hasAdditionalNode(QString _pluginName, QString _nodeName , int _id = 0);
+
/** \brief get an addition node from the object
- *
+ *
* If you store additional Scenegraph node with the objects you can get these nodes with this function.
- *
+ *
* @param _node Returns the node
* @param _pluginName Name of the current plugin
- * @param _nodeName Name of the Node
+ * @param _nodeName Name of the Node
* @param _id extra index, if there are multiple nodes with this name ( defaults to 0)
* @return true if found
*/
- template< typename NodeT >
+ template< typename NodeT >
bool getAdditionalNode(NodeT*& _node , QString _pluginName, QString _nodeName , int _id = 0 );
/** \brief remove an additional node from the object
- *
+ *
* If additional nodes are stored for this object, such a node can be removed using this function
- *
+ *
* @param _node Needed for type specification
* @param _pluginName Name of the current plugin
- * @param _nodeName Name of the Node
+ * @param _nodeName Name of the Node
* @param _id extra index, if there are multiple nodes with this name ( defaults to 0)
* @return true if found and removed
*/
- template< typename NodeT >
+ template< typename NodeT >
bool removeAdditionalNode(NodeT*& _node, QString _pluginName, QString _nodeName , int _id = 0 );
private:
/** This pointer may be used to store additional Nodes belonging to this Object
* The String should be used by the plugin to identify its Nodes
*/
std::vector< std::pair > additionalNodes_;
-
- /** @} */
-
+
+ /** @} */
+
};