I used the tutorial called HelloStates and now I am trying to work through my own example to gain a better understanding. When I run the class, it isn't displaying, so I think something is wrong with the line that specifies the url…
... I have that image in the package with my java file that I am trying to run. Is there a certain way that I define the path to the image or should I be placing it somewhere else?
public class HelloTextures1 extends SimpleGame
{
protected void simpleInitGame()
{
// create the box and pyramid to be used
Box box1 = new Box("box1", new Vector3f(0,0,0), new Vector3f(5,5,5));
Pyramid pyramid1 = new Pyramid("p1", 5f, 5f);
// put boundingBoxes on box1 and pyramid1
box1.setModelBound(new BoundingBox());
box1.updateModelBound();
pyramid1.setModelBound(new BoundingBox());
pyramid1.updateModelBound();
// translate pyramid1 away from box1 along x axis
pyramid1.setLocalTranslation(new Vector3f(10,0,0));
// attach box1 and pyramid1 to rootNode
rootNode.attachChild(box1);
rootNode.attachChild(pyramid1);
// create a location which points to the picture I want to use
URL circleBearLocation = HelloTextures1.class.getClassLoader().getResource("circlebear1.gif");
// create a texture state (based on LWJGL)
TextureState textureState = display.getRenderer().createTextureState();
// Load the texture I want to use
Texture cbTexture = TextureManager.loadTexture
(circleBearLocation,
Texture.MM_LINEAR,
Texture.FM_LINEAR);
// set the textureState as cbTexture
textureState.setTexture(cbTexture);
// set the renderState of both box1 and pyramid1 as textureState
box1.setRenderState(textureState);
pyramid1.setRenderState(textureState);