Esempio n. 1
0
void testGCamera() {
    printf("GCamera...");
    GCamera camera;
    camera.setCoordinateFrame(CFrame());
    camera.setFieldOfView(toRadians(90), GCamera::HORIZONTAL);
    camera.setNearPlaneZ(-1);
    camera.setFarPlaneZ(-100);

    Rect2D viewport = Rect2D::xywh(0,0,200,100);
    Array<Plane> plane;
    camera.getClipPlanes(viewport, plane);
    debugAssertM(plane.size() == 6, "Missing far plane");
    debugAssertM(plane[0].fuzzyContains(Vector3(0,0,-1)), plane[0].center().toString());
    debugAssertM(plane[0].normal() == Vector3(0,0,-1), plane[0].normal().toString());

    debugAssertM(plane[5].fuzzyContains(Vector3(0,0,-100)), plane[1].center().toString());
    debugAssertM(plane[5].normal() == Vector3(0,0,1), plane[1].normal().toString());

    debugAssertM(plane[1].normal().fuzzyEq(Vector3(-1,0,-1).direction()), plane[1].normal().toString());
    debugAssertM(plane[2].normal().fuzzyEq(Vector3(1,0,-1).direction()), plane[2].normal().toString());

    // top
    debugAssertM(plane[3].normal().fuzzyEq(Vector3(0,-0.894427f,-0.447214f).direction()), plane[3].normal().toString());
    debugAssertM(plane[4].normal().fuzzyEq(Vector3(0,0.894427f,-0.447214f).direction()), plane[4].normal().toString());

    Vector3 ll, lr, ul, ur;
    camera.getNearViewportCorners(viewport, ur, ul, ll, lr);
    debugAssertM(ur == Vector3(1, 0.5, -1), ur.toString());
    debugAssertM(lr == Vector3(1, -0.5, -1), lr.toString());
    debugAssertM(ll == Vector3(-1, -0.5, -1), ll.toString());
    debugAssertM(ul == Vector3(-1, 0.5, -1), ul.toString());
    printf("passed\n");
}
Esempio n. 2
0
void App::doFunStuff() {
    renderDevice->pushState();
        GCamera camera;
        camera.setCoordinateFrame(Vector3(0,1,10));
        camera.lookAt(Vector3(0,2.8f,0));

        renderDevice->setProjectionAndCameraMatrix(camera);

        knight.renderShadow(renderDevice);
        ogre.renderShadow(renderDevice);

        renderDevice->enableLighting();
        renderDevice->setLight(0, GLight::directional(Vector3(-1,1,2).direction(), Color3(.8f,.8f,.7f)));
        renderDevice->setLight(1, GLight::directional(Vector3(.5f,-1,1).direction(), Color3::red() * 0.2f));
        renderDevice->setAmbientLightColor(Color3(.5f,.5f,.6f));

        knight.render(renderDevice);
        ogre.render(renderDevice);

    renderDevice->popState();
}
Esempio n. 3
0
void doSimulation(GameTime timeStep) {
    // Simulation
    controller->doSimulation(clamp(timeStep, 0.0, 0.1));
	camera.setCoordinateFrame(controller->getCoordinateFrame());
}