Hi!
All best in new 2010.
I am trying to play with adding triangle and applying texture on Object3D, but currenty I can't see that my texture is apllied.
Here is result:
(http://img527.imageshack.us/img527/3036/screen01o.jpg)
Here is texture:
(http://img685.imageshack.us/img685/618/tex3.jpg)
import java.awt.Color;
import com.threed.jpct.FrameBuffer;
import com.threed.jpct.IRenderer;
import com.threed.jpct.Object3D;
import com.threed.jpct.SimpleVector;
import com.threed.jpct.Texture;
import com.threed.jpct.TextureManager;
import com.threed.jpct.World;
public class Template {
/**
* @param args
* @throws InterruptedException
*/
public static void main(String[] args) throws InterruptedException {
Template.setupAndRun();
}
private static void setupAndRun() throws InterruptedException {
TextureManager tm = TextureManager.getInstance();
String texName = "tex3.jpg";
Texture tex = new Texture(texName);
tm.addTexture(texName, tex);
int texID = tm.getTextureID(texName);
Object3D obj1 = new Object3D(2);
obj1.addTriangle(V(100, -100, 0), 0f, 0f, V(100, 0, 0), 0f, 1f, V(-100, 0, 0), 1f, 1f, texID);
obj1.build();
obj1.setEnvmapped(Object3D.ENVMAP_ENABLED);
World world = new World();
world.addLight(new SimpleVector(0, -50, 130), Color.WHITE);
world.setAmbientLight(255, 255, 255);
world.getCamera().setPosition(0, 0, 250);
world.getCamera().lookAt(V(0, 0, 0));
world.addObject(obj1);
FrameBuffer buffer = new FrameBuffer(800, 600, FrameBuffer.SAMPLINGMODE_NORMAL);
buffer.disableRenderer(IRenderer.RENDERER_SOFTWARE);
buffer.enableRenderer(IRenderer.RENDERER_OPENGL);
while (!org.lwjgl.opengl.Display.isCloseRequested()) {
buffer.clear(java.awt.Color.BLACK);
world.renderScene(buffer);
world.draw(buffer);
buffer.update();
buffer.displayGLOnly();
Thread.sleep(10);
}
buffer.disableRenderer(IRenderer.RENDERER_OPENGL);
buffer.dispose();
System.exit(0);
}
public static SimpleVector V(float x, float y, float z) {
return new SimpleVector(x, y, z);
}
}
No idea what is problem...
Remove this line:
obj1.setEnvmapped(Object3D.ENVMAP_ENABLED);
It enables environment mapping which creates uv-coordinates on the fly based on the objects position and shape. It's not what you want in this case.
That's it......
Thx!