//----------------------------------------------------------------------------- TurnTableGameScene::TurnTableGameScene(SkeletonData* defaultSkeletonData, SLint localPlayerIndex, SLint maxPlayers, SLMat4f* playerPositions, VR_MODEL* models) : GameScene(defaultSkeletonData, localPlayerIndex, maxPlayers, playerPositions, models) { _matTable = new SLMaterial[3]; _matTable[0].name("matTableLeg"); _matTable[0].ambient(SLVec4f(0.0f, 0.0f, 0.0f, 1.0f)); _matTable[0].diffuse(SLVec4f(0.0f, 0.0f, 0.0f, 1.0f)); _matTable[1].name("matTablePlate"); _matTable[1].ambient(SLVec4f(1.0f, 1.0f, 1.0f, 0.6f)); _matTable[1].diffuse(SLVec4f(1.0f, 1.0f, 1.0f, 0.6f)); _matTable[2].name("matTestBox"); _matTable[2].ambient(SLVec4f(1.0f, 0.5f, 0.0f, 1.0f)); _matTable[2].diffuse(SLVec4f(1.0f, 0.5f, 0.0f, 1.0f)); SLCylinder* cylinder = new SLCylinder(0.15f, 0.8f, 1, 32, true, true, "tableLeg", &_matTable[0]); SLNode* tableLeg = new SLNode("Table Leg"); tableLeg->addMesh(cylinder); tableLeg->rotate(-90, 1, 0, 0); _rootNode->addChild(tableLeg); _table = new SLNode("turnTable"); _table->translate(0, 0.8f, 0); cylinder = new SLCylinder(0.5f, 0.04f, 1, 32, true, true, "tablePlate", &_matTable[1]); SLNode* tablePlate = new SLNode("Table Plate"); tablePlate->addMesh(cylinder); tablePlate->rotate(-90, 1, 0, 0); _table->addChild(tablePlate); SLNode* tableObjects = new SLNode("tableObjects"); _table->addChild(tableObjects); tableObjects->translate(0, 0.04f, 0); // test object SLNode* pot = SLAssImp::load("../_data/models/teapot.obj"); pot->translate(0, 0.138f, 0); pot->scale(0.2f); tableObjects->addChild(pot); _rootNode->addChild(_table); }
/*! Copies the nodes meshes and children recursively. */ SLNode* SLNode::copyRec() { SLNode* copy = new SLNode(name()); copy->_om = _om; copy->_depth = _depth; copy->_isAABBUpToDate = _isAABBUpToDate; copy->_isAABBUpToDate = _isWMUpToDate; copy->_drawBits = _drawBits; copy->_aabb = _aabb; if (_animation) copy->_animation = new SLAnimation(*_animation); else copy->_animation = 0; for (auto mesh : _meshes) copy->addMesh(mesh); for (auto child : _children) copy->addChild(child->copyRec()); return copy; }