UVMapper

Moderator
Posts: 133
Joined: 2008.05
Post: #1
I think this problem lies with UVMapper, although I might be wrong. I'm fairly sure at least some of you have heard of this program, since I got the link from this site.

Anyway, I create an object in Poser 4.0 and I export certain parts of it as .obj files(the torso, the legs, are all seperate). When I put it into UVMapper, I pick planar export the texture and model maps.

As an example, I draw red on one side and blue on the other and put it into my program using the Object loader from Karl Berg.

The problem is, it looks very bad in my game. The colors are mangled like the texture coordinates are skewed. Like some facets have the wrong color on it, I don't know how to fix it, am I doing something wrong in UVMapper or in my code?

edit: Well, when I looked at it, when I go around the model to the backside it draws the front of it.. it's drawing it wrong for some reason..

This is the code for the update function:
Code:
    //-------------------------------
    //Setup rendering...
    //-------------------------------
    aglSetCurrentContext (*(engine->GetAGLContext()));
    aglUpdateContext(*(engine->GetAGLContext()));
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    //-------------------------------
    //Do game drawing first...
    //-------------------------------
    cam->Render(resolution);

    if(!engine->IsPaused() && world)
        world->Animate(0);
    if(world)
        world->Draw(cam);
    glTranslatef(0,0,0);
    glDisable(GL_BLEND);
    ath->Draw();
    //-------------------------------
    //Now draw windows and controls    
    //-------------------------------
    windows->Draw();
    
    ShowEffects();
    
    //-------------------------------
    //Swap double buffer
    //-------------------------------
    aglSwapBuffers(*(engine->GetAGLContext()));
}


The ath->draw function is where it draws the person, that just calls object loader draw function for anyone that is familiar with it. It's as though the modelview matrix isn't applied to it or something... or at least not towards the texture part or I don't even know, I'm not entirely sober. Any help or insight would be nice.
Quote this message in a reply
Oldtimer
Posts: 834
Joined: 2002.09
Post: #2
I guess we would need to take a look at the code you're using to draw the models... But that glTranslatef (0,0,0) call is entirely unecessary, so you can remove it. Smile

I know I've had problems with OBJ models in the past, when I didn't take into account that OBJ models start all their indices at 1, not 0. Post back and I'll see what I can do.
Quote this message in a reply
Moderator
Posts: 133
Joined: 2008.05
Post: #3
Source code for how the object is drawn is here:
http://www.sfu.ca/~kberg/Code/

And I just put that junk in there to test how the loader works.

It seems like it's the objects exported from Poser that have a problem...
Quote this message in a reply
kberg
Unregistered
 
Post: #4
When you export the models from UV mapper, you could try the reverse winding option. If this problem is caused by faces facing the wrong direction then that should fix your problems...

The model loader code certainly does take into account indicies starting at one Wink My best guess would be poser exporting faces in a clockwise direction instead of counterclockwise as opengl expects...
Quote this message in a reply
Moderator
Posts: 133
Joined: 2008.05
Post: #5
edit: It's drawing inside out, but winding it differently doesn't help...?
Quote this message in a reply
kberg
Unregistered
 
Post: #6
Winding doesn't make any difference... Are normals included in your obj models? Perhaps normals are inverted for some reason...
Quote this message in a reply
Oldtimer
Posts: 834
Joined: 2002.09
Post: #7
Spent half an hour looking at the code, nothing in particular stands out as broken, except perhaps that you are calling glTexCoord3f instead of the 2f you want. That shouldn't be a problem, but perhaps your driver doesn't like getting glTexCoord3f when GL_TEXTURE_2D is bound? Anyway, you are losing performance (although very little) that way, especially if you have GL_TEXTURE_3D enabled.

But, come to think of it, I've seen problems with UVMapper before - I've had horrible texture seams with models exported from Carrara 2 (which was developed by the same company as Poser). If I'm not entirely mistaken, it is mentioned in the manual... Oh yes, here:
Quote:"Edit->Tools->fix Seams" is an obsolete option that was written to solve the problem that Poser 3.0 had with exported Wavefront models.* The models displayed a seam between each of the model groups.* This was fixed with the 3.01 patch that was made available on the MetaCreations website.* This is not a problem with Poser 4.

I don't know which version you are using, but if your model is low-poly enough, that could explain something...

Edit: Sorry, I didn't see that you said you were using Poser 4...
Quote this message in a reply
Oldtimer
Posts: 834
Joined: 2002.09
Post: #8
Quote:I'm not entirely sober
You know, this could cause the artifacts you are seeing. ;-)

Joking aside, try downloading the example pack from UVMapper.com and see if those models work out for you. If they don't, then Karl is broken, otherwise, Poser is. My money is on Poser being broken, I'm afraid.
Quote this message in a reply
kberg
Unregistered
 
Post: #9
I certainly hope I'm not broken Rasp

The reason the texcoord3f calls are in there is that certain apps like 3DS max export UVW coordinates instead of simply UV coordinates. For obj files that provide only UV coordinates, the w value is set to 0 which is the default.
Quote this message in a reply
Moderator
Posts: 133
Joined: 2008.05
Post: #10
The model loads fine in any other program except mine. It appears from the outside that lots of chunks are missing, but when I blow up the model to a larger scale and go "inside" the object, its perfectly done. So it's thinking that it's drawing the back and front opposite of what they should be... should I be making a call to glFrontFace, glCullFace, or glPolygonMode? And if so, where in your code, Karl?

I don't understand why it insists on drawing it inside out, and I really hate opengl
Quote this message in a reply
kberg
Unregistered
 
Post: #11
The model loader assumes that materials are single sided and wound counter-clockwise. I haven't built any code in to flip face winding or invert normals, so there isn't any chance of setting the wrong variable / calling the wrong function from within my code. Could you send me a sample obj file so that I can check out whats gone wrong? Either post it to the board, or attach it to an email and sent it to me at kberg@sfu.ca.

I'll verify if this is a problem with my code, and if it is I'll post a fix for it...
Quote this message in a reply
Moderator
Posts: 133
Joined: 2008.05
Post: #12
I fixed it by turning on culling and culling out the back face... I'll send you the object though, so you can see what it does. Thanks!
Quote this message in a reply
Post Reply