Author
Topic: Textures (Read 3824 times)

Crowley

Hello. I have a problem with textures. I've created an Object3D by coding a bunch of addTriangles into the code. I know this isnt the smartest aproach to 3d modelling, but as we are talking about only a simple cube for testing purposes, it isnt a major problem for me.

When I set a texture to this object, compile the code and run, the texture doesn't show up right. It finds the file obviously, because the object does change it's color. Ie, if the texture is mostly brown, it changes to brown, and when I tried using the ql3.jpg from the FPS example, the object became gray. I've tried to find a solution myself, but I'm simply not experienced enough with the engine to be able to figure it out :oops: .

I'm creating a game, similar to those of the first two Grand Theft Auto games: top-down, with 2D sprites moving in a 3D world. Thus I was wondering if it is possible to make a texture partially transparent, so that I could make the 2D sprites happen by creating a flat surface in the 3d world and you could see the ground through it, a bit like a transparent GIF. This isn't all that critical, because I can always use 3D models, an option I will be considering in any case, but it would be nice to know if the 2D option would be available

Logged

Crowley

Sorry about double posting, but I'm not registered. Of course I figured it out myself just after posting here :oops: I obviously had to adjust the texture coordinates. Still wondering about the transparent textures tho.

You can do something similar...in jPCT, transparency in handled on a per object base. An object defined as transparent (setTransparency() in Object3D) will automatically be mapped by using alpha transparency (which is not what you really want) and a kind of color keying. Have a look in the docs for this method. You can use this behaviour to get something that's quite similar to the effect you describe. Just set the transparency to 2 or 3...that is usually high enough to prevent the colored parts of the texture to be too much see-through but you still get the color keying. Problem with this is, that the texture will get darker when using the software renderer, because the blending operation applied to it is close to but doesn't match the more correct OpenGL-blending (for performance reasons).

Logged

Crowley

As it happens, I have an another dilemma. How does one determine the mouse cursor coordinates when using hardware OpenGL? With software I think this would be done through the Frame, but I really prefer to use hardware whenever I can due to the obvious speed and other benefits.

Have a look at the LWJGL documention (http://www.lwjgl.org) about this. You'll get the same "problem" with the keyboard, but the next release of jPCT will include a "KeyMapper" that covers this topic...just not for the mouse because that should be a lot simpler than the keyboard.