Exemplo n.º 1
0
// Called from the app framework.
void appInit()
{
    int a;

    glEnable(GL_NORMALIZE);
    glEnable(GL_DEPTH_TEST);
    glDisable(GL_CULL_FACE);
    glShadeModel(GL_FLAT);

    glEnable(GL_LIGHTING);
    glEnable(GL_LIGHT0);
    glEnable(GL_LIGHT1);
    glEnable(GL_LIGHT2);

    glEnableClientState(GL_VERTEX_ARRAY);
    glEnableClientState(GL_COLOR_ARRAY);

    seedRandom(15);

    for (a = 0; a < SUPERSHAPE_COUNT; ++a)
    {
        sSuperShapeObjects[a] = createSuperShape(sSuperShapeParams[a]);
        assert(sSuperShapeObjects[a] != NULL);
    }
    sGroundPlane = createGroundPlane();
    assert(sGroundPlane != NULL);
}
Exemplo n.º 2
0
/* called by the C++ code for initialization */
extern "C" void device_init (char* cfg)
{
  /* create new Embree device */
  g_device = rtcNewDevice(cfg);
  error_handler(rtcDeviceGetError(g_device));

  /* set error handler */
  rtcDeviceSetErrorFunction(g_device,error_handler);

  RTCAlgorithmFlags aflags;
  if (g_mode == MODE_NORMAL) aflags = RTC_INTERSECT1;
  else                       aflags = RTC_INTERSECT1 | RTC_INTERSECT_STREAM;

  /* create scene */
  g_scene = rtcDeviceNewScene(g_device, RTC_SCENE_DYNAMIC,aflags);

  /* create scene with 4 triangulated spheres */
  g_scene1 = rtcDeviceNewScene(g_device, RTC_SCENE_STATIC,aflags);
  createTriangulatedSphere(g_scene1,Vec3fa( 0, 0,+1),0.5);
  createTriangulatedSphere(g_scene1,Vec3fa(+1, 0, 0),0.5);
  createTriangulatedSphere(g_scene1,Vec3fa( 0, 0,-1),0.5);
  createTriangulatedSphere(g_scene1,Vec3fa(-1, 0, 0),0.5);
  rtcCommit (g_scene1);

  /* instantiate geometry */
  g_instance0 = rtcNewInstance(g_scene,g_scene1);
  g_instance1 = rtcNewInstance(g_scene,g_scene1);
  g_instance2 = rtcNewInstance(g_scene,g_scene1);
  g_instance3 = rtcNewInstance(g_scene,g_scene1);
  createGroundPlane(g_scene);

  /* set all colors */
  colors[0][0] = Vec3fa(0.25,0,0);
  colors[0][1] = Vec3fa(0.50,0,0);
  colors[0][2] = Vec3fa(0.75,0,0);
  colors[0][3] = Vec3fa(1.00,0,0);

  colors[1][0] = Vec3fa(0,0.25,0);
  colors[1][1] = Vec3fa(0,0.50,0);
  colors[1][2] = Vec3fa(0,0.75,0);
  colors[1][3] = Vec3fa(0,1.00,0);

  colors[2][0] = Vec3fa(0,0,0.25);
  colors[2][1] = Vec3fa(0,0,0.50);
  colors[2][2] = Vec3fa(0,0,0.75);
  colors[2][3] = Vec3fa(0,0,1.00);

  colors[3][0] = Vec3fa(0.25,0.25,0);
  colors[3][1] = Vec3fa(0.50,0.50,0);
  colors[3][2] = Vec3fa(0.75,0.75,0);
  colors[3][3] = Vec3fa(1.00,1.00,0);

  /* set start render mode */
  if (g_mode == MODE_NORMAL) renderTile = renderTileStandard;
  else                       renderTile = renderTileStandardStream;
  key_pressed_handler = device_key_pressed_default;
}
Exemplo n.º 3
0
    void PhysicSampleBase::createScene()
    {
        // load empty scene with floor plane only
        mScene = getMain().getResourceManager()->queryResource<lite3dpp::Scene>("SampleScene",
            "samples:scenes/empty.json");
        setMainCamera(getMain().getCamera("MyCamera"));
        mScene->instancingMode(true);

        mGroundPlane = createGroundPlane("Ground");
    }
/* called by the C++ code for initialization */
extern "C" void device_init (char* cfg)
{
  /* initialize ray tracing core */
  rtcInit(cfg);

  /* set error handler */
  rtcSetErrorFunction(error_handler);

  /* create scene */
  g_scene = rtcNewScene(RTC_SCENE_DYNAMIC,RTC_INTERSECT1);

  /* create scene with 4 triangulated spheres */
  g_scene1 = rtcNewScene(RTC_SCENE_STATIC,RTC_INTERSECT1);
  createTriangulatedSphere(g_scene1,Vec3fa( 0, 0,+1),0.5);
  createTriangulatedSphere(g_scene1,Vec3fa(+1, 0, 0),0.5);
  createTriangulatedSphere(g_scene1,Vec3fa( 0, 0,-1),0.5);
  createTriangulatedSphere(g_scene1,Vec3fa(-1, 0, 0),0.5);
  rtcCommit (g_scene1);

  /* instantiate geometry */
  g_instance0 = rtcNewInstance(g_scene,g_scene1);
  g_instance1 = rtcNewInstance(g_scene,g_scene1);
  g_instance2 = rtcNewInstance(g_scene,g_scene1);
  g_instance3 = rtcNewInstance(g_scene,g_scene1);
  createGroundPlane(g_scene);

  /* set all colors */
  colors[0][0] = Vec3fa(0.25,0,0);
  colors[0][1] = Vec3fa(0.50,0,0);
  colors[0][2] = Vec3fa(0.75,0,0);
  colors[0][3] = Vec3fa(1.00,0,0);

  colors[1][0] = Vec3fa(0,0.25,0);
  colors[1][1] = Vec3fa(0,0.50,0);
  colors[1][2] = Vec3fa(0,0.75,0);
  colors[1][3] = Vec3fa(0,1.00,0);

  colors[2][0] = Vec3fa(0,0,0.25);
  colors[2][1] = Vec3fa(0,0,0.50);
  colors[2][2] = Vec3fa(0,0,0.75);
  colors[2][3] = Vec3fa(0,0,1.00);

  colors[3][0] = Vec3fa(0.25,0.25,0);
  colors[3][1] = Vec3fa(0.50,0.50,0);
  colors[3][2] = Vec3fa(0.75,0.75,0);
  colors[3][3] = Vec3fa(1.00,1.00,0);

  /* set start render mode */
  renderPixel = renderPixelStandard;
  key_pressed_handler = device_key_pressed_default;
}
Exemplo n.º 5
0
// Called from the app framework.
void appInit()
{
    int a;

    seedRandom(15);

    for (a = 0; a < SUPERSHAPE_COUNT; ++a)
    {
        sSuperShapeObjects[a] = createSuperShape(sSuperShapeParams[a]);
        assert(sSuperShapeObjects[a] != NULL);
    }
    sGroundPlane = createGroundPlane();
    assert(sGroundPlane != NULL);
}
Exemplo n.º 6
0
/* called by the C++ code for initialization */
extern "C" void device_init (char* cfg)
{
    /* create new Embree device */
    g_device = rtcNewDevice(cfg);

    /* set error handler */
    rtcDeviceSetErrorFunction(g_device,error_handler);

    /* create scene */
    g_scene = rtcDeviceNewScene(g_device,RTC_SCENE_STATIC,RTC_INTERSECT1);

    /* instantiate geometry */
    createGroundPlane(g_scene);
    for (size_t i=0; i<numSpheres; i++) {
        float a = 2.0*float(pi)*(float)i/(float)numSpheres;
        createLazyObject(g_scene,i,10.0f*Vec3fa(cosf(a),0,sinf(a)),1);
    }
    rtcCommit (g_scene);

    /* set start render mode */
    renderPixel = renderPixelStandard;
    key_pressed_handler = device_key_pressed_default;
}
Exemplo n.º 7
0
/* called by the C++ code for initialization */
extern "C" void device_init (int8* cfg)
{
  /* initialize ray tracing core */
  rtcInit(cfg);

  /* create scene */
  g_scene = rtcNewScene(RTC_SCENE_DYNAMIC,RTC_INTERSECT1);

  /* create scene with 4 analytical spheres */
  g_scene0 = rtcNewScene(RTC_SCENE_STATIC,RTC_INTERSECT1);
  Sphere* spheres = createAnalyticalSpheres(g_scene0,4);
  spheres[0].p = Vec3f( 0, 0,+1); spheres[0].r = 0.5f;
  spheres[1].p = Vec3f(+1, 0, 0); spheres[1].r = 0.5f;
  spheres[2].p = Vec3f( 0, 0,-1); spheres[2].r = 0.5f;
  spheres[3].p = Vec3f(-1, 0, 0); spheres[3].r = 0.5f;
  rtcCommit(g_scene0);

  /* create scene with 4 triangulated spheres */
  g_scene1 = rtcNewScene(RTC_SCENE_STATIC,RTC_INTERSECT1);
  createTriangulatedSphere(g_scene1,Vec3f( 0, 0,+1),0.5);
  createTriangulatedSphere(g_scene1,Vec3f(+1, 0, 0),0.5);
  createTriangulatedSphere(g_scene1,Vec3f( 0, 0,-1),0.5);
  createTriangulatedSphere(g_scene1,Vec3f(-1, 0, 0),0.5);
  rtcCommit(g_scene1);

  /* create scene with 2 triangulated and 2 analytical spheres */
  g_scene2 = rtcNewScene(RTC_SCENE_STATIC,RTC_INTERSECT1);
  createTriangulatedSphere(g_scene2,Vec3f( 0, 0,+1),0.5);
  createAnalyticalSphere  (g_scene2,Vec3f(+1, 0, 0),0.5);
  createTriangulatedSphere(g_scene2,Vec3f( 0, 0,-1),0.5);
  createAnalyticalSphere  (g_scene2,Vec3f(-1, 0, 0),0.5);
  rtcCommit(g_scene2);

  /* instantiate geometry */
  createGroundPlane(g_scene);
  g_instance0 = createInstance(g_scene,g_scene0,0,Vec3f(-2,-2,-2),Vec3f(+2,+2,+2));
  g_instance1 = createInstance(g_scene,g_scene1,1,Vec3f(-2,-2,-2),Vec3f(+2,+2,+2));
  g_instance2 = createInstance(g_scene,g_scene2,2,Vec3f(-2,-2,-2),Vec3f(+2,+2,+2));
  g_instance3 = createInstance(g_scene,g_scene2,3,Vec3f(-2,-2,-2),Vec3f(+2,+2,+2));

  /* set all colors */
  colors[0][0] = Vec3f(0.25,0,0);
  colors[0][1] = Vec3f(0.50,0,0);
  colors[0][2] = Vec3f(0.75,0,0);
  colors[0][3] = Vec3f(1.00,0,0);

  colors[1][0] = Vec3f(0,0.25,0);
  colors[1][1] = Vec3f(0,0.50,0);
  colors[1][2] = Vec3f(0,0.75,0);
  colors[1][3] = Vec3f(0,1.00,0);

  colors[2][0] = Vec3f(0,0,0.25);
  colors[2][1] = Vec3f(0,0,0.50);
  colors[2][2] = Vec3f(0,0,0.75);
  colors[2][3] = Vec3f(0,0,1.00);

  colors[3][0] = Vec3f(0.25,0.25,0);
  colors[3][1] = Vec3f(0.50,0.50,0);
  colors[3][2] = Vec3f(0.75,0.75,0);
  colors[3][3] = Vec3f(1.00,1.00,0);

  colors[4][0] = Vec3f(1.0,1.0,1.0);
  colors[4][1] = Vec3f(1.0,1.0,1.0);
  colors[4][2] = Vec3f(1.0,1.0,1.0);
  colors[4][3] = Vec3f(1.0,1.0,1.0);

  /* set start render mode */
  renderPixel = renderPixelStandard;
}