Commit bb0f5f2e authored by Jan Möbius's avatar Jan Möbius
Browse files

Added TypeSphere Plugin

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@9069 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 3c4274c1
......@@ -53,6 +53,38 @@
INIPlugin::INIPlugin() {
}
template <>
void INIPlugin::parseIniFileT(INIFile& _ini, LightObject* _object) {
if ( _object ) {
std::vector< QString > draw_modes;
if( _ini.get_entry(draw_modes, _object->name(), "MaterialDrawMode") )
_object->materialNode()->drawMode( listToDrawMode(draw_modes) );
bool visible;
if ( _ini.get_entry( visible, _object->name() , "Visible" ) ) {
_object->visible(visible);
std::cerr << "visible" << std::endl;
}
}
}
template <>
void INIPlugin::saveIniFileT(INIFile& _ini, LightObject* _object) {
if ( _object ) {
_ini.add_entry( _object->name() ,
"MaterialDrawMode" ,
drawModeToList( _object->materialNode()->drawMode()) );
_ini.add_entry( _object->name() ,
"Visible" ,
_object->visible() );
}
}
void INIPlugin::loadIniFile( INIFile& _ini, int _id ) {
BaseObjectData* baseObject;
......@@ -62,7 +94,8 @@ void INIPlugin::loadIniFile( INIFile& _ini, int _id ) {
}
PolyMeshObject* polyObject(0);
TriMeshObject* triObject(0);
TriMeshObject* triObject(0);
LightObject* lightObject(0);
if(baseObject->dataType() == DATA_POLY_MESH) {
polyObject = PluginFunctions::polyMeshObject(baseObject);
......@@ -71,7 +104,8 @@ void INIPlugin::loadIniFile( INIFile& _ini, int _id ) {
triObject = PluginFunctions::triMeshObject(baseObject);
parseIniFileT(_ini, triObject);
} else if ( baseObject->dataType() == DATA_LIGHT ) {
// No special Information needed yet
lightObject = PluginFunctions::lightObject(baseObject);
parseIniFileT(_ini, lightObject);
} else {
// Unhandled data type
emit log(LOGERR, tr("The specified data type is not supported, yet. Aborting!"));
......@@ -87,7 +121,8 @@ void INIPlugin::saveIniFile( INIFile& _ini, int _id) {
}
PolyMeshObject* polyObject(0);
TriMeshObject* triObject(0);
TriMeshObject* triObject(0);
LightObject* lightObject(0);
if(baseObject->dataType() == DATA_POLY_MESH) {
polyObject = PluginFunctions::polyMeshObject(baseObject);
......@@ -95,10 +130,15 @@ void INIPlugin::saveIniFile( INIFile& _ini, int _id) {
} else if ( baseObject->dataType() == DATA_TRIANGLE_MESH) {
triObject = PluginFunctions::triMeshObject(baseObject);
saveIniFileT(_ini, triObject);
} else if ( baseObject->dataType() == DATA_LIGHT ) {
lightObject = PluginFunctions::lightObject(baseObject);
saveIniFileT(_ini, lightObject);
} else {
// Unhandled data type
emit log(LOGERR, tr("The specified data type is not supported, yet. Aborting!"));
// Unhandled data type
emit log(LOGERR, tr("The specified data type is not supported, yet. Aborting!"));
}
}
Q_EXPORT_PLUGIN2( iniplugin , INIPlugin );
\ No newline at end of file
......@@ -83,12 +83,12 @@ class INIPlugin : public QObject, BaseInterface, LoggingInterface, ScriptInterfa
private:
// Template function to parse ini file entries
template <class MeshObject>
void parseIniFileT(INIFile& _ini, MeshObject* _object);
template <class Object>
void parseIniFileT(INIFile& _ini, Object* _object);
// Template function to save ini file entries
template <class MeshObject>
void saveIniFileT(INIFile& _ini, MeshObject* _object);
template <class Object>
void saveIniFileT(INIFile& _ini, Object* _object);
};
//=============================================================================
......
#include "iniPlugin.hh"
#include <OpenFlipper/BasePlugin/PluginFunctions.hh>
#include <OpenFlipper/ACGHelper/DrawModeConverter.hh>
#include <ObjectTypes/MeshObject/MeshObjectT.hh>
#include <OpenFlipper/common/BaseObjectData.hh>
template <class MeshObject>
void INIPlugin::parseIniFileT(INIFile& _ini, MeshObject* _object) {
......@@ -37,6 +40,11 @@ void INIPlugin::parseIniFileT(INIFile& _ini, MeshObject* _object) {
_object->materialNode()->set_reflectance(reflectance);
}
bool visible;
if ( _ini.get_entry( visible, _object->name() , "Visible" ) ) {
_object->visible(visible);
}
int size = 1;
if ( _ini.get_entry( size, _object->name() , "PointSize" ) )
_object->materialNode()->set_point_size(size);
......@@ -72,7 +80,10 @@ void INIPlugin::saveIniFileT(INIFile& _ini, MeshObject* _object) {
_object->materialNode()->shininess());
_ini.add_entry( _object->name() ,
"Reflectance" ,
_object->materialNode()->reflectance());
_object->materialNode()->reflectance());
_ini.add_entry( _object->name() ,
"Visible" ,
_object->visible() );
_ini.add_entry( _object->name() ,
"PointSize" ,
_object->materialNode()->point_size());
......@@ -81,3 +92,4 @@ void INIPlugin::saveIniFileT(INIFile& _ini, MeshObject* _object) {
_object->materialNode()->line_width());
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment