Author Topic: Primitives and Texture Wrap  (Read 3029 times)

Offline tober6584

  • byte
  • *
  • Posts: 3
    • View Profile
Primitives and Texture Wrap
« on: January 27, 2009, 02:01:46 am »
I'm just trying to recreate the rotating Earth from the demo on the home page, but when I create a sphere using Primitives and add my Earth texture it looks like the texture is actually applied twice, once to half the sphere, and once in mirror image to the other half, rather than wrapping around the whole sphere. Here's the code I'm using:

Quote
      earth = new Object3D(Primitives.getSphere(1000));
      earth.calcTextureWrapSpherical();
      earth.setTexture( "md2" + c + "004Earth.JPG" );
      earth.build();
      world.addObject( earth );

004Earth.JPG is a 256x256 pixel image of the Earth. I am able to correctly load md2 models and their textures, so maybe it has something to do with the calcTextureWrapSpherical call? Any help you could provide would be greatly appreciated.
« Last Edit: January 27, 2009, 02:03:39 am by tober6584 »

Offline JavaMan

  • long
  • ***
  • Posts: 231
    • View Profile
Re: Primitives and Texture Wrap
« Reply #1 on: January 27, 2009, 02:55:04 am »
Did you try just the caclTextureWrap? Maybe wrap spherical doesn't really work as expected on a Primitive's sphere. Or maybe Egon created a sphere and stored it in the jpct jar that is used in the demo and doesn't even call calcTextureWrapSpherical because his model has the texture coords set already.

Offline tober6584

  • byte
  • *
  • Posts: 3
    • View Profile
Re: Primitives and Texture Wrap
« Reply #2 on: January 27, 2009, 04:30:00 am »
I did try calcTextureWrap and that gave me even worse results, just a dark green mesh. The demos that I downloaded don't have any spheres in them, and I didn't see anywhere to download the spinning planet demo.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: Primitives and Texture Wrap
« Reply #3 on: January 27, 2009, 09:36:19 am »
The calcTextureWrap-methods are not meant to create great looking results. There are more or less for creating quick and dirty u/v-coordinates only. For creating a good looking planet, you need a textured sphere build in some modeler. I've uploaded the one that i was using for the planet-applet in ASC-format here: http://www.jpct.net/download/misc/terra.asc

Offline tober6584

  • byte
  • *
  • Posts: 3
    • View Profile
Re: Primitives and Texture Wrap
« Reply #4 on: January 27, 2009, 11:38:52 pm »
That seems to have done the trick. Thanks so much!

Offline .jayderyu

  • long
  • ***
  • Posts: 116
    • View Profile
Re: Primitives and Texture Wrap
« Reply #5 on: January 28, 2009, 12:08:42 pm »
The calcTextureWrap-methods are not meant to create great looking results. There are more or less for creating quick and dirty u/v-coordinates only. For creating a good looking planet, you need a textured sphere build in some modeler. I've uploaded the one that i was using for the planet-applet in ASC-format here: http://www.jpct.net/download/misc/terra.asc

yeah unfortunealty I find it a bit annoying since most of my smaller game ideas use Primitive Objects :(, but hey just make to with what you got.