Author Topic: Textures  (Read 5250 times)

Crowley

  • Guest
Textures
« on: June 25, 2004, 12:18:47 pm »
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  8)

Crowley

  • Guest
Doh!
« Reply #1 on: June 25, 2004, 03:08:13 pm »
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.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Textures
« Reply #2 on: June 25, 2004, 04:28:21 pm »
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).

Crowley

  • Guest
Thanks!
« Reply #3 on: June 25, 2004, 11:50:44 pm »
Thank you very much  :D . It works just fine.

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.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Textures
« Reply #4 on: June 26, 2004, 10:55:15 am »
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.

Crowley

  • Guest
Cool
« Reply #5 on: June 26, 2004, 06:23:53 pm »
Thanks again, it works! I'll post some shots if I at some point manage to create something presentable out of this experiment :)