Hi, I'm trying to texture a face of a cube VRML model with an Image by creating a TextureChunk holding the Image and TexGenChunk to automatically generate the texture coords for the Image. The texture is partly displayed, but only a small square (about 50x50 pixels from the lower left of the original 1024x1024 texture) displays on the face in the corner of the face. (Links to images of my problem below) Any ideas what the problem could be?
I could be related to the setGenFuncSPlane and setGenFuncTPlane settings, as when I change the 1 to a larger number it displays more of the texture, but it is still a small square in the corner of the face. I have the problem if I use either POT or NPOT images (the system has both NPOT and RectTex support). Problem: http://ubicomp.lancs.ac.uk/~molyneau/testTexture.jpg The actual texture: http://ubicomp.lancs.ac.uk/~molyneau/actualTexture_1024.jpg My code for texturing: std::string coretype = theFace->getCore()->getTypeName(); if (coretype == "MaterialGroup") // proably a VRML file { MaterialGroupPtr mg = MaterialGroupPtr::dcast( materialGroupNode->getCore() ); beginEditCP(mg); { ChunkMaterialPtr material = ChunkMaterialPtr::dcast(mg->getMaterial()); TextureChunkPtr tex = TextureChunk::create(); beginEditCP(tex); { tex->setImage( theImage ); tex->setMinFilter( GL_LINEAR ); tex->setMagFilter( GL_LINEAR ); tex->setWrapS( GL_CLAMP_TO_EDGE ); tex->setWrapT( GL_CLAMP_TO_EDGE ); tex->setEnvMode( GL_REPLACE ); if( osgispower2( theImage->getWidth() ) && osgispower2( theImage->getHeight() ) ) { // power-of-two image. Nice, nothing special to do here. } else if(hasNPOT) { // NPOT image, but GL_ARB_non_power_of_two supported, don't need to anything special } else if(hasRectTex) { // Rectangular texChunktures are available, but they need to be explicitly enabled tex->setTarget(GL_TEXTURE_RECTANGLE_ARB); } else { tex->setScale(false); // Tell OpenSG not to scale the image if NPOT. } } endEditCP(tex); TexGenChunkPtr texgen = TexGenChunk::create(); beginEditCP(texgen); texgen->setGenFuncS(GL_OBJECT_LINEAR); texgen->setGenFuncT(GL_OBJECT_LINEAR); texgen->setGenFuncSPlane(Vec4f(1,0,0,0)); texgen->setGenFuncTPlane(Vec4f(0,1,0,0)); endEditCP(texgen); beginEditCP(material); material->addChunk( tex ); material->addChunk( texgen ); endEditCP(material); } endEditCP(mg); } Part of my simple VRML code (each face is a shape) : #VRML V2.0 utf8 # Cube of 9.5cm side, origin is centre Group # for an object/scene made of more than one shape { children [ DEF back Shape # Node name here is front { appearance Appearance { material Material { diffuseColor 0.5 0.5 0.5 # RGB = grey } } geometry IndexedFaceSet # define front face { coord Coordinate # DM define centre of cube to be origin { # cube side of 20cm point [ -0.047 -0.047 -0.047, 0.047 -0.047 -0.047, 0.047 0.047 -0.047, -0.047 0.047 -0.047, ] } coordIndex [ 3,2,1,0 ] } } Also, Is there any more up-to-date and comprehensive documentation planned for OpenSG? While the tutorial is good for a first time user of OpenSG, it only provides a simplistic and incomplete view of OpenSG's capabilities. I'm finding that I have to spend a long time searching the mailing list archives and looking at the source code for lots of small pieces of information (such as how to add textures to material groups, NPOT texture handling or multithreading with external threads) which are not even mentioned in the tutorial, just to get a simple VRML model textured. Thanks, Dave BTW: Thanks for the replies on my earlier question (below) - it was an uninitialised thread giving me problems. ----- Original Message ----- From: <[EMAIL PROTECTED]> To: <opensg-users@lists.sourceforge.net> Sent: Tuesday, February 06, 2007 8:13 PM Subject: Opensg-users Digest, Vol 9, Issue 10 > Send Opensg-users mailing list submissions to > opensg-users@lists.sourceforge.net > > To subscribe or unsubscribe via the World Wide Web, visit > https://lists.sourceforge.net/lists/listinfo/opensg-users > or, via email, send a message with subject or body 'help' to > [EMAIL PROTECTED] > > You can reach the person managing the list at > [EMAIL PROTECTED] > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of Opensg-users digest..." > > > Today's Topics: > > 1. Re: Crash in osgthread.cpp when loading VRML file from Opensg > CVS compiled with MSVC2005 (Marcus Lindblom) > 2. Re: OpenSG with FOX (Dirk Reiners) > 3. Re: normals newbie q (Dirk Reiners) > 4. DynFieldAttachment Example (Aron Bierbaum) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Tue, 06 Feb 2007 15:41:56 +0100 > From: Marcus Lindblom <[EMAIL PROTECTED]> > Subject: Re: [Opensg-users] Crash in osgthread.cpp when loading VRML > file from Opensg CVS compiled with MSVC2005 > To: opensg-users@lists.sourceforge.net > Message-ID: <[EMAIL PROTECTED]> > Content-Type: text/plain; charset=ISO-8859-1; format=flowed > > Hi David, > > Dummy check: are you loading from a different (uninitialized) thread? > > Cheers > /Marcus > > David Molyneaux wrote: >> Hi everyone, >> >> I have an application which is trying to load some basic VRML files (such >> as >> a cube) and display them with GLUT. Unfortunately I'm getting a crash in >> osgthread.cpp with Opensg CVS version libraries compiled in MSVC2005 on >> Win32. The error occurs when trying to access the Thread Local Storage in >> the function UInt32 WinThreadBase::getAspect(void) >> >> At line: pUint = (UInt32 *) TlsGetValue(_aspectKey); >> The _aspectKey is 10, but windows returns NULL when calling TlsGetValue. >> I >> know this function is already being called successfully multiple times >> with >> the same _aspectKey value during the SceneFileHandler intialisation. >> >> Error Message: >> Unhandled exception at 0x00e46e69 (OSGSystemD.dll) in project.exe: >> 0xC0000005: Access violation reading location 0x00000000. >> >> The library and application are both compiled with Multi-threaded Debug >> DLL, >> using the standard support libraries. Both debug and release versions of >> my >> application crash at the same place. >> >> My code where the crash is occuring: >> >> bool OpenSGObject:: LoadGeometryToScenegraph( const string &filename ) >> { >> NodePtr nodeGeometry = SceneFileHandler::the().read( >> filename.c_str() ); >> // Crashes on this call... >> >> if ( nodeGeometry == NullFC ) >> return false; >> >> // Add node to scenegraph root >> beginEditCP(root, Node::ChildrenFieldMask); >> >> ....etc... >> >> Loading works correctly in the tutorial 10loading.cpp with the same VRML >> file. I'm using the same include files, libraries, DLLs and C++ >> pre-processor options in my application, so I'm a bit mystified. >> >> Any suggestions or ideas what this crash might indicate? >> >> Could I somehow define OSG_ASPECT_USE_DECLSPEC rather than >> OSG_ASPECT_USE_LOCALSTORAGE to get around this (I say this without >> knowing >> anything about the internals of OpenSG...). >> >> Thanks, >> Dave Molyneaux >> ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier. Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ Opensg-users mailing list Opensg-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/opensg-users