Re: [osg-users] osgOcean collision detection
Hi Jan, My apologies for not replying earlier, I haven't been checking osg-users as much as I possibly should have. It appears that I've missed quite a few osgOcean posts. BTW, is there a reason why is the size of the screen hardwired to 1024x768? Do the shaders expect this? Or why is it so? It took me a while to figure out why it doesn't draw correctly on our wall. J-S pretty much answered this one- the screen resolution is only required for setting up the FBOs involved in the fullscreen effects. However, this can be changed using: /** Sets the current screen size, needed to initialise the God Ray and DOF frame buffers. * Default is 1024x768. */ inline void OceanScene::setScreenDims( osg::Vec2s size ){ _screenDims = size; _isDirty = true; } Setting that will cause the FBO textures to be resized and rebound at the desired resolution on the next pass of the update visitor. You could easily bind this function to a callback which calls it when the screen resolution changes. Back to the original problem with collision detection. As J-S said, direct access to the vertices is not currently supported. However you should be able to get access to the geometry by adding some simple accessors. To be honest I haven't thought about collision detection much as it wasn't an original requirement for me, but I can see that it would be a valuable addition and i'll try and give you some pointers. The vertices and normals involved in the current frame are stored within the Vec3Arrays called _activeVertices and _activeNormals in FFTOceanSurface. Whenever the animation frame or LOD level changes the entire vertex and normal arrays are updated from precomputed LOD and animation frames stored in a 2D vector called _oceanTiles - where they're stored in the format _oceanTiles[frame][lodlevel] . These two arrays are then assigned to a series of custom osg::Geometry objects called MipmapGeometry which are basically just osg::Geometry objects with some extra member variables added. The MipmapGeometry class stores the current LOD level of the patch and the primitives that define the geometry for each of the ocean patches. These objects are then stored within a 2D std::vector called _oceanGeom. There is in fact a private inline function that will returns a raw pointer to the desired patch: /** * Convenience method for retrieving mipmap geometry from _oceanGeom. */ inline FFTOceanSurface::MipmapGeometry* getTile( unsigned int x, unsigned int y ){ return _oceanGeom.at(y).at(x).get(); } Like I say I haven't thought about collision detection much, but my initial thoughts are that you could use the bounding boxes of the mipmap geometries as a quick way to find the patch in which the collision occurs and the test the triangles within that patch. The animation, of course complicates things somewhat. If you're planning on doing accurate collision detection you should be able to get access all the vertices involved for the frames at the current LOD from the _mipmapData container. I hope that helps a bit, if you have any further questions don't hesitate to ask and I'll try and be more diligent with my replies. Regards, Kim. 2009/9/25 Jean-Sébastien Guay jean-sebastien.g...@cm-labs.com: Hi Jsn, I will have a look at it tomorrow. Excellent, let me know if you have any questions though Kim C. Bale is more familiar with the actual algorithms so for some questions I might have to defer to him. BTW, is there a reason why is the size of the screen hardwired to 1024x768? Do the shaders expect this? Or why is it so? It took me a while to figure out why it doesn't draw correctly on our wall. I think it's two things: a) preference on Kim's part (the example was coded like that when he first posted the code) b) all the post-render cameras for the RTT effects (DOF, glare, distortion) need to know the resolution of the screen, and I don't recall if/how they get this info, but I think he may have hard-coded it to 1024x768 to avoid having to pass the resolution all over the place. This can be changed. Remember that oceanExample is just that - an example. The API in the osgOcean lib should allow you to use it in any way, not just in the way oceanExample uses it. Bear in mind that osgOcean came from his own project, so the API was made for the way he used it. Then I came in and I had some other requirements for the API, so I made it evolve that way. It may well be that our two sets of requirements still don't cover all possible uses (in fact the opposite would be surprising) so if you need the API to evolve in some other way, it won't be a problem! :-) J-S -- __ Jean-Sebastien Guay jean-sebastien.g...@cm-labs.com http://www.cm-labs.com/ http://whitestar02.webhop.org/ ___ osg-users mailing list osg-users@lists.openscenegraph.org
Re: [osg-users] osgOcean collision detection
Hi Kim (and Jean-Sebastien), Kim Bale kcb...@googlemail.com wrote: Hi Jan, My apologies for not replying earlier, I haven't been checking osg-users as much as I possibly should have. It appears that I've missed quite a few osgOcean posts. No problem :) BTW, is there a reason why is the size of the screen hardwired to 1024x768? Do the shaders expect this? Or why is it so? It took me a while to figure out why it doesn't draw correctly on our wall. J-S pretty much answered this one- the screen resolution is only required for setting up the FBOs involved in the fullscreen effects. However, this can be changed using: /** Sets the current screen size, needed to initialise the God Ray and DOF frame buffers. * Default is 1024x768. */ inline void OceanScene::setScreenDims( osg::Vec2s size ){ _screenDims = size; _isDirty = true; } Ah, OK - I have missed this function. I saw that the variables are initialized in the constructors but that there wasn't a way to pass new screen dimension to them (would be a good addition to the constructor, IMO). Setting that will cause the FBO textures to be resized and rebound at the desired resolution on the next pass of the update visitor. You could easily bind this function to a callback which calls it when the screen resolution changes. Good, that will help. I more-or-less need to call this only on setup, but at least it saves me hacking in an extra constructor. Back to the original problem with collision detection. As J-S said, direct access to the vertices is not currently supported. However you should be able to get access to the geometry by adding some simple accessors. To be honest I haven't thought about collision detection much as it wasn't an original requirement for me, but I can see that it would be a valuable addition and i'll try and give you some pointers. What I need is rather simple - I need an object to bob on the surface of the waves, so basically I just need the current height at a given x,y position. ... Like I say I haven't thought about collision detection much, but my initial thoughts are that you could use the bounding boxes of the mipmap geometries as a quick way to find the patch in which the collision occurs and the test the triangles within that patch. The animation, of course complicates things somewhat. If you're planning on doing accurate collision detection you should be able to get access all the vertices involved for the frames at the current LOD from the _mipmapData container. I think that is even an overkill for me - I just need the height to be able to attach an object to the surface of the wave. But thanks for the pointers, I am going to have a closer look at it today. Regards, Jan signature.asc Description: This is a digitally signed message part. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] osgOcean collision detection
Hello, Dimitrios Filiagos dfili...@yahoo.com wrote: Hi, is it possible to gain the information of a specific point (providing the x,y) on the ocean surface? Because I am using osgOcean on a project and I need to do some collision detection stuff. Thank you! Cheers, Dimitrios I have the same need. I was looking at the code and while the information is obtainable from the raw heightmap (there is even a convenient interpolation function for it), it is not exposed in the public API. I think you need to hack the osgOcean code and expose the functionality yourself. Regards, Jan signature.asc Description: This is a digitally signed message part. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] osgOcean collision detection
Hi Dimitrios and Jan, I have the same need. I was looking at the code and while the information is obtainable from the raw heightmap (there is even a convenient interpolation function for it), it is not exposed in the public API. I think you need to hack the osgOcean code and expose the functionality yourself. I was planning on starting work on this kind of functionality soon. If you get to it before I do, you can send me the files with the modifications you needed to make to the API and I'll review the changes and merge them into the osgOcean SVN. J-S -- __ Jean-Sebastien Guayjean-sebastien.g...@cm-labs.com http://www.cm-labs.com/ http://whitestar02.webhop.org/ ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] osgOcean collision detection
Jean-Sébastien Guay jean-sebastien.g...@cm-labs.com wrote: I was planning on starting work on this kind of functionality soon. If you get to it before I do, you can send me the files with the modifications you needed to make to the API and I'll review the changes and merge them into the osgOcean SVN. J-S I will have a look at it tomorrow. BTW, is there a reason why is the size of the screen hardwired to 1024x768? Do the shaders expect this? Or why is it so? It took me a while to figure out why it doesn't draw correctly on our wall. Regards, Jan signature.asc Description: This is a digitally signed message part. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] osgOcean collision detection
Hi, is it possible to gain the information of a specific point (providing the x,y) on the ocean surface? Because I am using osgOcean on a project and I need to do some collision detection stuff. Thank you! Cheers, Dimitrios -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=17570#17570 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org