OK, danke^^
Ich glaub', ich werd' den Collisionsmodus umschalten^^
Ich glaub', ich werd' den Collisionsmodus umschalten^^
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 Menu
public class CollisionDemo {
World world;
Object3D cube;
Object3D ground;
static JFrame frame;
static FrameBuffer buffer;
private SimpleVector ellipsoid = new SimpleVector(2, 2, 2);
private void init() {
world = new World();
world.setAmbientLight(0, 255, 0);
cube = Primitives.getCube(2);
cube.setAdditionalColor(Color.BLACK);
ground = Primitives.getBox(30, 0.1f);
ground.setOrigin(new SimpleVector(0,10,0));
ground.setAdditionalColor(Color.CYAN);
cube.setCollisionMode(Object3D.COLLISION_CHECK_OTHERS);
ground.setCollisionMode(Object3D.COLLISION_CHECK_OTHERS);
world.addObject(cube);
world.addObject(ground);
world.buildAllObjects();
world.getCamera().setPosition(new SimpleVector(0,-5,-15));
world.getCamera().lookAt(cube.getOrigin());
}
private void run() {
frame = new JFrame();
frame.setSize(800, 600);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
buffer = new FrameBuffer(800,600,FrameBuffer.SAMPLINGMODE_NORMAL);
while(frame.isShowing()) {
gravity();
buffer.clear();
world.renderScene(buffer);
world.draw(buffer);
buffer.display(frame.getGraphics());
buffer.update();
}
buffer.dispose();
frame.dispose();
System.exit(0);
}
public void gravity() {
SimpleVector t = new SimpleVector(0, 0.1f, 0);
t = cube.checkForCollisionEllipsoid(t, ellipsoid, 1);
cube.translate(t);
}
public static void main(String[] args) {
CollisionDemo demo = new CollisionDemo();
demo.init();
demo.run();
}
}
Page created in 0.019 seconds with 12 queries.