www.jpct.net

jPCT - a 3d engine for Java => Support => Topic started by: fireside on August 01, 2008, 11:00:55 pm

Title: Textures in applet shifted
Post by: fireside on August 01, 2008, 11:00:55 pm
I just tried loading the mouse character in my applet and the textures that were fine in the application are all shifted over in the applet. 
Title: Re: Textures in applet shifted
Post by: EgonOlsen on August 01, 2008, 11:06:20 pm
Do you have a screen shot to compare both?
Title: Re: Textures in applet shifted
Post by: fireside on August 02, 2008, 12:03:08 am
(http://img505.imageshack.us/img505/4803/micexx1.th.jpg) (http://img505.imageshack.us/my.php?image=micexx1.jpg)

These are the same model and texture.  One only uses ambient light, but you can see how the black nose is in the right place on the one and off on the other.
Title: Re: Textures in applet shifted
Post by: EgonOlsen on August 02, 2008, 03:14:16 pm
Have you called build() on the model used in the applet. There is no difference between an applet and an application for jPCT. If the mapping is wrong, it has to be something in your code that differs. Are you using the hardware renderer in the application and the software one in the applet?
Title: Re: Textures in applet shifted
Post by: fireside on August 02, 2008, 10:11:58 pm
I'm using the same model loading function except the applet loads from a stream and I'm using the software renderer for the applet.  The load function does a build. Then I set the texture after in both programs.  I do a set scale in the applet after the load and texture setting that I don't think I do in the application.
Title: Re: Textures in applet shifted
Post by: EgonOlsen on August 02, 2008, 10:14:36 pm
You have to call build() after setting the textures. build() should be called right after the object is "ready to render". Without properly set textures, it isn't. The hardware renderer is just more forgiving in this respect than the software one.
Title: Re: Textures in applet shifted
Post by: fireside on August 02, 2008, 10:19:34 pm
OK, I'll try that.
Title: Re: Textures in applet shifted
Post by: fireside on August 02, 2008, 10:23:00 pm
That fixed it, thanks.
Title: Re: Textures in applet shifted
Post by: EgonOlsen on August 02, 2008, 10:29:05 pm
You may also use recreateTextureCoords(); which is cheaper than build() if build() has already been called at least once before. But on todays hardware, it shouldn't matter anyway...