Re: [osg-users] Runtime texture mod
On 17/7/09 6:14 PM, Brad Huber wrote: Does anyone know of a good way to modify pixels in a texture at runtime w OSG? Basically I’m looking for a way for the user to select an arbitrary color to be used on an airplane or similar. EG ability to switch to any color as in the attached image. From what you're saying it sounds like you really only need to modify the object base colour, using one of the techniques that Jason suggested. If you *really* want to modify individual pixels in a texture you can use Image::data() to get a pointer to the image data and modify that directly. It might be a bit tricky since you have to take the Image format into account. Call Image::dirty() when you're done with the modification to upload the new data to the texture. Cheers, /ulrich ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Transformations
Hi Ümit, I try to use osg::Switch to insert all the data I have in the files( each file in a separate node with his own transform matrix ), so I can switch the nodes in each frame, but I don't know why it seems that the second and following data I insert accumulates the previous matrix transformation, and I don't want this. I write it seems because I cannot be sure about that, my models are doing some strange movements that are not correctly. I also have a sphere attached to the root node after I attach the switch node, and it seems to be also afected by the previous transformation... Althought, that's not my biggest problem, I can just fix it by adding and deleting one by one the nodes to the root node. My problem is that the transformation I apply in OGL is not the same as in OSG, and I need the same transformation. So the gridOrientation is a Matrix3x3 wich contains the rotation in the object. , that's why I'm adding some more values. My matrix rotation in OGL is like that: gridOrientation.set(0,0,rotation.get(0,0)); gridOrientation.set(0,1,rotation.get(1,0)); gridOrientation.set(0,2,rotation.get(2,0)); gridOrientation.set(0,3,0.0f); gridOrientation.set(1,0,rotation.get(0,1)); gridOrientation.set(1,1,rotation.get(1,1)); gridOrientation.set(1,2,rotation.get(2,1)); gridOrientation.set(1,3,0.0f); gridOrientation.set(2,0,rotation.get(0,2)); gridOrientation.set(2,1,rotation.get(1,2)); gridOrientation.set(2,2,rotation.get(2,2)); gridOrientation.set(2,3,0.0f); gridOrientation.set(3,0,0.0f); gridOrientation.set(3,1,0.0f); gridOrientation.set(3,2,0.0f); gridOrientation.set(3,3,1.0f); As I can understand about the precedence of OGL and OSG, if I do translate and then rotate in ogl, I have to do rotate * translate in OSG Otherwise, I've tried both combinations, and no one is working... :S Cheers, Pau. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=15115#15115 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Best way to draw a volume
Hi, I'm new here, and don't have a ton of experience with OSG. I'm trying to draw a simple volume and would like to know what is the most appropriate way to do so. All shapes I will be drawing will have two faces (front and back) with equal number of sides and the corresponding connected sides. Basically, they will be extruded shapes where the front and back faces are not necessarily the same dimensions or parallel, though they will have the same basic shape. The method I tried is found at http://www.openscenegraph.org/documentation/NPSTutorials/osgGeometry.html. My function differs in that I am passing in two vectors: one with the coordinates of the front face and one for the back face. They are both ordered to draw the faces counter clockwise (CCW) as viewed from the outside. The volume object will be only one color, so I don't care about setting different colors for each vertex or face. The problem is that after it draws the volume the sides are not distinguishable from one another. Rotating the camera allows me to see that the shape is correct. The color only shows up if you are viewing from one angle. Rotating 180 degrees results in the volume displaying completely black. I have tried replacing the code to add the color with the following: /// // Grab the state set of the node, this will a StateSet if one does not exist osg::ref_ptrosg::StateSet state (geometry-getOrCreateStateSet()); //Creating the material object osg::ref_ptrosg::Material mat (new osg::Material); mat-setShininess(osg::Material::FRONT_AND_BACK,96.f); //Specifying the yellow colour of the object mat-setDiffuse(osg::Material::FRONT,osg::Vec4(.9f,.9f,.2f,1.0f)); //Attaching the newly defined state set object to the node state set state-setAttribute(mat.get()); /// This is a much easier way to give color to the volume, but I still have the same problem with the color only being visible from below the volume. I've changed the faces in both the setShininess and setDiffuse to both BACK and FRONT_AND_BACK with no luck. I've also looked at the osgshape example included with the download. This draws a three-sided pyramid- which seems very similar to what I want to do- using a ConvexHull object. I tried using this, but it seems that this method draws only triangles. The colors show up correctly, though. Am I on the right track? Is there an easier or more efficient way to draw a 3d object given the coordinates of all vertices? ... Thank you! Cheers, Evan -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=15117#15117 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Transformations
On 17/7/09 8:19 PM, Pau Moreno Font wrote: I'm trying to change my OGL code to OSG but I'm having really problems with the transformations... I have 174 data files that each contains a cloud of points, a vector3 with the translartion, and the matrix of rotation of each cloud. So in OGL, i just do: { LoadFile( x++) //Loads a diferent file in each iteration glPushMatrix(); glTranslate( x , y , z ) glMultMatrixf( rotation ); { osg::Matrixf rotation; rotation.set( gridOrientation.get( 0 , 0 ) , gridOrientation.get( 0 , 1 ) , gridOrientation.get( 0 , 2 ) , 0.0, gridOrientation.get( 1 , 0 ) , gridOrientation.get( 1 , 1 ) , gridOrientation.get( 1 , 2 ) , 0.0, gridOrientation.get( 2 , 0 ) , gridOrientation.get( 2 , 1 ) , gridOrientation.get( 2 , 2 ) , 0.0, 0.0f , 0.0f , 0.0f , 1.0f ); translation.setTrans( x , y , z ); By the way I read the OSGQSG (page 64) the memory layout of OSG and OpenGL matrices is identical. So it should be possible to pass the 'rotation' matrix from the OGL code to the Matrix constructor and at least tie down that end. rotationOGL.makeRotate( osg::DegreesToRadians(90.0) , osg::Vec3d( 0.0 , 1.0 , 0.0 )); transformationOGL-setMatrix(rotationOGL); transformationOGL-addChild(m_root); m_vViewer.setSceneData( transformationOGL ); Is 'rotationOGL' is supposed to convert OSG Z-up convention to OpenGL's Y-up? If that's the case you should rotate around the X-axis, not the Y-axis. Also: this probably doesn't affect the outcome but I tend to use osg::Vec3 and osg::Matrix instead of their respective float/double versions and instead rely on OSG to pick its compile setting. Cheers, /ulrich ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Geometry Culling
Hi all, I've uploaded a video http://www.youtube.com/watch?v=X4xgFzaBBWs to show the problem I'm facing when rendering a geometry. Any advices? Thank you! Cheers, CG[/url] -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=15121#15121 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] [build] OpenSceneGraph with STLPORT ?
Hi all, i would like to compile OpenSceneGraph with the Stlport (using cygwin) so i put the followong lines in the CMakeLists.txt (the one in the root) Code: INCLUDE_DIRECTORIES(C:/LIB/STLport-5.1.5/stlport) LINK_DIRECTORIES(C:/LIB/STLport-5.1.5/lib) TARGET_LINK_LIBRARIES(stlport.5.1) the compiler is ok, but the linker does not find my library stlport.5.1.lib. i think it miss the -lstlport.5.1 command i also tried the following line Code: SET(CMAKE_LDFLAGS ${CMAKE_LDFLAGS} -LC:/LIB/STLport-5.1.5/lib -lstlport.5.1) but nothing better. any ideas ? Thank you! Cheers, me -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=15119#15119 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [build] Notify Causing Linker Error
it seems you miss some visual std libraries or better the path to the std libraries which are in the Microsoft SDK i think -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=15122#15122 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org