bool EditorScene::PrepareAddingInstance(u32 collectionId) { SCollectionNodeInfo* collectionInfo = nullptr; for (u32 i = 0; i < mCollectionNodeInfos.size(); i++) { if (mCollectionNodeInfos[i].Id == collectionId) { collectionInfo = &mCollectionNodeInfos[i]; break; } } IInstanceCollectionNode* collectionNode = collectionInfo->CollectionNode; IInstanceNode* node = collectionNode->addInstance(false, XMFLOAT3(0, 0, 0)); node->setTag(MESH_NODE_TAG); node->addShadow(1); mAddedNode = node; return true; }
void addBoxInstance(ISceneManager* smgr, ISimpleMesh* mesh, IInstanceCollectionNode* collection) { f32 x = math::RandomFloat(-20.0f, 20.0f); f32 z = math::RandomFloat(-20.0f, 20.0f); f32 y = math::RandomFloat(20.0f, 200.0f); //f32 y = 0; IInstanceNode* boxNode = collection->addInstance(false, XMFLOAT3(x, y, z), XMFLOAT3(0, 0, 0)); boxNode->addShadow(1); f32 r = math::RandomFloat(0, 1.0f); f32 g = math::RandomFloat(0, 1.0f); f32 b = math::RandomFloat(0, 1.0f); XMFLOAT4 color(r, g, b, 1.0f); boxNode->setData(&color); //boxNode->setNeedCulling(false); XMFLOAT3 boxHalfSize(boxSize / 2, boxSize / 2, boxSize / 2); PhysicsCube* cube = new PhysicsCube(boxNode, boxHalfSize, XMFLOAT3(x, y, z), false, 0.5f, 0.5f); g_boxes.push_back(cube); }