|
From: <br...@us...> - 2009-04-27 14:48:48
|
Revision: 3896
http://openvrml.svn.sourceforge.net/openvrml/?rev=3896&view=rev
Author: braden
Date: 2009-04-27 14:48:40 +0000 (Mon, 27 Apr 2009)
Log Message:
-----------
Override do_modified for background_node; set the initial value of the url field for the subordinate image_texture_nodes.
Modified Paths:
--------------
trunk/ChangeLog
trunk/src/libopenvrml/openvrml/viewer.cpp
trunk/src/libopenvrml/openvrml/viewer.h
trunk/src/libopenvrml-gl/openvrml/gl/viewer.cpp
trunk/src/libopenvrml-gl/openvrml/gl/viewer.h
trunk/src/node/vrml97/background.cpp
trunk/src/node/vrml97/background.h
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2009-04-27 05:31:07 UTC (rev 3895)
+++ trunk/ChangeLog 2009-04-27 14:48:40 UTC (rev 3896)
@@ -1,5 +1,31 @@
2009-04-27 Braden McDaniel <br...@en...>
+ Override do_modified for background_node; set the initial value of
+ the url field for the subordinate image_texture_nodes.
+
+ * src/libopenvrml/openvrml/viewer.cpp: Changed insert_background
+ to take nonconst texture_nodes.
+ * src/libopenvrml/openvrml/viewer.h: Changed insert_background to
+ take nonconst texture_nodes.
+ * src/libopenvrml-gl/openvrml/gl/viewer.cpp: Changed
+ insert_background to take nonconst texture_nodes; always call
+ render_texture on the texture_nodes in order to trigger
+ downloading the image.
+ * src/libopenvrml-gl/openvrml/gl/viewer.h: Changed
+ insert_background to take nonconst texture_nodes.
+ * src/node/vrml97/background.cpp
+ (openvrml_node_vrml97::background_metatype::do_render(openvrml::viewer&)
+ const): Made static null_texture_nodes nonconst.
+ (openvrml_node_vrml97::background_node::do_initialize(double)):
+ Set the initial value for the "url" fields of the subordinate
+ image_texture_nodes.
+ (openvrml_node_vrml97::background_node::do_modified() const):
+ Check the modified flags of the subordinate image_texture_nodes.
+ * src/node/vrml97/background.h
+ (openvrml_node_vrml97::background_node): Override do_modified.
+
+2009-04-27 Braden McDaniel <br...@en...>
+
* src/node/vrml97/image_texture.cpp
(image_texture_node::do_render_texture(openvrml::viewer & v)):
openvrml::viewer::insert_texture no longer returns a value.
Modified: trunk/src/libopenvrml/openvrml/viewer.cpp
===================================================================
--- trunk/src/libopenvrml/openvrml/viewer.cpp 2009-04-27 05:31:07 UTC (rev 3895)
+++ trunk/src/libopenvrml/openvrml/viewer.cpp 2009-04-27 14:48:40 UTC (rev 3896)
@@ -246,12 +246,12 @@
const std::vector<color> & ground_color,
const std::vector<float> & sky_angle,
const std::vector<color> & sky_color,
- const texture_node & front,
- const texture_node & back,
- const texture_node & left,
- const texture_node & right,
- const texture_node & top,
- const texture_node & bottom)
+ texture_node & front,
+ texture_node & back,
+ texture_node & left,
+ texture_node & right,
+ texture_node & top,
+ texture_node & bottom)
{
return this->do_insert_background(ground_angle, ground_color,
sky_angle, sky_color,
@@ -259,7 +259,7 @@
}
/**
- * @fn void openvrml::viewer::do_insert_background(const std::vector<float> & ground_angle, const std::vector<color> & ground_color, const std::vector<float> & sky_angle, const std::vector<color> & sky_color, const texture_node & front, const texture_node & back, const texture_node & left, const texture_node & right, const texture_node & top, const texture_node & bottom)
+ * @fn void openvrml::viewer::do_insert_background(const std::vector<float> & ground_angle, const std::vector<color> & ground_color, const std::vector<float> & sky_angle, const std::vector<color> & sky_color, texture_node & front, texture_node & back, texture_node & left, texture_node & right, texture_node & top, texture_node & bottom)
*
* @brief Insert a background into a display list.
*
Modified: trunk/src/libopenvrml/openvrml/viewer.h
===================================================================
--- trunk/src/libopenvrml/openvrml/viewer.h 2009-04-27 05:31:07 UTC (rev 3895)
+++ trunk/src/libopenvrml/openvrml/viewer.h 2009-04-27 14:48:40 UTC (rev 3896)
@@ -74,12 +74,12 @@
const std::vector<color> & ground_color,
const std::vector<float> & sky_angle,
const std::vector<color> & sky_color,
- const texture_node & front,
- const texture_node & back,
- const texture_node & left,
- const texture_node & right,
- const texture_node & top,
- const texture_node & bottom);
+ texture_node & front,
+ texture_node & back,
+ texture_node & left,
+ texture_node & right,
+ texture_node & top,
+ texture_node & bottom);
void insert_box(const geometry_node & n, const vec3f & size);
void insert_cone(const geometry_node & n,
@@ -220,12 +220,12 @@
const std::vector<color> & ground_color,
const std::vector<float> & sky_angle,
const std::vector<color> & sky_color,
- const texture_node & front,
- const texture_node & back,
- const texture_node & left,
- const texture_node & right,
- const texture_node & top,
- const texture_node & bottom) = 0;
+ texture_node & front,
+ texture_node & back,
+ texture_node & left,
+ texture_node & right,
+ texture_node & top,
+ texture_node & bottom) = 0;
virtual
void do_insert_box(const geometry_node & n, const vec3f & size) = 0;
Modified: trunk/src/libopenvrml-gl/openvrml/gl/viewer.cpp
===================================================================
--- trunk/src/libopenvrml-gl/openvrml/gl/viewer.cpp 2009-04-27 05:31:07 UTC (rev 3895)
+++ trunk/src/libopenvrml-gl/openvrml/gl/viewer.cpp 2009-04-27 14:48:40 UTC (rev 3896)
@@ -1012,6 +1012,7 @@
const GLubyte * const error_str = gluErrorString(glerr);
const GLubyte * end;
for (end = error_str; *end; ++end) {}
+ boost::ignore_unused_variable_warning(s);
OPENVRML_GL_PRINT_MESSAGE_("GL ERROR: " + s + " "
+ std::string(error_str, end));
}
@@ -1172,13 +1173,14 @@
const std::vector<color> & groundColor,
const std::vector<float> & skyAngle,
const std::vector<color> & skyColor,
- const texture_node & front,
- const texture_node & back,
- const texture_node & left,
- const texture_node & right,
- const texture_node & top,
- const texture_node & bottom)
+ texture_node & front,
+ texture_node & back,
+ texture_node & left,
+ texture_node & right,
+ texture_node & top,
+ texture_node & bottom)
{
+ std::cout << "do_insert_background" << std::endl;
using std::vector;
float r = 0.0, g = 0.0, b = 0.0, a = 1.0;
@@ -1216,15 +1218,7 @@
glClear(mask);
// Draw the background as big spheres centered at the view position
- if (!this->select_mode
- && (!skyAngle.empty()
- || !groundAngle.empty()
- || !front.image().array().empty()
- || !back.image().array().empty()
- || !left.image().array().empty()
- || !right.image().array().empty()
- || !top.image().array().empty()
- || !bottom.image().array().empty())) {
+ if (!this->select_mode && (!skyAngle.empty() || !groundAngle.empty())) {
glDisable(GL_DEPTH_TEST);
glDisable(GL_LIGHTING);
@@ -1331,10 +1325,8 @@
glEnable(GL_TEXTURE_2D);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
- static const bool retain = true;
-
+ front.render_texture(*this);
if (!front.image().array().empty()) {
- this->insert_texture(front, retain);
glBegin(GL_QUADS);
glTexCoord2f(0, 0);
glVertex3f(-1, -1, -1);
@@ -1346,8 +1338,8 @@
glVertex3f(-1, 1, -1);
glEnd(); // GL_QUADS
}
+ back.render_texture(*this);
if (!back.image().array().empty()) {
- this->insert_texture(back, retain);
glBegin(GL_QUADS);
glTexCoord2f(0, 0);
glVertex3f(1, -1, 1);
@@ -1359,8 +1351,8 @@
glVertex3f(1, 1, 1);
glEnd(); // GL_QUADS
}
+ left.render_texture(*this);
if (!left.image().array().empty()) {
- this->insert_texture(left, retain);
glBegin(GL_QUADS);
glTexCoord2f(0, 0);
glVertex3f(-1, -1, 1);
@@ -1372,8 +1364,8 @@
glVertex3f(-1, 1, 1);
glEnd(); // GL_QUADS
}
+ right.render_texture(*this);
if (!right.image().array().empty()) {
- this->insert_texture(right, retain);
glBegin(GL_QUADS);
glTexCoord2f(0, 0);
glVertex3f(1, -1, -1);
@@ -1385,8 +1377,8 @@
glVertex3f(1, 1, -1);
glEnd(); // GL_QUADS
}
+ top.render_texture(*this);
if (!top.image().array().empty()) {
- this->insert_texture(top, retain);
glBegin(GL_QUADS);
glTexCoord2f(0, 0);
glVertex3f(-1, 1, -1);
@@ -1398,8 +1390,8 @@
glVertex3f(-1, 1, 1);
glEnd(); // GL_QUADS
}
+ bottom.render_texture(*this);
if (!bottom.image().array().empty()) {
- this->insert_texture(bottom, retain);
glBegin(GL_QUADS);
glTexCoord2f(0, 0);
glVertex3f(-1, -1, 1);
Modified: trunk/src/libopenvrml-gl/openvrml/gl/viewer.h
===================================================================
--- trunk/src/libopenvrml-gl/openvrml/gl/viewer.h 2009-04-27 05:31:07 UTC (rev 3895)
+++ trunk/src/libopenvrml-gl/openvrml/gl/viewer.h 2009-04-27 14:48:40 UTC (rev 3896)
@@ -205,12 +205,12 @@
const std::vector<color> & groundColor,
const std::vector<float> & skyAngle,
const std::vector<color> & skyColor,
- const texture_node & front,
- const texture_node & back,
- const texture_node & left,
- const texture_node & right,
- const texture_node & top,
- const texture_node & bottom);
+ texture_node & front,
+ texture_node & back,
+ texture_node & left,
+ texture_node & right,
+ texture_node & top,
+ texture_node & bottom);
virtual void do_insert_box(const geometry_node & n,
Modified: trunk/src/node/vrml97/background.cpp
===================================================================
--- trunk/src/node/vrml97/background.cpp 2009-04-27 05:31:07 UTC (rev 3895)
+++ trunk/src/node/vrml97/background.cpp 2009-04-27 14:48:40 UTC (rev 3896)
@@ -21,7 +21,6 @@
//
# include "background.h"
-# include "image_stream_listener.h"
# include <openvrml/browser.h>
# include <openvrml/scene.h>
# include <openvrml/scope.h>
@@ -249,12 +248,12 @@
static const vector<color> ground_color;
static const vector<float> sky_angle;
static const vector<color> sky_color;
- static const null_texture_node front(this->null_texture_node_type_);
- static const null_texture_node back(this->null_texture_node_type_);
- static const null_texture_node left(this->null_texture_node_type_);
- static const null_texture_node right(this->null_texture_node_type_);
- static const null_texture_node top(this->null_texture_node_type_);
- static const null_texture_node bottom(this->null_texture_node_type_);
+ static null_texture_node front(this->null_texture_node_type_);
+ static null_texture_node back(this->null_texture_node_type_);
+ static null_texture_node left(this->null_texture_node_type_);
+ static null_texture_node right(this->null_texture_node_type_);
+ static null_texture_node top(this->null_texture_node_type_);
+ static null_texture_node bottom(this->null_texture_node_type_);
v.insert_background(ground_angle, ground_color,
sky_angle, sky_color,
front, back,
@@ -271,10 +270,10 @@
v.remove_object(background);
}
- v.insert_background(background.ground_angle_.mffloat::value(),
- background.ground_color_.mfcolor::value(),
- background.sky_angle_.mffloat::value(),
- background.sky_color_.mfcolor::value(),
+ v.insert_background(background.ground_angle_.value(),
+ background.ground_color_.value(),
+ background.sky_angle_.value(),
+ background.sky_color_.value(),
*background.front,
*background.back,
*background.left,
@@ -755,14 +754,42 @@
node::emit_event(this->is_bound_emitter_, timestamp);
}
+namespace {
+ OPENVRML_LOCAL void set_url(openvrml::node & n,
+ const openvrml::mfstring & url,
+ const double timestamp)
+ OPENVRML_NOTHROW
+ {
+ using openvrml::mfstring;
+ using openvrml::mfstring_listener;
+ mfstring_listener & listener = n.event_listener<mfstring>("url");
+ listener.process_event(url, timestamp);
+ }
+}
+
/**
* @brief Initialize.
*
* @param timestamp the current time.
*/
-void openvrml_node_vrml97::background_node::do_initialize(double)
+void
+openvrml_node_vrml97::background_node::do_initialize(const double timestamp)
OPENVRML_NOTHROW
{
+ set_url(*this->front, this->front_url_, timestamp);
+ set_url(*this->back, this->back_url_, timestamp);
+ set_url(*this->left, this->left_url_, timestamp);
+ set_url(*this->right, this->right_url_, timestamp);
+ set_url(*this->top, this->top_url_, timestamp);
+ set_url(*this->bottom, this->bottom_url_, timestamp);
+
+ this->front->initialize(*this->scene(), timestamp);
+ this->back->initialize(*this->scene(), timestamp);
+ this->left->initialize(*this->scene(), timestamp);
+ this->right->initialize(*this->scene(), timestamp);
+ this->top->initialize(*this->scene(), timestamp);
+ this->bottom->initialize(*this->scene(), timestamp);
+
using boost::polymorphic_downcast;
background_metatype & nodeClass =
const_cast<background_metatype &>(
@@ -791,6 +818,17 @@
if (node_metatype.is_first(*this)) { node_metatype.reset_first(); }
}
+bool openvrml_node_vrml97::background_node::do_modified() const
+ OPENVRML_THROW1(boost::thread_resource_error)
+{
+ return (this->front && this->front->modified())
+ || (this->back && this->back->modified())
+ || (this->left && this->left->modified())
+ || (this->right && this->right->modified())
+ || (this->top && this->top->modified())
+ || (this->bottom && this->bottom->modified());
+}
+
namespace {
const boost::shared_ptr<openvrml::scope> null_scope_ptr;
Modified: trunk/src/node/vrml97/background.h
===================================================================
--- trunk/src/node/vrml97/background.h 2009-04-27 05:31:07 UTC (rev 3895)
+++ trunk/src/node/vrml97/background.h 2009-04-27 14:48:40 UTC (rev 3896)
@@ -110,5 +110,7 @@
private:
virtual void do_initialize(double timestamp) OPENVRML_NOTHROW;
virtual void do_shutdown(double timestamp) OPENVRML_NOTHROW;
+ virtual bool do_modified() const
+ OPENVRML_THROW1(boost::thread_resource_error);
};
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|