first step to support the new xml format in easyneuf.xml
author"Luc Saillard <luc@saillard.org>"
Mon Apr 28 11:56:21 2008 +0200 (2 weeks ago)
changeset 3700719c1d20933
parent 369672938f806f8
child 3719858b584f367
first step to support the new xml format in easyneuf.xml
easy3d/easy3d_universe.cpp
easy3d/load_universe.cpp
easy3d/load_universe.h
--- a/easy3d/easy3d_universe.cpp Wed Apr 16 10:22:01 2008 +0200
+++ b/easy3d/easy3d_universe.cpp Mon Apr 28 11:56:21 2008 +0200
@@ -144,6 +144,7 @@ void SceneUniverse::load()
osg::MatrixTransform* transformText = createTextSelectedItem("universe_");
for (int i = 0; i < maxCube; i++) {
+
if (LoadUniverse::instance()->galaxyVector[i]->hidden)
continue;
@@ -165,11 +166,19 @@ void SceneUniverse::load()
mItems[i].getText()->setAlignment(osgText::Text::CENTER_CENTER);
mItems[i].getText()->setText(LoadUniverse::instance()->galaxyVector[i]->name,osgText::String::ENCODING_UTF8);
- osg::Vec3 pos;
- std::string xmlnode_string = "universe_pos_icone_" + LoadUniverse::instance()->galaxyVector[i]->id;
- VarsEditor::instance()->get(xmlnode_string, pos);
- pos[0] *= screenRatioConvert;
- mItems[i].getRootTransform()->setMatrix(osg::Matrix::translate(pos));
+ if (LoadUniverse::instance()->galaxyVector[i]->position)
+ {
+ LoadUniverse::instance()->galaxyVector[i]->position->_v[0] *= screenRatioConvert;
+ mItems[i].getRootTransform()->setMatrix(osg::Matrix::translate(*LoadUniverse::instance()->galaxyVector[i]->position));
+ }
+ else
+ {
+ osg::Vec3 pos;
+ std::string xmlnode_string = "universe_pos_icone_" + LoadUniverse::instance()->galaxyVector[i]->id;
+ VarsEditor::instance()->get(xmlnode_string, pos);
+ pos[0] *= screenRatioConvert;
+ mItems[i].getRootTransform()->setMatrix(osg::Matrix::translate(pos));
+ }
initItemTransitionPosition(i);
}
--- a/easy3d/load_universe.cpp Wed Apr 16 10:22:01 2008 +0200
+++ b/easy3d/load_universe.cpp Mon Apr 28 11:56:21 2008 +0200
@@ -47,7 +47,7 @@ bool Satellite::isGoto() { return !go_t
Satellite::Satellite() {}
Planet::Planet() {}
-Galaxy::Galaxy() { hidden = false; }
+Galaxy::Galaxy() { hidden = false; position = NULL; }
Satellite* LoadUniverse::loadSatellite(xmlDocPtr doc, xmlNodePtr cur) {
@@ -219,6 +219,46 @@ Galaxy* LoadUniverse::loadGalaxy(xmlDocP
galaxy->hidden = true;
xmlFree(value);
}
+
+ value = xmlGetProp(cur,(const xmlChar *)"position");
+ if (value) {
+ float x, y, z;
+
+ if (sscanf((const char *)value, "Vec3 %f %f %f", &x, &y, &z) == 3) {
+ galaxy->position = new osg::Vec3(x,y,z);
+ } else {
+ trace("Bad value for position=\"%s\"\n", (char *)value);
+ }
+
+ xmlFree(value);
+ }
+
+ value = xmlGetProp(cur,(const xmlChar *)"color");
+ if (value) {
+ float r, g, b, a;
+
+ if (sscanf((const char *)value, "Vec4 %f %f %f %f", &r, &g, &b, &a) == 4) {
+ galaxy->color = new osg::Vec4(r, g, b, a);
+ } else {
+ error("Bad value for color=\"%s\"\n", (char *)value);
+ }
+
+ xmlFree(value);
+ }
+
+ value = xmlGetProp(cur,(const xmlChar *)"color_when_blended");
+ if (value) {
+ float r, g, b, a;
+
+ if (sscanf((const char *)value, "Vec4 %f %f %f %f", &r, &g, &b, &a) == 4) {
+ galaxy->color_when_blended = new osg::Vec4(r, g, b, a);
+ } else {
+ error("Bad value for color_when_blended=\"%s\"\n", (char *)value);
+ }
+
+ xmlFree(value);
+ }
+
cur = cur->xmlChildrenNode;
while (cur != NULL) {
--- a/easy3d/load_universe.h Wed Apr 16 10:22:01 2008 +0200
+++ b/easy3d/load_universe.h Mon Apr 28 11:56:21 2008 +0200
@@ -24,6 +24,7 @@
#include <string>
#include <vector>
#include <osg/Referenced>
+#include <osg/Geode>
#include <libxml/xmlmemory.h>
#include <libxml/parser.h>
@@ -66,6 +67,9 @@ public:
std::string bg_filename; // texture used for background
std::string icon_filename; // texture used as "galaxy icon"
std::vector<Planet*> planetVector;
+ osg::Vec3 *position;
+ osg::Vec4 *color;
+ osg::Vec4 *color_when_blended;
bool hidden; // set to true if the galaxy must no be show
Galaxy();