Creating a polygon and UV mapping it

Started by orange451, December 10, 2011, 11:01:47 PM

Previous topic - Next topic

orange451

Hi!
I've recently gotten started with JPCT, and I was wondering if anyone could supply me with either an example or just some code of how to create a polygon, uv map it, and add it to the world.

Thanks!

orange451

I've fixed my problem w/ the addTriangle :)

I have another, however...
the texture is very distorted... Here's a picture:

orange451

#2
I fixed my other problem, but yet again, another rises...



for the arm, how could I go about setting the center of the model I create? the .setCenter() does nothing in terms of rotations...

EgonOlsen


orange451

Thank you!

How would I go about having it load transparencies in the texture? At the moment, it turns all transparent pixels black :(

EgonOlsen

You have to enable transparency on the object by using setTransparency(<int>). Also keep in mind that jPCT ignores a textures alpha channel by default but creates its own one based on the black pixels in the texture. If you don't want this, use one of the Texture-constructors with that boolean useAlpha-flag.

orange451

#6
Can you provide me with an example on how to use the second thing you mentioned?

Could you also point me in the right direction of orthographicly projecting an image on to the screen? I've tried getting the screens graphics, and then drawing, but it isn't double buffered.

EgonOlsen

Sure: new Texture(<yourTexture>, true);

I'm not 100% sure what you mean with "orthographicly projecting an image on to the screen"!?

orange451

Quote from: EgonOlsen on December 11, 2011, 09:03:52 PM
Sure: new Texture(<yourTexture>, true);

I'm not 100% sure what you mean with "orthographicly projecting an image on to the screen"!?
That doesn't make it transparent... I've tried, but the transparent pixels remain black

By orthographicaly projecting an image, I mean draw an image on to the screen in a 2d space.
Such as a health bar, or other gui's.

EgonOlsen

No, that doesn't make it transparent...i never said this. What makes it transparent was written in the first sentence of my reply.... ???

To draw a 2D image, have a look at the blit-methods in FrameBuffer and/or at the Overlay-class in the util-package.

orange451

Quote from: EgonOlsen on December 11, 2011, 10:13:17 PM
No, that doesn't make it transparent...i never said this. What makes it transparent was written in the first sentence of my reply.... ???

To draw a 2D image, have a look at the blit-methods in FrameBuffer and/or at the Overlay-class in the util-package.

I'm still a bit confused, can you reexplain how I cna make a texture support transparencies?

EgonOlsen

Transparency is based on objects, not on textures. To make an object transparent, use the mentioned setTransparency(...)-method. The rest of the post was just about using the textures alpha channel or calculate a new one. If you want to make parts of an object transparent while others are not, you have to split into several objects.

orange451

Quote from: EgonOlsen on December 11, 2011, 10:44:53 PM
Transparency is based on objects, not on textures. To make an object transparent, use the mentioned setTransparency(...)-method. The rest of the post was just about using the textures alpha channel or calculate a new one. If you want to make parts of an object transparent while others are not, you have to split into several objects.
So basically, if I wanted to make a billboard gui with say, this texture:


I couldn't?

EgonOlsen

Of course you could...sadly, i don't get what you don't get here...!?

A texture has an alpha channel, which defines the transparency IF transparency is actually enabled for an object using this texture OR when blitting this texture. If the texture has no alpha in the file or you don't want to use it, jPCT will calculate one based on the black pixels at load time of that texture.


orange451

Quote from: EgonOlsen on December 11, 2011, 11:29:39 PM
Of course you could...sadly, i don't get what you don't get here...!?

A texture has an alpha channel, which defines the transparency IF transparency is actually enabled for an object using this texture OR when blitting this texture. If the texture has no alpha in the file or you don't want to use it, jPCT will calculate one based on the black pixels at load time of that texture.
Perhaps you could supply me with a code example?
For some reason, I just can't grasp what you're saying...