11716
Support / using camera.lookAt
« on: October 31, 2005, 11:08:55 pm »
I can't verify this. How exactly are you moving the camera, i.e. moveCamera(int mode, float speed) or moveCamera(SimpleVector direction, float speed)?
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
I believe JPCT is 1.1 compatible?For the software renderer path, yes. But OpenGL support requires at least 1.4.
However, I'm wondering if there is a way to make the light one-directional? I can't find any documentation on that, so I guess not. In that case, is the simplest solution to position the lightsource inside a hollow cylinder object? Or would the light shine through that cylinder?No, directional lighting is not possible with standard vertex lighting, which is what jPCT is using. There's no way to let other objects block the light either. jPCT is following OpenGL's specs when it comes to lighting.
then i got an exception and the program crashes.Which exception?
import com.threed.jpct.*;
import org.lwjgl.opengl.*;
import javax.swing.*;
import java.awt.*;
public class MTAWT {
public static void main(String[] args) throws Exception {
MTAWT mt = new MTAWT();
mt.doIt();
}
private void doIt() throws Exception {
JFrame frame=new JFrame();
frame.setSize(320,240);
frame.show();
FrameBuffer fb=new FrameBuffer(320, 240, FrameBuffer.SAMPLINGMODE_HARDWARE_ONLY);
fb.disableRenderer(IRenderer.RENDERER_SOFTWARE);
Canvas canvas=fb.enableGLCanvasRenderer(IRenderer.MODE_OPENGL);
frame.getContentPane().add(canvas);
World w=new World();
w.setAmbientLight(255,255,255);
TextureManager tm=TextureManager.getInstance();
Texture base=new Texture("base.jpg");
Texture decal=new Texture("decal.jpg");
tm.addTexture("base", base);
tm.addTexture("decal", decal);
int bid=tm.getTextureID("base");
int did=tm.getTextureID("decal");
Object3D plane=new Object3D(9);
plane.setCulling(Object3D.CULLING_DISABLED);
// Base texture only
TextureInfo tInf1=new TextureInfo(bid,0,0,1,0,0,1);
TextureInfo tInf2=new TextureInfo(bid,1,0,1,1,0,1);
plane.addTriangle(new SimpleVector(-10,-10,30), new SimpleVector(-10,0,30), new SimpleVector(0,-10,30), tInf1);
plane.addTriangle(new SimpleVector(-10,0,30), new SimpleVector(0,0,30), new SimpleVector(0,-10,30), tInf2);
// 2nd stage used, modulate
tInf1 = new TextureInfo(bid, 0, 0, 1, 0, 0, 1);
tInf1.add(did, 0, 0, 1, 0, 0, 1, TextureInfo.MODE_MODULATE);
tInf2 = new TextureInfo(bid, 1, 0, 1, 1, 0, 1);
tInf2.add(did, 1, 0, 1, 1, 0, 1, TextureInfo.MODE_MODULATE);
plane.addTriangle(new SimpleVector( 0, -10, 30), new SimpleVector( 0, 0, 30), new SimpleVector(10, -10, 30), tInf1);
plane.addTriangle(new SimpleVector( 0, 0, 30), new SimpleVector(10, 0, 30), new SimpleVector(10, -10, 30), tInf2);
// 2nd stage used, add
tInf1 = new TextureInfo(bid, 0, 0, 1, 0, 0, 1);
tInf1.add(did, 0, 0, 1, 0, 0, 1, TextureInfo.MODE_ADD);
tInf2 = new TextureInfo(bid, 1, 0, 1, 1, 0, 1);
tInf2.add(did, 1, 0, 1, 1, 0, 1, TextureInfo.MODE_ADD);
plane.addTriangle(new SimpleVector(-10,0,30), new SimpleVector(-10,10,30), new SimpleVector(0,0,30), tInf1);
plane.addTriangle(new SimpleVector(-10,10,30), new SimpleVector(0,10,30), new SimpleVector(0,0,30), tInf2);
// 2nd stage used, blend
tInf1 = new TextureInfo(bid, 0, 0, 1, 0, 0, 1);
tInf1.add(did, 0, 0, 1, 0, 0, 1, TextureInfo.MODE_BLEND);
tInf2 = new TextureInfo(bid, 1, 0, 1, 1, 0, 1);
tInf2.add(did, 1, 0, 1, 1, 0, 1, TextureInfo.MODE_BLEND);
plane.addTriangle(new SimpleVector( 0, 0, 30), new SimpleVector( 0, 10, 30), new SimpleVector(10, 0, 30), tInf1);
plane.addTriangle(new SimpleVector( 0, 10, 30), new SimpleVector(10, 10, 30), new SimpleVector(10, 0, 30), tInf2);
w.addObject(plane);
w.buildAllObjects();
while (frame.isActive()) {
fb.clear();
w.renderScene(fb);
w.draw(fb);
fb.displayGLOnly();
plane.rotateY(0.01f);
canvas.repaint();
Thread.sleep(10);
}
fb.disableRenderer(IRenderer.RENDERER_OPENGL);
System.exit(0);
}
}