Re: [osg-users] Bug when using multiple instances of osgViewer::Viewer
Hi Robert, I can't speak for Stefan in regards to the design choice of multiple Viewers rather than a CompositeViewer, but we made the same choice in our system. The reason is that our application provides functionality via a plugin system, and ideally plugins can be agnostic about what other plugins are doing. It is not uncommon for multiple plugin modules running simultaneously to use the OSG for rendering, and it was much simpler to let each plugin create a Viewer if it so desired - and for us, it works great. Cheers, Tom -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=45733#45733 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] setViewMatrixAsLookAt in Qt
Hi Chris, Can you give a bit more info about what you've tried and why it isn't working? I haven't worked with osgViewerQt before, but it looks like it inherits from osgViewer::Viewer, runs in single threaded mode, and frame() is called by the paintGL method, which is presumably triggered by the QApplication's event loop. In this case, it ought to be safe to set the camera position in other events in the same loop, such as user interaction through the sliders you want to use. What I'd recommend is connecting the sliders via the signal/slot mechanism to a function you define, which reads the value of each slider and creates an osg::Vec3 from them. This will be your eye vector. You also will define the center vector (the point the camera aims at) and the up vector of the camera. To actually get the camera, use ViewerQT::getCamera() (inherited from osgViewer::Viewer). Then make the call to setViewMatrixAsLookAt with the vectors from above. Hope that helps, Tom -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=45699#45699 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Running a viewer in a thread other than main thread
We use multiple viewers created and run from multiple threads, since our application is heavily modular and multiple modules can create and control their own viewers without a central coordinator. We don't limit what threading mode is used, and we haven't had problems with multiple viewers in multithreaded mode. We haven't done anything particularly complex as far as rendering goes so I don't know what the performance implications are, but I know it works for some things at least. Cheers, Tom -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=44279#44279 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Viewer/CompositeViewer inconsistency?
Hi Thomas, If you don't actually need the functionality of the 3rd party's update callbacks you could remove them using a custom visitor. Or you could do as Robert suggests and write your own frame loop which ignores the call you're having problems with as you see fit. This option really would not take much effort and would let you customize exactly the behavior you want. I don't have any experience with your other issue, sorry. Tom -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=43655#43655 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] ANN: osgBullet v2.0 RC available
Hi Paul, Congratulations, this looks great! It looks like something we'll be very interested in integrating with our system. I look forward to giving it a try - unfortunately I'm consumed with other projects at the moment so I won't be able to contribute to the testing any time soon. Hopefully in the next few months though! Thank you! Tom -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=43388#43388 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Viewer thread safety question
Hi ?, How frequent of an occurrence is the need to add/remove portions of the scene graph? And what kind of performance are you looking for as it happens? If it is infrequent, could you simply stop threading on the viewer, modify your scene graph structure however you need to, and start threading again (and your frame loop) after you're done? I've used an UpdateCallback in the past to add/replace nodes while the viewer is running. It wouldn't be particularly difficult to go this route (subclass from NodeCallback, use whatever threadsafe mechanism you want within the class to synchronize with your incoming data, and when needed add a child to a group node which has the callback attached). You could test the performance of it in your application, which is more important than what anyone can speculate about. Cheers, Tom -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=43341#43341 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] RemoveChild() overwriting application memory
Hi Joel, I can't tell what's going on from your description - is your Scene class derived from osg::Node and a child of root? If so, this may explain why a raw Scene* pointer is a problem. I'm having trouble picturing the layout of your application, if you can give more details that may help. Cheers, Tom -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=42942#42942 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] QT-OSG problem
Hi Thomas, I think a bit more information would be useful. Werner is correct about Qt paint events in that all QWidgets must be created in the QApplication thread and cannot be moved to any other threads. If you're trying to use osg to render into a Qt-based window, this will be an issue. However, it sounds like you have a completely separate osgViewer window. In this case, you are doing exactly what we do in the project I work on - and it works fine. Your description that some elements disappear isn't enough information for me to get an idea of what is happening. Are these elements QWidgets, or something else? I'm afraid where I am at the moment I don't have the tools to open your attached code, if you post some relevant code snippets in a message or just describe your application in more detail I may be able to help though. If you do Qt stuff in Qt gui windows, and have a scene graph of all non-qt stuff rendered in an osgViewer window, you should be totally fine - you just need to handle how you're updating your scene based on gui input in a threadsafe way. Cheers, Tom -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=42082#42082 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Determining whether a node is active in UpdateVisitor.
Hi Mark, I don't know if this is optimal or not, but one thing you could do is use the NodeVisitor::getNodePath() method. You can look through the path to find any switch nodes, and use the Switch::getChildValue(const Node*) method to see if the next node in the list is on or off. This is of course assuming that this is what you meant by active. Cheers, Tom -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=41956#41956 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] NodeCallback
Classes derived from NodeCallback are attached to nodes in the scene graph and operated during a scene graph traversal. Since the class you've posted is named CameraUpdateCallback, I'm guessing it is added using the setUpdateCallback method. During the update traversal of the scene, the update visitor calls the operator()(osg::Node* n, osg::NodeVisitor* nv) method. Since the callback is attached to a Camera node, n can be cast to a pointer to the Camera. The view and projection matrices of the camera are set based on the view and projection matrices of some other camera (mOtherCamera). So to answer your final questions, it is operated during the update traversal (until it is removed from the Camera node, if that ever happens), and it operates on whichever node in the scene graph that it is attached to. Cheers, Tom -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=41765#41765 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] OpenThreads/Windows7 issue
Hi Dietmar, Thanks for the reply. The variable aMutex is definitely valid - it is initialized on the stack in the constructor of the object that uses it. The call succeeds almost all the time, the program can go for minutes or hours before the crash occurs. And as I mentioned, entering and exiting a debugger allows program execution to continue. We've also seen similar issues with crashes in osg-65.dll where debugging and continuing succeeds, also only on Windows7. That's why I suspect it is something with the OS and not our code, as we never had/have this issue on our XP machines. I'm fairly lost as to how to go about debugging further other than trying to write very stripped down hello world type programs which reproduce the crash. Cheers, Tom -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=41550#41550 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] OpenThreads/Windows7 issue
Hi everyone, Has anyone experienced issues with OpenThreads on Windows 7? I don't exactly know how to describe the glitch we're seeing, but I'll give it a go and hope that someone can shed more light on it. Occasionally a crash occurs in an application, and a dialog pops up asking to debug. If I click no, the application exits. However, if I click yes, after debugging, the application will continue as if there were no problem. Upon debugging, Vis. Studio pops up and shows an unhandled exception, error writing to location... The line it identifies is always Code: OpenThreads::ScopedLock(OpenThreads::Mutex) lock(aMutex); I should note that ntdll.dll and the openthreads dll (ot11-OpenThreads.dll I believe, don't have the crash up in front of me right now though) are on the top of the call stack in the debugger, and the above call is immediately below those. I tried wrapping the call in a try/catch block to see if I could get more information about the exception, however the crash still happens and the debugger reports it on the same line without getting to the catch statements. (I'm very very inexperienced at using try/catch so I'm not even sure if I should expect it to work that way or not.) The crash occurs even when only a single thread accesses that method (we got rid of the other threads to test it out) so it shouldn't be that the crash is related to trying to access a locked mutex. System info: Windows 7 64-bit (we haven't seen the issue in XP, and don't have 32 bit 7) 32 and 64 bit projects both have the crash osg 2.8.4 Visual Studio 2008 The application also uses Qt, not sure if that is even relevant. Not all of our projects crash like this, but they all use the same source code for the osg/OpenThreads components. Does anyone have any experience with similar issues? Thanks for any input, Tom -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=41524#41524 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Setting up a camera
Hi Diana, I find it pretty convenient to use Code: getCamera()-setViewMatrixAsLookAt (const osg::Vec3 eye, const osg::Vec3 center, const osg::Vec3 up) for setting up the view matrix, it was one of Robert's suggestions but I thought I'd re-emphasize it. Vec3 eye will be the position you're getting from the server. Vec3 center will be the point the camera is aiming at - it doesn't have to be the center of the scene, if you are given or can calculate the direction vector the camera is pointing along, (0,1,0) for example to look along the y-axis, you can add that to your eye point and use the result as center. Vec3 up orients the camera, think about taking a photo in portrait vs landscape vs some other angle. To start if you know the coordinates of some point in the scene, you could use that as center and just play with changing eye, the camera will always look at the same point (center) but from different places. After that, you could then work on calculating center based on the orientation you're receiving from the server. HTH, Cheers, Tom -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=40217#40217 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] How to get the matrix of a PositionAttitudeTransform node?
Looking at the source code for computeLocalToWorldMatrix and computeWorldToLocalMatrix, the node visitor argument is ignored, so it would seem safe to use these functions and pass NULL as the second argument. I haven't tried it though. Cheers, Tom -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=39410#39410 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] stats issue with svn
Martin, J-S, Do you happen to know if this issue occurs only when the stats are enabled, or if it also occurs in the viewer without the stats displayed? I ask because I've never actually used the stats functionality, but sometimes when we launch our application, the graphics appear lower quality (as in occasional jumpiness) but other times this problem is gone or at least barely noticeable. I'm just curious if this might be the same issue. Cheers, Tom -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=39048#39048 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] NodeTrackerManipulator and PositionAttitudeTransform
Hi Tim, I've never used NodeTrackerManipulator personally, nor have I used oceanExample (or even PositionAttitudeTransform, I always just use MatrixTransform). So obviously I won't be much help. However, I think maybe it would make sense for you to make a small test application (small scene, just a couple of objects in it) to play around with and figure out how to do what you want with different node types, manipulators, etc. One thing to consider may be this old topic re:NodeTrackerManipulator: http://forum.openscenegraph.org/viewtopic.php?t=4890 Cheers, Tom -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=37808#37808 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Trouble Understanding osgPick (pick example QSG)
Hi Sanat, Code: const osg::NodePath nodePath = picker-getFirstIntersection().nodePath; is only giving you the first intersection, which may not be either of your models (it could be terrain, for example). I'm guessing you need to search the entire set rather than just trying the first intersection. Code: Intersections osgUtil::PolytopeIntersector::getIntersections () typedef std::setIntersection osgUtil::PolytopeIntersector::Intersections Cheers, Tom -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=37335#37335 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Trouble Understanding osgPick (pick example QSG)
osg::NodePath is: typedef std::vector Node* osg::NodePath Since you have two Node*s that you're looking for, you can iterate through the NodePath just like any other vector and compare your pointer to the pointers in the vector. You could also apply your intersection visitor to the nodes you're interested in rather than the scene root and just check if it intersects with anything in that case. I haven't worked with intersectors in a while though so I may be wrong. Cheers, Tom -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=37307#37307 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] osg::Quat
Hi Lucie, What you're looking for is how to convert the quaternion representation of a rotation into the Euler angle representation. Take a look at http://en.wikipedia.org/wiki/Conversion_between_quaternions_and_Euler_angles for more info and the equations. Alternatively, you can get the rotation about an arbitrary axis this way: 1) Create a unit vector perpendicular to your axis (e.g. (0,1,0) for rotations about the z-axis) 2) Rotate this vector by the quat: rotated = quat * forward_vec * quat.conj() 3) Project the result onto the plane perpendicular to your axis (see http://www.euclideanspace.com/maths/geometry/elements/plane/lineOnPlane/index.htm for info on projecting vectors onto planes) 4) Normalize the result to unit length. 5) Take the dot product between your initial forward vector and this normalized rotated forward vector. 6) Take the inverse cosine to get the angle. Cheers, Tom -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=35869#35869 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Making a Visible Vector with Translating point
Hi Richard, You seem to have a lot of the pieces already sort of in place. I'm not sure exactly what you're asking... but here goes. To have something render, you want to create an object of class osgViewer::Viewer. Then you need to add data (your scene graph) to the viewer using setSceneData(osg::Node*). In your case, this will be the PositionAttitudeTransform node (vectorOrient), which has the update callback attached and the geode (lineVector1) as a child as you've already done. Then you need to call viewer.run(), or create a loop with viewer.frame() within it. In the callback, it sounds like you want to set the attitude(rotation) of the PAT node. So, instead of calling setPosition(Vec3), you want to use setAttitude(Quat). The Quat class has a makeRotate method which creates a quaternion to rotate from one vector to another. So you want to have two vectors, one which points in the initial direction of the line you want to draw (defined when you created the geometry) and the other which points in the desired direction depending on your dynamic data. Once you have those vectors, do moveVector-setAttitude(osg::Quat::makeRotate(initial_vec, final_vec)). Hope that helps you get started, Tom -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=35879#35879 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] draw a half cone
Hi Lucie, I haven't tried it out but it looks like in the inner for loop, numSegments is defining how many panels it takes to complete a circle. If you iterate only until numSegments/2 it might give what you're looking for? Code: for(unsigned int topi=0; topi numSegments/2; ++topi,angle+=angleDelta,texCoord+=texCoordHorzDelta) {...} Tom -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=35706#35706 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Improper rotation
Hi Axel, In the step where you're calculating m, it looks like you're applying the rotation to the original matrix, which includes a translation already. Code: osg::Matrix m = amtRod-getMatrix() * osg::Matrix::rotate(rotation, osg::Vec3(0,1,0)); It sounds like what you want to do is rotate then translate - so you can create a rotation matrix, post-multiply it by a translation matrix (the translation of the original), and set the product as your overall matrix. Something like: Code: osg::Matrix rotation = osg::Matrix::rotate(rotation_amount, rotation_axis); osg::Matrix translation = osg::Matrix::translate(original_translation); amtRod-setMatrix(rotation*translation); I'm not sure why you say that the rotation and translation is formally right - the final translation should be equal to the original translation if you're rotating about a local axis, but it isn't. Cheers, Tom -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=35591#35591 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] animated moving of a MatrixTransform
Hi Andrew, Using the OSG's animation features isn't something I've done personally, so I can't say if this would work or not. However, what I'd do is subclass osg::AnimationPathCallback to make it handle the matrix the way you want. Whether that means saving the original matrix and restoring some or all elements at the end of the animation, or only letting it change certain values, that would be up to you. Cheers, Tom -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=35534#35534 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] SphericalManipulator with limited elevation range
If you want to reuse a lot of the code from SphericalManipulator but add some new features, derive a new class from SphericalManipulator (instead of changing the osg source at all). At the very least it's a good way to experiment with the new features you're adding without having to start over all the way. And later if you want to clean your manipulator up a bit you can derive it from MatrixManipulator directly, and reimplement that necessary functions while cutting out anything from SphericalManipulator which you don't need. Cheers, Tom -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=34897#34897 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Transparency issues with intersecting objects and shapedrawables.
Hi Jesper, Based on some suggestions I saw previously on the board, I'm using a method with two Geodes sharing a child Drawable and a parent Transform. Code: transform_node-addChild(geode1); transform_node-addChild(geode2); geode1-addDrawable(drawable); geode2-addDrawable(drawable); //Added drawable in order geode-geode2. This must match the cullface order - //first rendered should have frontface culled, second backface culled. geode1-getOrCreateStateSet()-setAttributeAndModes(new osg::CullFace(osg::CullFace::FRONT)); geode2-getOrCreateStateSet()-setAttributeAndModes(new osg::CullFace(osg::CullFace::BACK)); This solved the funky-looking transparency at least. Tom -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=33597#33597 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] viewer1=viewer2. Is it possible?
Hi John, Is there a reason you can't dynamically allocate the viewer and return a ref_ptr to it, instead of returning by value? Cheers, Tom -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=33188#33188 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] viewer1=viewer2. Is it possible?
You have to use 'new' somewhere, like: osg::ref_ptrosgViewer::Viewer viewer = new osgViewer::Viewer(); Cheers, Tom -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=33195#33195 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] changing the up direction of the SphericalManiuplator
I haven't tried it, but wouldn't changing the order of multiplication in the get(Inverse)Matrix methods do the trick: return osg::Matrixd::translate(osg::Vec3d(0.0, 0.0, m_distance))* osg::Matrixd::translate(m_center)* osg::Matrixd::rotate(M_PI_2-m_elevation, 1.0, 0.0, 0.0)* osg::Matrixd::rotate(M_PI_2+m_heading, 0.0, 0.0, 1.0)* osg::Matrixd::rotate(M_PI_2, 0.0, 1.0, 0.0);// NEW! You essentially want the m_center point to rotate around the object in addition to the camera-offset vector (m_distance) rotating - that way you can still pan, but the object would stay at the same location on the screen when you're rotating. So apply both translations before/after the rotations, instead of splitting them up. Again, haven't tested this, just throwing the idea out. Cheers, Tom -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=32938#32938 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] How Camera Manipulators Work
J-S, I tend to agree with you - it feels like a CameraManipulator should be able to change (manipulate!) the Camera in any way. Also, thanks for catching the getMatrix vs getInverseMatrix... you're definitely correct, although I'd hope that anyone writing a CameraManipulator would implement both appropriately, otherwise an interface method is messed up! :) Cameras can have callbacks just like any other node (I'd imagine) - I use UpdateCallbacks rather than CameraManipulators in my project and they work just fine, and they give you direct access to the Camera node (well, through the public interface of Camera)... but they aren't treated as an event handler, which can be limiting. Am I correct in thinking you are advocating an approach that blends these two concepts? Thank you! Cheers, Tom -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=32510#32510 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] How Camera Manipulators Work
Hi Matt, What is being manipulated is the matrix that is returned from the manipulator. The parameters that you've found all are used ultimately in computing the matrix. Have a look at FirstPersonManipulator::getMatrix() for example - matrices are made from _trans and _rotate parameters and multiplied to get the overall matrix of the camera. Variables like velocity are used in conjunction with a time step to figure out what the new _trans should be, so that next time getMatrix() is called, the updated matrix reflects the changes that were made. Cheers, Tom -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=32418#32418 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] How to programmatically clear trackball manipulator's mouse queue
You mistyped it - it's setAllowThrow, not setAllThrow. Cheers, Tom -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=32242#32242 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Creating a Visible Pivoting Vector/Cylinder
Hi Richard, Here's what I would do to start: 0) Read the QuickStartGuide if you haven't already. 1) Make two Geodes, one with a Cylinder as the Drawable, and the other with a Cone, (these are convenience classes which the osg provides) and add each Geode as the child of a MatrixTransform or PositionAttitudeTransform node. 2) Derive a class(es) from NodeCallback, overriding the operator()(Node*, NodeVisitor*) method with the behavior you want for each component of your arrow (setting the orientation or scaling or whatever you want) based on the interface device data. Matrix::rotate(Vec3 from, Vec3 to) will create a rotation matrix which rotates your objects from some starting orientation - the original axis of your arrow - to another orientation - the desired axis of your arrow. 3) Attach the callback(s) to the appropriate transform node(s) using Node-addUpdateCallback(derivedCallbackClass) 4) Add your root node as the scene data of an osgViewer::Viewer, and either do a frame() loop or viewer.run(). The QuickStartGuide will have everything you need to know about that. Hopefully that'll get you started... Cheers, Tom -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=31994#31994 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] StateSet setAttribute(Material) question
Hi Robert, I agree with your assessment of possible places to look. This occurs even with creating a single new Material, and I always use ref_ptrs, so that isn't the source of it. I'll look into drivers etc. and post anything I find here in case others come across the same issue. Anybody out there have suggestions of a Windows process memory usage tracker that would be good to use? Cheers, Tom -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=31901#31901 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] StateSet setAttribute(Material) question
Hi OSGers, I'm using setAttribute(osg::Material* mat) on a matrix transform to control the color of an object (just a simple sphere for now, nothing fancy). Just using task manager in windows to watch process memory usage, I noticed that upon adding an object to the scene, the memory usage would start to creep upward. Thinking this was a leak of some kind in my application I looked into it further and found that the creep (~20kB/sec) was dependent on calling getOrCreateStateSet()-setAttribute(Material) for the first time - If I never set a material, the memory usage stays constant. When I wait for a key press and then set the material, the creep starts right away. If I remove the node, the usage stops increasing but does not decrease. Finally, if I just let it run, after a while (~500kB worth) the memory usage plateaus and is steady. I'm wondering if this something I should be worried about or not moving forward, or if that just happens and it isn't really an issue... either way I wouldn't mind knowing what's going on. Thank you! Tom -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=31866#31866 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] setCamera for Viewer
Hey everyone, I'm having trouble using osgViewer::Viewer::setCamera(osg::Camera*) method (inherited from osg::View). I'm sure the problem is me and not with the function. :-* Here's the scenario: I have an already-realized viewer window with an empty scene, to which I am trying to add a new scene with a Camera node as the root. If I use setSceneData(osg::Node*) the scene appears in the window correctly, but osg::ComputeWorldToLocal doesn't ignore the camera that was the root of my graph. I thought using setCamera instead would do the trick - avoiding the 'myCameraNode' is a child of the real root camera problem - but the window simply disappears. Is this enough info that anyone would be able to point me at what I am doing wrong? Thanks for any hints, Tom -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=31355#31355 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Getting the List of Triangles from an osg model
Hi Sanat, When you find geometry (triangles) with your node visitor, apply the accumulated transform that you traversed to the triangles. NodeVisitors have a NodeList, which you can use with osg::ComputeLocalToWorld (I think) to get the accumulated matrix you need. Then each triangle will be positioned as it is in your osg model. Cheers, Tom -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=31341#31341 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] std::vectorbool performance issue
Erik, I think if Andrew could avoid it he would, but Code: typedef std::vectorbool ValueList; is built into osg::Switch. Cheers, Tom -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=31329#31329 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Can update callback be a mutex?
Hello all, I'm working on project where a viewer is running in one thread, and user input/physics simulations/external devices/etc. are happening in one or more other threads, but need to modify the scene graph. Currently, we use mutexes which the other threads modify, and update callbacks access the appropriate mutex to find out if anything has changed. I was reading some older forum topics which said the OSG doesn't natively support asynchronous updating, so this seemed like a good way to accomplish our goal - right now it does everything we need it to. However, I was thinking it might be possible to eliminate the middle man by having my update callback itself derive from OpenThreads::Mutex, and creating two methods (one for updateData() and one called by operator()) which lock the mutex, act on the data, and unlock it. I'm wondering if anyone with more experience sees anything wrong with this approach, either conceptually or because of performance issues. Thanks for any input! Cheers, Tom -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=31310#31310 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Can update callback be a mutex?
Ooh, nice - thanks for pointing me that way. I'm going to implement a triple buffer of some sort in my project - if I use some of the techniques in osgBullet as a pattern but don't actually copy code, what's the best/proper way to give credit? Right now the project is totally internal for an academic research lab, but we may share it at some point. Cheers, Tom -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=31321#31321 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] camera manpulator
Hi Otto, I think your suspicion is correct - building your own manipulator would probably be best. It really isn't hard to extend one of the camera manipulators to do what you want, or to just start with the source code of an existing manipulator and tweak the appropriate methods. This is what I do any time I want different behavior, so I'm not actually all that familiar with the stock manipulators, so maybe you can do what you want with one of them. However, I'd encourage you to try out making your own manipulator anyway - it is educational and not very difficult! Cheers, Tom -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=31281#31281 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Switch node and update traversal
Hi everyone, I have a quick question regarding switch nodes and update callbacks: I'm working on a system where users control objects in an osg scene (ie move around, etc). I'm using switch nodes to turn various objects in the scene on and off. I'd like to test for collisions between objects in the scene, even if they may be hidden. I already have collisions working fine as long as I have the transform matrix of the object. I'd like to be able to use an update callback to get the accumulated transformed coordinates of different objects, whether they are hidden or not. It would also be nice if the update callback could tell me whether a particular node is off or on (under a switch). So, two questions: 1) Does the update traversal visitor visit off children of switches, so that the accumulated matrix would be accurate even if the object was not shown? 2) Is there an easy way for an update callback to find out if its node is on or off - similar to how a callback can use ComputeWorldToLocal, for example, to get the accumulated transforms. Thank you! Cheers, Tom -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=31167#31167 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Switch node and update traversal
Hi Paul, Thanks for the response. In regards to question 2, if I'm understanding you right this will work if the node in question is the direct child of a switch. However, if there are intervening nodes (such as a switch at the root of a sub-graph, with a number of levels of nodes underneath it), I would essentially need to follow the node path (obtained from the node visitor) all the way up to the camera, checking to see if any of the nodes are switches with the child along the path set to off. Does that sound right? Last question - since I only need to know if any given node is on/off occasionally, like when a collision is detected, would it be safe to apply a method to traverse the node path in this way from a separate thread without halting the viewer loop or using a callback? I suspect it would not be safe, that it would cause crashes... Thank you! Cheers, Tom -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=31172#31172 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Rotate camera around the scene in osgViewer - simple way?
Something quick and easy would be to calculate a new position for your camera on each frame and set the view matrix as part of a frame() loop. while(!myViewer-done()) { myViewer-getCamera()-setViewMatrix(whatever it should be this frame); myViewer-frame(); } Cheers, Tom -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=31114#31114 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Geometry colorArray
Hi Emilie, I don't have much experience with doing what you're trying to do, but do you have the data variance on your geometry set to dynamic? When I've forgotten to do this in the past various things I've tried to modify dynamically weren't applied, I can't recall if position (for example) worked but not color - it could have been that nothing was updating right and completely different from your case... but perhaps a hint? Cheers, Tom -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=30945#30945 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Choosing a different cull mask for Viewer's master camera seems to mess up shadows...
Hi Frank, I can't claim to have experienced what you're experiencing, nor any experience with shadowing at all. Instead of setting the cull mask to exclude some objects, can you make them (the shadow-casting but not displayed objects) fully transparent? I don't know if that affects the shadows they cast or not, but to me the naive outsider in shadow-casting it seems like changing shadows based on transparency would be complex so it may allow you to cast stuff from invisible nodes. Cheers, Tom -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=30946#30946 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Lines and only the lines are getting cliped some how!
Hi David, I'm kind of intrigued... do you have some stripped-down example code which reproduces the problem, so we can poke around with it? There are a number of things which *could* be going on (in my imagination if not in reality or not if I knew more about OSG - I'm learning every day though!), but based only on what you've said I don't have meaningful input - but if you could make a small reproducible app, that would be fun to play with and perhaps shed some light on it. (I've solved many a self-generated issue before even asking anyone else while trying to reduce my code to bare essentials, so perhaps that's a worthy step regardless.) Tom -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=30950#30950 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] dynamic scenegraph design help
Hi Eric, To answer the last question first: if your new local scenegraph isn't attached to the scene that the viewer has, you can safely do whatever you want to it - that memory isn't being accessed by the viewer, since the viewer doesn't even know it exists. As for the rest, it depends a bit on how you are setting up your application and scene. How are you deciding where in the viewer's scene to add this new subgraph? If you know where it will be (e.g. you have a pointer to the group to which you wish to add your new subgraph, either predefined or by picking), it would be pretty straightforward to add the new subgraph - dynamic_castosg::Group*(yourPtr)-addChild(newRoot) would work. You just need to make sure your viewer isn't accessing the scenegraph at the time. What I do is have a custom viewer loop like so: Code: while(!viewer.done()) { viewer.frame(); if(modificationIsNecessary) { viewer.stopThreading(); //modify the scene graph tree //groupThatGetsNewScene-addChild(newSceneRoot); viewer.startThreading(); } } I've been running something along these lines without problems - whether it's the *right* way to do it, I don't know. If your viewer is running in single threaded mode already, just being between frame()s is enough, and the stopThreading/startThreading isn't doing anything. If you want to have an update callback in the existing viewer scene, that could probably work too - in that case I'd think you would want to make sure the parent node data variance is set to dynamic to be safe. It looks like you have a good idea of how you'd go about making that updateCallback already. Cheers, Tom[/code] -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=30398#30398 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Intersection with a ray
Hi Lucie, When you make a line segment intersector with just two Vec3s as input arguments, the line segment runs from one point to the other in model coordinates. How are you finding wandp1 and wandp2? In your code it looks like they are uninitialized in which case they are both (0, 0, 0). If you actually do have the values for the two points, would you expect that line to intersect your terrain? Cheers, Tom -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=30273#30273 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] osg camera : setting view matrix
Looks right to me, Ricky. For understanding coordinate frames and rotation directions, the right hand rule applies in both cases - actually they are two distinct rules but both go by the same name. Check it out on wikipedia or somewhere - it's a good mnemonic to know! Cheers, Tom -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=30250#30250 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] How to set new PAT position for every traversal run ?
Do you know if you actually have found an intersection? Try adding the statement if(backhoeLocationSegment-containsIntersections()). If you don't have a valid intersection, how are you supposed to get coordinates out of it? Cheers, Tom -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=30215#30215 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] How to set new PAT position for every traversal run ?
Hi Sanat, There's so much there, including functions that I have no idea what they do, that it'll be hard to figure out. There is definitely some unnecessary bits that make it even harder for people who aren't you to figure out what is going on - for example, Code: backhoeGroundPosition = backhoePosition-getPosition(); backhoeGroundPosition = getCurrentPosition(backhoeGroundPosition); It appears that the argument to getCurrentPosition is never used within the function, so the first call (backhoePosition-getPosition(); ) is pointless. Not necessarily a killer problem, but the more tangled your code is, the harder it is for both you and us to figure anything out. Regardless... have you tried printing the results of various computations/calls to the screen? I'm thinking for example the value of the Vec3 returned by getCurrentPosition. Debugging messages that you add to your own code are invaluable in determining how things are working - you'll get much further that way than we will by looking at the code. If backhoeGroundPosition is always (0,0,0) after your function, that's a very different problem than if that value is changing but your model always appears in the same place on the terrain. Cheers, Tom -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=30205#30205 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Event Handling from outside a Viewer
Hi Robert, I think the solution of having a GUIEventHandler through Viewer to capture and pass along all events will be the way I go. I was trying to have various users on our end write their own event handlers based on their needs, and be able to swap from one to the other on the fly depending on the context of the application. I noticed there was no removeEventHandler method in 2.8.2, and I saw a thread mentioning that this method has been added in the recent dev releases. However, we won't be changing versions until 3.0, so I was trying to get around it another way. Adding a second layer of event handler - one attached to Viewer to pass events through, and the user-written one accessing that information - should do the trick without ever having to change the handler that Viewer sees. Thanks for your input - helpful as always! Cheers, Tom -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=30123#30123 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Event Handling from outside a Viewer
Thanks for the info, Robert. I tried what you suggested, but I don't seem to be getting any events back at all: copyEvents(Events) returns false, and events.size() is zero. When I used getCurrentEventState() I could access the mouse position from the GUIEventAdapter that was returned, but I was never getting any events like button pushes or key presses. Code is below (I'm using 2.8.2 if that makes a difference). Code: osgViewer::Viewer v; osgGA::EventQueue::Events events; while(!v.done()) { v.frame(); if(v.getEventQueue()-copyEvents(events)) printf(returned true\n); if(events.size()) printf(%i events\n, events.size()); } Thanks for your help! Cheers, Tom -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=30103#30103 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Event Handling from outside a Viewer
Hi, I'm looking to implement event handling in a handler not attached to a View. The code snippet below is what I'm thinking of doing (the function would take an eventadapter similar to the handle method of the camera manipulators). Is this a valid way to go, or am I missing something? If multiple events accrue, do I have access to those through getCurrentEventState(), or just the most recent? Or am I thinking about this entirely wrong? Code: osgViewer::Viewer v; while(!v.done()) { v.frame(); MyEventHandlerFunctionOrClass(v.getEventQueue()-getCurrentEventState()) } Thank you! Cheers, Tom -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=30088#30088 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] new ref_ptrs in Callbacks
Hi, Let me preface this by saying that I know how to make my code do what I want it to, so this question is of low importance and arises from doing something that could(should?) be considered silly- dynamic allocation within a callback operator method when the callback can have a class member instead. However, I'm still curious about the behavior, and/or if others see this in a different way than I do. What I'm seeing (code below produces this on my two setups): The second sphere (which should always be green) flickers red. Uncommenting the traverse line in the operator method makes the flickering noticably worse. The flicker color being red is not a coincidence, it flickers whatever color the first sphere is. Making 'mat' a class member of the derived callback instead of creating a 'new' version of it eliminates this problem. As I said, this fixes my problem... but even if dynamically allocating a new Material each time is inefficient, I was still surprised at the flickering behavior. In my quest to learn more about all of this, I thought I'd see if anyone could enlighten me as to what's going on. Two questions: 1) Why is one sphere flickering when a new Material (ref_ptr or plain non-smart pointer) is created in the callback? 2) Why does calling traverse within the operator method (as the Quick Start Guide indicates) make the flickering worse? I'm using XP/VisStudio2008Express on one machine, and Windows7/VisStudio9 on another, osg 2.8.2 on both, just in case it matters. Thoughts? Code: class MyCallback : public osg::NodeCallback { public: MyCallback(osg::Vec4 c){color=c;} virtual void operator()(osg::Node* n, osg::NodeVisitor* nv) { osg::ref_ptrosg::MatrixTransform mt = dynamic_castosg::MatrixTransform*(n); osg::ref_ptrosg::Material mat = new osg::Material(); mat-setDiffuse(osg::Material::FRONT, color); mt-getOrCreateStateSet()-setAttribute(mat); //traverse(n, nv); } protected: osg::Vec4 color; }; int _tmain(int argc, char * argv[]) { osg::ref_ptrosg::Group root = new osg::Group(); osg::ref_ptrosg::Geode sphere = new osg::Geode(); sphere-addDrawable(new osg::ShapeDrawable(new osg::Sphere(osg::Vec3(0., 0., 0.), 0.1))); osg::Vec4 color1, color2; color1.set(1., 0., 0., 0.); color2.set(0., 1., 0., 0.); { osg::ref_ptrosg::MatrixTransform mt = new osg::MatrixTransform(); root-addChild(mt); mt-addChild(sphere); mt-setMatrix(osg::Matrix::translate(-.1, 0., 0.)); mt-setUpdateCallback(new MyCallback(color1)); } { osg::ref_ptrosg::MatrixTransform mt = new osg::MatrixTransform(); root-addChild(mt); mt-addChild(sphere); mt-setMatrix(osg::Matrix::translate(0.1, 0., 0.)); mt-setUpdateCallback(new MyCallback(color2)); } osgViewer::Viewer v; v.setSceneData(root); v.getCamera()-setViewMatrixAsLookAt(osg::Vec3(0., -.500, 0.), osg::Vec3(0., 0., 0.), osg::Vec3(0., 0., 1.)); v.setUpViewInWindow(750, 550, 600, 400, 0); while(!v.done()) { v.frame(); } return 0; } Cheers, Tom -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=30012#30012 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] My Lines Disapering but Ploygons don't
Skylark wrote: That last one should probably have been: state-setMode( GL_BLEND, osg::StateAttribute::ON ); Aye, that's what I meant. I just copied/pasted the wrong line of code. Thanks for pointing that out J-S. I always turn on GL_DEPTH_TEST anyway to be safe, even though on is the default it doesn't seem to hurt anything. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=30033#30033 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] new ref_ptrs in Callbacks
Hi JP, Tim, Thanks for the replies. Using the single threaded mode gets rid of the flicker, as does setting the state set data variance to dynamic when I create the scene graph: mt-getOrCreateStateSet()-setDataVariance(osg::Object::DYNAMIC); I'm convinced that your explanation of collision between draw and update traversals is in play, since those fixes worked. However, I'm still unsure of why(whether?) the flickering was related to creating 'new' materials in the callback. When I use multi-threaded viewer mode and I don't set variance to dynamic (i.e., ripe for collisions), the color does NOT flicker if I'm NOT using a 'new' material, but does flicker when I do use 'new'. In addition, it is only the second sphere that flickers, while both of them are creating new materials and modifying the state set each time, which leads me to believe there is something more complicated going on. The collisions would be occurring in all of these cases but the flickering does not always follow as the result. I'm not sharing state sets at all - there are two different matrixtransform nodes, each with it's own state set. That's why I'm confused about how the color of the first one is ever applied to the second. Each newly created material has its color defined before the state set is modified to include that attribute, so even with thread collisions happening I don't understand how stateset2 knows what color stateset1 is. Again, you are both absolutely right about how to avoid the issue, and I understand that the test code I originally included does things one shouldn't do. I was just trying to understand what was happening in memory to get that effect - probably it is just that traveral collisions are doing stranger things than I imagine. They have never crashed the test app though. ;) Thank you! Cheers, Tom -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=30042#30042 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] My Lines Disapering but Ploygons don't
dglenn wrote: So, I have color, but is there anything I need to set to get the alpha chenal to work? In this example I have alpha set to 0.5f but I don't see what I drawing fading half away! Are you enabling transparency? - for example by: Code: osg::StateSet* state = node-getOrCreateStateSet(); state-setRenderingHint( osg::StateSet::TRANSPARENT_BIN ); state-setMode( GL_DEPTH_TEST, osg::StateAttribute::ON ); I don't have the expertise to pitch in on the other issue I'm afraid. Cheers, Tom -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=30010#30010 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] osg camera location
Hi, It sounds like what you want to use is: setViewMatrixAsLookAt(eye, center, up) where eye is a Vec3 for where the camera is located, center is the point the camera is looking at, and up is the camera's up unit vector. viewer.getCamera()-setViewMatrixAsLookAt(osg::Vec3(x_camera, y_camera, z_camera), osg::Vec3(0., 0., 0.), osg::Vec3(0., 0., 1.)); for example. Cheers, Tom -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=30011#30011 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] find coordeinates in IVE
Hi Bruce, I'm doing something similar to you, where I want to be able to click in a scene and add objects at that point. I do it as JS suggests, using an event adapter to get the mouse coordinates, a line segment intersector using Window coordinates, and an intersection visitor. If you want, you can use node masks to determine which objects in the scene the intersector will find. From the intersector you can get Vec3s of position and normal vector of the surface that was found. The normal can be used to orient an object you place on terrain, for example. Code: osg::ref_ptrosgUtil::LineSegmentIntersector lsi = new osgUtil::LineSegmentIntersector(osgUtil::Intersector::WINDOW, ea.getX(), ea.getY()); osgUtil::IntersectionVisitor iv(lsi.get()); iv.setTraversalMask(MY_MASK); _camera-accept(iv); osg::Vec3 position, normal; if(lsi-containsIntersections()) { position = mlsi-getFirstIntersection().getWorldIntersectPoint(); normal = mlsi-getFirstIntersection().getWorldIntersectNormal(); } Good luck getting it working! Cheers, Tom -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=29808#29808 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] osgviewerd cow.osg ---no data loaded
Hi, Error: [Screen #0] ChooseMatchingPixelFormat -Unable to choose the requested pixel format I've had this error pop up while trying to run OSG applications on a remote machine via Windows remote desktop - don't know if that's what you're doing, but if so, it's probably where the issue is arising. Cheers, Tom -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=29809#29809 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] moving object along rotated vector
Hi, q*f in OSG is shorthand for (qc * fq * q). It's the opposite of what one might expect. There are some inconsistencies... My approach is always to try it the way I think it should work, and when it doesn't, start playing with the multiplication order - eventually something works. It does mess with my head a bit when I try and understand the math, but in the end as long as my code does what I want, I'm don't worry much. Just out of curiosity, does anyone know why quat*vec3 was implemented the way it was? Everything I've read (outside of osg) about using quats to rotate points (ie vectors) says q*fq*qc is the way to do it. Cheers, Tom -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=29633#29633 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Can't pick HUD geometry under perspective projection
Hi Don, If you put some smallish geodes into your (non-HUD) scene - not just a background, but some test cubes or spheres or something - does your picker class pick those objects as you expect? Cheers, Tom -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=29643#29643 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] moving object along rotated vector
The various methods we're talking about for figuring out a forward vector are rotating in different directions - here's a bit of test code to confirm. Code: FILE* fp = fopen(printout.txt, w); osg::Vec3 f(0., 1., 0.); osg::Quat fq(0., 1., 0., 0.); osg::Quat q(osg::DegreesToRadians(45.0), osg::Vec3(0., 0., 1.)); osg::Quat qc = q.conj(); osg::Vec3 r1 = q*f; osg::Vec3 r2 = (q * fq * qc).asVec3(); osg::Vec3 r3 = q.inverse() * f; fprintf(fp, quat * vec: %f %f %f\n, r1.x(), r1.y(), r1.z()); fprintf(fp, q * fq * qc: %f %f %f\n, r2.x(), r2.y(), r2.z()); fprintf(fp, q.inverse*f: %f %f %f\n, r3.x(), r3.y(), r3.z()); fclose(fp); Results: quat * vec: -0.707107 0.707107 0.00 q * fq * qc: 0.707107 0.707107 0.00 q.inverse*f: 0.707107 0.707107 0.00 Since the test rotation you've been using is close to pi/2, it looks like the axis is switched... but really, it's just rotated in the opposite direction than you expect. When you get a rotation quat out of of a PAT or MatrixTransform, (I guess) it's giving you the coordinate system transform. When you transform a coordinate system in one direction, it's equivalent to rotating vectors in the opposite direction. So if you try and rotate a vector directly by this transform, ie by doing quat*vec, your forward vector will be rotated an equal amount but in the opposite direction from how the model appears on the screen. By doing quat * vec * quat.conj(), or by doing quat.inverse() * vec, you're applying the coordinate system transform to your vector, and everything works out such that your forward vector and your on-screen model have rotated together. I'm still quite new to these maths, so please, an expert should pitch in! I am basing this all on my own experiences with moving objects around in osg. Cheers, Tom[/code] -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=29611#29611 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] moving object along rotated vector
Hi, I've been doing it this way, works like a charm: Say your forward vector is (0, 1, 0), pointing along the y axis, make an with from this by adding a real coordinate (4th coordinate) of zero - (0, 1, 0, 0). You also have a rotation quat q, and take it's conjugate to get q_prime. Then multiply as below to get the new forward quat, then get the vector from that. q_prime = q.conj(); osg::Quat forward_quat(0., 1., 0. 0.); osg::Quat rotated_foward = q * forward_quat * q_prime; osg::Vec3 new_forward_vec = rotated_forward.asVec3(); I'm no expert so take this with a grain of salt, but when I tried the method JP outlined (which was my first shot at doing it) the rotated vector wasn't correct (or at least not what I expected). Looking up quaterion rotation online, wikipedia for example, I found the method I described above. Of course, JP's method works spot on for what to do with your object when you're moving it along your newly rotated forward vector by however far you want to move it. Cheers, Tom -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=29533#29533 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] DrawCallBack Screeshot problem
Hi Thomas, One thing I would check: In windowed mode, is the entire window on your screen, or are you clipping some of the image that way? I would try just running the program with a viewer loop (without taking screenshots and exiting right away) to make sure this is alright. This would also allow you to confirm that the image looks right in the viewer without bringing the screenshot into play. I threw your code into a test app here, and it works fine for me. If I clip the window off the top of the screen though, I get rows of black pixels - not exactly what you see, but not the full image either. Cheers, Tom -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=29564#29564 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Identical code not working in XP 32 bit but working in Vista 64 bit ??
When switching machines, did you make sure that you have the appropriate osg libraries for the version of your compiler (are you using Vis studio?), and that you've matched release/debug libraries with your project properties? If that isn't the problem, you could try creating a fresh project from scratch and building the app again - I recently had a weird bug crop up (without even changing machines or even settings) that was only solved with a new project - just cleaning and rebuilding didn't fix it, and it wasn't an issue with library versions or anything. Just something weird with windows/Visual Studio. Cheers, Tom -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=29565#29565 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Sudden runtime error
Hi Gordon, Thanks for the suggestions. I am working in release, and I don't have any of the debug libs on my machine. I re-extracted all osg files just in case something got corrupted. I cleaned and rebuilt the application. Didn't help. However, I started a new Visual Studio project, copied all the settings over exactly, and now it works fine. This makes me pretty confident that the issue is not to do with OSG but rather with Vis Studio, but I'm completely at a loss as to what the problem actually is - nothing short of creating a fresh project fixed the issue. Just for the sake of completeness I want to share what I discovered about where in the code I could cause/not cause the crash: Having 5 or fewer osg::Vec3d or Vec3f (up to 5 of each) class members was safe - no crash. A sixth of each, however, lead to the program crashing when trying to create a Group. I put a Node directly in front, the node was created successfully, it was still crashing on Group. Again, I don't think the issue is with OSG - and I don't think I got libs mixed up, since I don't really have any stale libs on the machine. Have other Vis Studio users experienced anything like this? I suppose I just have to keep in mind that when weird stuff happens I can try creating a fresh project but that seems like a weak solution. Cheers, Tom -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=29332#29332 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Sudden runtime error
Hello OSG users, This afternoon, I had a program I've been working on start crashing on me and I thought I'd see if anyone had insight into where I should be looking for the problem. I've been making changes to the code and re-building the project to test the changes, but I don't know that my changes had anything to do with this. Basically, yesterday morning my application started crashing right when I exited the viewer (by hitting esc) - instead of just exiting the program, an error message would pop up that the program stopped working unexpectedly. This seemed unusual since I'd never had it happen before, but it wasn't interfering with my ability to test the part of the code I was working on so I didn't pursue it further at that point. This afternoon, the application starts up but at one particular line (nothing complicated, just osg::Geode* geode = new osg::Geode; ) the command prompts displays This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information. Thus far, I have rebooted and re-extracted all osg files from the zip I downloaded. I tried changing the name of the variable on that line, and I made sure to clean and rebuild the solution. None of that changed anything. I also set the OSG_NOTIFY_LEVEL to DEBUG but there were no messages that popped up between my debugging message the line before and when it displays the error message. I don't think the issue is with my code because when I copy the source to my other computer, the program works just fine. In addition, other applications I've created with osg (including Geode of course) still execute just fine. I'm not looking for someone to solve this for me, but I thought I'd see if anyone else has had similar issues crop up and could point me in the right direction. System info: Windows 7 64-bit, osg-2.8.2, Visual Studio 9. Cheers, Tom -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=29281#29281 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Screeshots from multiple cameras/views
Ricky, Based on the code you posted, you're taking a screenshot every frame - and from the same position, no less. You're creating the same matrix each time, and thus setting the view matrix to be identical each frame. Then you're doing file I/O that is the exact same too. When I ran your code without doing all of this on every frame (i.e. returning after the first frame or two) everything seemed to work. In fact, I also ran it exactly as you'd posted it, and it still executed without error, just very slowly. I'm not sure where the seg faults are coming from but perhaps you're just bogging stuff down too much since the code isn't really doing something you actually want it to do...? In principle I don't see a problem with moving the camera from one view to another and taking a picture from two (or more) points - but the way it is set up right now isn't right. At least, not as I see it. Cheers, Tom -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=29238#29238 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Problem with large TerrainTiles?
Hi Robert, Thanks for the quick reply. Upon further debugging and inspection, I think the problem was fixed already in 2.8.3. I'm using Visual Studio 9, and haven't gone to 2.8.3 since the downloads page still says binaries for VS9 are not yet available. Anyhow, in 2.8.2 GeometryTechnique::generateGeometry always uses DrawElementsUShort when creating the skirt- for the interior of the tile, DrawElementsUInt is used. 2.8.3 has a check for tile size built in: osg::ref_ptrosg::DrawElements skirtDrawElements = smallTile ? static_castosg::DrawElements*(new osg::DrawElementsUShort(GL_QUAD_STRIP)) : static_castosg::DrawElements*(new osg::DrawElementsUInt(GL_QUAD_STRIP)); I suspect this fixes the problem, but haven't tested it directly. In the mean time, if I don't create a skirt, I can avoid the problem even in 2.8.2. Cheers, Tom -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=28886#28886 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Draw a 2D Halo
Theo, There should be plenty of resources for learning how to create and manipulate 2D objects - it is fundamentally just like creating 3D objects, only the polygon(s) are all in a plane. You can just create a set of vertices manually to start with. If you've found the examples that deal with 3D shapes, I'd suggest starting there. If you can understand that, you're pretty much there! Maybe start with just creating spheres and see if that helps you understand. Try the plane primitives using example code if you really need more guidance... the billboard example may also give you a sense of how to create some 2D geometry. Cheers, Tom -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=28909#28909 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Problem with large TerrainTiles?
Hello community, I've been playing around with manually creating terrain tiles (as opposed to letting VPB do it) and noticed what to me seems like strange behavior, and I was wondering if anyone else had noticed a similar issue - or could point out what I'm doing wrong. I'm using osg2.8.2 on Windows 7 64-bit, stripped down code is below. Basically, I've been following the osgterrain example code but creating a HeightField manually instead of loading it from a file. If I create a tile with ~64100 elements, everything looks fine. If I go above this (256*256, for example), something looks like it goes wacky with how the vertices are turned into triangles - but only the first so many of them (~64k ish), and beyond that the terrain looks right. Either creating a viewer programatically or saving to a .osg file and using osgviewer.exe looks the same. To test whether the problem is in HeightField or somewhere in the TerrainTile, I added the heightfield to a geode - and it looked fine at all sizes. I realize that VPB generates 64*64 tiles, and this is a non-issue when using tiles of that size, but I thought I'd see if there was an explanation out there. I have looked through the forums, but may have missed something about this issue (or feature?), so my apologies if this has been discussed already. Thanks, Tom osg::ref_ptrosgTerrain::TerrainTile terrainTile = new osgTerrain::TerrainTile; osg::ref_ptrosgTerrain::Locator locator = new osgTerrain::Locator; osg::ref_ptrosgTerrain::ValidDataOperator validDataOperator = new osgTerrain::NoDataValue(-100.0); osg::ref_ptrosgTerrain::Layer lastAppliedLayer; locator-setCoordinateSystemType(osgTerrain::Locator::PROJECTED); locator-setTransformAsExtents(-100., -100., 100., 100.); osg::Texture::FilterMode filter = osg::Texture::LINEAR; unsigned int layerNum = 0; osg::ref_ptrosg::HeightField hf = new osg::HeightField(); hf-allocate(254,254);//looks as expected //hf-allocate(256,256);//funny triangles //hf-allocate(256,512);//funny triangles over first half hf-setOrigin(osg::Vec3(-50., -50., 0.)); hf-setXInterval(1.0f); hf-setYInterval(1.0f); hf-setSkirtHeight(1.0f); for (int c=0; chf-getNumColumns(); c++) { for (int r=0; rhf-getNumRows(); r++) { if(r%20 == 0) hf-setHeight(c, r, 20.0f); else hf-setHeight(c, r, 0.0f); } } osg::ref_ptrosgTerrain::HeightFieldLayer hfl = new osgTerrain::HeightFieldLayer(hf.get()); hfl-setLocator(locator.get()); hfl-setValidDataOperator(validDataOperator.get()); hfl-setMagFilter(filter); terrainTile-setElevationLayer(hfl.get()); lastAppliedLayer = hfl.get(); ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org