[osg-users] how matrixTransform works?
Hi, everybody Could someone explain me how matrixTransform works? In the updatecallback, I set the matrixTransform like this static float c = 1.0; c = c + 0.01; mt-setMatrix(osg::Matrixf::translate(-bs.center()) * osg::Matrixf::scale(1.0, c, 1.0) osg::Matrixf::translate(bs.center())); With the time goes by, the center of boundingbox will change frequently. At the end, some error happens like CullVisitor::applyGeode detected NaN, depth=1.#QNAN, center=49.8655 50.2613 50.5221, matrix = { 1 0 0 0 0 0 -7.21007 0 0 1 0 0 -1.#IND -1.#IND -1.#IND -1.#IND} If anybody meets this ever before? ... Thank you! Cheers, Lingyun -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=15131#15131 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] how matrixTransform works?
Hi, Gordon, Thank you for your reply. I already understood. Yun On Mon, Jul 20, 2009 at 3:42 PM, Tomlinson, Gordon gtomlin...@overwatch.textron.com wrote: Which part don't you fully understand ? the fact the your BS center is moving or the NAN ? Gordon Product Manager 3d __ Gordon Tomlinson Email : gtomlinson @ overwatch.textron.com __ -Original Message- From: osg-users-boun...@lists.openscenegraph.org [mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf Of Lingyun Yu Sent: Monday, July 20, 2009 4:36 AM To: osg-users@lists.openscenegraph.org Subject: [osg-users] how matrixTransform works? Hi, everybody Could someone explain me how matrixTransform works? In the updatecallback, I set the matrixTransform like this static float c = 1.0; c = c + 0.01; mt-setMatrix(osg::Matrixf::translate(-bs.center()) * osg::Matrixf::scale(1.0, c, 1.0) osg::Matrixf::translate(bs.center())); With the time goes by, the center of boundingbox will change frequently. At the end, some error happens like CullVisitor::applyGeode detected NaN, depth=1.#QNAN, center=49.8655 50.2613 50.5221, matrix = { 1 0 0 0 0 0 -7.21007 0 0 1 0 0 -1.#IND -1.#IND -1.#IND -1.#IND} If anybody meets this ever before? ... Thank you! Cheers, Lingyun -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=15131#15131 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.or ghttp://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.or%0Ag ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org -- Cheers, Yun ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] what's the value of RIGHT_MOUSE_BUTTON?
Hi, everybody In the GUIEventAdapter.h, we can see enum MouseButtonMask { LEFT_MOUSE_BUTTON= 10, MIDDLE_MOUSE_BUTTON = 11, RIGHT_MOUSE_BUTTON = 12 }; so right key's value is 4. and we can easily get num = 4 from int num = osgGA::GUIEventAdapter::RIGHT_MOUSE_BUTTON; But why in the EventQueue.cpp file, when we judge which botton is pressed for example, we use switch(button) { case(1): event-setButton(GUIEventAdapter::LEFT_MOUSE_BUTTON); break; case(2): event-setButton(GUIEventAdapter::MIDDLE_MOUSE_BUTTON); break; case(3): event-setButton(GUIEventAdapter::RIGHT_MOUSE_BUTTON); break; } It means RIGHT_MOUSE_BUTTON value is 3?? Cheers, Lingyun -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=12922#12922 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] what's the value of RIGHT_MOUSE_BUTTON?
I see, thank you paul. So if I want to judge which botton is pressed, I should use ea-getButton(). But what's ea-getButtonMask() use for? On Mon, May 25, 2009 at 7:45 PM, Paul Martz pma...@skew-matrix.com wrote: You seem to be confusing the incoming button parameter, which is an unsigned int, with the GUIEventAdapter MouseButtonMask, which is a completely different type. The code you quoted from EventQueue.cpp is from the function mouseButtonPress. Take a look at the code comments in the EventQueue header: /** Method for adapting mouse button pressed events, placing this event on the back of the event queue, with specified time. * Button numbering is 1 for left mouse button, 2 for middle, 3 for right. */ void mouseButtonPress(float x, float y, unsigned int button, double time); Paul Martz Skew Matrix Software LLC http://www.skew-matrix.com +1 303 859 9466 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org -- Cheers, Yun ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Taking it easy for a couple of days
Take care, Robert. Look forward for your back. On Wed, May 13, 2009 at 10:55 AM, Robert Osfield robert.osfi...@gmail.comwrote: Hi All, I've gone down with a bad cold, so am struggling to focus, read and think clearly today. So... please don't expect much support from me today, some active threads will just have do without my contribution for a couple of days. Luckily human virus can't be transmitted by email/forums just yet. Robert. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org -- Cheers, Yun ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] how can I turn a camera on and off? (UNCLASSIFIED)
camera-setNodeMask(0) and camera-setNodeMask(0x) might work. On Fri, Apr 17, 2009 at 4:26 PM, Konkle, Daniel T AMRDEC/Dynetics daniel.kon...@us.army.mil wrote: Classification: UNCLASSIFIED Caveats: NONE I need to turn a camera on and off. Use it and not use it. I've look through the docs and can't find the settings. The only thing I've found is an old reference to Producer Camera which of course didn't work. Is there a way to turn a camera on and off? thanks in advance, Danny The reference I found is below: http://www.3drealtimesimulation.com/osg/osg_faq_2.htm How can I dynamically turn a Camera On or Offb It is very straight forward to turn a Camera On or Off firest you ned to get a pointer to your camera e.g. Producer::Camera *camera = getPointerToMyCamera(); then to turn the camera On call camera-enable(); else to turn the camera Off call camera-disable(); Classification: UNCLASSIFIED Caveats: NONE ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org -- Cheers, Yun ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Problem of points showing
Hi, Ismail, I don't understand how the expanding happen? I read all dataset into an array of P, then when it expands? and why? and what's old array? On Tue, Apr 14, 2009 at 2:27 PM, Ismail Pazarbasi pazarb...@gmail.comwrote: Hi Lingyun, std::bad_alloc is thrown when operator new cannot allocate memory, which indicates there is not enough memory. You may reserve your array before hand, as Paul mentioned, but it may throw as well. This could reduce, if nothing, copy operations. It may also prevent exception, because when expanding, std::vector will have two large copies at the same time. That is: e.g. old array length was 150 expand by 50 While allocating 200 elements, previous 150 elements will also be alive/allocated, that requires room for 350 elements in total. Resize may reduce this cost to 200 only, because vector will not have to expand afterwards (i.e. during push_back), which requires a copy operation. Note that C++ standard allocator doesn't do realloc(). Instead, vector will allocate a block of N * sizeof(T) items (or little more), copy existing block into new one, then free existing block. // instantiate vertices normally vertices = new osg::Vec3Array; // if number of parts is greater than 1000, // reserve your items before. if (NumPart 1000) { try { vertices-reserve(NumPart); } catch (std::bad_alloc e) { // handle exception here; log and return error from this function. // alternatively, you can rethrow here, and catch in caller. } } // wrap your push_back calls in a try-catch block try { vertices-push_back(...); } catch (std::exception) { } To be on the safe side, handle your exceptions and wrap your pointers in a smart pointer class. If an exception is thrown and you rethrow/return from function, you need to delete your Geode, Group and other objects. You may get all these for free, if you use a smart pointer (osg::ref_ptrT, in this case, as osg::Node's destructor is protected, IIRC, which prevents it to be deleted externally, but only when its ref count reaches 0). HTH Ismail 2009/4/13 Paul Martz pma...@skew-matrix.com: Hi Lingyun Yu -- You don't have a variable named 'galaxy' defined, so the addDrawable(galaxy) is suspicious. I'd so a resize on the vertex and color arrays, rather than a push_back, for efficiency reasons. I don't think numParts100 should cause any problems. OpenGL doesn not place an upper limit on the number of primitives you can render with a single glDrawArrays call. I don't really see anything that would cause a crash so I guess you should use a debugger and look at the call stack, like you would any other crash. Paul Martz Skew Matrix Software LLC http://www.skew-matrix.com +1 303 859 9466 -Original Message- From: osg-users-boun...@lists.openscenegraph.org [mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf Of Sent: Monday, April 13, 2009 9:27 AM To: osg-users@lists.openscenegraph.org Subject: [osg-users] Problem of points showing Hi, everybody, I met a problem when I want to show huge amount of points, as you can see the code below, if my NumPart is 100, no problem, it shows points properly. But if the NumPart is 200, then it shows a lot of lines. If NumPart is even bigger, the program complained like this:Microsoft C++ exception: std::bad_alloc at memory location 0x0030e898. I don't know that's because the dataset is too big or not? because while it shows not so many points, everything goes well. By the way, the data in P array are all right. osg::Geode *makeGalaxy() { osg::Geode *geode = new osg::Geode(); osg::Geometry *geometry= new osg::Geometry(); osg::Vec3Array *vertices = new osg::Vec3Array(); osg::Vec4Array *colors = new osg::Vec4Array(); osg::Vec4 ini(1,0.1,0.55,1); osg::Vec4 fin(0,1,0,1); for (int i = 1; i = NumPart; i++) { vertices-push_back(osg::Vec3(P[i].Pos[0],P[i].Pos[1],P[i].Pos[2])); colors-push_back(ini+(fin-ini)*(i*1/NumPart)); } geometry-setVertexArray(vertices); geometry-setColorArray(colors); geometry-setColorBinding(osg::Geometry::BIND_PER_VERTEX); geometry-addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::POINTS, 0, NumPart)); geode-addDrawable(galaxy); return geode; } ... Thank you. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=10166#10166 ___ 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] Problem of points showing
And yes, after I did if (NumPart 1000) { try { vertices-reserve(NumPart); } catch (std::bad_alloc e) { // handle exception here; log and return error from this function. // alternatively, you can rethrow here, and catch in caller. } } it jumps to catch part. 2009/4/15 Lingyun Yu lingyun.yu...@gmail.com Hi, Ismail, I don't understand how the expanding happen? I read all dataset into an array of P, then when it expands? and why? and what's old array? On Tue, Apr 14, 2009 at 2:27 PM, Ismail Pazarbasi pazarb...@gmail.comwrote: Hi Lingyun, std::bad_alloc is thrown when operator new cannot allocate memory, which indicates there is not enough memory. You may reserve your array before hand, as Paul mentioned, but it may throw as well. This could reduce, if nothing, copy operations. It may also prevent exception, because when expanding, std::vector will have two large copies at the same time. That is: e.g. old array length was 150 expand by 50 While allocating 200 elements, previous 150 elements will also be alive/allocated, that requires room for 350 elements in total. Resize may reduce this cost to 200 only, because vector will not have to expand afterwards (i.e. during push_back), which requires a copy operation. Note that C++ standard allocator doesn't do realloc(). Instead, vector will allocate a block of N * sizeof(T) items (or little more), copy existing block into new one, then free existing block. // instantiate vertices normally vertices = new osg::Vec3Array; // if number of parts is greater than 1000, // reserve your items before. if (NumPart 1000) { try { vertices-reserve(NumPart); } catch (std::bad_alloc e) { // handle exception here; log and return error from this function. // alternatively, you can rethrow here, and catch in caller. } } // wrap your push_back calls in a try-catch block try { vertices-push_back(...); } catch (std::exception) { } To be on the safe side, handle your exceptions and wrap your pointers in a smart pointer class. If an exception is thrown and you rethrow/return from function, you need to delete your Geode, Group and other objects. You may get all these for free, if you use a smart pointer (osg::ref_ptrT, in this case, as osg::Node's destructor is protected, IIRC, which prevents it to be deleted externally, but only when its ref count reaches 0). HTH Ismail 2009/4/13 Paul Martz pma...@skew-matrix.com: Hi Lingyun Yu -- You don't have a variable named 'galaxy' defined, so the addDrawable(galaxy) is suspicious. I'd so a resize on the vertex and color arrays, rather than a push_back, for efficiency reasons. I don't think numParts100 should cause any problems. OpenGL doesn not place an upper limit on the number of primitives you can render with a single glDrawArrays call. I don't really see anything that would cause a crash so I guess you should use a debugger and look at the call stack, like you would any other crash. Paul Martz Skew Matrix Software LLC http://www.skew-matrix.com +1 303 859 9466 -Original Message- From: osg-users-boun...@lists.openscenegraph.org [mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf Of Sent: Monday, April 13, 2009 9:27 AM To: osg-users@lists.openscenegraph.org Subject: [osg-users] Problem of points showing Hi, everybody, I met a problem when I want to show huge amount of points, as you can see the code below, if my NumPart is 100, no problem, it shows points properly. But if the NumPart is 200, then it shows a lot of lines. If NumPart is even bigger, the program complained like this:Microsoft C++ exception: std::bad_alloc at memory location 0x0030e898. I don't know that's because the dataset is too big or not? because while it shows not so many points, everything goes well. By the way, the data in P array are all right. osg::Geode *makeGalaxy() { osg::Geode *geode = new osg::Geode(); osg::Geometry *geometry= new osg::Geometry(); osg::Vec3Array *vertices = new osg::Vec3Array(); osg::Vec4Array *colors = new osg::Vec4Array(); osg::Vec4 ini(1,0.1,0.55,1); osg::Vec4 fin(0,1,0,1); for (int i = 1; i = NumPart; i++) { vertices-push_back(osg::Vec3(P[i].Pos[0],P[i].Pos[1],P[i].Pos[2])); colors-push_back(ini+(fin-ini)*(i*1/NumPart)); } geometry-setVertexArray(vertices); geometry-setColorArray(colors); geometry-setColorBinding(osg::Geometry::BIND_PER_VERTEX); geometry-addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::POINTS, 0, NumPart)); geode-addDrawable(galaxy); return geode; } ... Thank you. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=10166#10166
Re: [osg-users] Problem of points showing
Hi, Ismail, ok, jey, I really need to read it. thank you very much. On Wed, Apr 15, 2009 at 4:11 PM, Ismail Pazarbasi pazarb...@gmail.comwrote: Lingyun, I strongly recommend you to read your std::vector implementation's source code and debug it to understand its behavior. Vector starts with 0 or room for few elements. When you push_back, it checks for available space in its internal block. If requested size is greater than current capacity, vector will want to grow to accomodate new items. Because it can't realloc, it will allocate a completely new buffer, which will be greater than or equal to new size (new size is greater than the current size). For instance: std::vectorint v; // push_back 6 items... 'v' has 6 items. that is, 6 * sizeof(int) memory for storage. if you want to insert 7th item, vector needs to grow (how much it grows depends on implementation; e.g. Visual C++'s, Dinkumware's library says try to grow by 50%), because there is no room to place 7th item. To perform this operation, library allocates a new block of memory that can accomodate *at least* 7 items *before* destroying existing block. Dinkumware's library expands by 50%, so it may grow by 3 items' size (assuming it had 6 items), which makes new capacity 9 items (6 + (6 * 0.5)). This sums up: 6 existing items 9 new size +-- 15 items. After new block is allocated successfully, vector copies its existing objects (6 objects) onto new buffer (which can hold 9 items). After copy succeeds, vector destroys previous buffer (6 items), then you have a vector whose capacity is sizeof(int) * 9. Until 9th item, vector will not need to reallocate memory. 2009/4/15 Lingyun Yu lingyun.yu...@gmail.com: Hi, Ismail, I don't understand how the expanding happen? I read all dataset into an array of P, then when it expands? and why? and what's old array? On Tue, Apr 14, 2009 at 2:27 PM, Ismail Pazarbasi pazarb...@gmail.com wrote: Hi Lingyun, std::bad_alloc is thrown when operator new cannot allocate memory, which indicates there is not enough memory. You may reserve your array before hand, as Paul mentioned, but it may throw as well. This could reduce, if nothing, copy operations. It may also prevent exception, because when expanding, std::vector will have two large copies at the same time. That is: e.g. old array length was 150 expand by 50 While allocating 200 elements, previous 150 elements will also be alive/allocated, that requires room for 350 elements in total. Resize may reduce this cost to 200 only, because vector will not have to expand afterwards (i.e. during push_back), which requires a copy operation. Note that C++ standard allocator doesn't do realloc(). Instead, vector will allocate a block of N * sizeof(T) items (or little more), copy existing block into new one, then free existing block. // instantiate vertices normally vertices = new osg::Vec3Array; // if number of parts is greater than 1000, // reserve your items before. if (NumPart 1000) { try { vertices-reserve(NumPart); } catch (std::bad_alloc e) { // handle exception here; log and return error from this function. // alternatively, you can rethrow here, and catch in caller. } } // wrap your push_back calls in a try-catch block try { vertices-push_back(...); } catch (std::exception) { } To be on the safe side, handle your exceptions and wrap your pointers in a smart pointer class. If an exception is thrown and you rethrow/return from function, you need to delete your Geode, Group and other objects. You may get all these for free, if you use a smart pointer (osg::ref_ptrT, in this case, as osg::Node's destructor is protected, IIRC, which prevents it to be deleted externally, but only when its ref count reaches 0). HTH Ismail 2009/4/13 Paul Martz pma...@skew-matrix.com: Hi Lingyun Yu -- You don't have a variable named 'galaxy' defined, so the addDrawable(galaxy) is suspicious. I'd so a resize on the vertex and color arrays, rather than a push_back, for efficiency reasons. I don't think numParts100 should cause any problems. OpenGL doesn not place an upper limit on the number of primitives you can render with a single glDrawArrays call. I don't really see anything that would cause a crash so I guess you should use a debugger and look at the call stack, like you would any other crash. Paul Martz Skew Matrix Software LLC http://www.skew-matrix.com +1 303 859 9466 -Original Message- From: osg-users-boun...@lists.openscenegraph.org [mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf Of Sent: Monday, April 13, 2009 9:27 AM To: osg-users@lists.openscenegraph.org Subject: [osg-users] Problem of points showing Hi, everybody, I met a problem
Re: [osg-users] Problem of points showing
Thank you very much, Ismail and Martin, I have 3G memory installed. and 1.02G is avaible, I use windows vista. and I didn't use file page file/swap. I will read carefully about both of you suggested. If you have some source can be read for that, please tell me. Yun On Wed, Apr 15, 2009 at 5:10 PM, Martin Beckett m...@mgbeckett.com wrote: vector typically doubles the size of memory it reserves when it needs more space. This is because every time it allocates new memory it must move the contents of the existing memory - it's slow to copy all the existing elements and so it makes sense to only increase as few times as possible (see http://www.ddj.com/cpp/184401375 for a discussion). Unfortunately this isn't a good stratergy when you are almost out of memory. Another problem is that the memory must be contiguous (ie in one block), so if you frequently allocate and delete memory there might not be a single free block large enough - even if you have enough overall memory. There is also a little 'trick' to reduce a vector back down to the minimum required memory - see http://www.gotw.ca/gotw/054.htm Code: vectorstuff( c ).swap( c ); (note - can someone confirm the swap() trick works with ref counting?) -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=10259#10259 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org -- Cheers, Yun ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Problem of points showing
no, 2G is avaible I mean On Wed, Apr 15, 2009 at 5:43 PM, Lingyun Yu lingyun.yu...@gmail.com wrote: Thank you very much, Ismail and Martin, I have 3G memory installed. and 1.02G is avaible, I use windows vista. and I didn't use file page file/swap. I will read carefully about both of you suggested. If you have some source can be read for that, please tell me. Yun On Wed, Apr 15, 2009 at 5:10 PM, Martin Beckett m...@mgbeckett.com wrote: vector typically doubles the size of memory it reserves when it needs more space. This is because every time it allocates new memory it must move the contents of the existing memory - it's slow to copy all the existing elements and so it makes sense to only increase as few times as possible (see http://www.ddj.com/cpp/184401375 for a discussion). Unfortunately this isn't a good stratergy when you are almost out of memory. Another problem is that the memory must be contiguous (ie in one block), so if you frequently allocate and delete memory there might not be a single free block large enough - even if you have enough overall memory. There is also a little 'trick' to reduce a vector back down to the minimum required memory - see http://www.gotw.ca/gotw/054.htm Code: vectorstuff( c ).swap( c ); (note - can someone confirm the swap() trick works with ref counting?) -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=10259#10259 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org -- Cheers, Yun -- Cheers, Yun ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Problem of points showing
Thank you, Paul and Ismail! I will try Ismail's solution, and will tell you the result. On Tue, Apr 14, 2009 at 2:27 PM, Ismail Pazarbasi pazarb...@gmail.comwrote: Hi Lingyun, std::bad_alloc is thrown when operator new cannot allocate memory, which indicates there is not enough memory. You may reserve your array before hand, as Paul mentioned, but it may throw as well. This could reduce, if nothing, copy operations. It may also prevent exception, because when expanding, std::vector will have two large copies at the same time. That is: e.g. old array length was 150 expand by 50 While allocating 200 elements, previous 150 elements will also be alive/allocated, that requires room for 350 elements in total. Resize may reduce this cost to 200 only, because vector will not have to expand afterwards (i.e. during push_back), which requires a copy operation. Note that C++ standard allocator doesn't do realloc(). Instead, vector will allocate a block of N * sizeof(T) items (or little more), copy existing block into new one, then free existing block. // instantiate vertices normally vertices = new osg::Vec3Array; // if number of parts is greater than 1000, // reserve your items before. if (NumPart 1000) { try { vertices-reserve(NumPart); } catch (std::bad_alloc e) { // handle exception here; log and return error from this function. // alternatively, you can rethrow here, and catch in caller. } } // wrap your push_back calls in a try-catch block try { vertices-push_back(...); } catch (std::exception) { } To be on the safe side, handle your exceptions and wrap your pointers in a smart pointer class. If an exception is thrown and you rethrow/return from function, you need to delete your Geode, Group and other objects. You may get all these for free, if you use a smart pointer (osg::ref_ptrT, in this case, as osg::Node's destructor is protected, IIRC, which prevents it to be deleted externally, but only when its ref count reaches 0). HTH Ismail 2009/4/13 Paul Martz pma...@skew-matrix.com: Hi Lingyun Yu -- You don't have a variable named 'galaxy' defined, so the addDrawable(galaxy) is suspicious. I'd so a resize on the vertex and color arrays, rather than a push_back, for efficiency reasons. I don't think numParts100 should cause any problems. OpenGL doesn not place an upper limit on the number of primitives you can render with a single glDrawArrays call. I don't really see anything that would cause a crash so I guess you should use a debugger and look at the call stack, like you would any other crash. Paul Martz Skew Matrix Software LLC http://www.skew-matrix.com +1 303 859 9466 -Original Message- From: osg-users-boun...@lists.openscenegraph.org [mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf Of Sent: Monday, April 13, 2009 9:27 AM To: osg-users@lists.openscenegraph.org Subject: [osg-users] Problem of points showing Hi, everybody, I met a problem when I want to show huge amount of points, as you can see the code below, if my NumPart is 100, no problem, it shows points properly. But if the NumPart is 200, then it shows a lot of lines. If NumPart is even bigger, the program complained like this:Microsoft C++ exception: std::bad_alloc at memory location 0x0030e898. I don't know that's because the dataset is too big or not? because while it shows not so many points, everything goes well. By the way, the data in P array are all right. osg::Geode *makeGalaxy() { osg::Geode *geode = new osg::Geode(); osg::Geometry *geometry= new osg::Geometry(); osg::Vec3Array *vertices = new osg::Vec3Array(); osg::Vec4Array *colors = new osg::Vec4Array(); osg::Vec4 ini(1,0.1,0.55,1); osg::Vec4 fin(0,1,0,1); for (int i = 1; i = NumPart; i++) { vertices-push_back(osg::Vec3(P[i].Pos[0],P[i].Pos[1],P[i].Pos[2])); colors-push_back(ini+(fin-ini)*(i*1/NumPart)); } geometry-setVertexArray(vertices); geometry-setColorArray(colors); geometry-setColorBinding(osg::Geometry::BIND_PER_VERTEX); geometry-addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::POINTS, 0, NumPart)); geode-addDrawable(galaxy); return geode; } ... Thank you. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=10166#10166 ___ 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
Re: [osg-users] Problem of points showing
Thanks Martin, yes, this is also a solution. thank you very much. Yun On Tue, Apr 14, 2009 at 4:04 PM, Martin Beckett m...@mgbeckett.com wrote: The c++ standard also requires that the memory for vector is contiguous like a C array. You can try reserving the memory soon after program start and keep the array around until you load the data, the memory has the least chance of being fragmented before anything else is allocated. You can also split the data into smaller blocks and attach multiple geometries to the same geode - the 3dc plugin does this to limit the blocks to 10,000 points -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=10201#10201 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org -- Cheers, Yun ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Problem of points showing
Hi, everybody, I met a problem when I want to show huge amount of points, as you can see the code below, if my NumPart is 100, no problem, it shows points properly. But if the NumPart is 200, then it shows a lot of lines. If NumPart is even bigger, the program complained like this:Microsoft C++ exception: std::bad_alloc at memory location 0x0030e898. I don't know that's because the dataset is too big or not? because while it shows not so many points, everything goes well. By the way, the data in P array are all right. osg::Geode *makeGalaxy() { osg::Geode *geode = new osg::Geode(); osg::Geometry *geometry= new osg::Geometry(); osg::Vec3Array *vertices = new osg::Vec3Array(); osg::Vec4Array *colors = new osg::Vec4Array(); osg::Vec4 ini(1,0.1,0.55,1); osg::Vec4 fin(0,1,0,1); for (int i = 1; i = NumPart; i++) { vertices-push_back(osg::Vec3(P[i].Pos[0],P[i].Pos[1],P[i].Pos[2])); colors-push_back(ini+(fin-ini)*(i*1/NumPart)); } geometry-setVertexArray(vertices); geometry-setColorArray(colors); geometry-setColorBinding(osg::Geometry::BIND_PER_VERTEX); geometry-addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::POINTS, 0, NumPart)); geode-addDrawable(galaxy); return geode; } ... Thank you. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=10166#10166 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] osgmovie problem
I also updated my driver to the newest. it is still the same. my quicktime version is 7.3. Is it too old? On Thu, Apr 2, 2009 at 1:57 AM, Ulrich Hertlein u.hertl...@sandbox.dewrote: On 2/4/09 5:32 AM, Lingyun Yu wrote: another warning TextureRectangle::apply(..) failed, texture rectangle is not support by your OpenGL drivers. That explains the white rectangle. The 8800 definitively supports texture rectangles. Maybe you need to update your driver? /ulrich ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org -- Cheers, Yun ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] osgmovie problem
Hi, while I am running osgmovie, I met the warning like warning: GraphicsWindowWin32::grabFocus failed grabbing the focus then only a white window on the screen. what's wrong with this? Thank you. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=9548#9548 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] osgmovie problem
Now I use osg2.9 to run it. it doesn't have warning anymore, but still just a white window On Wed, Apr 1, 2009 at 6:50 PM, Lingyun Yu lingyun.yu...@gmail.com wrote: Hi, while I am running osgmovie, I met the warning like warning: GraphicsWindowWin32::grabFocus failed grabbing the focus then only a white window on the screen. what's wrong with this? Thank you. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=9548#9548 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org -- Cheers, Yun ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] osgmovie problem
Other examples run fine. I already compiled with quicktime plugins. my graphics card is Nvidia geforce 8800 GTX I just use osgmovie d:\1.avi robertosfield wrote: Hi Yun, No one will be able to help you unless you provide more information. Key details are graphics card/graphics driver. Also do other examples run fine? Have you compiled with the ffmpeg or quicktime plugins? What exactly command line options are you using? Robert. 2009/4/1 Lingyun Yu () Now I use osg2.9 to run it. it doesn't have warning anymore, but still just a white window On Wed, Apr 1, 2009 at 6:50 PM, Lingyun Yu () wrote: Hi, while I am running osgmovie, I met the warning like warning: GraphicsWindowWin32::grabFocus failed grabbing the focus then only a white window on the screen. what's wrong with this? Thank you. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=9548#9548 (http://forum.openscenegraph.org/viewtopic.php?p=9548#9548) ___ osg-users mailing list () http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org (http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org) -- Cheers, Yun ___ osg-users mailing list () http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org (http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org) -- Post generated by Mail2Forum -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=9561#9561 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] osgmovie problem
Warning: GraphicsWindowWin32::grabFocus() - Failed grabbing the focus -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=9562#9562 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] osgmovie problem
another warning TextureRectangle::apply(..) failed, texture rectangle is not support by your OpenGL drivers. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=9563#9563 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Manipulator or Mouse Event
Hi, Robert and every friend, I want to implement some interaction gestures like IPod or IPhone. I don't know if I need to design another manipulator or just design a mouse event. So my question is, when do I need to make another manipulator like Driver or so, when do I need to make a mouse event? Thank you. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=9465#9465 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] How to remove the blue background color
Hi dat, I think viewer-getCamera()-setClearColor() can make it. Yun 2009/3/25 tien dat tienda...@gmail.com Dear all, I need to remove the blue background color so that I can do augmented display (you can run the cow.osg example to see the blue color). Do any of you know how to do that? Thank you very much, Dat ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org -- Cheers, Yun ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Trackball Manipulator in OpenGL + OSG
Hi, everybody, I used viewer-setUpViewerAsEmbeddedInWindow way as Robert suggested to embed an OSG window in OpenGL context. Then I tried to setup Manipulator like Trackball, I did some code like this: osg::observer_ptrosgViewer::GraphicsWindow gw = viewer-setUpViewerAsEmbeddedInWindow(...) if(event-button() == Qt::LeftButton) button = 0; else if(event-button() == Qt::RightButton) button = 2; In mousePressEvent: if(gw-valid() isInRange(event-x(), height - event-y())) (gw-getEventQueue())-mouseButtonPress(event-x(), event-y(), button + 1); In mouseReleaseEvent: if(gw-valid() isInRange(event-x(), height - event-y())) (gw-getEventQueue())-mouseButtonPress(event-x(), event-y(), button + 1); isInRange Function judge if event happen in the OSG window. Problem is when I only use left key, or only use right key, no problem at all. But if I switch once, then it just pan the whole scene, both keys lost their own ability. anybody has any idea about it? Thank you. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=9097#9097 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Trackball Manipulator in OpenGL + OSG
please ignore my question. I just made something stupid. [Laughing] -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=9100#9100 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] OSG in an existing OpenGL context
Robert Osfield wrote: Hi Uli, Perhaps another solution would be to render the OSG scene to a a pbuffer and then use the pbuffer as a texture source for the original graphics context. This would isolate the OSG and your own OpenGL context completely from each other. Robert. On Fri, Jan 23, 2009 at 9:56 AM, Ulrich von Zadow wrote: Hi, we are using OSG here to render into an OpenGL context created outside of OSG. The application renders some stuff into the context, then OSG renders its scene graph, and then the application renders some more things on top of what OSG has rendered. This raises some state management questions. Here is some pseudocode that shows what we're doing: void render() { renderApplicationScene(); pushGLState(); hackToSetStateToWhatOSGExpects(); m_pSceneView-update(); m_pSceneView-cull(); m_pSceneView-draw(); popGLState(); renderMoreApplicationStuff(); } This works, but the line that sais 'hackToSetStateToWhatOSGExpects()' bothers me ;-). Is there a way to tell OSG to set the OpenGL state in a non-lazy fashion once? Some background: This is a plugin for the 2d engine libavg that places an OSG scene graph inside of the 2d scene graph that libavg uses. libavg itself has no dependency on OSG and it's rendering state should be completely independent of the OSG state. Any ideas? Thanks, Uli -- Ulrich von Zadow Software Engineer (Dipl. Inf.) Exhibit Development Tel +49 (0)30 / 2000 577 12 Fax +49 (0)30 / 2000 577 20 Skype: uzadow Archimedes Solutions GmbH SaarbrüŸcker Str. 24 10405 Berlin www.archimedes-solutions.com GeschŠftsfŸührung: A. Valder | D. Feser | W. Rien | J. Schmidtsiefen | S. Spenling Amtsgericht: Berlin Charlottenburg HR Nr.: 107563 B UST-ID Nr.: DE-253.771.793 ___ osg-users mailing list http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org -- Post generated by Mail2Forum If I use pbuffer, I can still keep osg manipulator somewhere? -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=8908#8908 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] switch between two camera
Hi, Ben, I use something like camera0-setNodeMask(0X); camera1-setNodeMask(0); to enable camera0 but disable camera1. I hope it helps. Yun On Fri, Mar 20, 2009 at 10:48 AM, Ben ben.poul...@gmail.com wrote: Hi, if I have understood , I must design my application with a CompositeViewer in order to use two scene, each in it's own view. I have a 3D classic view and a map vue. How can I display only one at once using compositeviewer? (I don't see how to use nodemask) thank's ps: sorry to post beginners questions . [Rolling Eyes] -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=8833#8833 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org -- Cheers, Yun ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] GraphicsContext problem
Hi guys, I want to use OpenGL to render the interface, but use OSG to render in a region. And in this region I use OSG manipulator, but in the rest of the interface I use others. I don't know if it is possible, if it is, how to do? Thanks in advance. -- Cheers, Yun ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] switch between two camera
Hi ben, where did you put your code? I put them in the updatecallback function, that's why mine will change every frame. Yun 2009/3/20 Ben ben.poul...@gmail.com benbao wrote: I try to use nodemask but doesn't work. Id do this : Code: osgViewer::CompositeViewer viewer; osgViewer::GraphicsWindowEmbedded* gw = new osgViewer::GraphicsWindowEmbedded; osgViewer::View* vue2D = new osgViewer::View; osgViewer::View* vue3D = new osgViewer::View; viewer.addView(vue2D); viewer.addView(vue3D); vue2D-getCamera()-setGraphicsContext(gw ); vue2D-getCamera()-setProjectionMatrixAsPerspective(30.0f, width()/(double) height(), 1.0, 1000.0); vue2D-getCamera()-setViewport(new osg::Viewport(0,0,width(),height() )); vue2D-setCameraManipulator(new osgGA::TrackballManipulator); vue3D-getCamera()-setGraphicsContext(gw ); vue3D-getCamera()-setProjectionMatrixAsPerspective(30.0f, width()/(double) height(), 1.0, 1000.0); vue3D-getCamera()-setViewport(new osg::Viewport(0,0,width(),height() )); vue3D-setCameraManipulator(new osgGA::TrackballManipulator); Code: // to switch vue3D OFF and vue2D on vue2D-getCamera()-setNodeMask(0X); vue3D-getCamera()-setNodeMask(0); sorry it's work, but only the view on top is updated by mouse manipulator. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=8854#8854 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org -- Cheers, Yun ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] GraphicsContext problem
nobody had the same thing? On Fri, Mar 20, 2009 at 12:20 PM, Lingyun Yu lingyun.yu...@gmail.comwrote: Hi guys, I want to use OpenGL to render the interface, but use OSG to render in a region. And in this region I use OSG manipulator, but in the rest of the interface I use others. I don't know if it is possible, if it is, how to do? Thanks in advance. -- Cheers, Yun -- Cheers, Yun ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Intergration with OSG
Hi all, Does anybody know if I can render one part of window in OSG, and use another framework to render the rest? Thanks. -- Cheers, Yun ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] switch between two camera
Hi Robert, I also meet the same problem, I have 128 snapshots of particles, and I want to use those 128 shapshots to make an real time animation. First thing I tried, was using a update callback function and bind it on my geode, everytime I just updated all positions of particles. But obviously it was quite slow. Then I tried to use two view, and each one has it's own camera, and render two snapshots in the same time. Well, it works, but still very slow. Then I tried to use one view but two cameras, and load three snapshots in the same time, two below two caremas, one below my Root. because I do really need to update it. And link the right snapshots while I need to render it. Somehow it is still slow, and while it switches snapshots and I use trackball, it is played not fruently. So my question is, basicly I need to render un-structed points dataset, and I have a lot snapshots, do you have any idea how can I make an realtime animation fruently? Looking forward to your reply and thank you very much. Yun 2009/3/16 Robert Osfield robert.osfi...@gmail.com Hi Peter, Benoit et, On Mon, Mar 16, 2009 at 8:15 PM, Peter Amstutz peter.amst...@tseboston.com wrote: The way I handled this in my application was to create multiple instances of osgViewer::Viewer with a separate camera for each view but all bound to the same output window. On each render iteration, draw just the active camera. I'm afraid I really wouldn't recommend this solution, having multiple viewers just to alternate between views is complicated implementation and conceptual wise and you'd be very lucky for it to work in anything other that very limited usage models. Using multiple viewers will cause problems with threading, timing codes, it'd be a right old mess. The best solution depends on exactly what you need to display; I decided to switch between completely independent scenes because my 2D and 3D views looks actually render somewhat different geometry (the 2D ortho view is an abstracted version of the real 3D geometry). Having entirely separate scenes is also pretty straightforward although it imposes some overhead due to duplication of resources that could otherwise be shared between among views. In your case you are talking about multiple Views, and this is fine, but you don't use multiple Viewers for it, you'd use a single CompositeViewer with multiple Views. You can add and remove Views, or just toggle Camera's on/off using NodeMask's. For Benoit having a single master Camera track different CameraView nodes in the scene might well be the most convinient way to manage things. Robert. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org -- Cheers, Yun ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org