52 return QString( tr(
"Light definition files ( *.lgt )") );
56 return QString( tr(
"Light definition files ( *.lgt )") );
64 int FileLightPlugin::loadObject(QString _filename)
75 QFileInfo fi(_filename);
82 QSettings settings(_filename, QSettings::IniFormat);
83 settings.beginGroup(
"LIGHT");
85 if ( settings.contains(
"Name") ) {
87 QString name = settings.value(
"Name").toString();
94 if (settings.contains(
"PositionX")) {
96 position[0] = settings.value(
"PositionX").toDouble();
97 position[1] = settings.value(
"PositionY").toDouble();
98 position[2] = settings.value(
"PositionZ").toDouble();
103 if (settings.contains(
"DirectionX")) {
105 direction[0] = settings.value(
"DirectionX").toDouble();
106 direction[1] = settings.value(
"DirectionY").toDouble();
107 direction[2] = settings.value(
"DirectionZ").toDouble();
112 if (settings.contains(
"SpotDirectionX")) {
114 spotDirection[0] = settings.value(
"SpotDirectionX").toDouble();
115 spotDirection[1] = settings.value(
"SpotDirectionY").toDouble();
116 spotDirection[2] = settings.value(
"SpotDirectionZ").toDouble();
121 if (settings.contains(
"AmbientColorR")) {
123 ambientColor[0] = settings.value(
"AmbientColorR").toDouble();
124 ambientColor[1] = settings.value(
"AmbientColorG").toDouble();
125 ambientColor[2] = settings.value(
"AmbientColorB").toDouble();
126 if (settings.contains(
"AmbientColorA"))
127 ambientColor[3] = settings.value(
"AmbientColorA").toDouble();
129 ambientColor[3] = 1.0f;
134 if (settings.contains(
"DiffuseColorR")) {
136 diffuseColor[0] = settings.value(
"DiffuseColorR").toDouble();
137 diffuseColor[1] = settings.value(
"DiffuseColorG").toDouble();
138 diffuseColor[2] = settings.value(
"DiffuseColorB").toDouble();
139 if (settings.contains(
"DiffuseColorA"))
140 diffuseColor[3] = settings.value(
"DiffuseColorA").toDouble();
142 diffuseColor[3] = 1.0f;
147 if (settings.contains(
"SpecularColorR")) {
149 specularColor[0] = settings.value(
"SpecularColorR").toDouble();
150 specularColor[1] = settings.value(
"SpecularColorG").toDouble();
151 specularColor[2] = settings.value(
"SpecularColorB").toDouble();
152 if (settings.contains(
"SpecularColorA"))
153 specularColor[3] = settings.value(
"SpecularColorA").toDouble();
155 specularColor[3] = 1.0f;
160 if (settings.contains(
"FixedPosition")) {
162 bool fixedPosition = settings.value(
"FixedPosition").toBool();
167 if (settings.contains(
"SpotExponent")) {
169 float spotExponent = settings.value(
"SpotExponent").toDouble();
171 light->spotExponent(spotExponent);
174 if (settings.contains(
"SpotCutOff")) {
176 float spotCutOff = settings.value(
"SpotCutOff").toDouble();
178 light->spotCutoff(spotCutOff);
181 if (settings.contains(
"ConstantAttenuation")) {
183 float cAttenuation = settings.value(
"ConstantAttenuation").toDouble();
185 light->constantAttenuation(cAttenuation);
188 if (settings.contains(
"LinearAttenuation")) {
190 float lAttenuation = settings.value(
"LinearAttenuation").toDouble();
192 light->linearAttenuation(lAttenuation);
195 if (settings.contains(
"QuadraticAttenuation")) {
197 float qAttenuation = settings.value(
"QuadraticAttenuation").toDouble();
199 light->quadraticAttenuation(qAttenuation);
202 if (settings.contains(
"Radius")) {
204 float radius = settings.value(
"Radius").toDouble();
209 if (settings.contains(
"Enabled")) {
211 bool enabled = settings.value(
"Enabled").toBool();
220 emit openedFile( lightObject->
id() );
229 bool FileLightPlugin::saveObject(
int _id, QString _filename)
240 QSettings settings(_filename, QSettings::IniFormat);
241 settings.beginGroup(
"LIGHT");
243 settings.setValue(
"Name",lightObject->
name());
246 settings.setValue(
"PositionX", light->
position()[0]);
247 settings.setValue(
"PositionY", light->
position()[1]);
248 settings.setValue(
"PositionZ", light->
position()[2]);
250 settings.setValue(
"DirectionX", light->
direction()[0]);
251 settings.setValue(
"DirectionY", light->
direction()[1]);
252 settings.setValue(
"DirectionZ", light->
direction()[2]);
255 settings.setValue(
"SpotDirectionX", light->
spotDirection()[0]);
256 settings.setValue(
"SpotDirectionY", light->
spotDirection()[1]);
257 settings.setValue(
"SpotDirectionZ", light->
spotDirection()[2]);
259 settings.setValue(
"AmbientColorR", light->
ambientColor()[0]);
260 settings.setValue(
"AmbientColorG", light->
ambientColor()[1]);
261 settings.setValue(
"AmbientColorB", light->
ambientColor()[2]);
262 settings.setValue(
"AmbientColorA", light->
ambientColor()[3]);
264 settings.setValue(
"DiffuseColorR", light->
diffuseColor()[0]);
265 settings.setValue(
"DiffuseColorG", light->
diffuseColor()[1]);
266 settings.setValue(
"DiffuseColorB", light->
diffuseColor()[2]);
267 settings.setValue(
"DiffuseColorA", light->
diffuseColor()[3]);
269 settings.setValue(
"SpecularColorR", light->
specularColor()[0]);
270 settings.setValue(
"SpecularColorG", light->
specularColor()[1]);
271 settings.setValue(
"SpecularColorB", light->
specularColor()[2]);
272 settings.setValue(
"SpecularColorA", light->
specularColor()[3]);
276 settings.setValue(
"SpotExponent", light->spotExponent());
278 settings.setValue(
"SpotCutOff", light->spotCutoff());
280 settings.setValue(
"ConstantAttenuation", light->constantAttenuation());
282 settings.setValue(
"LinearAttenuation", light->linearAttenuation());
284 settings.setValue(
"QuadraticAttenuation", light->quadraticAttenuation());
286 settings.setValue(
"Radius", light->
radius());
288 settings.setValue(
"Enabled", light->
enabled());
QString name()
Return a name for the plugin.
const UpdateType UPDATE_ALL(UpdateTypeSet(1))
Identifier for all updates.
bool directional() const
Check if the light source is a directional light source.
void spotDirection(Vec3d _pos)
Set spot direction.
void specularColor(Vec4f _color)
set Specular color for LightSource
void enable()
enable LightSource
void setFromFileName(const QString &_filename)
LightObject * lightObject(BaseObjectData *_object)
Cast an BaseObject to a LightObject if possible.
DataType supportedType()
Return your supported object type( e.g. DATA_TRIANGLE_MESH )
void fixedPosition(bool _state)
make LightSource fixed or moveable with ModelViewMatrix
virtual void setName(QString _name)
path to the file from which the object is loaded ( defaults to "." )
bool getObject(const int _identifier, BaseObject *&_object)
Get the object which has the given identifier.
QString name() const
return the name of the object. The name defaults to NONAME if unset.
QString filename() const
return the filename of the object
void disable()
disable LightSource
Structure to hold options for one LightSource.
bool enabled() const
Get light source status.
void diffuseColor(Vec4f _color)
set Diffuse color for LightSource
Vec3d direction() const
Get direction of the light source.
void position(Vec3d _pos)
Set position for LightSource.
LightSource * lightSource(BaseObjectData *_object)
Get the lightSource in this Object.
void setName(QString _name)
Set the name of the Object.
void ambientColor(Vec4f _color)
set Ambient color for LightSource
void initializePlugin()
Initialize Plugin.
float radius() const
Get light source radius.