Nice to see you back in action. Game is still looking great and runs fine in Chrome.
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 Menuimport java.awt.*;
import java.awt.event.*;
import com.threed.jpct.*;
public class Transparency extends Frame implements WindowListener {
private World theWorld;
private FrameBuffer buffer;
private Camera cam;
private Object3D obj;
private boolean keepGoing, turnRight, turnLeft;
private com.threed.jpct.util.KeyMapper keyMapper;
private Texture boxMap;
private int transparency = 0;
public Transparency() {
this.setTitle("BR's");
theWorld = new World();
buffer = new FrameBuffer(1440, 900, FrameBuffer.SAMPLINGMODE_NORMAL);
obj = com.threed.jpct.util.ExtendedPrimitives.createBox(new SimpleVector(2f, 2f, 2f));//Primitives.getCube(1f);
TextureManager.getInstance().addTexture("boxMap", (boxMap=new Texture("test.jpg", true)));
obj.setTexture("boxMap");
obj.setTransparency(0);
//obj.setTransparencyMode(Object3D.TRANSPARENCY_MODE_ADD);
obj.build();
Object3D backgroundPlane = Primitives.getPlane(1, 4f);
backgroundPlane.build();
backgroundPlane.translate(0f, -2f, 0f);
theWorld.addObject(backgroundPlane);
cam = theWorld.getCamera();
cam.moveCamera(Camera.CAMERA_MOVEOUT, 8f);
theWorld.addObject(obj);
theWorld.setAmbientLight(255, 255, 255);
keyMapper = new com.threed.jpct.util.KeyMapper(this);
this.addWindowListener(this);
this.setSize(buffer.getWidth(), buffer.getHeight());
this.setVisible(true);
loop();
}
public void loop() {
keepGoing = true;
transparency=0;
int dir = 1;
int its= 0;
while (keepGoing) {
buffer.clear();
com.threed.jpct.util.KeyState keyState = keyMapper.poll();
if (keyState.getState() == com.threed.jpct.util.KeyState.PRESSED)
keyPressed(keyState.getKeyCode());
else if (keyState.getState() == com.threed.jpct.util.KeyState.RELEASED)
keyReleased(keyState.getKeyCode());
if (turnRight)
obj.rotateY(-.01f);
if (turnLeft)
obj.rotateY(.01f);
theWorld.renderScene(buffer);
theWorld.draw(buffer);
//theWorld.drawWireframe(buffer, Color.yellow);
buffer.display(this.getGraphics());
its++;
if (its>10) {
transparency+=dir;
if (Math.abs(transparency)>255 || transparency==0) {
dir*=-1;
}
//obj.setTransparency(transparency);
TextureManager.getInstance().getTexture("boxMap").setAlpha(transparency<<24);
System.out.println("Trans: "+transparency);
its = 0;
}
Thread.yield();
}
buffer.dispose();
this.dispose();
System.exit(0);
}
private void keyPressed(int keyCode) {
if (keyCode == KeyEvent.VK_RIGHT)
turnRight = true;
if (keyCode == KeyEvent.VK_LEFT)
turnLeft = true;
}
private void keyReleased(int keyCode) {
if (keyCode == KeyEvent.VK_RIGHT)
turnRight = false;
if (keyCode == KeyEvent.VK_LEFT)
turnLeft = false;
}
public void windowClosing(WindowEvent e) {
keepGoing = false;
}
public void windowClosed(WindowEvent e) {}
public void windowOpened(WindowEvent e) {}
public void windowActivated(WindowEvent e) {}
public void windowDeactivated(WindowEvent e) {}
public void windowIconified(WindowEvent e) {}
public void windowDeiconified(WindowEvent e) {}
public static void main(String[] args) {
new Transparency();
}
}
Page created in 0.030 seconds with 9 queries.