[Plib-users] Texturing a triangle
Brought to you by:
sjbaker
From: D L. <ea...@no...> - 2001-03-07 14:52:50
|
Hi all, I'm having trouble applying a texture to a triangle. All I get is an overall colour that looks like it might be the averaged texture colour. I'm sure I'm doing something very simple wrong but I just can't see it. The code snippet is here - I just added it to the tux example code. ssgTexture *texture = new ssgTexture("wood.rgb"); ssgSimpleState *state = new ssgSimpleState; state->setTexture(texture); state->enable( GL_TEXTURE_2D ); // Allocate ssg structure ssgVertexArray *vl = new ssgVertexArray( 3 ); ssgNormalArray *nl = new ssgNormalArray( 3 ); ssgTexCoordArray *tl = new ssgTexCoordArray( 3 ); ssgColourArray *cl = new ssgColourArray( 3 ); sgVec4 color; sgSetVec4( color, 1.0, 0.0, 0.0, 1.0 ); cl->add( color ); cl->add( color ); cl->add( color ); sgVec3 tmpvec; sgSetVec3( tmpvec, -50.0, -10.0, 0.0 ); vl->add( tmpvec ); sgSetVec3( tmpvec, 50.0, -10.0, 0.0 ); vl->add( tmpvec ); sgSetVec3( tmpvec, 0.0, 50.0, 0.0 ); vl->add( tmpvec ); // Add normals sgSetVec3( tmpvec, 0.0, 0.0, 1.0 ); nl->add(tmpvec); nl->add(tmpvec); nl->add(tmpvec); // Add texture coordinates sgVec2 texvec; sgSetVec2(texvec,0.0,0.0); sgSetVec2(texvec,1.0,0.0); sgSetVec2(texvec,0.5,1.0); tl->add(texvec); tl->add(texvec); tl->add(texvec); ssgLeaf *leaf = new ssgVtxTable ( GL_TRIANGLES, vl, nl, tl, NULL ); leaf->setState(state); penguin -> addKid ( tux_obj ) ; pedestal -> addKid ( leaf ) ; I just can't see what I'm missing / doing wrong :-( Cheers - Dave -- David Luff Engines Research Group University of Nottingham 0115-9513814 dav...@no... |