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

Write all things from materialnode in baseobjectdata

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@9071 383ad7c9-94d9-4d36-a494-682f7c89f535
parent bb0f5f2e
......@@ -46,6 +46,7 @@
#include <OpenFlipper/common/Types.hh>
#include <ObjectTypes/PolyMesh/PolyMesh.hh>
#include <ObjectTypes/Light/Light.hh>
#include <ObjectTypes/Sphere/Sphere.hh>
#include <ObjectTypes/TriangleMesh/TriangleMesh.hh>
#include <OpenFlipper/BasePlugin/PluginFunctions.hh>
......@@ -58,15 +59,11 @@ 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;
}
}
}
......@@ -75,16 +72,95 @@ 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() );
drawModeToList( _object->materialNode()->drawMode()) );
}
}
void INIPlugin::parseIniFile(INIFile& _ini, BaseObjectData* _object) {
if ( _object ) {
std::vector< QString > draw_modes;
if( _ini.get_entry(draw_modes, _object->name(), "MaterialDrawMode") )
_object->materialNode()->drawMode( listToDrawMode(draw_modes) );
ACG::Vec4f col(0.0,0.0,0.0,0.0);
if ( _ini.get_entryVecf( col, _object->name() , "BaseColor" ) )
_object->materialNode()->set_base_color(col);
if ( _ini.get_entryVecf( col, _object->name() , "AmbientColor" ) )
_object->materialNode()->set_ambient_color(col);
if ( _ini.get_entryVecf( col, _object->name() , "DiffuseColor" ) )
_object->materialNode()->set_diffuse_color(col);
if ( _ini.get_entryVecf( col, _object->name() , "SpecularColor" ) )
_object->materialNode()->set_specular_color(col);
double shininess;
if ( _ini.get_entry( shininess, _object->name() , "Shininess" ) )
_object->materialNode()->set_shininess(shininess);
double reflectance;
if ( _ini.get_entry( reflectance, _object->name() , "Reflectance" ) ) {
_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);
if ( _ini.get_entry( size, _object->name() , "LineWidth" ) )
_object->materialNode()->set_line_width(size);
}
}
void INIPlugin::saveIniFile(INIFile& _ini, BaseObjectData* _object) {
if ( _object ) {
_ini.add_entry( _object->name() ,
"MaterialDrawMode" ,
drawModeToList( _object->materialNode()->drawMode()) );
_ini.add_entryVec( _object->name() ,
"BaseColor" ,
_object->materialNode()->base_color()) ;
_ini.add_entryVec( _object->name() ,
"AmbientColor" ,
_object->materialNode()->ambient_color()) ;
_ini.add_entryVec( _object->name() ,
"DiffuseColor" ,
_object->materialNode()->diffuse_color());
_ini.add_entryVec( _object->name() ,
"SpecularColor" ,
_object->materialNode()->specular_color());
_ini.add_entry( _object->name() ,
"Shininess" ,
_object->materialNode()->shininess());
_ini.add_entry( _object->name() ,
"Reflectance" ,
_object->materialNode()->reflectance());
_ini.add_entry( _object->name() ,
"Visible" ,
_object->visible() );
_ini.add_entry( _object->name() ,
"PointSize" ,
_object->materialNode()->point_size());
_ini.add_entry( _object->name() ,
"LineWidth" ,
_object->materialNode()->line_width());
}
}
void INIPlugin::loadIniFile( INIFile& _ini, int _id ) {
BaseObjectData* baseObject;
......@@ -97,6 +173,9 @@ void INIPlugin::loadIniFile( INIFile& _ini, int _id ) {
TriMeshObject* triObject(0);
LightObject* lightObject(0);
// Load all data from baseobjectdata part
parseIniFile(_ini,baseObject);
if(baseObject->dataType() == DATA_POLY_MESH) {
polyObject = PluginFunctions::polyMeshObject(baseObject);
parseIniFileT(_ini, polyObject);
......@@ -124,6 +203,9 @@ void INIPlugin::saveIniFile( INIFile& _ini, int _id) {
TriMeshObject* triObject(0);
LightObject* lightObject(0);
// Save all data from baseobjectdata part
saveIniFile(_ini,baseObject);
if(baseObject->dataType() == DATA_POLY_MESH) {
polyObject = PluginFunctions::polyMeshObject(baseObject);
saveIniFileT(_ini, polyObject);
......
......@@ -89,6 +89,13 @@ class INIPlugin : public QObject, BaseInterface, LoggingInterface, ScriptInterfa
// Template function to save ini file entries
template <class Object>
void saveIniFileT(INIFile& _ini, Object* _object);
// Parse data from baseObjectData derived objects
void parseIniFile(INIFile& _ini, BaseObjectData* _object);
// Save data from baseObjectData derived objects
void saveIniFile(INIFile& _ini, BaseObjectData* _object);
};
//=============================================================================
......
......@@ -10,46 +10,12 @@ template <class MeshObject>
void INIPlugin::parseIniFileT(INIFile& _ini, MeshObject* _object) {
if ( _object ) {
std::vector< QString > draw_modes;
if( _ini.get_entry(draw_modes, _object->name(), "MaterialDrawMode") )
_object->materialNode()->drawMode( listToDrawMode(draw_modes) );
if( _ini.get_entry(draw_modes, _object->name(), "MeshDrawMode") )
_object->meshNode()->drawMode( listToDrawMode(draw_modes) );
ACG::Vec4f col(0.0,0.0,0.0,0.0);
if ( _ini.get_entryVecf( col, _object->name() , "BaseColor" ) )
_object->materialNode()->set_base_color(col);
if ( _ini.get_entryVecf( col, _object->name() , "AmbientColor" ) )
_object->materialNode()->set_ambient_color(col);
if ( _ini.get_entryVecf( col, _object->name() , "DiffuseColor" ) )
_object->materialNode()->set_diffuse_color(col);
if ( _ini.get_entryVecf( col, _object->name() , "SpecularColor" ) )
_object->materialNode()->set_specular_color(col);
double shininess;
if ( _ini.get_entry( shininess, _object->name() , "Shininess" ) )
_object->materialNode()->set_shininess(shininess);
double reflectance;
if ( _ini.get_entry( reflectance, _object->name() , "Reflectance" ) ) {
_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);
if ( _ini.get_entry( size, _object->name() , "LineWidth" ) )
_object->materialNode()->set_line_width(size);
std::vector< QString > draw_modes;
if( _ini.get_entry(draw_modes, _object->name(), "MeshDrawMode") )
_object->meshNode()->drawMode( listToDrawMode(draw_modes) );
}
}
......@@ -57,39 +23,9 @@ template <class MeshObject>
void INIPlugin::saveIniFileT(INIFile& _ini, MeshObject* _object) {
if ( _object ) {
_ini.add_entry( _object->name() ,
"MaterialDrawMode" ,
drawModeToList( _object->materialNode()->drawMode()) );
_ini.add_entry( _object->name() ,
"MeshDrawMode" ,
drawModeToList( _object->meshNode()->drawMode()) );
_ini.add_entryVec( _object->name() ,
"BaseColor" ,
_object->materialNode()->base_color()) ;
_ini.add_entryVec( _object->name() ,
"AmbientColor" ,
_object->materialNode()->ambient_color()) ;
_ini.add_entryVec( _object->name() ,
"DiffuseColor" ,
_object->materialNode()->diffuse_color());
_ini.add_entryVec( _object->name() ,
"SpecularColor" ,
_object->materialNode()->specular_color());
_ini.add_entry( _object->name() ,
"Shininess" ,
_object->materialNode()->shininess());
_ini.add_entry( _object->name() ,
"Reflectance" ,
_object->materialNode()->reflectance());
_ini.add_entry( _object->name() ,
"Visible" ,
_object->visible() );
_ini.add_entry( _object->name() ,
"PointSize" ,
_object->materialNode()->point_size());
_ini.add_entry( _object->name() ,
"LineWidth" ,
_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