Author Topic: [solved] Can't render a texture from inside of a shape  (Read 666 times)

Offline kennydude

  • byte
  • *
  • Posts: 3
    • View Profile
[solved] Can't render a texture from inside of a shape
« on: May 06, 2013, 03:44:13 pm »
I'm trying to make JPCT-AE render inside of a shape. Basically, I am inside of a sphere primitive and I want to display a texture.

However, I can't get the texture to show up when I move the camera inside of the sphere. I can make it show by moving outside of the shape though, which is odd and annoying.

Here is my basic code at the moment:

Code: [Select]
    Texture texture = new Texture(3000, 3000, RGBColor.RED);
    TextureManager.getInstance().addTexture("sphere", texture);

    mSphere = Primitives.getSphere(20);
    //mSphere.calcTextureWrapSpherical();
    mSphere.setTexture("sphere");
    mSphere.build();

    mWorld = new World();
    //mWorld.setAmbientLight(50,50,50);

    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();

I have tried many variations of the code (commenting and uncommenting areas) but it just refuses to render the red colour at all.
« Last Edit: May 06, 2013, 04:24:11 pm by kennydude »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11748
    • View Profile
    • http://www.jpct.net
Re: Can't render a texture from inside of a shape
« Reply #1 on: May 06, 2013, 04:14:44 pm »
Objects will be backface culled by default, i.e. from inside a sphere, nothing will be visible, because you are looking at backfaces only. Try setCulling(false); on the sphere.

Offline kennydude

  • byte
  • *
  • Posts: 3
    • View Profile
Re: Can't render a texture from inside of a shape
« Reply #2 on: May 06, 2013, 04:23:50 pm »
Thank you so much!

That worked perfectly <3