Re: [osg-users] [osgPlugins] OpenFlight Export - MultiTexturing - wrong Texture Coordinates
Thanks Paul, fix now merged and submitted to svn/trunk. On Mon, Dec 20, 2010 at 9:13 PM, Paul Martz pma...@skew-matrix.com wrote: Hi Robert Jose -- Apparently, I still don't have write permission for the OpenFlight plugin. Please commit this change to resolve Katharina's problem. Thanks. -Paul On 12/20/2010 1:56 PM, Paul Martz wrote: On 12/17/2010 9:13 AM, Katharina Plugge wrote: Hi, MultiTexturing has still its problems. Now I tried the first time to use up to 3 textures. Converting to flt again lead to corrupted texture coords. I attached an osg-file which can be used to reproduce the problem. Converting this file to flt shows the effect. Unfortunatly this time I have no idea what goes wrong. In FltExportVisitor::writeUVList the texture coords for both channels are determined correctly and written to _records. Somehow the texture coordinates have to be corrupted later. In the resulting file texture coords from channel one are mixed up with those from channel 2 and vice versa. Would be great, if someone could help here. Thank you! I think I've identified the problem. in expGeometryRecords.cpp lines 813-820, we write the UV list data incorrectly. According to the FLT spec, the data should be grouped per-vertex, not per-layer. We should have: UV for vertex 0, layer 1 UV for vertex 0, layer 2 UV for vertex 1, layer 1 UV for vertex 1, layer 2 ...etc... Instead, we have this: UV for vertex 0, layer 1 UV for vertex 1, layer 1 ...etc... UV for vertex 0, layer 2 UV for vertex 1, layer 2 ...etc... Oops! I'll commit a fix shortly (if Robert has granted me write permission, otherwise I'll post to osg-submissions). I'll also add your test case to the regression suite. -Paul ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org -- -Paul Martz Skew Matrix Software http://www.skew-matrix.com/ ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [osgPlugins] OpenFlight Export - MultiTexturing - wrong Texture Coordinates
Hi, wow, that was fast! I tried it with my data and everything looks fine. Thanks a lot! Cheers, Katharina -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=35024#35024 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [osgPlugins] OpenFlight Export - MultiTexturing - wrong Texture Coordinates
On 12/17/2010 9:13 AM, Katharina Plugge wrote: Hi, MultiTexturing has still its problems. Now I tried the first time to use up to 3 textures. Converting to flt again lead to corrupted texture coords. I attached an osg-file which can be used to reproduce the problem. Converting this file to flt shows the effect. Unfortunatly this time I have no idea what goes wrong. In FltExportVisitor::writeUVList the texture coords for both channels are determined correctly and written to _records. Somehow the texture coordinates have to be corrupted later. In the resulting file texture coords from channel one are mixed up with those from channel 2 and vice versa. Would be great, if someone could help here. Thank you! I think I've identified the problem. in expGeometryRecords.cpp lines 813-820, we write the UV list data incorrectly. According to the FLT spec, the data should be grouped per-vertex, not per-layer. We should have: UV for vertex 0, layer 1 UV for vertex 0, layer 2 UV for vertex 1, layer 1 UV for vertex 1, layer 2 ...etc... Instead, we have this: UV for vertex 0, layer 1 UV for vertex 1, layer 1 ...etc... UV for vertex 0, layer 2 UV for vertex 1, layer 2 ...etc... Oops! I'll commit a fix shortly (if Robert has granted me write permission, otherwise I'll post to osg-submissions). I'll also add your test case to the regression suite. -Paul ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [osgPlugins] OpenFlight Export - MultiTexturing - wrong Texture Coordinates
Hi Robert Jose -- Apparently, I still don't have write permission for the OpenFlight plugin. Please commit this change to resolve Katharina's problem. Thanks. -Paul On 12/20/2010 1:56 PM, Paul Martz wrote: On 12/17/2010 9:13 AM, Katharina Plugge wrote: Hi, MultiTexturing has still its problems. Now I tried the first time to use up to 3 textures. Converting to flt again lead to corrupted texture coords. I attached an osg-file which can be used to reproduce the problem. Converting this file to flt shows the effect. Unfortunatly this time I have no idea what goes wrong. In FltExportVisitor::writeUVList the texture coords for both channels are determined correctly and written to _records. Somehow the texture coordinates have to be corrupted later. In the resulting file texture coords from channel one are mixed up with those from channel 2 and vice versa. Would be great, if someone could help here. Thank you! I think I've identified the problem. in expGeometryRecords.cpp lines 813-820, we write the UV list data incorrectly. According to the FLT spec, the data should be grouped per-vertex, not per-layer. We should have: UV for vertex 0, layer 1 UV for vertex 0, layer 2 UV for vertex 1, layer 1 UV for vertex 1, layer 2 ...etc... Instead, we have this: UV for vertex 0, layer 1 UV for vertex 1, layer 1 ...etc... UV for vertex 0, layer 2 UV for vertex 1, layer 2 ...etc... Oops! I'll commit a fix shortly (if Robert has granted me write permission, otherwise I'll post to osg-submissions). I'll also add your test case to the regression suite. -Paul ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org -- -Paul Martz Skew Matrix Software http://www.skew-matrix.com/ /* * This library is open source and may be redistributed and/or modified under * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or (at * your option) any later version. The full license is in the LICENSE file * included with this distribution, and on the openscenegraph.org website. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * OpenSceneGraph Public License for more details. */ // // Copyright(c) 2008 Skew Matrix Software LLC. // #include FltExportVisitor.h #include DataOutputStream.h #include Opcodes.h #include MaterialPaletteManager.h #include TexturePaletteManager.h #include VertexPaletteManager.h #include osg/CullFace #include osg/BlendFunc #include osg/Geometry #include osg/Geode #include osg/Billboard #include osg/io_utils #include osg/Material #include osg/Texture2D #include sstream namespace flt { // Bit flags for multitexturing static unsigned int LAYER_1( 0x8000 0 ); #if 0 // unused so if'deffing out static unsigned int LAYER_2( 0x8000 1 ); static unsigned int LAYER_3( 0x8000 2 ); static unsigned int LAYER_4( 0x8000 3 ); static unsigned int LAYER_5( 0x8000 4 ); static unsigned int LAYER_6( 0x8000 5 ); static unsigned int LAYER_7( 0x8000 6 ); #endif bool FltExportVisitor::isLit( const osg::Geometry geom ) const { const osg::StateSet* ss = getCurrentStateSet(); if ( ss-getMode( GL_LIGHTING ) osg::StateAttribute::ON ) return true; else return false; //( geom.getNormalBinding() == osg::Geometry::BIND_PER_VERTEX ); } bool FltExportVisitor::isTextured( int unit, const osg::Geometry geom ) const { const osg::StateSet* ss = getCurrentStateSet(); bool texOn( ss-getTextureMode( unit, GL_TEXTURE_2D ) osg::StateAttribute::ON ); bool hasCoords( geom.getTexCoordArray( unit ) != NULL ); return( texOn hasCoords ); } bool FltExportVisitor::isMesh( const GLenum mode ) const { return( (mode == GL_TRIANGLE_STRIP) || (mode == GL_TRIANGLE_FAN) || (mode == GL_QUAD_STRIP) ); } bool FltExportVisitor::atLeastOneFace( const osg::Geometry geom ) const { // Return true if at least one PrimitiveSet mode will use a Face record. unsigned int jdx; for (jdx=0; jdx geom.getNumPrimitiveSets(); jdx++) { const osg::PrimitiveSet* prim = geom.getPrimitiveSet( jdx ); if( !isMesh( prim-getMode() ) ) return true; } // All PrimitiveSet modes will use Mesh records. return false; } bool FltExportVisitor::atLeastOneMesh( const osg::Geometry geom ) const { // Return true if at least one PrimitiveSet mode will use a Mesh record. unsigned int jdx; for (jdx=0; jdx geom.getNumPrimitiveSets(); jdx++) { const osg::PrimitiveSet* prim = geom.getPrimitiveSet( jdx ); if( isMesh( prim-getMode() ) ) return true; } // All PrimitiveSet modes will use Face records. return false; } void FltExportVisitor::writeFace( const
Re: [osg-users] [osgPlugins] OpenFlight Export - MultiTexturing - wrong Texture Coordinates
On 12/17/2010 9:13 AM, Katharina Plugge wrote: Hi, MultiTexturing has still its problems. Now I tried the first time to use up to 3 textures. Converting to flt again lead to corrupted texture coords. I attached an osg-file which can be used to reproduce the problem. Converting this file to flt shows the effect. Unfortunatly this time I have no idea what goes wrong. In FltExportVisitor::writeUVList the texture coords for both channels are determined correctly and written to _records. Somehow the texture coordinates have to be corrupted later. In the resulting file texture coords from channel one are mixed up with those from channel 2 and vice versa. Would be great, if someone could help here. OK, I will try to take a look. I might have some time to dig in over the next couple weeks. Thanks for posting the test file. -- -Paul Martz Skew Matrix Software http://www.skew-matrix.com/ ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [osgPlugins] OpenFlight Export - MultiTexturing - wrong Texture Coordinates
Hi, sorry that my answer took so long. I had a lot of other things to do the last weeks. I posted an issue at the OSG FLT export project issue page: http://code.google.com/p/osgfltexport/issues/detail?id=1 And I added my files to the submission page: http://forum.openscenegraph.org/viewtopic.php?p=33857#33857 Cheers, Katharina -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=33858#33858 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [osgPlugins] OpenFlight Export - MultiTexturing - wrong Texture Coordinates
Thanks -- Just taking a look at your test file now. It references two image files, which you did not attach to the Google Code issue. Could you email those directly to me, please? Or attach them to the issue, either one. Thank you, -Paul On 11/19/2010 5:40 AM, Katharina Plugge wrote: Hi, sorry that my answer took so long. I had a lot of other things to do the last weeks. I posted an issue at the OSG FLT export project issue page: http://code.google.com/p/osgfltexport/issues/detail?id=1 And I added my files to the submission page: http://forum.openscenegraph.org/viewtopic.php?p=33857#33857 Cheers, Katharina -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=33858#33858 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org -- -Paul Martz Skew Matrix Software http://www.skew-matrix.com/ ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [osgPlugins] OpenFlight Export - MultiTexturing - wrong Texture Coordinates
Actually, it appears this model will not be suitable for the osgfltexport test suite, as the initial view is an edge-on polygon, so the image compare will succeed even if the polygon is drawn incorrectly. However, I've noted that the issue appears to be related to rendering a PrimitiveSet with more than one quad, so I will modify the existing testMultiTex.osg test to render multiple quads, which should reproduce the issue. -Paul On 11/19/2010 10:24 AM, Paul Martz wrote: Thanks -- Just taking a look at your test file now. It references two image files, which you did not attach to the Google Code issue. Could you email those directly to me, please? Or attach them to the issue, either one. Thank you, -Paul On 11/19/2010 5:40 AM, Katharina Plugge wrote: Hi, sorry that my answer took so long. I had a lot of other things to do the last weeks. I posted an issue at the OSG FLT export project issue page: http://code.google.com/p/osgfltexport/issues/detail?id=1 And I added my files to the submission page: http://forum.openscenegraph.org/viewtopic.php?p=33857#33857 Cheers, Katharina -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=33858#33858 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org -- -Paul Martz Skew Matrix Software http://www.skew-matrix.com/ ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] [osgPlugins] OpenFlight Export - MultiTexturing - wrong Texture Coordinates
Hi, lately I was trying to convert an osg-file which uses multitexturing to openFlight and realized, that the texture coordinates for units 0 got corrupted. (First 3 coords are repeated again and again). So I had a look at the openFlight Plugin and found the problem in expGeometry.cpp, line 772, function writeUVList: Code: void FltExportVisitor::writeUVList( int numVerts, const osg::Geometry geom ) { unsigned int numLayers( 0 ); uint32 flags( 0 ); unsigned int idx; for( idx=1; idx8; idx++) { if( isTextured( idx, geom ) ) { flags |= LAYER_1 (idx-1); numLayers++; } } if( numLayers == 0 ) return; uint16 length( 8 + (8*numLayers*numVerts) ); _records-writeInt16( (int16) UV_LIST_OP ); _records-writeUInt16( length ); _records-writeInt32( flags ); osg::Vec2 defaultCoord( 0., 0. ); // const osg::StateSet* ss = getCurrentStateSet(); for( idx=1; idx8; idx++) { if( isTextured( idx, geom ) ) { osg::Array* t = const_castosg::Array*( geom.getTexCoordArray( idx ) ); osg::ref_ptrosg::Vec2Array t2 = dynamic_castosg::Vec2Array*( t ); if (!t2.valid()) { std::ostringstream warning; warning fltexp: No Texture2D for unit idx; osg::notify( osg::WARN ) warning.str() std::endl; _fltOpt-getWriteResult().warn( warning.str() ); t2 = new osg::Vec2Array; } else if (static_castint(t2-getNumElements()) != numVerts) { std::ostringstream warning; warning fltexp: Invalid number of texture coordinates for unit idx; osg::notify( osg::WARN ) warning.str() std::endl; _fltOpt-getWriteResult().warn( warning.str() ); } const int size = t2-getNumElements(); int vIdx; for( vIdx=0; vIdxnumVerts; vIdx++) { osg::Vec2 tc( defaultCoord ); if (vIdx size) tc = (*t2)[ vIdx ]; _records-writeFloat32( tc[0] ); _records-writeFloat32( tc[1] ); } } } } My Geometry contained 444 vertices and as many texture coordinates, so the size of the array t2 is 444 (and therefor does not equal numVerts which is 3 (using triangles)). The indices are always 0, 1, 2, so each time the function is called, the same three texture coordinates are added. I fixed this problem adding indices respectivly firstIndex as input parameter like it is done in writeVertexList: Code: void FltExportVisitor::writeUVList( int numVerts, const osg::Geometry geom, const std::vectorunsigned int indices ) { unsigned int numLayers( 0 ); uint32 flags( 0 ); unsigned int idx; for( idx=1; idx8; idx++) { if( isTextured( idx, geom ) ) { flags |= LAYER_1 (idx-1); numLayers++; } } if( numLayers == 0 ) return; uint16 length( 8 + (8*numLayers*numVerts) ); _records-writeInt16( (int16) UV_LIST_OP ); _records-writeUInt16( length ); _records-writeInt32( flags ); osg::Vec2 defaultCoord( 0., 0. ); // const osg::StateSet* ss = getCurrentStateSet(); for( idx=1; idx8; idx++) { if( isTextured( idx, geom ) ) { osg::Array* t = const_castosg::Array*( geom.getTexCoordArray( idx ) ); osg::ref_ptrosg::Vec2Array t2 = dynamic_castosg::Vec2Array*( t ); if (!t2.valid()) { std::ostringstream warning; warning fltexp: No Texture2D for unit idx; osg::notify( osg::WARN ) warning.str() std::endl; _fltOpt-getWriteResult().warn( warning.str() ); t2 = new osg::Vec2Array; } const int size = t2-getNumElements(); for( int cIdx=0; cIdxnumVerts; cIdx++) { int vIdx = indices[cIdx]; osg::Vec2 tc( defaultCoord ); if (vIdx size) tc = (*t2)[ vIdx ]; _records-writeFloat32( tc[0] ); _records-writeFloat32( tc[1] ); } } } } and Code: void FltExportVisitor::writeUVList( int numVerts, const osg::Geometry geom, unsigned int first ) { unsigned int numLayers( 0 ); uint32 flags( 0 ); unsigned int idx; for( idx=1; idx8; idx++) { if( isTextured( idx, geom ) ) { flags |= LAYER_1 (idx-1); numLayers++; } } if( numLayers == 0 ) return; uint16 length( 8 + (8*numLayers*numVerts) ); _records-writeInt16( (int16) UV_LIST_OP ); _records-writeUInt16( length ); _records-writeInt32( flags ); osg::Vec2 defaultCoord( 0., 0. ); // const osg::StateSet* ss =
Re: [osg-users] [osgPlugins] OpenFlight Export - MultiTexturing - wrong Texture Coordinates
On 10/29/2010 8:56 AM, Roland Smeenk wrote: Hi Katharina, thanks for chasing and fixing this problem. Can you attach the complete modified file to a new thread on the submissions forum. This way it will end up on the todo list for inclusion in osg. Hi Katharina -- Also, you mentioned you created an OSG file that reproduces the issue and verifies the fix. If you can share this file, please consider opening an issue at the OSG FLT export project issue page: http://code.google.com/p/osgfltexport/ Attach the OSG test file to the issue. I'll try to add it to the project when time allows. -Paul ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org