www.jpct.net

jPCT - a 3d engine for Java => Support => Topic started by: orange451 on December 10, 2011, 11:01:47 pm

Title: Creating a polygon and UV mapping it
Post by: orange451 on December 10, 2011, 11:01:47 pm
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!
Title: Re: Creating a polygon and UV mapping it
Post by: orange451 on December 11, 2011, 01:54:28 am
I've fixed my problem w/ the addTriangle :)

I have another, however...
the texture is very distorted... Here's a picture:
(http://troll.ws/i/tChXWy.png)
Title: Re: Creating a polygon and UV mapping it
Post by: orange451 on December 11, 2011, 05:58:48 am
I fixed my other problem, but yet again, another rises...

(http://troll.ws/i/PIP8YI.png)

for the arm, how could I go about setting the center of the model I create? the .setCenter() does nothing in terms of rotations...
Title: Re: Creating a polygon and UV mapping it
Post by: EgonOlsen on December 11, 2011, 09:48:54 am
Use setRotationPivot instead.
Title: Re: Creating a polygon and UV mapping it
Post by: orange451 on December 11, 2011, 02:41:52 pm
Thank you!

How would I go about having it load transparencies in the texture? At the moment, it turns all transparent pixels black :(
Title: Re: Creating a polygon and UV mapping it
Post by: EgonOlsen on December 11, 2011, 08:19:24 pm
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.
Title: Re: Creating a polygon and UV mapping it
Post by: orange451 on December 11, 2011, 08:31:48 pm
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.
Title: Re: Creating a polygon and UV mapping it
Post by: 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"!?
Title: Re: Creating a polygon and UV mapping it
Post by: orange451 on December 11, 2011, 10:05:21 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.
Title: Re: Creating a polygon and UV mapping it
Post by: 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.
Title: Re: Creating a polygon and UV mapping it
Post by: orange451 on December 11, 2011, 10:23:19 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?
Title: Re: Creating a polygon and UV mapping it
Post by: 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.
Title: Re: Creating a polygon and UV mapping it
Post by: orange451 on December 11, 2011, 11:10:20 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:
(http://troll.ws/i/ZuniSa.png)

I couldn't?
Title: Re: Creating a polygon and UV mapping it
Post by: 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.

Title: Re: Creating a polygon and UV mapping it
Post by: orange451 on December 11, 2011, 11:33:06 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...
Title: Re: Creating a polygon and UV mapping it
Post by: EgonOlsen on December 11, 2011, 11:35:56 pm
I already did this...it's a one liner. I've no idea how to explain it in other words ATM...maybe looking at the examples is worth a try...take the car-example...it has transparent objects (the plants) and transparent blits (the fps numbers)...maybe that helps.
Title: Re: Creating a polygon and UV mapping it
Post by: orange451 on December 14, 2011, 09:33:39 pm
I could really use that example :P
Title: Re: Creating a polygon and UV mapping it
Post by: EgonOlsen on December 14, 2011, 11:02:57 pm
It's in the zip  ???
Title: Re: Creating a polygon and UV mapping it
Post by: orange451 on December 14, 2011, 11:52:29 pm
It's in the zip  ???
...I completely missed the "page 2" of this topic... I'm sorry! XD

[edit]
I love you! :D