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.
Show posts MenumyObject.setLighting(Object3D.LIGHTING_NO_LIGHTS);
world.addLight()
...but not for ambient light.
package com.algodes.jpct;
import java.applet.Applet;
import java.awt.Color;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import com.threed.jpct.Camera;
import com.threed.jpct.Config;
import com.threed.jpct.FrameBuffer;
import com.threed.jpct.Object3D;
import com.threed.jpct.Primitives;
import com.threed.jpct.SimpleVector;
import com.threed.jpct.World;
public class TestApplet extends Applet implements MouseListener, Runnable{
FrameBuffer buffer;
World world;
Thread loopThread;
boolean exit = false;
public TestApplet(){
addMouseListener(this);
buffer = changeSampleMode(FrameBuffer.SAMPLINGMODE_NORMAL);
// comment this out to get rid of the memory leak.
Config.maxPolysVisible = 64000;
}
public void run() {
world = new World();
Object3D root = Object3D.createDummyObj();
root.setName("root");
world.addObject(root);
addContent();
setCamera();
while(!exit){
buffer.clear(Color.WHITE);
synchronized (world) {
world.renderScene(buffer);
world.draw(buffer);
buffer.display(getGraphics());
}
buffer.update();
}
}
protected void addContent() {
// world.removeAll();
Object3D obj = Primitives.getBox(10, 10);
Object3D root = world.getObjectByName("root");
world.addObject(obj);
root.addChild(obj);
world.buildAllObjects();
world.addLight(new SimpleVector(150, 150, -450), 95, 95, 95);
world.setAmbientLight(220, 220, 220);
}
public void start() {
System.out.println("Initializing threads!");
if (loopThread == null) {
loopThread = new Thread(this);
loopThread.start();
}
}
public void destroy() {
System.out.println("destroy applet");
// Object3D.resetObjCount();
exit = true;
super.destroy();
}
private FrameBuffer changeSampleMode(int mode){
// memory leak
buffer = new FrameBuffer(550, 550, mode);
return buffer;
}
public void mouseClicked(MouseEvent event) {
changeSampleMode(FrameBuffer.SAMPLINGMODE_NORMAL);
}
public void mousePressed(MouseEvent event) {}
public void mouseEntered(MouseEvent event) {}
public void mouseExited(MouseEvent event) {}
public void mouseReleased(MouseEvent event) {
changeSampleMode(FrameBuffer.SAMPLINGMODE_OGSS);
}
public void keyTyped(KeyEvent e) {
}
protected void setCamera() {
SimpleVector cameraPosition = new SimpleVector(0, 0, 0);
// cameraPosition = product.getCenter();
cameraPosition.z = cameraPosition.z + 500;
Camera camera = world.getCamera();
camera.setPosition(cameraPosition);
// SimpleVector center = product.getCenter();
SimpleVector center = new SimpleVector(0, 0, 0);
camera.lookAt(center);
camera.setFOV(1.0f);
}
}
Page created in 0.030 seconds with 10 queries.