fe[3] = new Vector3(1.0f, 1.0f, -1.0f).normalize();
fe[4] = new Vector3(-1.0f, 1.0f, -1.0f).normalize();
fe[5] = new Vector3(-1.0f, 1.0f, 1.0f).normalize();
ViewModel floorModel = loadObjModel(new File("models/platform.obj"), Vector3.one());
Entity floor = new Entity(floorModel);
floor.transform.position = new Vector3(0, -7, 0);
//floor.transform.set(new Vector3(0, -12, 0), Vector3.yAxis().negate(), Vector3.zAxis(), Vector3.one());
floor.addBehavior(new Collider(fv, fn, fe));
World.main.add(floor);
Light light = new Light(Color.WHITE);
light.transform.position = new Vector3(-5, 5, 2);
light.setAttenuation(1, 0, 0);
//player = new Player(new Vector3(0, 0, 4));
//World.main.add(player);
camera = new Transform(new Vector3(-10, 10, 10), new Vector3(1, -1, -1), Vector3.yAxis(), Vector3.one());
gravity = new UniformGravity();
World.main.addForce(gravity);
counter = new Canvas(128, 32);
updateCounter();
spawner = new Entity();
spawner.transform.position.y = 15.0f;
spawner.addBehavior(new Behavior() {
private float timeUntilSpawn = 2.0f;
@Override
public void update() {
timeUntilSpawn -= Time.deltaTime();
if (timeUntilSpawn <= 0) {
float width = random.nextFloat() * 2.0f + 1.0f;
float height = random.nextFloat() * 2.0f + 1.0f;
float depth = random.nextFloat() * 2.0f + 1.0f;
final Entity entity = RigidBody.box(new Material(Color.random()), width, height, depth, 1.0f);
entity.addBehavior(new Behavior() {
@Override
public void update() {
if (entity.transform.position.y < -20.0f || isKeyDown(KEY_LCONTROL)) {
entity.destroy();
numBlocks--;
updateCounter();
}
}
});