SkyBox missing feature?

Started by Kaiidyn, February 23, 2011, 11:36:53 AM

Previous topic - Next topic

Kaiidyn

It is possible to initialize the skybox using
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

EgonOlsen

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.
*/

Kaiidyn

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

EgonOlsen

You can always replace them via the TextureManager. The method is just meant as a shortcut.

Kaiidyn

#4
I like shortcuts  ;D

Thanks anyway :)

Made myself a shortcut :)
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);
}

}
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