void startSearch() { int currentNodeID = 0; //Current node while starting is 0 init_Dfs(); //Initialize the stack spine init_motors(); run(); int nextNodeID; addNeigbourNodesToFrontier(currentNodeID); addToSet(&markedNodes,currentNodeID); push(&spine, currentNodeID); nextNodeID = DecideNextNode(currentNodeID); int cnt = 0; while(1) { //scanAndSearch(); //openCV code if(objectFound == true) { // Functionality here TBD printf("Obj found: %d",cnt); cnt ++; rotate360(); objectFound = false; /* while(isObjectClose() == 0) moveForward(); // Provided by the motor library if(distanceTravelledFromPrevNode == distanceToNextNode) addToSet(&markedNodes,currentNodeID); //?? Who updates the current position of the object */ //Keep track of the distance so that obj position is known //Keep track of where we are in the graph } else { printf("Spine. \n"); printStack(&spine); printf("\n\n"); printf("Next node to be traversed: %d\n", nextNodeID); moveToNextNode(currentNodeID,nextNodeID); //Move to the next node currentNodeID = nextNodeID; addToSet(&markedNodes,currentNodeID); //Current Node has been traversed. Add to the set addNeigbourNodesToFrontier(currentNodeID); //Adding frontier nodes from the new current node removeNodeFromSet(&frontierNodes,currentNodeID); //Removing the current node from frontier printf("Done nodes : \n"); listSet(markedNodes); printf("Frontier Nodes : \n"); listSet(frontierNodes); if (checkIfNeighborExistsInFrontier(currentNodeID)) //Check if neighbor exists in frontier { // If so visit there push(&spine, currentNodeID); //Change nextNodeID = DecideNextNode(currentNodeID); } else { if(isStackEmpty(&spine)) return ; // Done traversing. Stop else { nextNodeID = pop(&spine); } } } } }
void Planet::load() { unload(); if ( fileName[0] && (!manager->isServer())) { ResourceManager &rm = *SimResource::get(manager); // const char *filename = SimTagDictionary::getString(manager, textureTag); // load the texture hTexture = rm.load(fileName); AssertWarn((bool)hTexture, avar("Error reading bitmap file \"%s\"", fileName)); // don't want to assert fatal because we don't want to bring down // the mission editor if ((bool)hTexture) { planet.texture = (GFXBitmap *)hTexture; addToSet(SimRenderSetId); inRenderSet = true; loaded = true; } } else planet.texture = NULL; // calculate planet position in world coordinates // add 90 to azimuth so that zero is at up Y axis if (incidence > 89.0f) incidence = 89.0f; if (incidence < -89.0f) incidence = -89.0f; const float az = azimuth + 90.0f; const float c = planet.distance*m_cos(DEGRAD*incidence); planet.position = Point3F(c*m_cos(DEGRAD*az), c*m_sin(DEGRAD*az), planet.distance*m_sin(DEGRAD*incidence)); // initialize light if any Point3F direction = planet.position; direction.normalize(); direction *= -1.0f; if (castShadows) { // set static data items shadowDirection = direction; shadows = true; } light.setAim(direction); //light.setType(TS::Light::LightDirectional); light.setType(TS::Light::LightDirectionalWrap); light.setIntensity(intensity.red, intensity.green, intensity.blue); if (intensity.red > 0.0f || intensity.green > 0.0f || intensity.blue > 0.0f || ambient.red > 0.0f || ambient.green > 0.0f || ambient.blue > 0.0f) { addToSet(SimLightSetId); inLightSet = true; lensFlare.setColor(intensity); } planet.lensFlare = useLensFlare ? &lensFlare : NULL; // initialize static texture coordinates textCoord[0].x = 0.0f; textCoord[0].y = 0.0f; textCoord[1].x = 1.0f; textCoord[1].y = 0.0f; textCoord[2].x = 1.0f; textCoord[2].y = 1.0f; textCoord[3].x = 0.0f; textCoord[3].y = 1.0f; setMaskBits(Modified); }
bool SimInterior::loadShape(const char* fileName) { // setFilename returns false if the filename is invalid, OR if the filename // is the same as the one already set. In either case, we exit wo/ doing // any work... // if (setFilename(fileName) == false) { return false; } // NOTE: This function is VERY poor on error checking, there are only a few // asserts in ITRInstance(). Maybe restructure to be a bit more robust? // ResourceManager *rm = SimResource::get(manager); Resource<ITRShape> itrShape; bool missionLit; // check if we need to try and find the missionlit ver if( rm->findFile( fileName ) ) { missionLit = missionLitName(); itrShape = rm->load( fileName); } else { if( !missionLitName() ) return( false ); String base = String(fileName); getBaseFilename( base ); if( rm->findFile( base.c_str() ) ) itrShape = rm->load(base.c_str()); missionLit = false; } if( !bool( itrShape ) ) return( false ); // If we make it to here, then all is cool, nuke the old resources... // unloadResources(); ITRInstance* pInstance = new ITRInstance(rm, itrShape, 0); if( missionLit ) pInstance->setMissionLit(); renderImage.instance = pInstance; // Set the geometry for the database and collision image. Note that this // is the highest level of state 0 for the interior. May have to change // the collision image geometry pointer on detail level change, probably // will only change the database pointer on state switches... // updateBoundingBox(); SimContainer* root = NULL; root = findObject(manager,SimRootContainerId,root); root->addObject(this); getInstance()->getAutoStartIDs(animatingLights); SimSet* pITRTimerSet = dynamic_cast<SimSet*>(manager->findObject(SimITRTimerSetId)); if (pITRTimerSet == NULL) manager->addObject(new SimTimerSet(1.0f/15.0f, SimITRTimerSetId)); bool timerSuccess = addToSet(SimITRTimerSetId); AssertFatal(timerSuccess == true, "Could not add to SimITRTimerSet"); return true; }