Author Topic: Creating a polygon and UV mapping it  (Read 7027 times)

Offline orange451

  • byte
  • *
  • Posts: 19
    • View Profile
Creating a polygon and UV mapping it
« 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!

Offline orange451

  • byte
  • *
  • Posts: 19
    • View Profile
Re: Creating a polygon and UV mapping it
« Reply #1 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:

Offline orange451

  • byte
  • *
  • Posts: 19
    • View Profile
Re: Creating a polygon and UV mapping it
« Reply #2 on: December 11, 2011, 05:58:48 am »
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...
« Last Edit: December 11, 2011, 06:08:45 am by orange451 »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Creating a polygon and UV mapping it
« Reply #3 on: December 11, 2011, 09:48:54 am »
Use setRotationPivot instead.

Offline orange451

  • byte
  • *
  • Posts: 19
    • View Profile
Re: Creating a polygon and UV mapping it
« Reply #4 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 :(

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Creating a polygon and UV mapping it
« Reply #5 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.

Offline orange451

  • byte
  • *
  • Posts: 19
    • View Profile
Re: Creating a polygon and UV mapping it
« Reply #6 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.
« Last Edit: December 11, 2011, 08:36:59 pm by orange451 »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Creating a polygon and UV mapping it
« Reply #7 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"!?

Offline orange451

  • byte
  • *
  • Posts: 19
    • View Profile
Re: Creating a polygon and UV mapping it
« Reply #8 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.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Creating a polygon and UV mapping it
« Reply #9 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.

Offline orange451

  • byte
  • *
  • Posts: 19
    • View Profile
Re: Creating a polygon and UV mapping it
« Reply #10 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?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Creating a polygon and UV mapping it
« Reply #11 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.

Offline orange451

  • byte
  • *
  • Posts: 19
    • View Profile
Re: Creating a polygon and UV mapping it
« Reply #12 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:


I couldn't?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Creating a polygon and UV mapping it
« Reply #13 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.


Offline orange451

  • byte
  • *
  • Posts: 19
    • View Profile
Re: Creating a polygon and UV mapping it
« Reply #14 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...