Loading images

Started by Irene, August 19, 2011, 12:16:25 PM

Previous topic - Next topic

Irene

Hi!
My question is probably trivial, but I can't find a solution because I am very new in jpct and 3D at all.
I have an image file 256x256 jpg and I want to load it as texture on primitive created like that:

Object3D myBox = null;
myBox = Primitives.getBox(21f, 2f);

I loading a texture this way:

TextureManager tm = TextureManager.getInstance();
Texture test = new Texture(Main.getTexture("/resources/test.jpg")); // getTexture code works well with another image
tm.addTexture("test", test);
myBox.setTexture("test");
myBox.build();

But when I have done so I can not see my image on box. In the same time when I loading the same way "rocks.jpg" image from samples, my box became green and texture works.
What am I doing wrong?
Please somebody tell me, how can I place my pic or text for example on primitive or a model?


Also I have the second trivial question:
How can I know the angle between camera and  world's Y coordinate axis   in degrees? I had tried different ways , like that for example

world.getCamera().getDirection().x

but I completely messed up with results and was unable to detect camera direction relatively to world's Y-axis. Could you help me, please?

Thank you!

EgonOlsen

Keep in mind that objects created by the Primitives class have no texture coordinates (see also: http://www.jpct.net/forum2/index.php?topic=1928.0). Maybe that's your problem rather than the loading of the texture itself? If not, post the log output please.

About your second question...maybe this is helpful: http://www.jpct.net/doc/com/threed/jpct/SimpleVector.html#calcAngle(com.threed.jpct.SimpleVector)