Author Topic: Fit Texture to Sphere  (Read 1646 times)

Offline kennydude

  • byte
  • *
  • Posts: 3
    • View Profile
Fit Texture to Sphere
« on: May 06, 2013, 08:10:44 pm »
Hi, I'm trying to fix a texture to a sphere. However, it only shows part of the texture.

A texture in my app can look like this - http://i.imgur.com/dT7vDlY.jpg (the red parts will be changed in the future, just for reference)

However, I can only see the red area on my device using

Code: [Select]
public void setupWorld(){
mSphere = Primitives.getSphere(SPHERE_RADIUS);
mSphere.setCulling(false);
mSphere.setTexture("sphere");
mSphere.build();

mWorld = new World();
mWorld.setAmbientLight(200,200,200);

mWorld.addObject(mSphere);

Camera camera = mWorld.getCamera();
camera.moveCamera( Camera.CAMERA_MOVEOUT, 30 );
//camera.setPosition( mSphere.getTransformedCenter() );
camera.lookAt( mSphere.getTransformedCenter() );
//camera.moveCamera(Camera.CAMERA_MOVEIN, 5);

MemoryHelper.compact();
}

If someone could tell me what I'm doing wrong, that would be fantastic :)

Joe :)

p.s the whole code is Open Source @ https://github.com/kennydude/photosphere/tree/master/Android

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Fit Texture to Sphere
« Reply #1 on: May 06, 2013, 09:26:30 pm »
Like the docs for the Primitives class state:

Quote
Except for the plane, objects created by this class don't have proper texture coordinates.

They are meant to be used as quick-and-dirty placeholders, not for real production use. You need some sphere model with proper coordinates and load that instead. Like this: http://www.jpct.de/download/net/misc/terra.asc