52 #if QT_VERSION >= 0x050000
62 return QString( tr(
"Light definition files ( *.lgt )") );
66 return QString( tr(
"Light definition files ( *.lgt )") );
74 int FileLightPlugin::loadObject(QString _filename)
85 QFileInfo fi(_filename);
92 QSettings settings(_filename, QSettings::IniFormat);
93 settings.beginGroup(
"LIGHT");
95 if ( settings.contains(
"Name") ) {
97 QString name = settings.value(
"Name").toString();
104 if (settings.contains(
"PositionX")) {
106 position[0] = settings.value(
"PositionX").toDouble();
107 position[1] = settings.value(
"PositionY").toDouble();
108 position[2] = settings.value(
"PositionZ").toDouble();
113 if (settings.contains(
"DirectionX")) {
115 direction[0] = settings.value(
"DirectionX").toDouble();
116 direction[1] = settings.value(
"DirectionY").toDouble();
117 direction[2] = settings.value(
"DirectionZ").toDouble();
122 if (settings.contains(
"SpotDirectionX")) {
124 spotDirection[0] = settings.value(
"SpotDirectionX").toDouble();
125 spotDirection[1] = settings.value(
"SpotDirectionY").toDouble();
126 spotDirection[2] = settings.value(
"SpotDirectionZ").toDouble();
131 if (settings.contains(
"AmbientColorR")) {
133 ambientColor[0] = settings.value(
"AmbientColorR").toDouble();
134 ambientColor[1] = settings.value(
"AmbientColorG").toDouble();
135 ambientColor[2] = settings.value(
"AmbientColorB").toDouble();
136 if (settings.contains(
"AmbientColorA"))
137 ambientColor[3] = settings.value(
"AmbientColorA").toDouble();
139 ambientColor[3] = 1.0f;
144 if (settings.contains(
"DiffuseColorR")) {
146 diffuseColor[0] = settings.value(
"DiffuseColorR").toDouble();
147 diffuseColor[1] = settings.value(
"DiffuseColorG").toDouble();
148 diffuseColor[2] = settings.value(
"DiffuseColorB").toDouble();
149 if (settings.contains(
"DiffuseColorA"))
150 diffuseColor[3] = settings.value(
"DiffuseColorA").toDouble();
152 diffuseColor[3] = 1.0f;
157 if (settings.contains(
"SpecularColorR")) {
159 specularColor[0] = settings.value(
"SpecularColorR").toDouble();
160 specularColor[1] = settings.value(
"SpecularColorG").toDouble();
161 specularColor[2] = settings.value(
"SpecularColorB").toDouble();
162 if (settings.contains(
"SpecularColorA"))
163 specularColor[3] = settings.value(
"SpecularColorA").toDouble();
165 specularColor[3] = 1.0f;
170 if (settings.contains(
"FixedPosition")) {
172 bool fixedPosition = settings.value(
"FixedPosition").toBool();
177 if (settings.contains(
"SpotExponent")) {
179 float spotExponent = settings.value(
"SpotExponent").toDouble();
181 light->spotExponent(spotExponent);
184 if (settings.contains(
"SpotCutOff")) {
186 float spotCutOff = settings.value(
"SpotCutOff").toDouble();
188 light->spotCutoff(spotCutOff);
191 if (settings.contains(
"ConstantAttenuation")) {
193 float cAttenuation = settings.value(
"ConstantAttenuation").toDouble();
195 light->constantAttenuation(cAttenuation);
198 if (settings.contains(
"LinearAttenuation")) {
200 float lAttenuation = settings.value(
"LinearAttenuation").toDouble();
202 light->linearAttenuation(lAttenuation);
205 if (settings.contains(
"QuadraticAttenuation")) {
207 float qAttenuation = settings.value(
"QuadraticAttenuation").toDouble();
209 light->quadraticAttenuation(qAttenuation);
212 if (settings.contains(
"Radius")) {
214 float radius = settings.value(
"Radius").toDouble();
219 if (settings.contains(
"Enabled")) {
221 bool enabled = settings.value(
"Enabled").toBool();
230 emit openedFile( lightObject->
id() );
239 bool FileLightPlugin::saveObject(
int _id, QString _filename)
250 QSettings settings(_filename, QSettings::IniFormat);
251 settings.beginGroup(
"LIGHT");
253 settings.setValue(
"Name",lightObject->
name());
256 settings.setValue(
"PositionX", light->
position()[0]);
257 settings.setValue(
"PositionY", light->
position()[1]);
258 settings.setValue(
"PositionZ", light->
position()[2]);
260 settings.setValue(
"DirectionX", light->
direction()[0]);
261 settings.setValue(
"DirectionY", light->
direction()[1]);
262 settings.setValue(
"DirectionZ", light->
direction()[2]);
265 settings.setValue(
"SpotDirectionX", light->
spotDirection()[0]);
266 settings.setValue(
"SpotDirectionY", light->
spotDirection()[1]);
267 settings.setValue(
"SpotDirectionZ", light->
spotDirection()[2]);
269 settings.setValue(
"AmbientColorR", light->
ambientColor()[0]);
270 settings.setValue(
"AmbientColorG", light->
ambientColor()[1]);
271 settings.setValue(
"AmbientColorB", light->
ambientColor()[2]);
272 settings.setValue(
"AmbientColorA", light->
ambientColor()[3]);
274 settings.setValue(
"DiffuseColorR", light->
diffuseColor()[0]);
275 settings.setValue(
"DiffuseColorG", light->
diffuseColor()[1]);
276 settings.setValue(
"DiffuseColorB", light->
diffuseColor()[2]);
277 settings.setValue(
"DiffuseColorA", light->
diffuseColor()[3]);
279 settings.setValue(
"SpecularColorR", light->
specularColor()[0]);
280 settings.setValue(
"SpecularColorG", light->
specularColor()[1]);
281 settings.setValue(
"SpecularColorB", light->
specularColor()[2]);
282 settings.setValue(
"SpecularColorA", light->
specularColor()[3]);
286 settings.setValue(
"SpotExponent", light->spotExponent());
288 settings.setValue(
"SpotCutOff", light->spotCutoff());
290 settings.setValue(
"ConstantAttenuation", light->constantAttenuation());
292 settings.setValue(
"LinearAttenuation", light->linearAttenuation());
294 settings.setValue(
"QuadraticAttenuation", light->quadraticAttenuation());
296 settings.setValue(
"Radius", light->
radius());
298 settings.setValue(
"Enabled", light->
enabled());
302 obj->setFromFileName(_filename);
303 obj->setName(obj->filename());
309 #if QT_VERSION < 0x050000
bool enabled() const
Get light source status.
void disable()
disable LightSource
QString name() const
return the name of the object. The name defaults to NONAME if unset.
const UpdateType UPDATE_ALL(UpdateTypeSet(1))
Identifier for all updates.
bool getObject(int _identifier, BSplineCurveObject *&_object)
void diffuseColor(Vec4f _color)
set Diffuse color for LightSource
LightSource * lightSource(BaseObjectData *_object)
Get the lightSource in this Object.
void setFromFileName(const QString &_filename)
void fixedPosition(bool _state)
make LightSource fixed or moveable with ModelViewMatrix
void initializePlugin()
Initialize Plugin.
DataType supportedType()
Return your supported object type( e.g. DATA_TRIANGLE_MESH )
LightObject * lightObject(BaseObjectData *_object)
Cast an BaseObject to a LightObject if possible.
Vec3d direction() const
Get direction of the light source.
void setName(QString _name)
Set the name of the Object.
Structure to hold options for one LightSource.
bool directional() const
Check if the light source is a directional light source.
void specularColor(Vec4f _color)
set Specular color for LightSource
QString name()
Return a name for the plugin.
void enable()
enable LightSource
float radius() const
Get light source radius.
void ambientColor(Vec4f _color)
set Ambient color for LightSource
void position(Vec3d _pos)
Set position for LightSource.
void spotDirection(Vec3d _pos)
Set spot direction.