www.jpct.net

jPCT - a 3d engine for Java => Support => Topic started by: Irene on August 19, 2011, 12:16:25 pm

Title: Loading images
Post by: Irene on August 19, 2011, 12:16:25 pm
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:
Code: [Select]
Object3D myBox = null;
myBox = Primitives.getBox(21f, 2f);
I loading a texture this way:
Code: [Select]
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
Code: [Select]
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!
Title: Re: Loading images
Post by: EgonOlsen on August 19, 2011, 02:14:29 pm
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 (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) (http://www.jpct.net/doc/com/threed/jpct/SimpleVector.html#calcAngle(com.threed.jpct.SimpleVector))