Binary file easy3d-data/galaxy/GAT_bg.jpg has changed
--- a/easy3d/application.cpp Wed Jun 18 09:31:50 2008 +0200
+++ b/easy3d/application.cpp Wed Jun 18 09:32:07 2008 +0200
@@ -129,6 +129,8 @@ error_show_error:
#endif
#if defined(SDL_VIDEO_DRIVER_X11)
+static void show_window_properties(void);
+
static void net_wm_change_state(Display *display, Window xwindow, bool add, Atom state1, Atom state2)
{
XEvent xev;
@@ -193,16 +195,10 @@ static void net_wm_set_window_type(Displ
}
-static void net_wm_unset_window_type(Display *display, Window xwindow)
-{
- Atom net_wm_window_type_destop = XInternAtom(display, "_NET_WM_WINDOW_TYPE_NORMAL", False);
-
- XChangeProperty(display, xwindow,
- XInternAtom(display, "_NET_WM_WINDOW_TYPE", False),
- XA_ATOM, 32, PropModeReplace,
- (unsigned char *) &net_wm_window_type_destop, 1);
-
- XDeleteProperty(display, xwindow, XInternAtom(display, "XFCE_DESKTOP_WINDOW", False));
+static void net_wm_window_type_normal(Display *display, Window xwindow)
+{
+
+
}
@@ -234,10 +230,14 @@ void net_wm_iconify_window(void)
Window window = sdl_info.info.x11.wmwindow;
Display *display = sdl_info.info.x11.display;
+ XLowerWindow(display, window);
XUnmapWindow(display, window);
XSync(display, False);
sdl_info.info.x11.unlock_func();
+
+ trace("\n");
+ show_window_properties();
}
void net_wm_deiconify_window(void)
@@ -258,13 +258,92 @@ void net_wm_deiconify_window(void)
Display *display = sdl_info.info.x11.display;
XUnmapWindow(display, window);
+ XSync(display, False);
XMapRaised(display, window);
+ XSync(display, False);
XLowerWindow(display, window);
XSync(display, False);
+
+
+
+
+ net_wm_set_hints(display, window);
+ //net_wm_set_window_type(display, window);
+ /* Normally this settings is done by net_wm_set_window_type() but if the wm doesn't support it ... */
+ net_wm_change_state(display, window, True, XInternAtom(display, "_NET_WM_STATE_SKIP_TASKBAR", False), 0);
+ net_wm_change_state(display, window, True, XInternAtom(display, "_NET_WM_STATE_SKIP_PAGER", False), 0);
+ net_wm_change_state(display, window, True, XInternAtom(display, "_NET_WM_STATE_BELOW", False), 0);
+ net_wm_change_state(display, window, False, XInternAtom(display, "_NET_WM_STATE_FULLSCREEN", False), 0);
+ #define ALL_WORKSPACES (0xFFFFFFFF)
+ net_wm_change_workspace(display, window, ALL_WORKSPACES);
+
+ XLowerWindow(display, window);
+ XSync(display, False);
+
+
sdl_info.info.x11.unlock_func();
-}
-
+
+
+ trace("\n");
+ show_window_properties();
+}
+
+static int
+ignore_errors(Display *display, XErrorEvent *event)
+{
+ display=display;
+ event=event;
+ return 0;
+}
+
+
+static void
+show_window_properties(void)
+{
+ SDL_SysWMinfo sdl_info;
+
+ SDL_VERSION(&sdl_info.version);
+ if (SDL_GetWMInfo(&sdl_info) != 1)
+ return;
+ if (sdl_info.subsystem != SDL_SYSWM_X11)
+ return;
+
+ sdl_info.info.x11.lock_func();
+
+ trace("\n");
+
+ Atom *atoms;
+ int i, num_prop_return;
+
+ Window window = sdl_info.info.x11.wmwindow;
+ Display *display = sdl_info.info.x11.display;
+
+ atoms = XListProperties(display, window, &num_prop_return);
+ for (i = 0; i < num_prop_return; i++)
+ {
+ char *name;
+ XErrorHandler handler;
+
+ handler = XSetErrorHandler(ignore_errors);
+ name = XGetAtomName(display, atoms[i]);
+ XSetErrorHandler(handler);
+
+ if (name == NULL)
+ {
+ trace("undefined atom # 0x%lx", atoms[i]);
+ }
+ else
+ {
+ trace("atom # 0x%lx => %s\n", atoms[i], name);
+ XFree(name);
+ }
+
+ }
+
+
+ sdl_info.info.x11.unlock_func();
+}
#endif
@@ -374,7 +453,7 @@ namespace easy3d
if (running_events)
{
- trace("\n");
+ //trace("\n");
handleEvent(events);
}
@@ -490,7 +569,7 @@ namespace easy3d
if (last_commands_launched.size() == 0)
return;
- std::string url = "http://www.easyneuf.org/reporting/" + easyneuf_get_flavour() + "/easy.php?";
+ std::string url = "http://www.easyneuf.org/reporting/" + std::string(easyneuf_get_flavour()) + "/easy.php?";
std::string post_string;
std::vector<std::string>::const_iterator i;
for (i=last_commands_launched.begin(); i != last_commands_launched.end(); i++)
@@ -584,6 +663,7 @@ namespace easy3d
// init it, sdl should free it, and I can't release it by hand
SDL_Surface *screen = 0;
+ _fullscreen = 0;
// set video mode
if (!(screen = SDL_SetVideoMode(_width,
_height,
@@ -658,7 +738,7 @@ namespace easy3d
XSync(display, False);
net_wm_set_hints(display, window);
- net_wm_set_window_type(display, window);
+ //net_wm_set_window_type(display, window);
/* Normally this settings is done by net_wm_set_window_type() but if the wm doesn't support it ... */
net_wm_change_state(display, window, True, XInternAtom(display, "_NET_WM_STATE_SKIP_TASKBAR", False), 0);
net_wm_change_state(display, window, True, XInternAtom(display, "_NET_WM_STATE_SKIP_PAGER", False), 0);
--- a/easy3d/easy3d.cpp Wed Jun 18 09:31:50 2008 +0200
+++ b/easy3d/easy3d.cpp Wed Jun 18 09:32:07 2008 +0200
@@ -375,7 +375,7 @@ bool Easy3d::check_if_easy3d_xml_changed
if (last_time_easy3d_xml_checked == 0)
last_time_easy3d_xml_checked = current_time;
- if (current_time < last_time_easy3d_xml_checked+8)
+ if (current_time < last_time_easy3d_xml_checked+600)
return false;
#if 0
@@ -435,20 +435,12 @@ void Easy3d::handleEvent(std::vector<SDL
return;
}
- /*
-
- VarsEditor::instance()->read(getEasy3dConfigFile());
- LoadUniverse::instance()->read(getEasyNeufConfigFile());
- VarsEditor::instance()->dump();
- loadVars();
- VarsEditor::instance()->get("app_camera_free", mFreeCamera);
- break;
-
-
-
- */
std::cout << "New configuration seems valid " << easy3d_xml_filename << std::endl;
+ VarsEditor::instance()->read(easy3d_xml_filename);
+ LoadUniverse::instance()->read(getEasyNeufConfigFile());
+ // VarsEditor::instance()->dump();
+ loadVars();
}
--- a/easy3d/easy3d.xml Wed Jun 18 09:31:50 2008 +0200
+++ b/easy3d/easy3d.xml Wed Jun 18 09:32:07 2008 +0200
@@ -1,42 +1,47 @@
<editor>
<var name="app_user_screensize" value="0"/>
-<var name="app_maxfps" value="30"/>
+<var name="app_maxfps" value="27"/>
<var name="app_zbuffer" value="16"/>
<var name="app_fov" value="45"/>
<var name="app_width" value="1680"/>
<var name="app_height" value="1050"/>
<var name="app_width" value="1600"/>
<var name="app_height" value="1200"/>
-<var name="app_width" value="1024"/>
-<var name="app_height" value="768"/>
+<var name="app_width" value="1280"/>
+<var name="app_height" value="1024"/>
<var name="app_depth" value="24"/>
-<var name="app_fullscreen" value="0"/>
+<var name="app_fullscreen" value="1"/>
<var name="app_camera_step" value="100"/>
<var name="app_drawstats" value="0"/>
-<var name="app_font" value="/usr/share/fonts/truetype/ttf-bitstream-vera/Vera.ttf"/>
+<var name="app_font" value="/usr/share/fonts/ttf-bitstream-vera/Vera.ttf"/>
<var name="app_font_size" value="16"/>
<var name="app_font_texture_size" value="16"/>
<var name="app_camera_pos" value="Vec3 2 20 30"/>
<var name="app_camera_pos" value="Vec3 0 0 0.7"/>
<var name="app_camera_free" value="0"/>
-<var name="app_filter_events" value="0"/>
+<var name="app_filter_events" value="1"/>
<!-- easy3d application configuration -->
-<var name="easy3d_release_version" value="0"/>
+<var name="easy3d_release_version" value="1"/>
<var name="easy3d_universe_mapfile" value="/tmp/easy3d_map_universe.xml"/>
<var name="easy3d_galaxy_mapfile" value="/tmp/easy3d_map_galaxy.xml"/>
<var name="easy3d_planet_mapfile" value="/tmp/easy3d_map_planet.xml"/>
+<!-- path to load data -->
+<var name="easy3d_verbose" value="0"/>
+<var name="easy3d_datadir" value="../easy3d-data/"/>
+<var name="easy3d_autostart_nb_directory" value="2"/>
+<var name="easy3d_autostart_directory00" value="/usr/share/autostart/"/>
+<var name="easy3d_autostart_directory01" value="/usr/share/3dsquare/autostart/"/>
+<var name="easy3d_autostart_script" value="@prefix@/share/easy3d/easy3d_autostart"/>
<!-- universe content file -->
-<var name="easy3d_verbose" value="0"/>
-<var name="universe_datadir" value="../easy3d-data"/>
+<!-- old value var name="universe_tree_file" value="/usr/share/easyneuf/easyneuf.xml"/ -->
+<!--<var name="universe_datadir" value="/usr/share/easy3d"/> -->
<var name="universe_tree_file" value="easyneuf.xml"/>
-<!-- path to load data -->
-<var name="easy3d_datadir" value="../easy3d-data/"/>
<!-- scene cube common -->
<var name="angle_rotation" value="100"/>
@@ -159,39 +164,39 @@
<var name="galaxy_anim_cube_fade_target" value="1"/>
<var name="galaxy_anim_cube_fade_clamp_factor" value="1"/>
-<var name="galaxy_return_text" value="Back" />
-<var name="galaxy_click_text" value="Click me" />
-
-<var name="galaxy_cube_diffuse_ADV" value="Vec4 1 0.7 0 1"/>
-<var name="galaxy_cube_diffuse_ADV_when_blended" value="Vec4 1 0.7 0 0.2"/>
-<var name="galaxy_cube_diffuse_APP" value="Vec4 0.1 0.1 0.8 1"/>
-<var name="galaxy_cube_diffuse_APP_when_blended" value="Vec4 0.1 0.1 0.8 0.2"/>
-<var name="galaxy_cube_diffuse_BUR" value="Vec4 0.8 0 0.8 1"/>
-<var name="galaxy_cube_diffuse_BUR_when_blended" value="Vec4 0.8 0 0.8 0.2"/>
-<var name="galaxy_cube_diffuse_CLT" value="Vec4 0.1 0.2 0.8 1"/>
-<var name="galaxy_cube_diffuse_CLT_when_blended" value="Vec4 0.1 0.2 0.8 0.2"/>
-<var name="galaxy_cube_diffuse_COM" value="Vec4 0.2 0.3 0.8 1"/>
-<var name="galaxy_cube_diffuse_COM_when_blended" value="Vec4 0.2 0.3 0.8 0.2"/>
-<var name="galaxy_cube_diffuse_GAM" value="Vec4 1 0.2 0.5 1"/>
-<var name="galaxy_cube_diffuse_GAM_when_blended" value="Vec4 1 0.2 0.5 0.2"/>
-<var name="galaxy_cube_diffuse_GAT" value="Vec4 0.3 0.7 1 1"/>
-<var name="galaxy_cube_diffuse_GAT_when_blended" value="Vec4 0.3 0.7 1 0.2"/>
-<var name="galaxy_cube_diffuse_INF" value="Vec4 1 0.3 0.6 1"/>
-<var name="galaxy_cube_diffuse_INF_when_blended" value="Vec4 1 0.3 0.6 0.2"/>
-<var name="galaxy_cube_diffuse_PRA" value="Vec4 1 0.2 0 1"/>
-<var name="galaxy_cube_diffuse_PRA_when_blended" value="Vec4 1 0.2 0 0.2"/>
-<var name="galaxy_cube_diffuse_REC" value="Vec4 1 0 0 1"/>
-<var name="galaxy_cube_diffuse_REC_when_blended" value="Vec4 1 0 0 0.2"/>
-<var name="galaxy_cube_diffuse_SAN" value="Vec4 0.25 0.9 0.7 1"/>
-<var name="galaxy_cube_diffuse_SAN_when_blended" value="Vec4 0.25 0.9 0.7 0.2"/>
-<var name="galaxy_cube_diffuse_SOL" value="Vec4 0 0.2 1 1"/>
-<var name="galaxy_cube_diffuse_SOL_when_blended" value="Vec4 0 0.2 1 0.2"/>
-<var name="galaxy_cube_diffuse_TOU" value="Vec4 1 0.3 0 1"/>
-<var name="galaxy_cube_diffuse_TOU_when_blended" value="Vec4 1 0.3 0 0.2"/>
-<var name="galaxy_cube_diffuse_APPL" value="Vec4 0.8 0 0.8 1"/>
-<var name="galaxy_cube_diffuse_APPL_when_blended" value="Vec4 0.8 0 0.8 0.2"/>
-<var name="galaxy_cube_diffuse_DEV" value="Vec4 0.8 0 0.8 1"/>
-<var name="galaxy_cube_diffuse_DEV_when_blended" value="Vec4 0.8 0 0.8 0.2"/>
+<var name="galaxy_return_text" value="retour" />
+<var name="galaxy_click_text" value="Cliquez" />
+
+<var name="galaxy_cube_diffuse_ADV" value="Vec4 0.9 0.7 0.1 1"/>
+<var name="galaxy_cube_diffuse_ADV_when_blended" value="Vec4 0.9 0.7 0.1 0.2"/>
+<var name="galaxy_cube_diffuse_APP" value="Vec4 0.1 0.4 0.7 1"/>
+<var name="galaxy_cube_diffuse_APP_when_blended" value="Vec4 0.1 0.4 0.7 0.2"/>
+<var name="galaxy_cube_diffuse_BUR" value="Vec4 0.6 0.1 0.6 1"/>
+<var name="galaxy_cube_diffuse_BUR_when_blended" value="Vec4 0.6 0.1 0.6 0.2"/>
+<var name="galaxy_cube_diffuse_CLT" value="Vec4 0.1 0.4 0.7 1"/>
+<var name="galaxy_cube_diffuse_CLT_when_blended" value="Vec4 0.1 0.4 0.7 0.2"/>
+<var name="galaxy_cube_diffuse_COM" value="Vec4 0.2 0.5 0.7 1"/>
+<var name="galaxy_cube_diffuse_COM_when_blended" value="Vec4 0.2 0.5 0.7 0.2"/>
+<var name="galaxy_cube_diffuse_GAM" value="Vec4 0.8 0.4 0.5 1"/>
+<var name="galaxy_cube_diffuse_GAM_when_blended" value="Vec4 0.8 0.4 0.5 0.2"/>
+<var name="galaxy_cube_diffuse_GAT" value="Vec4 0.4 0.7 0.8 1"/>
+<var name="galaxy_cube_diffuse_GAT_when_blended" value="Vec4 0.4 0.7 0.8 0.2"/>
+<var name="galaxy_cube_diffuse_INF" value="Vec4 0.9 0.5 0.6 1"/>
+<var name="galaxy_cube_diffuse_INF_when_blended" value="Vec4 0.9 0.5 0.6 0.2"/>
+<var name="galaxy_cube_diffuse_PRA" value="Vec4 0.8 0.5 0.1 1"/>
+<var name="galaxy_cube_diffuse_PRA_when_blended" value="Vec4 0.8 0.5 0.1 0.2"/>
+<var name="galaxy_cube_diffuse_REC" value="Vec4 0.4 0 0 1"/>
+<var name="galaxy_cube_diffuse_REC_when_blended" value="Vec4 0.4 0 0 0.2"/>
+<var name="galaxy_cube_diffuse_SAN" value="Vec4 0.6 0.8 0.7 1"/>
+<var name="galaxy_cube_diffuse_SAN_when_blended" value="Vec4 0.6 0.8 0.7 0.2"/>
+<var name="galaxy_cube_diffuse_SOL" value="Vec4 0 0.3 0.8 1"/>
+<var name="galaxy_cube_diffuse_SOL_when_blended" value="Vec4 0 0.3 0.8 0.2"/>
+<var name="galaxy_cube_diffuse_TOU" value="Vec4 0.8 0.5 0.1 1"/>
+<var name="galaxy_cube_diffuse_TOU_when_blended" value="Vec4 0.8 0.5 0.1 0.2"/>
+<var name="galaxy_cube_diffuse_DEV" value="Vec4 0.6 0.1 0.6 1"/>
+<var name="galaxy_cube_diffuse_DEV_when_blended" value="Vec4 0.6 0.1 0.6 0.2"/>
+<var name="galaxy_cube_diffuse_APPL" value="Vec4 0.6 0.1 0.6 1"/>
+<var name="galaxy_cube_diffuse_APPL_when_blended" value="Vec4 0.6 0.1 0.6 0.2"/>
<var name="galaxy_text_color" value="Vec4 1 1 1 1"/>
<var name="galaxy_text_color_when_blended" value="Vec4 1 1 1 0.2"/>
--- a/easy3d/easy3d_galaxy.cpp Wed Jun 18 09:31:50 2008 +0200
+++ b/easy3d/easy3d_galaxy.cpp Wed Jun 18 09:32:07 2008 +0200
@@ -100,12 +100,22 @@ void SceneGalaxy::initCubeSet(int maxCub
void SceneGalaxy::initCubeSet(int maxCube)
{
EASY3D_ASSERT(maxCube);
- Galaxy* gxy = LoadUniverse::instance()->galaxyVector[mGalaxyId];
-
- mCubeDiffuse = osg::Vec4(1, 1, 1, 1);
- mCubeDiffuseBlended = osg::Vec4(1, 1, 1, 1);
- VarsEditor::instance()->get("galaxy_cube_diffuse_" + std::string(gxy->id), mCubeDiffuse);
- VarsEditor::instance()->get("galaxy_cube_diffuse_" + std::string(gxy->id) + "_when_blended", mCubeDiffuseBlended);
+ Galaxy *galaxy = LoadUniverse::instance()->galaxyVector[mGalaxyId];
+
+ if (galaxy->color) {
+ mCubeDiffuse = *galaxy->color;
+ } else {
+ mCubeDiffuse = osg::Vec4(1, 1, 1, 1);
+ VarsEditor::instance()->get("galaxy_cube_diffuse_" + std::string(galaxy->id), mCubeDiffuse);
+ }
+
+ if (galaxy->color_when_blended) {
+ mCubeDiffuseBlended = *galaxy->color_when_blended;
+ } else {
+ mCubeDiffuseBlended = osg::Vec4(1, 1, 1, 1);
+ VarsEditor::instance()->get("galaxy_cube_diffuse_" + std::string(galaxy->id) + "_when_blended", mCubeDiffuseBlended);
+ }
+
// setup cube set
mCubeSet = new EasyCubeSet(maxCube);
@@ -119,9 +129,9 @@ void SceneGalaxy::initCubeSet(int maxCub
mCubeSet->getCube(i)->mIcons->getStateSet()->removeAttribute(osg::StateAttribute::MATERIAL);
if (i == getMainItemIndex()) {
- initCubeSetItem(getMainItemIndex(), mCubeDiffuse, gxy->icon_filename);
+ initCubeSetItem(getMainItemIndex(), mCubeDiffuse, galaxy->icon_filename);
} else {
- initCubeSetItem(i, mCubeDiffuse, gxy->planetVector[i]->icon_filename);
+ initCubeSetItem(i, mCubeDiffuse, galaxy->planetVector[i]->icon_filename);
}
}
}
@@ -153,14 +163,25 @@ void SceneGalaxy::load()
initRootNode();
- Galaxy* gxy = LoadUniverse::instance()->galaxyVector[mGalaxyId];
- int maxCube = gxy->planetVector.size() + 1; // for BigCube
+ Galaxy* galaxy = LoadUniverse::instance()->galaxyVector[mGalaxyId];
+ int maxCube = galaxy->planetVector.size() + 1; // for BigCube
// setup color fadein fadeout globally to items
- mTextColor = osg::Vec4(1, 1, 1, 1);
- VarsEditor::instance()->get("galaxy_text_color", mTextColor);
- mTextColorBlended = osg::Vec4(1, 1, 1, 1);
- VarsEditor::instance()->get("galaxy_text_color_when_blended", mTextColorBlended);
+ if (galaxy->text_color)
+ mTextColor = *galaxy->text_color;
+ else
+ {
+ mTextColor = osg::Vec4(1, 1, 1, 1);
+ VarsEditor::instance()->get("galaxy_text_color", mTextColor);
+ }
+
+ if (galaxy->text_color_when_selected)
+ mTextColorBlended = *galaxy->text_color_when_selected;
+ else
+ {
+ mTextColorBlended = osg::Vec4(1, 1, 1, 1);
+ VarsEditor::instance()->get("galaxy_text_color_when_blended", mTextColorBlended);
+ }
// init CubeSet
initCubeSet(maxCube);
@@ -206,7 +227,7 @@ void SceneGalaxy::load()
if ( i != getMainItemIndex()) {
mItems[i].getText()->setAlignment(osgText::Text::LEFT_CENTER);
- mItems[i].getText()->setText(gxy->planetVector[i]->name,osgText::String::ENCODING_UTF8);
+ mItems[i].getText()->setText(galaxy->planetVector[i]->name,osgText::String::ENCODING_UTF8);
mItems[i].setTransitionInPositionSource(dst);
mItems[i].setTransitionInPositionDestination(ori);
--- a/easy3d/easy3d_planet.cpp Wed Jun 18 09:31:50 2008 +0200
+++ b/easy3d/easy3d_planet.cpp Wed Jun 18 09:32:07 2008 +0200
@@ -34,6 +34,7 @@
#include "easy3d_writemap.h"
#include "load_universe.h"
+#include "utils.h"
#include <osg/BlendFunc>
#include <osg/Geode>
@@ -162,15 +163,16 @@ void ScenePlanet::load()
mItems.clear();
- int galaxy = mGalaxyId;
- int planet = mPlanetId;
int nbItems = 0;
- Galaxy* gxy = 0;
-
- if (planet != -1 && galaxy != -1) {
- fixGalaxyIdAndPlanetId (galaxy, planet);
- gxy = LoadUniverse::instance()->galaxyVector[galaxy];
- nbItems = (int)gxy->planetVector[planet]->satelliteVector.size();
+ Galaxy *galaxy = 0;
+
+ if (mPlanetId != -1 && mGalaxyId != -1) {
+ fixGalaxyIdAndPlanetId (mGalaxyId, mPlanetId);
+ galaxy = LoadUniverse::instance()->galaxyVector[mGalaxyId];
+ nbItems = (int)galaxy->planetVector[mPlanetId]->satelliteVector.size();
+ } else {
+ trace("No mPlanetId or mGalaxyId defined !!!!\n");
+ return;
}
std::string urlTexture;
@@ -179,16 +181,32 @@ void ScenePlanet::load()
VarsEditor::instance()->get("planet_icon_command", commandTexture);
mItems.resize(nbItems);
- for (int i = 0; i < (int)mItems.size(); i++) {
+
+ for (unsigned int i = 0; i < mItems.size(); i++) {
+
+ Satellite *satellite = galaxy->planetVector[mPlanetId]->satelliteVector[i];
+
mItems[i].create();
mItems[i].loadSettings();
- mItems[i].getText()->setText(gxy->planetVector[planet]->satelliteVector[i]->name, osgText::String::ENCODING_UTF8);
- if (gxy->planetVector[planet]->satelliteVector[i]->icon_filename.empty() == false)
- mItems[i].setTextureIcon(gxy->planetVector[planet]->satelliteVector[i]->icon_filename);
- else if (gxy->planetVector[planet]->satelliteVector[i]->isCommand())
+ mItems[i].getText()->setText(satellite->name, osgText::String::ENCODING_UTF8);
+
+ if (satellite->icon_filename.empty() == false)
+ mItems[i].setTextureIcon(satellite->icon_filename);
+ else if (satellite->isCommand())
mItems[i].setTextureIcon(commandTexture);
- else if (gxy->planetVector[planet]->satelliteVector[i]->isUrl())
+ else if (satellite->isUrl())
mItems[i].setTextureIcon(urlTexture);
+
+ if (satellite->text_color)
+ mItems[i].setTextColor(*satellite->text_color);
+ else if (galaxy->text_color)
+ mItems[i].setTextColor(*galaxy->text_color);
+
+ if (satellite->text_color_when_selected)
+ mItems[i].setTextSelectedColor(*satellite->text_color_when_selected);
+ else if (galaxy->text_color_when_selected)
+ mItems[i].setTextColor(*galaxy->text_color_when_selected);
+
mTextsTransform->addChild(mItems[i].getTransform());
}
@@ -321,6 +339,16 @@ void ScenePlanet::manageClick()
int focus = mPicker.getFocusItem();
if (focus == -1)
return;
+
+ /* we have a precision of one second (should be enough to start application) */
+ time_t current_time = time(NULL);
+ static time_t last_click_time = 0;
+
+ trace("last_click_time=%u current_time=%u\n", last_click_time, current_time);
+ if (current_time < last_click_time+5)
+ return;
+ last_click_time = current_time;
+
Planet* plt = LoadUniverse::instance()->galaxyVector[mGalaxyId]->planetVector[mPlanetId];
EASY3D_ASSERT(focus >=0 && focus < (int)plt->satelliteVector.size());
@@ -341,12 +369,12 @@ void ScenePlanet::handleEvent(std::vecto
if (isActiveState())
load();
} else if (evt.type == SDL_MOUSEBUTTONDOWN) {
- if (!clicked) {
- manageClick();
- clicked = true;
- }
+ clicked = true;
}
}
+
+ if (clicked)
+ manageClick();
easy3d::Controller::handleEvent(_events);
}
--- a/easy3d/easy3d_planet_animation.cpp Wed Jun 18 09:31:50 2008 +0200
+++ b/easy3d/easy3d_planet_animation.cpp Wed Jun 18 09:32:07 2008 +0200
@@ -78,6 +78,16 @@ void PlanetItemTextAnimated::setTextureI
mIcon->setTexture(texture);
}
+void PlanetItemTextAnimated::setTextColor(const osg::Vec4 &color)
+{
+ mTextColor = color;
+}
+
+void PlanetItemTextAnimated::setTextSelectedColor(const osg::Vec4 &color)
+{
+ mTextColorSelected = color;
+}
+
void PlanetItemTextAnimated::loadSettings()
{
mTextAnimationTransitionIn.load("planet_","text_transition_in");
--- a/easy3d/easy3d_planet_animation.h Wed Jun 18 09:31:50 2008 +0200
+++ b/easy3d/easy3d_planet_animation.h Wed Jun 18 09:32:07 2008 +0200
@@ -62,6 +62,8 @@ public:
PlanetItemTextAnimated() {}
void setTextureIcon(const std::string& texturename);
void setPosition(const osg::Vec3& src);
+ void setTextColor(const osg::Vec4& color);
+ void setTextSelectedColor(const osg::Vec4& color);
const osg::Vec3& getPosition() const;
void update(float dt);
void loadSettings();
--- a/easy3d/easy3d_universe.cpp Wed Jun 18 09:31:50 2008 +0200
+++ b/easy3d/easy3d_universe.cpp Wed Jun 18 09:32:07 2008 +0200
@@ -33,6 +33,7 @@
#include "easy3d_background.h"
#include "easy3d_item.h"
+#include "utils.h"
#include <osg/BlendFunc>
#include <osg/Math>
@@ -111,13 +112,13 @@ void SceneUniverse::load()
float currentRatio = osg::Renderer::instance()->getViewport()->aspectRatio();
float screenBaseRatio = 5/4.0;
- VarsEditor::instance()->get("screen_base_ratio",screenBaseRatio);
+ VarsEditor::instance()->get("screen_base_ratio", screenBaseRatio);
float screenRatioConvert = currentRatio / screenBaseRatio;
- int maxCube = 0;
+ unsigned int maxCube = 0;
for (unsigned int i = 0; i < LoadUniverse::instance()->galaxyVector.size(); i++) {
- if (LoadUniverse::instance()->galaxyVector[i]->hidden == false)
- maxCube++;
+ if (LoadUniverse::instance()->galaxyVector[i]->hidden == false)
+ maxCube++;
}
mTransform = new osg::MatrixTransform;
@@ -143,33 +144,45 @@ void SceneUniverse::load()
// add the "cliquer" text on cube
osg::MatrixTransform* transformText = createTextSelectedItem("universe_");
- for (int i = 0; i < maxCube; i++) {
- if (LoadUniverse::instance()->galaxyVector[i]->hidden)
- continue;
-
- mCubeSet->setIconTexture(i, LoadUniverse::instance()->galaxyVector[i]->icon_filename);
-
- // one item
- mItems[i].create();
-
- mItems[i].getAnimationIdleTransform()->addChild(mCubeSet->getGeode(i));
- mTransform->addChild(mItems[i].getRootTransform());
-
- if (transformText)
- mItems[i].getAnimationIdleTransform()->addChild(transformText);
-
-
- mItems[i].setIndex(i);
- mItems[i].loadSettings();
-
- 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));
+ for (unsigned int i = 0; i < maxCube; i++) {
+
+ Galaxy *galaxy = LoadUniverse::instance()->galaxyVector[i];
+
+ if (galaxy->hidden)
+ continue;
+
+ mCubeSet->setIconTexture(i, galaxy->icon_filename);
+
+ // one item
+ mItems[i].create();
+
+ mItems[i].getAnimationIdleTransform()->addChild(mCubeSet->getGeode(i));
+ mTransform->addChild(mItems[i].getRootTransform());
+
+ if (transformText)
+ mItems[i].getAnimationIdleTransform()->addChild(transformText);
+
+
+ mItems[i].setIndex(i);
+ mItems[i].loadSettings();
+
+ mItems[i].getText()->setAlignment(osgText::Text::CENTER_CENTER);
+ mItems[i].getText()->setText(galaxy->name, osgText::String::ENCODING_UTF8);
+
+ osg::Vec3 pos;
+ if (galaxy->position)
+ {
+ trace("Using position from the easyneuf.xml\n");
+ pos = *galaxy->position;
+ }
+ else
+ {
+ trace("Using position from the easy3d.xml\n");
+ std::string xmlnode_string = "universe_pos_icone_" + galaxy->id;
+ VarsEditor::instance()->get(xmlnode_string, pos);
+ }
+ pos[0] *= screenRatioConvert;
+ mItems[i].getRootTransform()->setMatrix(osg::Matrix::translate(pos));
initItemTransitionPosition(i);
}
@@ -348,27 +361,60 @@ void SceneUniverse::ManageClick()
float currentRatio = osg::Renderer::instance()->getViewport()->aspectRatio();
float screenBaseRatio = 5/4.0;
- VarsEditor::instance()->get("screen_base_ratio",screenBaseRatio);
+ VarsEditor::instance()->get("screen_base_ratio", screenBaseRatio);
float ratio = currentRatio / screenBaseRatio;
- dest[0] *= ratio;
- mCubeDiffuseDestination = osg::Vec4(1,1,1,1);
- VarsEditor::instance()->get("galaxy_cube_diffuse_"+LoadUniverse::instance()->galaxyVector[mSelectedGalaxy]->id, mCubeDiffuseDestination);
-
- osg::Vec3 currentPos = mItems[focus].getRootTransform()->getMatrix().getTrans();
- std::cout << "mCubeDiffuseDestination " << mCubeDiffuseDestination << std::endl;
-
- dest = dest-currentPos;
- mItems[focus].setTransitionOutPositionDestination(dest);
-
- // sent events
Galaxy *galaxy = LoadUniverse::instance()->galaxyVector[mSelectedGalaxy];
- Easy3dEvents::pushEventBackgroundFadeTo(galaxy->bg_filename, galaxy->name);
-
- float idle1, idle2;
- idle1 = idle2 = 0;
- mItems[mSelectedGalaxy].getTimeOfIdleAnimation(idle1, idle2);
- Easy3dEvents::pushEventUniverseExitWanted(idle1, idle2, getSelectedGalaxy());
+
+ if (galaxy->planetVector.size() == 1)
+ {
+ EASY3D_ASSERT(mSelectedGalaxy >= 0 && mSelectedGalaxy < (int)LoadUniverse::instance()->galaxyVector.size());
+ Planet* plt = LoadUniverse::instance()->galaxyVector[mSelectedGalaxy]->planetVector[0];
+
+ if (plt->satelliteVector.size() == 1)
+ {
+ // Selected galaxy has only one planet which has only one satellite
+ if (plt->satelliteVector[0]->isGoto())
+ {
+ // Do nothing for the moment
+ }
+ else
+ {
+ // Launch the satellite command
+ AppLaunch::instance()->registerToLaunch(plt->satelliteVector[0]->command_type, plt->satelliteVector[0]->command);
+ pushUserEvent(CUSTOM_EVENT_APPLICATION_START);
+ pushUserEvent(CUSTOM_EVENT_FADEBLACK_IN);
+ }
+ }
+ }
+ else
+ {
+
+ dest[0] *= ratio;
+
+ if (galaxy->color)
+ {
+ mCubeDiffuseDestination = osg::Vec4(*galaxy->color);
+ }
+ else
+ {
+ mCubeDiffuseDestination = osg::Vec4(1,1,1,1);
+ VarsEditor::instance()->get("galaxy_cube_diffuse_" + galaxy->id, mCubeDiffuseDestination);
+ }
+
+ osg::Vec3 currentPos = mItems[focus].getRootTransform()->getMatrix().getTrans();
+
+ dest = dest-currentPos;
+ mItems[focus].setTransitionOutPositionDestination(dest);
+
+ // sent events
+ Easy3dEvents::pushEventBackgroundFadeTo(galaxy->bg_filename, galaxy->name);
+
+ float idle1, idle2;
+ idle1 = idle2 = 0;
+ mItems[mSelectedGalaxy].getTimeOfIdleAnimation(idle1, idle2);
+ Easy3dEvents::pushEventUniverseExitWanted(idle1, idle2, getSelectedGalaxy());
+ }
}
void SceneUniverse::handleEvent(std::vector<SDL_Event>& _events)
--- a/easy3d/load_universe.cpp Wed Jun 18 09:31:50 2008 +0200
+++ b/easy3d/load_universe.cpp Wed Jun 18 09:32:07 2008 +0200
@@ -33,6 +33,41 @@
#include <libxml/xmlreader.h>
#include "utils.h"
+/*
+ * From an xml node @xml_node read the property @attribute_name, and convert the value into
+ * a color (really osg::Vec4)
+ *
+ * @param xml_node
+ * @param attribute_name
+ *
+ * @return NULL if the value can't be converted
+ * a new allocated osg::Vec4 that contains the color
+ */
+static osg::Vec4 *
+xml_get_color_from_xml_node(xmlNodePtr xml_node, const char *attribute_name)
+{
+ xmlChar *value;
+ float r, g, b, a;
+ osg::Vec4 *color = NULL;
+
+ value = xmlGetProp(xml_node,(const xmlChar *)attribute_name);
+ if (value == NULL)
+ return color;
+
+ if (sscanf((const char *)value, "Vec4 %f %f %f %f", &r, &g, &b, &a) == 4) {
+ color = new osg::Vec4(r, g, b, a);
+ } else {
+ error("Bad color value for %s=\"%s\"\n", attribute_name, (char *)value);
+ }
+
+ xmlFree(value);
+
+ return color;
+}
+
+
+
+
LoadUniverse* LoadUniverse::instance(bool erase)
{
static osg::ref_ptr<LoadUniverse> s_loadUniverse = new LoadUniverse;
@@ -45,13 +80,24 @@ bool Satellite::isUrl() { return comman
bool Satellite::isUrl() { return command_type == AppLaunch::APPLAUNCH_URL; }
bool Satellite::isGoto() { return !go_to.empty(); }
-Satellite::Satellite() {}
+Satellite::Satellite() {
+ text_color = NULL;
+ text_color_when_selected = NULL;
+}
+
Planet::Planet() {}
-Galaxy::Galaxy() { hidden = false; }
+
+Galaxy::Galaxy() {
+ hidden = false;
+ position = NULL;
+ color = NULL;
+ color_when_blended = NULL;
+ text_color = NULL;
+ text_color_when_selected = NULL;
+}
Satellite* LoadUniverse::loadSatellite(xmlDocPtr doc, xmlNodePtr cur) {
- xmlChar *type;
xmlChar *value;
Satellite* satellite = new Satellite();
@@ -79,19 +125,19 @@ Satellite* LoadUniverse::loadSatellite(x
}
- type = xmlGetProp(cur,(const xmlChar *)"type");
- if (type != NULL) {
- if ((!xmlStrcmp(type, (const xmlChar *)"url")) && xmlHasProp(cur,(const xmlChar *)"a")) {
+ value = xmlGetProp(cur,(const xmlChar *)"type");
+ if (value != NULL) {
+ if ((!xmlStrcmp(value, (const xmlChar *)"url")) && xmlHasProp(cur,(const xmlChar *)"a")) {
satellite->command_type = AppLaunch::APPLAUNCH_URL;
satellite->command = std::string((char*)xmlGetProp(cur,(const xmlChar *)"a"));
- } else if ((!xmlStrcmp(type, (const xmlChar *)"command")) && (xmlHasProp(cur,(const xmlChar *)"command") != NULL)) {
+ } else if ((!xmlStrcmp(value, (const xmlChar *)"command")) && (xmlHasProp(cur,(const xmlChar *)"command") != NULL)) {
satellite->command_type = AppLaunch::APPLAUNCH_EXE;
satellite->command = std::string((char*)xmlGetProp(cur,(const xmlChar *)"command"));
- } else if ((!xmlStrcmp(type, (const xmlChar *)"go")) && (xmlHasProp(cur,(const xmlChar *)"to") != NULL)) {
+ } else if ((!xmlStrcmp(value, (const xmlChar *)"go")) && (xmlHasProp(cur,(const xmlChar *)"to") != NULL)) {
satellite->go_to = std::string((char*)xmlGetProp(cur,(const xmlChar *)"to"));
@@ -100,8 +146,11 @@ Satellite* LoadUniverse::loadSatellite(x
std::cerr << "Bad planet description for " << satellite->name << std::endl;
}
- xmlFree(type);
- }
+ xmlFree(value);
+ }
+
+ satellite->text_color = xml_get_color_from_xml_node(cur, "text_color");
+ satellite->text_color_when_selected = xml_get_color_from_xml_node(cur, "text_color_when_selected");
return satellite;
}
@@ -219,6 +268,26 @@ 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);
+ }
+
+ galaxy->color = xml_get_color_from_xml_node(cur, "color");
+ galaxy->color_when_blended = xml_get_color_from_xml_node(cur, "color_when_blended");
+ galaxy->text_color = xml_get_color_from_xml_node(cur, "text_color");
+ galaxy->text_color_when_selected = xml_get_color_from_xml_node(cur, "text_color_when_blended");
+
+
cur = cur->xmlChildrenNode;
while (cur != NULL) {
--- a/easy3d/load_universe.h Wed Jun 18 09:31:50 2008 +0200
+++ b/easy3d/load_universe.h Wed Jun 18 09:32:07 2008 +0200
@@ -24,6 +24,7 @@
#include <string>
#include <vector>
#include <osg/Referenced>
+#include <osg/Geode>
#include <libxml/xmlmemory.h>
#include <libxml/parser.h>
@@ -38,6 +39,9 @@ public:
std::string go_to; // name of the galaxy to jump into
std::string icon_filename; // texture used as "satellite icon"
AppLaunch::AppLaunchType command_type; // type of the satellite (url or application)
+
+ osg::Vec4 *text_color;
+ osg::Vec4 *text_color_when_selected;
bool isCommand();
bool isUrl();
@@ -66,6 +70,11 @@ 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;
+ osg::Vec4 *text_color;
+ osg::Vec4 *text_color_when_selected;
bool hidden; // set to true if the galaxy must no be show
Galaxy();