Re: [osg-users] Get A line on the terrain surrface at current lod level
Hi David and Robert, I have not followed this discussion, but have recently been working on something similar myself other software. Would it not be advantagous to have a callback function as part of the terrain LOD block, so that each time there is a change of LOD, the terrain block is updated, and calls a callback object to update its elevations / vertices? Also the callback object will have to be moved to the correct LOD block. Erlend. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Robert Osfield Sent: 23. juni 2008 10:05 To: OpenSceneGraph Users Subject: Re: [osg-users] Get A line on the terrain surrface at current lod level Hi Davd, ElevationSlice is designed to extract the high res level. Selecting the elevations that are on screen would require a visitor that makes LOD decisions based on a view frustum - this could be written - a variation/tweaks of the osgUtil::IntersectionVisitor for instance. You are welcome to dive in a code such a solution. Robert. On Mon, Jun 23, 2008 at 3:09 AM, ZHMW [EMAIL PROTECTED] wrote: Hi everyone. I want a line on the terrain surface, while my terrain data is a paged lod database. when I use osgSim::ElevationSlice, The visitor(osgUtil::IntersectionVisitor) always go to the max valid level of the terrain detail. so when i draw the line of ElevationSlice's result, the line is not exactly on the surface of terrain. Is there any visitor like cullvisitor can go to current valid lod level? and then I can draw the ElevationSlice's result line on the surface always. best wishes. zhmw ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] SceneView error
When I call sceneViewer-cull() first it works like a charm.. But should I have to? From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] Sent: 8. april 2008 13:51 To: osg-users@lists.openscenegraph.org Subject: [osg-users] SceneView error I try to use OpenSceneGraph and SceneView as shown in example when using an existing renderer, but get an error when calling SceneView-draw() or more spesific in _localStateSet-setAttribute(getViewport()); The example code I use is as following: int CMapRenderThread::InitOpenSceneGraph() { root = new osg::Group; pyramidGeode = new osg::Geode; pyramidGeometry = new osg::Geometry; // Associate the pyramid geometry with the pyramid geode // Add the pyramid geode to the root node of the scene graph. pyramidGeode-addDrawable(pyramidGeometry); root-addChild(pyramidGeode); // Declare an array of vertices. osg::Vec3Array* pyramidVertices = new osg::Vec3Array; pyramidVertices-push_back( osg::Vec3( 0, 0, 0) ); // front left pyramidVertices-push_back( osg::Vec3(10, 0, 0) ); // front right pyramidVertices-push_back( osg::Vec3(10,10, 0) ); // back right pyramidVertices-push_back( osg::Vec3( 0,10, 0) ); // back left pyramidVertices-push_back( osg::Vec3( 5, 5,10) ); // peak pyramidGeometry-setVertexArray( pyramidVertices ); // Create a primitive set and add it to the pyramid geometry. osg::DrawElementsUInt* pyramidBase = new osg::DrawElementsUInt(osg::PrimitiveSet::QUADS, 0); pyramidBase-push_back(3); pyramidBase-push_back(2); pyramidBase-push_back(1); pyramidBase-push_back(0); pyramidGeometry-addPrimitiveSet(pyramidBase); // Repeat the same for each of the four sides. Again, vertices are // specified in counter-clockwise order. osg::DrawElementsUInt* pyramidFaceOne = new osg::DrawElementsUInt(osg::PrimitiveSet::TRIANGLES, 0); pyramidFaceOne-push_back(0); pyramidFaceOne-push_back(1); pyramidFaceOne-push_back(4); pyramidGeometry-addPrimitiveSet(pyramidFaceOne); osg::DrawElementsUInt* pyramidFaceTwo = new osg::DrawElementsUInt(osg::PrimitiveSet::TRIANGLES, 0); pyramidFaceTwo-push_back(1); pyramidFaceTwo-push_back(2); pyramidFaceTwo-push_back(4); pyramidGeometry-addPrimitiveSet(pyramidFaceTwo); osg::DrawElementsUInt* pyramidFaceThree = new osg::DrawElementsUInt(osg::PrimitiveSet::TRIANGLES, 0); pyramidFaceThree-push_back(2); pyramidFaceThree-push_back(3); pyramidFaceThree-push_back(4); pyramidGeometry-addPrimitiveSet(pyramidFaceThree); osg::DrawElementsUInt* pyramidFaceFour = new osg::DrawElementsUInt(osg::PrimitiveSet::TRIANGLES, 0); pyramidFaceFour-push_back(3); pyramidFaceFour-push_back(0); pyramidFaceFour-push_back(4); pyramidGeometry-addPrimitiveSet(pyramidFaceFour); // Declare and load an array of Vec4 elements to store colors. osg::Vec4Array* colors = new osg::Vec4Array; colors-push_back(osg::Vec4(1.0f, 0.0f, 0.0f, 1.0f) ); //index 0 red colors-push_back(osg::Vec4(0.0f, 1.0f, 0.0f, 1.0f) ); //index 1 green colors-push_back(osg::Vec4(0.0f, 0.0f, 1.0f, 1.0f) ); //index 2 blue colors-push_back(osg::Vec4(1.0f, 1.0f, 1.0f, 1.0f) ); //index 3 white // Declare the variable that will match vertex array elements to color // array elements. osg::TemplateIndexArrayunsigned int, osg::Array::UIntArrayType,4,4 *colorIndexArray; colorIndexArray = new osg::TemplateIndexArrayunsigned int, osg::Array::UIntArrayType,4,4; colorIndexArray-push_back(0); // vertex 0 assigned color array element 0 colorIndexArray-push_back(1); // vertex 1 assigned color array element 1 colorIndexArray-push_back(2); // vertex 2 assigned color array element 2 colorIndexArray-push_back(3); // vertex 3 assigned color array element 3 colorIndexArray-push_back(0); // vertex 4 assigned color array element 0 // The next step is to associate the array of colors with the geometry, // assign the color indices created above to the geometry and set the // binding mode to BIND_PER_VERTEX. pyramidGeometry-setColorArray(colors); pyramidGeometry-setColorIndices(colorIndexArray); pyramidGeometry-setColorBinding(osg::Geometry::BIND_PER_VERTEX); // Declare and initialize a transform node. pyramidTwoXForm = new osg::PositionAttitudeTransform; // Use the 'addChild' method of the osg::Group class to // add the transform as a child of the root node and the // pyramid node as a child of the transform. root-addChild(pyramidTwoXForm); pyramidTwoXForm-addChild(pyramidGeode); // Declare and initialize a Vec3 instance to change the // position of the model in the scene //m_pRenderer- //double x,y,z; //LatLonAltToXYZ(61.0,
[osg-users] update example
It would be usefull i think if anyone would post some examples / doc on how to update textures images and geometry using osg in real time, since I (and probably others) have had problems with this. I can't still figure this out and therefore had to stop using osg for now. Erlend ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] osg::Vec3Array _dataSize
Why is the _dataSize used? Shouldn't the size of the std vector be used instead?? If i want to update the vertex array the _dataSize is not changed SET ANYWERE except in the constructor, but i think it's used by primitive_set and geometry for rendering... Erlend ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] osg::Vec3Array _dataSize
My bad.. Data size is size of vector.. (Vec3 == 3).. Still have problems updating geometry though, even though im doing this after update(maybe a little overkill..) and also try to create a new VecArray.. _drawArrays-dirty(); _vertices-dirty(); _line-setPrimitiveSet(0,_drawArrays.get()); _line-setVertexArray(_vertices.get()); _line-dirtyDisplayList(); _line-dirtyBound(); _lineGeode-setDrawable(0, _line.get()); _lineGeode-dirtyBound(); dirtyBound(); I guess The error lies somewhere else.. From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] Sent: 2. mai 2008 13:28 To: osg-users@lists.openscenegraph.org Subject: [osg-users] osg::Vec3Array _dataSize Why is the _dataSize used? Shouldn't the size of the std vector be used instead?? If i want to update the vertex array the _dataSize is not changed SET ANYWERE except in the constructor, but i think it's used by primitive_set and geometry for rendering... Erlend ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] error when updating geometry data when adding points to a Vec3Array
I want to draw a line, and to update this line with more points. Now i render the line, but as soon I do a update which changes the vertices size the line dissapears. please submit an example / suggestions if anyone have, before im going totally nuts! :) PS. 1. Im doing the update via a callback ( in the frame() traversal) 2. Also all osg objects are set to DYNAMIC 3. and the positions are correct 4. i use osg 2.4.0 on vista 5. i use SceneViewer in an Embedded window to render My code is something like this: MyClass : public Group { osg::ref_ptrosg::Geode _lineGeode; osg::ref_ptrosg::Geometry_line; osg::ref_ptrosg::DrawArrays _drawArrays; osg::ref_ptrosg::Vec3Array _vertices; osg::ref_ptrosg::StateSet_lineStateSet; MyClass() // INIT My Osg variables { // stateset attributes _lineStateSet = new osg::StateSet; _lineStateSet-setDataVariance(osg::Object::DYNAMIC); // create line primitive _vertices = new osg::Vec3Array; _vertices-setDataVariance(osg::Object::DYNAMIC); _line = new osg::Geometry; _line-setDataVariance(osg::Object::DYNAMIC); _line-setVertexArray(_vertices.get()); _line-setStateSet(_lineStateSet.get()); //_line-setUseDisplayList(false); //_line-setUseVertexBufferObjects(false); _drawArrays = new osg::DrawArrays; _drawArrays-setDataVariance(osg::Object::DYNAMIC); _line-addPrimitiveSet(_drawArrays.get()); _lineGeode = new osg::Geode; _lineGeode-setDataVariance(osg::Object::DYNAMIC); _lineGeode-addDrawable(_line.get()); addChild(_lineGeode.get()); } Update() { //_vertices-clear(); // TRIED THIS FIRST _vertices = new osg::Vec3Array(_size); _vertices-setDataVariance(osg::Object::DYNAMIC); double x,y,z; for(int i=0; i_size; i++) { MyGet(x,y,z); //_vertices-push_back(osg::Vec3((float)x,(float)y,(float)z); (*_vertices)[i].set((float)x,(float)y,(float)z); } _drawArrays-set(osg::PrimitiveSet::LINE_STRIP, 0, _size); // PS HAVE TRIED LOT OF DIFFERENT VARIATIONS OF THESE _drawArrays-dirty(); _line-setVertexArray(_vertices.get()); _line-setPrimitiveSet(0,_drawArrays.get()); _lineGeode-setDrawable(0, _line.get()); _lineGeode-dirtyBound(); dirtyBound(); } Thank you very much! Erlend ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] creating power of two textures using nonPow2 images
Hello, I want to creating power of two textures using nonPow2 images for backwards comptability ( I dont want to use TextureRectangle). It seems that Texture2D does this for you using the standard settings by operations by scaling the image. (Am i right?) Which seem to be a costly operation. Before using OSG, i created a texture using a pow2 size larger then the image size, then using glTexSubImage2D and scaling the texcoords i got the correct texture and mapping using pow2 texture. Is this what the GlyphTexture is for? Or how would you do this? Thanks! Erlend ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Picking as the QuickGuide example only using Viewer as embedded window, does only catch FRAME type, no mouse events!
I've created the PickHandler as in the QuickGuide book and added to my Viewer ( as embedded! ), but I cant catch mouse events, only FRAME type. Do you know what I'm doing wrong? Erlend ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Picking as the QuickGuide example only using Viewer as embedded window, does only catch FRAME type, no mouse events!
ps.. using osg 2.3.7 on win vista.. could it be some kind of bug with this version? do you think upgrading to 2.4 would solve my problem? From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] Sent: 28. april 2008 16:07 To: osg-users@lists.openscenegraph.org Subject: [osg-users] Picking as the QuickGuide example only using Viewer as embedded window, does only catch FRAME type, no mouse events! I've created the PickHandler as in the QuickGuide book and added to my Viewer ( as embedded! ), but I cant catch mouse events, only FRAME type. Do you know what I'm doing wrong? Erlend ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] picking using osgViewer with embedded window without osgGA::GUIEventHandler
Im using osgViewer with an exisiting rendering engine as an embedded window. But i dont want to use the GUIEvent handler, as Im handling the events myself. I have followed the osgpick example, normally the x,y mouse pos is retrieved from the osgGA::GUIEventAdapter with the values[0,1]. I am passing the actual mouse coords [0,windowsize] to a method with the following code, scaling the values to [0,1] based on window size, but i Never get any hits..! Do you see what im doing wrong here? CODE: std::string Pick(int mouse_x, int mouse_y) { osgUtil::LineSegmentIntersector::Intersections intersections; int wx,wy,ww,wh; _window-getWindowRectangle(wx,wy,ww,wh); float x = (float) mouse_x / (float)ww; //ea.getX(); float y = fabs((float) mouse_y / (float)wh); //ea.getY(); if (_viewer-computeIntersections(x,y,intersections)) { for(osgUtil::LineSegmentIntersector::Intersections::iterator hitr = intersections.begin(); hitr != intersections.end(); ++hitr) { if (!hitr-nodePath.empty() !(hitr-nodePath.back()-getName().empty())) { return hitr-nodePath.back()-getName(); } else if (hitr-drawable.valid()) { return No name; } } } return ; } using osg 2.3.7 on vista- Thanks! Erlend ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Off-screen rendering
you want to avoid creating a window then and just render the scene given a view to a off screen buffer (backbuffer, fbo, pbuffer) and read pixels from it without switching to the front buffer. but im new to osg so thats about the explanation i could give you :/ -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Tessier, Philip Sent: 24. april 2008 23:13 To: OpenSceneGraph Users Subject: Re: [osg-users] Off-screen rendering Thank you, Phil -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Jeremy Moles Sent: Thursday, April 24, 2008 4:08 PM To: OpenSceneGraph Users Subject: Re: [osg-users] Off-screen rendering On Thu, 2008-04-24 at 15:48 -0500, Tessier, Philip wrote: All, I was able to use the osgprerender example to obtain most of what I need - the rendering of a scene into an osg::Image. As that's ALL I want, I need help with a tweak to it. It uses a viewer.run() to do the work. I've replaced this with a viewer.frame(). This produces a flicker on the screen as the viewer realizes the frame. As I'm interested in an off-screen grab, this is annoying. I'm reasonably sure that I don't want a viewer at all, but I don't know what to simplify it to. This is a copy/paste of a response Robert gave to a question like this a few months ago... -- Where supported one can use a pbuffer on Win32, X11 and Carbon implementations in osgViewer. Just create the Traits with the pbuffer option set to true, then create your GraphicsContext as per the osgcamera or osgwindows examples. -- I had recommended looking at how SDL hides the Window, but this is almost certainly a better solution. :) If you want to get real crazy you could do something like: # OSG_WINDOW=0 0 1 1 ./myApp ...but that's an abysmal hack, and still ends up showing a little tiny block you can't do anything about. :) Thanks, in advance, Phil Philip A. Tessier Northrop Grumman IT [EMAIL PROTECTED] 210-867-6775 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.or g ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.or g ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Newbie question, when to use osg::Object datavariance on update
I have a osg objects (Drawables, StateAttributes ( Texture2D) Image, Arrays) that need frequent update's, do I have to set datavariance DYNAMIC on all of those objects? For example a Geode has Geometry of type DrawArrays and Vec3Array, do i set DYNAMIC on all four objects in addition to set dirty() dirtyBound() and dirtyDisplayList() or else the update will not be noticed by the scenegraph, etc bounding box will not be recalculated, displaylists not recreated..? Is it not easier if osg implmented so that a dirty flag is set each time an object's value set? Erlend ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] osg::SceneView thread model
Do SceneView-Camera create a own thread / using multiple threads when drawing and culling? If so is it possible to use a single threaded model? Erlend ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] osg::SceneView thread model
Hi Robert, I mean the osgUtil::SceneView, which has a osg::Camera, which has a method setCameraThread(OperationsThread *gt). Whats the point of OperationsThread in camera then? Im using osg as a scenegraph now with a other renderer which calls cull/draw in it's own thread So I was concerned there could be some threading issue using osgUtil::SceneView. I would like to use Viewer but at the time im afraid chaning the rendering/window/event system would involve too much time/risk. Erlend -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Robert Osfield Sent: 24. april 2008 16:00 To: OpenSceneGraph Users Subject: Re: [osg-users] osg::SceneView thread model Hi Erland, I don't know what part of the OSG you are refering to when you say SceneView-Camera. SceneView doesn't do any threading whatsoever. Its only osgViewer that added threading, and here SceneView is just an implementation details, its not something you'll typically interact with. I don't personally recommend using SceneView directly anymore as osgViewer classes are far more functional. Robert. On Thu, Apr 24, 2008 at 2:48 PM, [EMAIL PROTECTED] wrote: Do SceneView-Camera create a own thread / using multiple threads when drawing and culling? If so is it possible to use a single threaded model? Erlend ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] cullface problem
I cant seem to turn off cullface on the geometry. I am doing the following: _stateSet = new osg::StateSet; _cullFaceState = new osg::CullFace; _stateSet-setAttributeAndModes(_cullFaceState.get(), osg::StateAttribute::OFF | osg::StateAttribute::OVERRIDE); _someGeometry-setStateSet(_stateSet); still only renders when i'm on one side of the geometry ps. i do this in a class which inherits from osg::Group, also tried to just set: getOrCreateStateSet()-setMode(GL_CULL_FACE, osg::StateAttribute::OFF | osg::StateAttribute::OVERRIDE); in my class.. using: osg2.3.7, SceneView Erlend ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] updating geometry and textures
I have a 'container' class A which inherit from Group, which has several nodes, drawables etc. I also have a controller class B that calls some update methods on A to update the geometry of some of A's member ( B has a pointer to A objects.. is that 'allowed'?). I am wondering if im doing the update correctly.. I render stuff but then suddenly everything dissapear.. Im pretty sure it's not the osg, but If you could see if im doing the updates correct i would appreciate it very much, since i didnt find any info on this. The geometry in A is in a Vec3Array vertices, which is cleared and given new data for each time updated. Afterwards i use DrawArrays-set() to sett correct primitive set and size. At the end I call vertices-dirty(). Bwt. I do not explisitly need to call dirtyBound() do i? I also have a class B same as A but which creates a billboard texture and so on, and i am frequently updating the image data. I've set both the image and texture's setDataVariance to DYNAMIC and in the to update the image i call: _image-setImage(_width, _height, 1, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, pixels, osg::Image::USE_NEW_DELETE); And also, when i create a texture from a image, is the texture allways created as a power-of-two texture? scaling the texcoords? Thanks in advance! Erlend Example.. class A : osg::Group { osg::ref_ptrosg::Geode_geomNode; osg::ref_ptrosg::Geometry _line; osg::ref_ptrosg::DrawArrays _drawArrays; osg::ref_ptrosg::Vec3Array_vertices; A() { //instantiate and add nodes drawables.. } updateSomething() { _vertices.clear(); while(something) { _vertices-push_back(osg::Vec3(data)); } _drawArrays-set(osg::PrimitiveSet::TRIANGLE_STRIP, 0, _size); _vertices.dirty(); } }___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] updating geometry and textures
it seems now that the objects only dissapear at certain camera position's. could there be an error with the culling using SceneView? From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] Sent: 23. april 2008 17:30 To: osg-users@lists.openscenegraph.org Subject: [osg-users] updating geometry and textures I have a 'container' class A which inherit from Group, which has several nodes, drawables etc. I also have a controller class B that calls some update methods on A to update the geometry of some of A's member ( B has a pointer to A objects.. is that 'allowed'?). I am wondering if im doing the update correctly.. I render stuff but then suddenly everything dissapear.. Im pretty sure it's not the osg, but If you could see if im doing the updates correct i would appreciate it very much, since i didnt find any info on this. The geometry in A is in a Vec3Array vertices, which is cleared and given new data for each time updated. Afterwards i use DrawArrays-set() to sett correct primitive set and size. At the end I call vertices-dirty(). Bwt. I do not explisitly need to call dirtyBound() do i? I also have a class B same as A but which creates a billboard texture and so on, and i am frequently updating the image data. I've set both the image and texture's setDataVariance to DYNAMIC and in the to update the image i call: _image-setImage(_width, _height, 1, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, pixels, osg::Image::USE_NEW_DELETE); And also, when i create a texture from a image, is the texture allways created as a power-of-two texture? scaling the texcoords? Thanks in advance! Erlend void Render() { // save matrices glPushAttrib(GL_ALL_ATTRIB_BITS ); glMatrixMode(GL_PROJECTION); glPushMatrix(); glMatrixMode(GL_TEXTURE); glPushMatrix(); glMatrixMode(GL_MODELVIEW); glPushMatrix(); // set correct view glLoadIdentity(); _renderer-rotate_eyepos(); _renderer-translate_sub_eyepos(); // set osg view GLint viewParams[4]; glGetIntegerv( GL_VIEWPORT, viewParams ); _sceneViewer-setViewport(viewParams[0], viewParams[1], viewParams[2], viewParams[3]); GLfloat glMat[16]; glGetFloatv( GL_PROJECTION_MATRIX, glMat ); _sceneViewer-setProjectionMatrix(osg::Matrix(glMat)); glGetFloatv( GL_MODELVIEW_MATRIX, glMat ); _sceneViewer-setViewMatrix(osg::Matrix(glMat)); // update timestamp double time_since_start = _timer.delta_s( _start_tick, _timer.tick() ); _frameStamp-setReferenceTime( time_since_start ); _frameStamp-setFrameNumber( _frameNumber++ ); _sceneViewer-setFrameStamp( _frameStamp.get() ); // render _sceneViewer-update(); _sceneViewer-cull(); _sceneViewer-draw(); // reset matrices glMatrixMode(GL_TEXTURE); glPopMatrix(); glMatrixMode(GL_PROJECTION); glPopMatrix(); glMatrixMode(GL_MODELVIEW); glPopMatrix(); glPopAttrib(); }___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] updating geometry and textures
I though dirty() called dirtyBound().. Anyway, tried it still have problem, with billboards popping in and out of view when im moving around.. :/ -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Art Tevs Sent: 23. april 2008 18:09 To: OpenSceneGraph Users Subject: Re: [osg-users] updating geometry and textures Hi, I think if you change your geometry on the fly, you have to call dirtyBound() of course. Otherwise the old bound can be used during the cull traversal and your node maybe culled. cheers, Art --- [EMAIL PROTECTED] schrieb: it seems now that the objects only dissapear at certain camera position's. could there be an error with the culling using SceneView? From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] Sent: 23. april 2008 17:30 To: osg-users@lists.openscenegraph.org Subject: [osg-users] updating geometry and textures I have a 'container' class A which inherit from Group, which has several nodes, drawables etc. I also have a controller class B that calls some update methods on A to update the geometry of some of A's member ( B has a pointer to A objects.. is that 'allowed'?). I am wondering if im doing the update correctly.. I render stuff but then suddenly everything dissapear.. Im pretty sure it's not the osg, but If you could see if im doing the updates correct i would appreciate it very much, since i didnt find any info on this. The geometry in A is in a Vec3Array vertices, which is cleared and given new data for each time updated. Afterwards i use DrawArrays-set() to sett correct primitive set and size. At the end I call vertices-dirty(). Bwt. I do not explisitly need to call dirtyBound() do i? I also have a class B same as A but which creates a billboard texture and so on, and i am frequently updating the image data. I've set both the image and texture's setDataVariance to DYNAMIC and in the to update the image i call: _image-setImage(_width, _height, 1, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, pixels, osg::Image::USE_NEW_DELETE); And also, when i create a texture from a image, is the texture allways created as a power-of-two texture? scaling the texcoords? Thanks in advance! Erlend void Render() { // save matrices glPushAttrib(GL_ALL_ATTRIB_BITS ); glMatrixMode(GL_PROJECTION); glPushMatrix(); glMatrixMode(GL_TEXTURE); glPushMatrix(); glMatrixMode(GL_MODELVIEW); glPushMatrix(); // set correct view glLoadIdentity(); _renderer-rotate_eyepos(); _renderer-translate_sub_eyepos(); // set osg view GLint viewParams[4]; glGetIntegerv( GL_VIEWPORT, viewParams ); _sceneViewer-setViewport(viewParams[0], viewParams[1], viewParams[2], viewParams[3]); GLfloat glMat[16]; glGetFloatv( GL_PROJECTION_MATRIX, glMat ); _sceneViewer-setProjectionMatrix(osg::Matrix(glMat)); glGetFloatv( GL_MODELVIEW_MATRIX, glMat ); _sceneViewer-setViewMatrix(osg::Matrix(glMat)); // update timestamp double time_since_start = _timer.delta_s( _start_tick, _timer.tick() ); _frameStamp-setReferenceTime( time_since_start ); _frameStamp-setFrameNumber( _frameNumber++ ); _sceneViewer-setFrameStamp( _frameStamp.get() ); // render _sceneViewer-update(); _sceneViewer-cull(); _sceneViewer-draw(); // reset matrices glMatrixMode(GL_TEXTURE); glPopMatrix(); glMatrixMode(GL_PROJECTION); glPopMatrix(); glMatrixMode(GL_MODELVIEW); glPopMatrix(); glPopAttrib(); } ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org __ Gesendet von Yahoo! Mail. Mehr Möglichkeiten, in Kontakt zu bleiben. http://de.overview.mail.yahoo.com ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] picking osg objects using osgUtil::SceneView (cant find osgUtil::PickVisitor!)
I want to pick osg objects in the scene when pressing the mouse button on them. I am using sceneView so i guess i cant use the osgViewer::View. computeIntersections and i did not find PickVisitor! Im using osg 2.3.7. So i guess i have to use IntersectVisitor. Is there a utility function for getting a line from camera towards mouse position. Or do i: camera.pos - gluUnproject screen to world erlend ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] picking osg objects using osgUtil::SceneView (cant find osgUtil::PickVisitor!)
Hei Robert. I would like to do that, but im working in a company and right now im trying to integrating osg in a existing rendring system (which handles events, mfc window, renders 3d terrain++) for rendering simple objects, so i'd rather use SceneView as for now. I think i could be using LineProjector and IntersectVisitor to find intersections..? But havent testet yet. See attachment. Erlend -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Robert Osfield Sent: 17. april 2008 22:22 To: OpenSceneGraph Users Subject: Re: [osg-users] picking osg objects using osgUtil::SceneView (cant find osgUtil::PickVisitor!) Hi Erland, Would it not be possible just to use osgViewer rather than SceneView. One of the points of osgViewer is that it provides more higher level functionality that users commonly require, and in doing so avoid the pain of end users having to implement themselves, and the pain involved in trying to communicate all the low level details required to teach a 3rd party how to implement something already implemented for them. Robert. On Thu, Apr 17, 2008 at 8:49 PM, [EMAIL PROTECTED] wrote: I want to pick osg objects in the scene when pressing the mouse button on them. I am using sceneView so i guess i cant use the osgViewer::View. computeIntersections and i did not find PickVisitor! Im using osg 2.3.7. So i guess i have to use IntersectVisitor. Is there a utility function for getting a line from camera towards mouse position. Or do i: camera.pos - gluUnproject screen to world erlend ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org osgManipulator::PointerInfo pInfo; pInfo.setMousePosition(mouse_x, mouse_y); pInfo.setCamera(_sceneViewer-getCamera()); osg::ref_ptrosgManipulator::LineProjector lineProj = new osgManipulator::LineProjector; osg::Vec3 point; lineProj-project(pInfo, point); osg::ref_ptrosg::LineSegment pickLine = new osg::LineSegment(lineProj-getLineStart(), lineProj-getLineEnd()); osgUtil::IntersectVisitor visitor; //visitor.setEyePoint(_sceneViewer-getCamera()-getPosition()); visitor.addLineSegment(pickLine.get()); _root-accept(visitor); osgUtil::IntersectVisitor::HitList hitList = visitor.getHitList(pickLine.get()); osgUtil::Hit firstHit = hitList.front(); std::string id = firstHit.getDrawable()-getName();___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Linker error when using createTexturedQuadGeometry in debug
I get a Linker error when using createTexturedQuadGeometry in debug, but no error in release, see attachment for error output. i use osg 2.3.7 on vista, and the function is called in a ref class. Erlend error LNK2028: unresolved token (0A001BE8) class osg::Geometry * __stdcall osg::createTexturedQuadGeometry(class osg::Vec3f const ,class osg::Vec3f const ,class osg::Vec3f const ,float,float,float,float) ([EMAIL PROTECTED]@@[EMAIL PROTECTED]@[EMAIL PROTECTED]@[EMAIL PROTECTED]) referenced in function class osg::Geometry * __stdcall osg::createTexturedQuadGeometry(class osg::Vec3f const ,class osg::Vec3f const ,class osg::Vec3f const ,float,float) ([EMAIL PROTECTED]@@[EMAIL PROTECTED]@[EMAIL PROTECTED]@[EMAIL PROTECTED]) error LNK2019: unresolved external symbol class osg::Geometry * __stdcall osg::createTexturedQuadGeometry(class osg::Vec3f const ,class osg::Vec3f const ,class osg::Vec3f const ,float,float,float,float) ([EMAIL PROTECTED]@@[EMAIL PROTECTED]@[EMAIL PROTECTED]@[EMAIL PROTECTED]) referenced in function class osg::Geometry * __stdcall osg::createTexturedQuadGeometry(class osg::Vec3f const ,class osg::Vec3f const ,class osg::Vec3f const ,float,float) ([EMAIL PROTECTED]@@[EMAIL PROTECTED]@[EMAIL PROTECTED]@[EMAIL PROTECTED]) ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] warning when creating image
I use osg 2.3.7 on vista in a ref class the following lines: osg::Image * image = new osg::Image; image-setImage(width, height, 0, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, pixels, osg::Image::AllocationMode::USE_NEW_DELETE); causes the warning: Warning 4 warning C4482: nonstandard extension used: enum 'osg::Image::AllocationMode' used in qualified name ... isnt this the correct way of creating a image if the pixels have been created using new? Erlend ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] warning when creating image
thanks! -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Thibault Genessay Sent: 16. april 2008 15:05 To: OpenSceneGraph Users Subject: Re: [osg-users] warning when creating image Hi Erlend image-setImage(width, height, 0, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, pixels, osg::Image::AllocationMode::USE_NEW_DELETE); causes the warning: Warning 4 warning C4482: nonstandard extension used: enum 'osg::Image::AllocationMode' used in qualified name ... This is a C++ language issue. USE_NEW_DELETE is a member of osg::Image, not of the enum osg::Image::AllocationMode You should write: osg::Image::USE_NEW_DELETE, because even though your (Microsoft ...) C++ understands what you mean this is not correct code. Besides, Vincent's remark still holds: at run-time, you will probably run into a problem with the depth set to 0. Regards Thibault ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] error in doing SceneView-cull, primitiveset is 0
after created a billboard as in the example at at (also see code.txt). http://www.cs.clemson.edu/~malloy/courses/3dgames-2007/tutor/web/billboards/billboards/scene.cpp ( i used this since createTextureQuad did not link) primitiveset was an error pointer so when DrawArrays-getMode causes an error, but as you can see in the code i have created the primitiveset Erlend using osg 2.3.7 vista _createSquare(const osg::Vec3 corner,const osg::Vec3 width,const osg::Vec3 height, osg::Image* image) { // set up the Geometry. osg::Geometry* geom = new osg::Geometry; osg::Vec3Array* coords = new osg::Vec3Array(4); (*coords)[0] = corner; (*coords)[1] = corner+width; (*coords)[2] = corner+width+height; (*coords)[3] = corner+height; geom-setVertexArray(coords); osg::Vec3Array* norms = new osg::Vec3Array(1); (*norms)[0] = width^height; (*norms)[0].normalize(); geom-setNormalArray(norms); geom-setNormalBinding(osg::Geometry::BIND_OVERALL); osg::Vec2Array* tcoords = new osg::Vec2Array(4); (*tcoords)[0].set(0.0f,0.0f); (*tcoords)[1].set(1.0f,0.0f); (*tcoords)[2].set(1.0f,1.0f); (*tcoords)[3].set(0.0f,1.0f); geom-setTexCoordArray(0,tcoords); geom-addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::QUADS,0,4)); if (image) { osg::StateSet* stateset = new osg::StateSet; osg::Texture2D* texture = new osg::Texture2D; texture-setImage(image); stateset-setTextureAttributeAndModes(0,texture,osg::StateAttribute::ON); geom-setStateSet(stateset); } return geom; osg33-osgd.dll!osg::PrimitiveSet::getMode() Line 252 + 0x11 bytes C++ osg33-osgd.dll!osg::Geometry::accept(osg::PrimitiveFunctor functor={...}) Line 2277 + 0x8 bytes C++ osg33-osgd.dll!osg::Drawable::computeBound() Line 764 + 0x13 bytes C++ osg33-osgd.dll!osg::Drawable::getBound() Line 200 + 0x13 bytes C++ osg33-osgd.dll!osg::Billboard::computeBound() Line 317 + 0x8 bytes C++ osg33-osgd.dll!osg::Node::getBound() Line 268 + 0x13 bytes C++ osg33-osgd.dll!osg::Group::computeBound() Line 357 + 0x16 bytes C++ osg33-osgd.dll!osg::Node::getBound() Line 268 + 0x13 bytes C++ osg33-osgd.dll!osg::Node::isCullingActive() Line 191 + 0x39 bytes C++ osg33-osgd.dll!osg::CullStack::isCulled(const osg::Node node={...}) Line 109 + 0x8 bytes C++ osg33-osgUtild.dll!osgUtil::CullVisitor::apply(osg::Group node={...}) Line 969 + 0x12 bytes C++ osg33-osgd.dll!osg::Group::accept(osg::NodeVisitor nv={...}) Line 38 + 0x41 bytesC++ osg33-osgUtild.dll!osgUtil::SceneView::cullStage(const osg::Matrixd projection={...}, const osg::Matrixd modelview={...}, osgUtil::CullVisitor * cullVisitor=0x1a202618, osgUtil::StateGraph * rendergraph=0x1a2b5690, osgUtil::RenderStage * renderStage=0x1a2b5780) Line 821 + 0x42 bytesC++ osg33-osgUtild.dll!osgUtil::SceneView::cull() Line 687 + 0x4e bytes C++ when not stepping i get this callstack: ntdll.dll!777e0004() [Frames below may be incorrect and/or missing, no symbols loaded for ntdll.dll] msvcr80d.dll!_CrtDbgBreak() Line 89C msvcr80d.dll!_VCrtDbgReportW(int nRptType=2, const wchar_t * szFile=0x1039c478, int nLine=71, const wchar_t * szModule=0x, const wchar_t * szFormat=0x103a1788, char * arglist=0x0016fd0c) Line 505C msvcr80d.dll!_CrtDbgReportWV(int nRptType=2, const wchar_t * szFile=0x1039c478, int nLine=71, const wchar_t * szModule=0x, const wchar_t * szFormat=0x103a1788, char * arglist=0x0016fd0c) Line 300 + 0x1d bytes C++ msvcr80d.dll!_CrtDbgReportW(int nRptType=2, const wchar_t * szFile=0x1039c478, int nLine=71, const wchar_t * szModule=0x, const wchar_t * szFormat=0x103a1788, ...) Line 317 + 0x1d bytes C++ osg33-osgd.dll!std::_Vector_const_iteratorosg::ref_ptrosg::PrimitiveSet,std::allocatorosg::ref_ptrosg::PrimitiveSet ::_Vector_const_iteratorosg::ref_ptrosg::PrimitiveSet,std::allocatorosg::ref_ptrosg::PrimitiveSet (osg::ref_ptrosg::PrimitiveSet * _Ptr=0x1ab1aef8, const std::_Container_base * _Pvector=0x1ab19af4) Line 71 + 0x38 bytes C++ osg33-osgd.dll!std::vectorosg::ref_ptrosg::PrimitiveSet,std::allocatorosg::ref_ptrosg::PrimitiveSet ::begin() Line 633 + 0x13 bytes C++ osg33-osgd.dll!osg::Geometry::accept(osg::PrimitiveFunctor functor={...}) Line 2272 + 0x12 bytes C++ osg33-osgd.dll!osg::Drawable::computeBound() Line 764 + 0x13 bytes C++ osg33-osgd.dll!osg::Drawable::getBound() Line 200 + 0x13 bytes C++ osg33-osgd.dll!osg::Billboard::computeBound() Line 317 + 0x8 bytes C++ osg33-osgd.dll!osg::Node::getBound() Line 268 + 0x13 bytes C++ osg33-osgd.dll!osg::Group::computeBound() Line 357
Re: [osg-users] error in doing SceneView-cull, primitiveset is 0
Hi Robert, Sorry for bad example, but the example is actually just the same as in the osgbillboard example, which works.. So i guess there is some other error. I do cast the Billboard pointer to an IntPtr and then back to a Node* before inserting into the scenegraph root node. I do this in a ref (mixed mode)class for building object from managed to native. But i guess that should be ok..? Erlend -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Robert Osfield Sent: 16. april 2008 16:14 To: OpenSceneGraph Users Subject: Re: [osg-users] error in doing SceneView-cull, primitiveset is 0 Hi Erland, Are you expecting support on some third party code that you've found on the web? If you can stick with ones on the OSG example set you'll have a much better chance of the code being up to date and working with the present version of the OSG. Robert. On Wed, Apr 16, 2008 at 3:09 PM, [EMAIL PROTECTED] wrote: after created a billboard as in the example at at (also see code.txt). http://www.cs.clemson.edu/~malloy/courses/3dgames-2007/tutor/web/billboards/billboards/scene.cpp ( i used this since createTextureQuad did not link) primitiveset was an error pointer so when DrawArrays-getMode causes an error, but as you can see in the code i have created the primitiveset Erlend using osg 2.3.7 vista ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] error in doing SceneView-cull, primitiveset is 0
An IntPtr is managed version of a void pointer. Erlend -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Robert Osfield Sent: 16. april 2008 16:46 To: OpenSceneGraph Users Subject: Re: [osg-users] error in doing SceneView-cull, primitiveset is 0 On Wed, Apr 16, 2008 at 3:42 PM, [EMAIL PROTECTED] wrote: Hi Robert, Sorry for bad example, but the example is actually just the same as in the osgbillboard example, which works.. So i guess there is some other error. I do cast the Billboard pointer to an IntPtr and then back to a Node* before inserting into the scenegraph root node. I do this in a ref (mixed mode)class for building object from managed to native. But i guess that should be ok..? Well you've lost me, what's a IntPtr?? Do you mean ref_ptr? If so just use the .get() to get the C pointer that you can pass into a group-addChild(nodePtr) method. Robert. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] custom drawable
i have some custom classes which inherits from osg::Drawable, and is inserted into an osg::Geode but nothing renders. I have implemented the drawImplementation(osg::RenderInfo renderInfo) method to do some custom OpenGL rendering calls. I found that useDisplayList is initially true which caused drawImplementation to be called and creating a display list, but i need it to be false since i update some glTranslate params. When i set the Drawable's _useDisplay List to false, the drawImplementation is not called at all. I also overrided the computeBound() method of the Drawable's to create a max bounding box(min==FLT_MIN) ( when is computeBound() method called btw? before culling if not allready set?) i call it in the constructor just to be sure its set. I notice Geode also has a _bounding box, but i guess this is calculated from the Drawable's bounding box. Do you have any advice on how what i am doing wrong? ( i know i should probably use the scenegraph a lot different but im only prototyping at this point..) Thanks in advance. Erlend. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] creating custom drawables
i have a hierarcy of classes which i want to make osg compatible, so initially i let the base class of my class hieracy inherit from osg::Drawable and overrided the drawImplementation method with my own gl rendering, I also create a osg::Geode for each Drawable. but it nothing get's rendered, are there any more steps in the creating your custom drawables? (tutorials on this?) i also implmented empty cloneType and clone methods as for now. Erlend ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] osg Image data
use GL_UNSIGNED_BYTE a char is 1 byte From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Vincent Bourdier Sent: 10. april 2008 13:33 To: OpenSceneGraph Users Subject: Re: [osg-users] osg Image data Yes, but GL_UNSIGNED_CHAR doesn't exist. so I don't know what to use... 2008/4/10, J.P. Delport [EMAIL PROTECTED]mailto:[EMAIL PROTECTED]: Hi, sizeof(unsigned char) != sizeof(GL_UNSIGNED_SHORT) try GL_UNSIGNED_CHAR jp Vincent Bourdier wrote: Hi All, I have a problem concerning writing image data. My code is simple : const long size = _x*_y*3; unsigned char* data = (unsigned char*)calloc(size, sizeof(unsigned char)); for(long i=0; i size ; i+= 3) { data[i] = 0;//red data[i+1] = 0;//green data[i+2] =0;//blue } osg::ref_ptrosg::Image image = new osg::Image; image-allocateImage(_x, _y, 1, GL_RGB, GL_UNSIGNED_SHORT); image-setOrigin(osg::Image::BOTTOM_LEFT);//start counting pixels on the Bottom left of the picture image-setImage(_x, _y, 1, GL_RGB, GL_RGB, GL_UNSIGNED_SHORT, data, osg::Image::NO_DELETE); osgDB::writeImageFile(*image, Z:/autres/Gradient.jpg); the result must be a black picture... but I've a totally different result (see attached file) Does anyone see a mistake ? Thanks. Regards, Vincent. ___ osg-users mailing list osg-users@lists.openscenegraph.orgmailto:osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org -- This message is subject to the CSIR's copyright terms and conditions, e-mail legal notice, and implemented Open Document Format (ODF) standard. The full disclaimer details can be found at http://www.csir.co.za/disclaimer.html. This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. MailScanner thanks Transtec Computers for their support. ___ osg-users mailing list osg-users@lists.openscenegraph.orgmailto:osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] SceneView error
ps, its the latest version, 2.3.7. its just an example i created myself. From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] Sent: 10. april 2008 18:42 To: osg-users@lists.openscenegraph.org Subject: Re: [osg-users] SceneView error i did get a runtime error at _localStateSet-setAttribute(getViewport()); when calling SceneView-draw if not calling SceneView-cull first. dont have the log file here right now, and i am in the middle of some other coding stuff, just thought you should know. From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Robert Osfield Sent: 10. april 2008 18:08 To: OpenSceneGraph Users Subject: Re: [osg-users] SceneView error Hi Erf??? Can't make any sense of your email, and not about to go trying to sieve through your example code trying to work out what you might mean. Please try and be specific, tell us what error you get, a compile, and link error, a runtime error Also try telling us which version of the OSG you are talking about? 2.x doesn't have any SceneView examples for instance... Robert. On Tue, Apr 8, 2008 at 12:50 PM, [EMAIL PROTECTED]mailto:[EMAIL PROTECTED] wrote: I try to use OpenSceneGraph and SceneView as shown in example when using an existing renderer, but get an error when calling SceneView-draw() or more spesific in _localStateSet-setAttribute(getViewport()); The example code I use is as following: int CMapRenderThread::InitOpenSceneGraph() { root = new osg::Group; pyramidGeode = new osg::Geode; pyramidGeometry = new osg::Geometry; // Associate the pyramid geometry with the pyramid geode // Add the pyramid geode to the root node of the scene graph. pyramidGeode-addDrawable(pyramidGeometry); root-addChild(pyramidGeode); // Declare an array of vertices. osg::Vec3Array* pyramidVertices = new osg::Vec3Array; pyramidVertices-push_back( osg::Vec3( 0, 0, 0) ); // front left pyramidVertices-push_back( osg::Vec3(10, 0, 0) ); // front right pyramidVertices-push_back( osg::Vec3(10,10, 0) ); // back right pyramidVertices-push_back( osg::Vec3( 0,10, 0) ); // back left pyramidVertices-push_back( osg::Vec3( 5, 5,10) ); // peak pyramidGeometry-setVertexArray( pyramidVertices ); // Create a primitive set and add it to the pyramid geometry. osg::DrawElementsUInt* pyramidBase = new osg::DrawElementsUInt(osg::PrimitiveSet::QUADS, 0); pyramidBase-push_back(3); pyramidBase-push_back(2); pyramidBase-push_back(1); pyramidBase-push_back(0); pyramidGeometry-addPrimitiveSet(pyramidBase); // Repeat the same for each of the four sides. Again, vertices are // specified in counter-clockwise order. osg::DrawElementsUInt* pyramidFaceOne = new osg::DrawElementsUInt(osg::PrimitiveSet::TRIANGLES, 0); pyramidFaceOne-push_back(0); pyramidFaceOne-push_back(1); pyramidFaceOne-push_back(4); pyramidGeometry-addPrimitiveSet(pyramidFaceOne); osg::DrawElementsUInt* pyramidFaceTwo = new osg::DrawElementsUInt(osg::PrimitiveSet::TRIANGLES, 0); pyramidFaceTwo-push_back(1); pyramidFaceTwo-push_back(2); pyramidFaceTwo-push_back(4); pyramidGeometry-addPrimitiveSet(pyramidFaceTwo); osg::DrawElementsUInt* pyramidFaceThree = new osg::DrawElementsUInt(osg::PrimitiveSet::TRIANGLES, 0); pyramidFaceThree-push_back(2); pyramidFaceThree-push_back(3); pyramidFaceThree-push_back(4); pyramidGeometry-addPrimitiveSet(pyramidFaceThree); osg::DrawElementsUInt* pyramidFaceFour = new osg::DrawElementsUInt(osg::PrimitiveSet::TRIANGLES, 0); pyramidFaceFour-push_back(3); pyramidFaceFour-push_back(0); pyramidFaceFour-push_back(4); pyramidGeometry-addPrimitiveSet(pyramidFaceFour); // Declare and load an array of Vec4 elements to store colors. osg::Vec4Array* colors = new osg::Vec4Array; colors-push_back(osg::Vec4(1.0f, 0.0f, 0.0f, 1.0f) ); //index 0 red colors-push_back(osg::Vec4(0.0f, 1.0f, 0.0f, 1.0f) ); //index 1 green colors-push_back(osg::Vec4(0.0f, 0.0f, 1.0f, 1.0f) ); //index 2 blue colors-push_back(osg::Vec4(1.0f, 1.0f, 1.0f, 1.0f) ); //index 3 white // Declare the variable that will match vertex array elements to color // array elements. osg::TemplateIndexArrayunsigned int, osg::Array::UIntArrayType,4,4 *colorIndexArray; colorIndexArray = new osg::TemplateIndexArrayunsigned int, osg::Array::UIntArrayType,4,4; colorIndexArray-push_back(0); // vertex 0 assigned color array element 0 colorIndexArray-push_back(1); // vertex 1 assigned color array element 1 colorIndexArray-push_back(2); // vertex 2 assigned color array element 2 colorIndexArray-push_back(3); // vertex 3 assigned color array element 3 colorIndexArray
Re: [osg-users] Examples for using image as a background
do this: _sceneViewer-getCamera()-setClearMask(0); From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Judie Stanley Sent: 10. april 2008 18:49 To: osg-users@lists.openscenegraph.org Subject: [osg-users] Examples for using image as a background Trying to add video capture as the background to a scene. I am not very familiar with osg and am working in an existing code base. The render loop calls SceneView::Draw which apparently does all the traversal. Unfortunately for me, it also clears the color buffer so I don't see my video capture if I enable this call, but then if I disable it, I only see my video capture - drawn using OpenGL, because of course, the scene is not drawn. Is there a way to disable clearing the color buffer? Another way would be if I could set the video capture as the background. I have searched and see there is such a thing as a osg::ImageBackground object. However, I searched the osg solution (osg 2.0) and nothing was found has the name changed? http://www.opensg.org/doc-1.6.0/classosg_1_1ImageBackground.html Does anybody know of some sample code? Thanks, Judie ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] SceneView error
i did get a runtime error at _localStateSet-setAttribute(getViewport()); when calling SceneView-draw if not calling SceneView-cull first. dont have the log file here right now, and i am in the middle of some other coding stuff, just thought you should know. From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Robert Osfield Sent: 10. april 2008 18:08 To: OpenSceneGraph Users Subject: Re: [osg-users] SceneView error Hi Erf??? Can't make any sense of your email, and not about to go trying to sieve through your example code trying to work out what you might mean. Please try and be specific, tell us what error you get, a compile, and link error, a runtime error Also try telling us which version of the OSG you are talking about? 2.x doesn't have any SceneView examples for instance... Robert. On Tue, Apr 8, 2008 at 12:50 PM, [EMAIL PROTECTED]mailto:[EMAIL PROTECTED] wrote: I try to use OpenSceneGraph and SceneView as shown in example when using an existing renderer, but get an error when calling SceneView-draw() or more spesific in _localStateSet-setAttribute(getViewport()); The example code I use is as following: int CMapRenderThread::InitOpenSceneGraph() { root = new osg::Group; pyramidGeode = new osg::Geode; pyramidGeometry = new osg::Geometry; // Associate the pyramid geometry with the pyramid geode // Add the pyramid geode to the root node of the scene graph. pyramidGeode-addDrawable(pyramidGeometry); root-addChild(pyramidGeode); // Declare an array of vertices. osg::Vec3Array* pyramidVertices = new osg::Vec3Array; pyramidVertices-push_back( osg::Vec3( 0, 0, 0) ); // front left pyramidVertices-push_back( osg::Vec3(10, 0, 0) ); // front right pyramidVertices-push_back( osg::Vec3(10,10, 0) ); // back right pyramidVertices-push_back( osg::Vec3( 0,10, 0) ); // back left pyramidVertices-push_back( osg::Vec3( 5, 5,10) ); // peak pyramidGeometry-setVertexArray( pyramidVertices ); // Create a primitive set and add it to the pyramid geometry. osg::DrawElementsUInt* pyramidBase = new osg::DrawElementsUInt(osg::PrimitiveSet::QUADS, 0); pyramidBase-push_back(3); pyramidBase-push_back(2); pyramidBase-push_back(1); pyramidBase-push_back(0); pyramidGeometry-addPrimitiveSet(pyramidBase); // Repeat the same for each of the four sides. Again, vertices are // specified in counter-clockwise order. osg::DrawElementsUInt* pyramidFaceOne = new osg::DrawElementsUInt(osg::PrimitiveSet::TRIANGLES, 0); pyramidFaceOne-push_back(0); pyramidFaceOne-push_back(1); pyramidFaceOne-push_back(4); pyramidGeometry-addPrimitiveSet(pyramidFaceOne); osg::DrawElementsUInt* pyramidFaceTwo = new osg::DrawElementsUInt(osg::PrimitiveSet::TRIANGLES, 0); pyramidFaceTwo-push_back(1); pyramidFaceTwo-push_back(2); pyramidFaceTwo-push_back(4); pyramidGeometry-addPrimitiveSet(pyramidFaceTwo); osg::DrawElementsUInt* pyramidFaceThree = new osg::DrawElementsUInt(osg::PrimitiveSet::TRIANGLES, 0); pyramidFaceThree-push_back(2); pyramidFaceThree-push_back(3); pyramidFaceThree-push_back(4); pyramidGeometry-addPrimitiveSet(pyramidFaceThree); osg::DrawElementsUInt* pyramidFaceFour = new osg::DrawElementsUInt(osg::PrimitiveSet::TRIANGLES, 0); pyramidFaceFour-push_back(3); pyramidFaceFour-push_back(0); pyramidFaceFour-push_back(4); pyramidGeometry-addPrimitiveSet(pyramidFaceFour); // Declare and load an array of Vec4 elements to store colors. osg::Vec4Array* colors = new osg::Vec4Array; colors-push_back(osg::Vec4(1.0f, 0.0f, 0.0f, 1.0f) ); //index 0 red colors-push_back(osg::Vec4(0.0f, 1.0f, 0.0f, 1.0f) ); //index 1 green colors-push_back(osg::Vec4(0.0f, 0.0f, 1.0f, 1.0f) ); //index 2 blue colors-push_back(osg::Vec4(1.0f, 1.0f, 1.0f, 1.0f) ); //index 3 white // Declare the variable that will match vertex array elements to color // array elements. osg::TemplateIndexArrayunsigned int, osg::Array::UIntArrayType,4,4 *colorIndexArray; colorIndexArray = new osg::TemplateIndexArrayunsigned int, osg::Array::UIntArrayType,4,4; colorIndexArray-push_back(0); // vertex 0 assigned color array element 0 colorIndexArray-push_back(1); // vertex 1 assigned color array element 1 colorIndexArray-push_back(2); // vertex 2 assigned color array element 2 colorIndexArray-push_back(3); // vertex 3 assigned color array element 3 colorIndexArray-push_back(0); // vertex 4 assigned color array element 0 // The next step is to associate the array of colors with the geometry, // assign the color indices created above to the geometry and set the // binding mode to BIND_PER_VERTEX
[osg-users] use of ref_ptr
I just started using OSG and have never used ref_ptr's before, though I've read the A Short Introduction to the Basic Principles of the Open Scene Graph and belive I understand the concept. But I wonder if you have any advice on the use of ref_ptr's on OSG objects, and If you use them in some standard way. I recon all the objects that inherits from Referenced should use ref_ptr for safer memory alloction/deleting, but I guess it's just a subjective choice. The tutorials though use dumb pointers as in the Basic Geometry example: ... int main() { ... osg::Group* root = new osg::Group(); osg::Geode* pyramidGeode = new osg::Geode(); osg::Geometry* pyramidGeometry = new osg::Geometry(); but i guess it's just for simplicity. In the guide A Short Introduction to the Basic Principles of the Open Scene Graph on the use of ref_ptr, they first create a node using ref pointer, then they add a node using new, and say: Line 25 does more or less the same thing as the previous case. The difference is that the geode is allocated with new and added as group's child in a single line of code. This is quite safe, too, because there are not many bad things that can happen in between (after all, there is no in between.) that may be a little missleading since it's not a smart pointer, and needs to be deleted explicitly. Erlend ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] SceneView error
I try to use OpenSceneGraph and SceneView as shown in example when using an existing renderer, but get an error when calling SceneView-draw() or more spesific in _localStateSet-setAttribute(getViewport()); The example code I use is as following: int CMapRenderThread::InitOpenSceneGraph() { root = new osg::Group; pyramidGeode = new osg::Geode; pyramidGeometry = new osg::Geometry; // Associate the pyramid geometry with the pyramid geode // Add the pyramid geode to the root node of the scene graph. pyramidGeode-addDrawable(pyramidGeometry); root-addChild(pyramidGeode); // Declare an array of vertices. osg::Vec3Array* pyramidVertices = new osg::Vec3Array; pyramidVertices-push_back( osg::Vec3( 0, 0, 0) ); // front left pyramidVertices-push_back( osg::Vec3(10, 0, 0) ); // front right pyramidVertices-push_back( osg::Vec3(10,10, 0) ); // back right pyramidVertices-push_back( osg::Vec3( 0,10, 0) ); // back left pyramidVertices-push_back( osg::Vec3( 5, 5,10) ); // peak pyramidGeometry-setVertexArray( pyramidVertices ); // Create a primitive set and add it to the pyramid geometry. osg::DrawElementsUInt* pyramidBase = new osg::DrawElementsUInt(osg::PrimitiveSet::QUADS, 0); pyramidBase-push_back(3); pyramidBase-push_back(2); pyramidBase-push_back(1); pyramidBase-push_back(0); pyramidGeometry-addPrimitiveSet(pyramidBase); // Repeat the same for each of the four sides. Again, vertices are // specified in counter-clockwise order. osg::DrawElementsUInt* pyramidFaceOne = new osg::DrawElementsUInt(osg::PrimitiveSet::TRIANGLES, 0); pyramidFaceOne-push_back(0); pyramidFaceOne-push_back(1); pyramidFaceOne-push_back(4); pyramidGeometry-addPrimitiveSet(pyramidFaceOne); osg::DrawElementsUInt* pyramidFaceTwo = new osg::DrawElementsUInt(osg::PrimitiveSet::TRIANGLES, 0); pyramidFaceTwo-push_back(1); pyramidFaceTwo-push_back(2); pyramidFaceTwo-push_back(4); pyramidGeometry-addPrimitiveSet(pyramidFaceTwo); osg::DrawElementsUInt* pyramidFaceThree = new osg::DrawElementsUInt(osg::PrimitiveSet::TRIANGLES, 0); pyramidFaceThree-push_back(2); pyramidFaceThree-push_back(3); pyramidFaceThree-push_back(4); pyramidGeometry-addPrimitiveSet(pyramidFaceThree); osg::DrawElementsUInt* pyramidFaceFour = new osg::DrawElementsUInt(osg::PrimitiveSet::TRIANGLES, 0); pyramidFaceFour-push_back(3); pyramidFaceFour-push_back(0); pyramidFaceFour-push_back(4); pyramidGeometry-addPrimitiveSet(pyramidFaceFour); // Declare and load an array of Vec4 elements to store colors. osg::Vec4Array* colors = new osg::Vec4Array; colors-push_back(osg::Vec4(1.0f, 0.0f, 0.0f, 1.0f) ); //index 0 red colors-push_back(osg::Vec4(0.0f, 1.0f, 0.0f, 1.0f) ); //index 1 green colors-push_back(osg::Vec4(0.0f, 0.0f, 1.0f, 1.0f) ); //index 2 blue colors-push_back(osg::Vec4(1.0f, 1.0f, 1.0f, 1.0f) ); //index 3 white // Declare the variable that will match vertex array elements to color // array elements. osg::TemplateIndexArrayunsigned int, osg::Array::UIntArrayType,4,4 *colorIndexArray; colorIndexArray = new osg::TemplateIndexArrayunsigned int, osg::Array::UIntArrayType,4,4; colorIndexArray-push_back(0); // vertex 0 assigned color array element 0 colorIndexArray-push_back(1); // vertex 1 assigned color array element 1 colorIndexArray-push_back(2); // vertex 2 assigned color array element 2 colorIndexArray-push_back(3); // vertex 3 assigned color array element 3 colorIndexArray-push_back(0); // vertex 4 assigned color array element 0 // The next step is to associate the array of colors with the geometry, // assign the color indices created above to the geometry and set the // binding mode to BIND_PER_VERTEX. pyramidGeometry-setColorArray(colors); pyramidGeometry-setColorIndices(colorIndexArray); pyramidGeometry-setColorBinding(osg::Geometry::BIND_PER_VERTEX); // Declare and initialize a transform node. pyramidTwoXForm = new osg::PositionAttitudeTransform; // Use the 'addChild' method of the osg::Group class to // add the transform as a child of the root node and the // pyramid node as a child of the transform. root-addChild(pyramidTwoXForm); pyramidTwoXForm-addChild(pyramidGeode); // Declare and initialize a Vec3 instance to change the // position of the model in the scene //m_pRenderer- //double x,y,z; //LatLonAltToXYZ(61.0, 10.0, 500.0, x, y, z, this); //osg::Vec3 pyramidTwoPosition(x,y,z); //pyramidTwoXForm-setPosition( pyramidTwoPosition ); pyramidTwoXForm-setScale(osg::Vec3d(100,100,100)); // The final step is to set up and enter a simulation loop. /*
Re: [osg-users] why arent the .h postfix used in openscenegraph?
I figured out the syntax bit but arent .h c++ standard for include files?? From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Robert Osfield Sent: 8. april 2008 14:44 To: OpenSceneGraph Users Subject: Re: [osg-users] why arent the .h postfix used in openscenegraph? On Tue, Apr 8, 2008 at 12:54 PM, [EMAIL PROTECTED]mailto:[EMAIL PROTECTED] wrote: why arent the .h postfix used in openscenegraph? Because of this i get no syntax highlighting in visual studio.nethttp://studio.net The OpenSceneGraph is written in C++ rather than C so it uses Standard C++ style headers rather than C style headers. I believe you can enable syntax high lighting in VS from the GUI, have a look through the archives for details. Robert. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] why arent the .h postfix used in openscenegraph?
Allright.. I didn't know that was the standard, allways used and seen .h used. :) Thanks for your answer. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Jean-Sébastien Guay Sent: 8. april 2008 15:19 To: OpenSceneGraph Users Subject: Re: [osg-users] why arent the .h postfix used in openscenegraph? Hi, I figured out the syntax bit but arent .h c++ standard for include files?? #include iostream #include string #include vector #include osg/Geode You can still use .h (I do, as do most others) but OSG elected to go the same route as the Standard C++ Library. See The C++ Programming Language by Bjarne Stroustrup for details. J-S -- __ Jean-Sebastien Guay[EMAIL PROTECTED] http://www.cm-labs.com/ http://whitestar02.webhop.org/ ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] why arent the .h postfix used in openscenegraph?
Thanks for your elaborated insight on the history of headers! :) Btw. I guess you meant extentionless at the end? :) Erlend From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Robert Osfield Sent: 8. april 2008 16:56 To: OpenSceneGraph Users Subject: Re: [osg-users] why arent the .h postfix used in openscenegraph? On Tue, Apr 8, 2008 at 2:31 PM, [EMAIL PROTECTED]mailto:[EMAIL PROTECTED] wrote: Allright.. I didn't know that was the standard, allways used and seen .h used. :) The problems with standards is that their are jut so many to choose from... .h is most common for C++ simply from C heritage, but in the early days of C++ loads of others sprung up in the absence of any clear definition so .H, .hxx, .hpp and many other variants all turn up in the wild, there a many of these convoluted variations none of which really make any sense once you take a step back. When Standard C++ finally made it out it didn't use any of these convoluted attempts at something different from C's .h, rather it just dropped the extension entirely. Compilers just open files that are specified via #include without making any assumptions, so you can use absolutely anything you want, you could use .CPlusPlusHeaderFile if you wished and it'll still compile. Back in the late nineties I made the choice about extensionless header for the OSG as it aligns itself with what the Standard C++ headers convention, rather than going for one of the many .yetanotherabitaryc++headerextensions that were proliferating at the time. Back then I wouldn't have thought that it'd take more than a decade for IDE's to automatically realise that an extension C++ header file is a C++ header file for all the sophistication of modern software some really dumb arse things aren't possible... Robert. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org