Author Topic: SkyBox missing feature?  (Read 4034 times)

Offline Kaiidyn

  • long
  • ***
  • Posts: 103
    • View Profile
SkyBox missing feature?
« on: February 23, 2011, 11:36:53 am »
It is possible to initialize the skybox using
Code: [Select]
new SkyBox(1024);So without the textures,
However there is no way to set the textures at a later stadium.
At least, not that I could find.
Maybe add some functions like SkyBox.setNorth or SkyBox.setTextures(n, e, s, w) ?
Clean code is simple and direct. Clean code reads like well-written prose. Clean code never obscures the designer’s intent but rather is full of crisp abstractions and straightforward lines of control. - Grady Booch

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: SkyBox missing feature?
« Reply #1 on: February 23, 2011, 12:38:33 pm »
The problem is, that the beta releases lack JavaDocs. Because the docs would say this:

Quote
/**
 * Creates a new skybox. This constructor assumes that the textures for
 * front, back, left, right, up and down have already been added to the
 * TextureManager and that their names are equal to their purpose, i.e. the
 * front texture is called "front", the left one "left" and so on.
 *
 * @param size
 *            the size of the box. The box will extend in all directions by
 *            half the size when viewed from the center.
 */

Offline Kaiidyn

  • long
  • ***
  • Posts: 103
    • View Profile
Re: SkyBox missing feature?
« Reply #2 on: February 23, 2011, 01:32:52 pm »
I see..
Isn't it more useful to use default texture when none is set, and be able to change them later (real-time)?
If it is at all possible..
Clean code is simple and direct. Clean code reads like well-written prose. Clean code never obscures the designer’s intent but rather is full of crisp abstractions and straightforward lines of control. - Grady Booch

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: SkyBox missing feature?
« Reply #3 on: February 23, 2011, 01:39:11 pm »
You can always replace them via the TextureManager. The method is just meant as a shortcut.

Offline Kaiidyn

  • long
  • ***
  • Posts: 103
    • View Profile
Re: SkyBox missing feature?
« Reply #4 on: February 23, 2011, 01:43:04 pm »
I like shortcuts  ;D

Thanks anyway :)

Made myself a shortcut :)
Code: [Select]
import com.threed.jpct.FrameBuffer;
import com.threed.jpct.Texture;
import com.threed.jpct.TextureManager;
import com.threed.jpct.World;

public class SkyBox {
private com.threed.jpct.util.SkyBox skyBox;
private TextureManager tm;
public SkyBox(float size){
TextureManager tm = TextureManager.getInstance();
tm.addTexture("front", new Texture(Gameplay.resources.openRawResource(R.raw.north)));
tm.addTexture("back", new Texture(Gameplay.resources.openRawResource(R.raw.south)));
tm.addTexture("left", new Texture(Gameplay.resources.openRawResource(R.raw.west)));
tm.addTexture("right", new Texture(Gameplay.resources.openRawResource(R.raw.east)));
tm.addTexture("up", new Texture(Gameplay.resources.openRawResource(R.raw.up)));
tm.addTexture("down", new Texture(Gameplay.resources.openRawResource(R.raw.down)));

skyBox = new com.threed.jpct.util.SkyBox("left","front","right","back","up","down", size);
}

public void render(World world, FrameBuffer fb){
skyBox.render(world, fb);
}

public void changeTextures(Texture front, Texture back, Texture left, Texture right, Texture up, Texture down){
tm.replaceTexture("front", front);
tm.replaceTexture("back", back);
tm.replaceTexture("left", left);
tm.replaceTexture("right", right);
tm.replaceTexture("up", up);
tm.replaceTexture("down", down);
}

}
« Last Edit: February 23, 2011, 01:51:35 pm by Kaiidyn »
Clean code is simple and direct. Clean code reads like well-written prose. Clean code never obscures the designer’s intent but rather is full of crisp abstractions and straightforward lines of control. - Grady Booch