void MouseUp() { if( g_app->m_location ) { Vector3 rayStart; Vector3 rayDir; g_app->m_camera->GetClickRay(g_app->m_renderer->ScreenW()/2, g_app->m_renderer->ScreenH()/2, &rayStart, &rayDir); Vector3 _pos; g_app->m_location->m_landscape.RayHit( rayStart, rayDir, &_pos ); _pos.y = 300.0f; Crate crateTemplate; crateTemplate.m_pos = _pos; Building *newBuilding = Building::CreateBuilding( Building::TypeCrate ); int id = g_app->m_location->m_buildings.PutData(newBuilding); newBuilding->Initialise( (Building*)&crateTemplate); newBuilding->SetDetail( 1 ); newBuilding->m_id.Set( 255, UNIT_BUILDINGS, -1, g_app->m_globalWorld->GenerateBuildingId() ); ((Crate*)newBuilding)->m_rewardId = m_reward; g_app->m_markerSystem->RegisterMarker_Crate( newBuilding->m_id ); } }
void MouseUp() { Vector3 rayStart; Vector3 rayDir; g_app->m_camera->GetClickRay(g_app->m_renderer->ScreenW()/2, g_app->m_renderer->ScreenH()/2, &rayStart, &rayDir); Vector3 _pos; g_app->m_location->m_landscape.RayHit( rayStart, rayDir, &_pos ); Building *building = g_app->m_location->GetBuilding(g_app->m_locationEditor->m_selectionId); DarwiniaDebugAssert(building); Building *newBuilding = Building::CreateBuilding( building->m_type ); newBuilding->Initialise( building ); newBuilding->SetDetail( g_prefsManager->GetInt( "RenderBuildingDetail", 1 ) ); newBuilding->m_id.SetUniqueId( g_app->m_globalWorld->GenerateBuildingId() ); newBuilding->m_pos = _pos; g_app->m_location->m_levelFile->m_buildings.PutData( newBuilding ); }