Example #1
0
void MeshGame::initialize()
{
    // Display the gameplay splash screen for at least 1 second.
    displayScreen(this, &MeshGame::drawSplash, NULL, 1000L);

    // Load the font
    _font = Font::create("res/ui/arial.gpb");

    // Load the scene from file
    _scene = Scene::load("res/mesh.scene");

    // Get the duck node
	_modelNode = _scene->findNode("duck");

	_scene = Scene::load("res/room1.scene");

    // Find the light node
    Node* lightNode = _scene->findNode("directionalLight1");

    // Bind the light node's direction into duck's material.
    _modelNode->getModel()->getMaterial()->getParameter("u_directionalLightColor[0]")->setValue(lightNode->getLight()->getColor());
    _modelNode->getModel()->getMaterial()->getParameter("u_directionalLightDirection[0]")->bindValue(lightNode, &Node::getForwardVectorView);

    // Update the aspect ratio for our scene's camera to match the current device resolution
    _scene->getActiveCamera()->setAspectRatio(getAspectRatio());

    // Create the grid and add it to the scene.
    Model *model = createGridModel();
    _scene->addNode("grid")->setModel(model);
    model->release();
}
Example #2
0
void Audio3DTest::loadGrid(Scene* scene)
{
    assert(scene);
    Model* gridModel = createGridModel();
    assert(gridModel);
    gridModel->setMaterial("res/common/grid.material");
    Node* node = scene->addNode("grid");
    node->setModel(gridModel);
    gridModel->release();
}
Example #3
0
   _gridCheckBox->addListener(this, Control::Listener::VALUE_CHANGED);
   _gridCheckBox->setEnabled(true);

   // Set the metarial lighting
   _scene->visit(this, &SceneViewer::setLights);

   _clearColor = Vector4::zero();

   // let add a node to have the Camera looking at
   Node *rootNode = _scene->addNode("root");
   rootNode->setTranslation(0, 0, 0);
   Node *cameraNode = _scene->getActiveCamera()->getNode();
   rootNode->addChild(cameraNode);

   // Create the grid and add it to the scene.
   Model* model = createGridModel();
   _scene->addNode("grid")->setModel(model);
   model->release();
}

void SceneViewer::finalize()
{
   SAFE_RELEASE(_form);
   SAFE_RELEASE(_scene);
}

bool SceneViewer::setLights(Node* node)
{
   if (node->getModel()) {
      Material * m = node->getModel()->getMaterial(0);
      m->getTechnique()->getParameter("u_directionalLightColor[0]")->setValue(Vector3(1,1,1));