// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> bool StationMagnitude::detachFrom(PublicObject* object) { if ( object == NULL ) return false; // check all possible parents Origin* origin = Origin::Cast(object); if ( origin != NULL ) { // If the object has been added already to the parent locally // just remove it by pointer if ( object == parent() ) return origin->remove(this); // The object has not been added locally so it must be looked up else { StationMagnitude* child = origin->findStationMagnitude(publicID()); if ( child != NULL ) return origin->remove(child); else { SEISCOMP_DEBUG("StationMagnitude::detachFrom(Origin): stationMagnitude has not been found"); return false; } } } SEISCOMP_ERROR("StationMagnitude::detachFrom(%s) -> wrong class type", object->className()); return false; }
FPType Utils::checkFeasibility(StarNetwork *net, ODMatrix *mat){ std::vector<FPType> total(net->getNbNodes()); for (int i = 0; i < net->getNbNodes(); ++i) { total[i] = 0.0; } // load demands for (OriginIterator it = mat->begin(); it != mat->end(); ++it){ Origin* origin = *it; for (PairODIterator jt = origin->begin(); jt != origin->end(); ++jt) { PairOD* dest = *jt; total[origin->getIndex()] += dest->getDemand(); total[dest->getIndex()] -= dest->getDemand(); } } //travers network and check for (StarLink *link = net->beginOnlyLink(); link != NULL; link = net->getNextOnlyLink()) { total[link->getNodeFromIndex()] -= link->getFlow(); total[link->getNodeToIndex()] += link->getFlow(); } FPType maxVal = 0.0; for (int i = 0; i < net->getNbNodes(); ++i) { if (fabs(total[i]) > maxVal) maxVal = fabs(total[i]); } return maxVal; };
void sub25(){ Clone1 a; Clone2 b; Origin *p; p=&a; if (typeid(*(p->clone(a)))==typeid(Clone1)) cout<<"is"<<endl; }
void ODMatrix::print(){ std::cout << "nb pairs = " << nbODPairs_ << std::endl; for (OriginIterator it = begin(); it != end(); ++it){ Origin* origin = *it; std::cout << "Origin: " << origin->getIndex() << std::endl; for (PairODIterator jt = origin->begin(); jt != origin->end(); ++jt) { PairOD* dest = *jt; dest->print(); } }; };
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> bool StationMagnitude::attachTo(PublicObject* parent) { if ( parent == NULL ) return false; // check all possible parents Origin* origin = Origin::Cast(parent); if ( origin != NULL ) return origin->add(this); SEISCOMP_ERROR("StationMagnitude::attachTo(%s) -> wrong class type", parent->className()); return false; }
void TollsManagement::generateRandomTollsOnShortestPath(TollContainerType& tolls, FPType probabylity, TollType maxToll, ODMatrix* mat, ShortestPath *shPath){ for (OriginIterator it = mat->begin(); it != mat->end(); ++it) { Origin* origin = *it; shPath->calculate(origin->getIndex()); for (PairODIterator jt = origin->begin(); jt != origin->end(); ++jt) { if (Utils::generateRndNumber(1.0) <= probabylity) { PairOD* dest = *jt; assignRndTolls(shPath, dest->getIndex(), tolls, probabylity, maxToll); } } } };
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> bool Comment::attachTo(PublicObject* parent) { if ( parent == NULL ) return false; // check all possible parents MomentTensor* momentTensor = MomentTensor::Cast(parent); if ( momentTensor != NULL ) return momentTensor->add(this); FocalMechanism* focalMechanism = FocalMechanism::Cast(parent); if ( focalMechanism != NULL ) return focalMechanism->add(this); Amplitude* amplitude = Amplitude::Cast(parent); if ( amplitude != NULL ) return amplitude->add(this); Magnitude* magnitude = Magnitude::Cast(parent); if ( magnitude != NULL ) return magnitude->add(this); StationMagnitude* stationMagnitude = StationMagnitude::Cast(parent); if ( stationMagnitude != NULL ) return stationMagnitude->add(this); Pick* pick = Pick::Cast(parent); if ( pick != NULL ) return pick->add(this); Event* event = Event::Cast(parent); if ( event != NULL ) return event->add(this); Origin* origin = Origin::Cast(parent); if ( origin != NULL ) return origin->add(this); Parameter* parameter = Parameter::Cast(parent); if ( parameter != NULL ) return parameter->add(this); ParameterSet* parameterSet = ParameterSet::Cast(parent); if ( parameterSet != NULL ) return parameterSet->add(this); Stream* stream = Stream::Cast(parent); if ( stream != NULL ) return stream->add(this); SensorLocation* sensorLocation = SensorLocation::Cast(parent); if ( sensorLocation != NULL ) return sensorLocation->add(this); Station* station = Station::Cast(parent); if ( station != NULL ) return station->add(this); Network* network = Network::Cast(parent); if ( network != NULL ) return network->add(this); SEISCOMP_ERROR("Comment::attachTo(%s) -> wrong class type", parent->className()); return false; }
JNIEXPORT void JNICALL Java_org_nzdis_example03_GLESView_myCleanup (JNIEnv *env, jclass c) { SENSORS_ENABLED = 0; origin.cleanup(); sphere.cleanup(); terrain.cleanup(); }
JNIEXPORT void JNICALL Java_org_nzdis_example03_GLESView_myDrawFrame (JNIEnv *env, jclass c) { glClear(GL_COLOR_BUFFER_BIT); glClearColor(0.2f, 0.2f, 0.2f, 1.0f); sphere.drawFrame(&perspective); origin.drawFrame(&perspective); terrain.drawFrame(&perspective); }
FPType DAGraph::checkOFlowsFeasibility(){ int nbNodes = net_->getNbNodes(); FPType total[nbNodes]; for (int i = 0; i < nbNodes; ++i) { total[i] = 0.0; } // load demands for (OriginIterator it = mat_->begin(); it != mat_->end(); ++it){ Origin* origin = *it; if (origin->getIndex() == originIndex_){ for (PairODIterator jt = origin->begin(); jt != origin->end(); ++jt) { PairOD* dest = *jt; FPType demand = dest->getDemand(); total[origin->getIndex()] += demand; total[dest->getIndex()] -= demand; } break; } } //travers network and check int i = -1; StarLink* link = NULL; std::list<StarLink*> inLinks; for (int j = 0; j < nodeSize_; ++j) { i = nodeIndexes_[j]; getInLinks(i, inLinks); for (std::list<StarLink*>::iterator it = inLinks.begin(); it != inLinks.end(); ++it){ link = *it; total[link->getNodeFromIndex()] -= getOriginFlow(link->getIndex()); total[link->getNodeToIndex()] += getOriginFlow(link->getIndex()); } } FPType max = 0.0; for (int i = 0; i < net_->getNbNodes(); ++i) { if (fabs(total[i]) > max) { max = fabs(total[i]); } } return max; };
void ODMatrix::setIndexes(){ int count = 0; int originIndex = -1; // for (OriginIterator it = begin(); it != end(); ++it){ Origin* origin = *it; originIndex = origin->getIndex(); for (PairODIterator jt = origin->begin(); jt != origin->end(); ++jt) { PairOD* dest = *jt; dest->setODIndex(count); demandByIndex_.insert(std::make_pair<std::string, FPType>( createKey(originIndex, dest->getIndex()), dest->getDemand())); ++count; } } nbODPairs_ = count; std::cout << "nbODPairs = " << nbODPairs_ << std::endl; };
PathSet::PathSet(ODSetType setType, StarNetwork *net, ODMatrix *mat, ShortestPath *shPath, PathCost *pathCost, FPType zeroFlow, PathBasedFlowMove* flowMove, PathBasedFlowMoveWithStep* flowMoveWithStep, PathBasedFlowMoveGP* flowMoveGP, AONAssignment* aon) : odSetList_(mat->getNbODPairs()), size_(mat->getNbODPairs()), currPath_(NULL), aon_(aon){ int odIndex = -1; for (OriginIterator it = mat->begin(); it != mat->end(); ++it){ Origin* origin = *it; for (PairODIterator jt = origin->begin(); jt != origin->end(); ++jt) { PairOD* dest = *jt; odIndex = dest->getODIndex(); if (setType == PEAPP3) { odSetList_[odIndex] = new ODSet(odIndex, dest->getIndex(), origin->getIndex(), pathCost, net, shPath, zeroFlow, flowMove); } else if (setType == WITH_STEP) { odSetList_[odIndex] = new ODSetWithStep(odIndex, dest->getIndex(), origin->getIndex(), pathCost, net, shPath, zeroFlow, flowMoveWithStep); } else if (setType == GPAPP3) { odSetList_[odIndex] = new ODSetGPApp3(odIndex, dest->getIndex(), origin->getIndex(), pathCost, net, shPath, zeroFlow, flowMoveGP, mat); } else { throw Error("Unexpected OD set type."); } } } };
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> bool EventParameters::add(Origin* origin) { if ( origin == NULL ) return false; // Element has already a parent if ( origin->parent() != NULL ) { SEISCOMP_ERROR("EventParameters::add(Origin*) -> element has already a parent"); return false; } if ( PublicObject::IsRegistrationEnabled() ) { Origin* originCached = Origin::Find(origin->publicID()); if ( originCached ) { if ( originCached->parent() ) { if ( originCached->parent() == this ) SEISCOMP_ERROR("EventParameters::add(Origin*) -> element with same publicID has been added already"); else SEISCOMP_ERROR("EventParameters::add(Origin*) -> element with same publicID has been added already to another object"); return false; } else origin = originCached; } } // Add the element _origins.push_back(origin); origin->setParent(this); // Create the notifiers if ( Notifier::IsEnabled() ) { NotifierCreator nc(OP_ADD); origin->accept(&nc); } // Notify registered observers childAdded(origin); return true; }
void ColoredCubeApp::drawScene() { D3DApp::drawScene(); // Restore default states, input layout and primitive topology // because mFont->DrawText changes them. Note that we can // restore the default states by passing null. md3dDevice->OMSetDepthStencilState(0, 0); float blendFactors[] = {0.0f, 0.0f, 0.0f, 0.0f}; md3dDevice->OMSetBlendState(0, blendFactors, 0xffffffff); md3dDevice->IASetInputLayout(mVertexLayout); // set some variables for the shader int foo[1]; foo[0] = 0; // set the point to the shader technique D3D10_TECHNIQUE_DESC techDesc; mTech->GetDesc(&techDesc); //setting the color flip variable in the shader mfxFLIPVar->SetRawValue(&foo[0], 0, sizeof(int)); rightWall.draw(mView, mProj, mTech); //floor.draw(mView, mProj, mTech); leftWall.draw(mView, mProj, mTech); //ceiling.draw(mView, mProj, mTech); shootCube.draw(mView, mProj, mTech); hitCubes->draw(mView,mProj,mTech); avoidCubes->draw(mView,mProj,mTech); //for(int i = 0; i < 20; i++) //{ // tiles[i].draw(mView, mProj, mTech); // //wall[i].draw(mView,mProj,mTech); //} //draw the origin origin.draw(mView, mProj, mTech); // We specify DT_NOCLIP, so we do not care about width/height of the rect. RECT R = {5, 5, 0, 0}; mFont->DrawText(0, mTimer.c_str(), -1, &R, DT_NOCLIP, BLUE); mSwapChain->Present(0, 0); }
JNIEXPORT void JNICALL Java_org_nzdis_example03_GLESView_mySurfaceChanged (JNIEnv *env, jclass c, jint width, jint height) { glViewport(0, 0, width, height); aspect = (float)width / (float)height; // Generate a perspective matrix with a 60 degree FOV esMatrixLoadIdentity(&perspective); //LOGI("%f %d %d", aspect, width, height); esPerspective(&perspective, 60.0f, aspect, 1.0f, 30.0f); esTranslate(&perspective, 0.0f, 0.0f, -5.0f); //esRotate(&perspective, 45.0f, 1.0f, 0.0f, 0.0f); //esRotate(&perspective, -5.0f, 0.0f, 1.0f, 0.0f); origin.init(width, height); sphere.init(width, height); terrain.init(width, height); }
void ColoredCubeApp::initApp() { D3DApp::initApp(); //0: Parallel //1: Point //2: Spot hurtLight = D3DXCOLOR(1,0,0,1); ambientLight = D3DXCOLOR(0.3f, 0.03f, 0.2f, 1.0f); //ambientLight = D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f); lights[1].ambient = ambientLight; lights[1].diffuse = D3DXCOLOR(0.0f, 0.02f, 0.02f, 1.0f); lights[1].specular = D3DXCOLOR(0.0f, 0.0f, 0.0f, 1.0f); lights[1].att.x = 1.0f; lights[1].att.y = 0.0f; lights[1].att.z = 0.0f; lights[1].spotPow = 20; lights[1].range = 100; lights[1].pos = D3DXVECTOR3(-10,20,-10); lights[1].dir = D3DXVECTOR3(0, -1, 0); lights[1].lightType.x = 0; buildFX(); buildVertexLayouts(); Dimension d; d.x = 10; d.z = 10; mazeX = d.x; mazeZ = d.z; maze.init(d,mfxWVPVar,mfxWorldVar,md3dDevice); maze.build(); maze.setTex(mfxDiffuseMapVar,mfxSpecMapVar,L"brickwork-texture.jpg",L"brickwork-bump-map.jpg"); maze.setCeilTex(mfxDiffuseMapVar,mfxSpecMapVar,L"13.free-brick-textures.jpg",L"brickwork-bump-map.jpg"); maze.setFloorTex(mfxDiffuseMapVar,mfxSpecMapVar,L"carpet_diffuse.jpg",L"brickwork-bump-map.jpg"); camera.init(&maze); mBox.init(md3dDevice, 1.0f); //testMesh.init(md3dDevice,1.0f,"surfrev2.dat"); line.init(md3dDevice, 1.0f, DARKBROWN); line2.init(md3dDevice, 1.0f, RED); line3.init(md3dDevice, 1.0f, GREEN); origin.init(&line,&line2,&line3,mfxWVPVar,10); quad1.init(md3dDevice,1,D3DXCOLOR(0.5,0.25,0.1,1.0)); //make the texture init in another function so it is not an issue switching between shaders /*floor.init(&mBox,mfxWVPVar,mfxWorldVar,2,Vector3(0,-3,0),Vector3(0,0,0),0,Vector3(20,0.1,20)); floor.setTex(mfxDiffuseMapVar,mfxSpecMapVar,L"WoodCrate01.dds",L"defaultspec.dds"); wall1.init(&mBox,mfxWVPVar,mfxWorldVar,2,Vector3(-20,-3+20,0),Vector3(0,0,0),0,Vector3(0.1,20,20)); wall2.init(&mBox,mfxWVPVar,mfxWorldVar,2,Vector3(20,-3+20,0),Vector3(0,0,0),0,Vector3(0.1,20,20)); wall3.init(&mBox,mfxWVPVar,mfxWorldVar,2,Vector3(0,-3+20,20),Vector3(0,0,0),0,Vector3(20,20,0.1)); wall4.init(&mBox,mfxWVPVar,mfxWorldVar,2,Vector3(0,-3+20,-20),Vector3(0,0,0),0,Vector3(20,20,0.1));*/ player.init(&mBox,mfxWVPVar,mfxWorldVar,sqrt(2.0f),Vector3(10,0,10),Vector3(0,0,0),0,Vector3(1,1,1)); player.setTex(mfxDiffuseMapVar,mfxSpecMapVar,L"brickwork-texture.jpg",L"brickwork-bump-map.jpg"); Location start = maze.getStartPosition(); start = maze.cellToPx(start); player.setPosition(Vector3(start.x+10,0,start.z+10)); flashLightObject.init(md3dDevice,mfxWVPVar,mfxWorldVar,2,Vector3(0,0,0),Vector3(0,0,0),0,Vector3(0.25,0.25,0.25)); flashLightObject.setRotation(Vector3(ToRadian(90),0,0)); //lightObject1.init(md3dDevice,mfxWVPVar,mfxWorldVar,2,Vector3(10,3,0),Vector3(0,0,0),0,Vector3(0.25,0.25,0.25)); //lightObject1.setTex(mfxDiffuseMapVar,mfxSpecMapVar,L"WoodCrate01.dds",L"ice.dds"); for(int i = 0; i < numLightObjects; i++) { lamps[i].init(md3dDevice,mfxWVPVar,mfxWorldVar,2,Vector3(10,3,0),Vector3(0,0,0),0,Vector3(0.75,0.75,0.75)); lamps[i].setTex(mfxDiffuseMapVar,mfxSpecMapVar,L"WoodCrate01.dds",L"ice.dds"); Location l; l.x = rand()%mazeX; l.z = rand()%mazeZ; auto spot = maze.cellToPx(l); lamps[i].setPosition(Vector3(spot.x,5,spot.z)); lamps[i].setColor(D3DXCOLOR(0.2f, 0.5f, 0.3f, 1.0f)); } key.init(md3dDevice,1,"item1.txt"); for(int i = 0; i < totalKeys; i++) { keyObject[i].init(&key,mfxWVPVar,mfxWorldVar,sqrt(2.0f),Vector3(0,0,0),Vector3(0,0,0),0,Vector3(0.25,0.25,0.25)); Location l; l.x = rand()%mazeX; l.z = rand()%mazeZ; auto spot = maze.cellToPx(l); keyObject[i].setPosition(Vector3(spot.x,-1,spot.z)); } endCube.init(&mBox,mfxWVPVar,mfxWorldVar,sqrt(3.0f),Vector3(0,0,0),Vector3(0,0,0),0,Vector3(2,2,2)); endCube.setTex(mfxDiffuseMapVar,mfxSpecMapVar,L"WoodCrate01.dds",L"ice.dds"); Location end = maze.getEndPosition(); end = maze.cellToPx(end); endCube.setPosition(Vector3(end.x,0,end.z)); //set up the end light endLight.ambient = D3DXCOLOR(0.0f, 0.0f, 0.0f, 1.0f); endLight.diffuse = D3DXCOLOR(1.0f, 1.0f, 0.3f, 1.0f); endLight.specular = D3DXCOLOR(0.0f, 0.0f, 0.0f, 1.0f); endLight.att.x = 1.0f; endLight.att.y = 0.0f; endLight.att.z = 0.0f; endLight.spotPow = 10; endLight.range = 100; endLight.pos = D3DXVECTOR3(end.x,10,end.z); endLight.dir = D3DXVECTOR3(0, -1, 0); endLight.lightType.x = 2; //batteryObject.init(md3dDevice,mfxWVPVar,mfxWorldVar,sqrt(2.0f),Vector3(0,0,5),Vector3(0,0,0),0,Vector3(0.25,0.25,0.25)); for(int i = 0; i < numBatteries; i++) { batteries[i].init(md3dDevice,mfxWVPVar,mfxWorldVar,sqrt(2.0f),Vector3(0,0,5),Vector3(0,0,0),0,Vector3(0.5,0.5,0.5)); Location l; l.x = rand()%mazeX; l.z = rand()%mazeZ; auto spot = maze.cellToPx(l); batteries[i].setPosition(Vector3(spot.x,-1,spot.z)); } ghosts.init(md3dDevice,mfxWVPVar,mfxWorldVar,sqrt(2.0f),Vector3(5,0,0),Vector3(0,0,0),10,Vector3(0.25,0.25,0.25)); ghosts.setTex(mfxDiffuseMapVar,mfxSpecMapVar,L"WoodCrate01.dds",L"ice.dds"); //Normalize(&mParallelLight.dir,&(flashLightObject.getPosition()-wall1.getPosition())); // init sound system audio = new Audio(); if (*WAVE_BANK != '\0' && *SOUND_BANK != '\0') // if sound files defined { if( FAILED( hr = audio->initialize() ) ) { exit(1); //if( hr == HRESULT_FROM_WIN32( ERROR_FILE_NOT_FOUND ) ) // throw(GameError(gameErrorNS::FATAL_ERROR, "Failed to initialize sound system because media file not found.")); //else // throw(GameError(gameErrorNS::FATAL_ERROR, "Failed to initialize sound system.")); } } //set up the camera camera.setHeightAndWidth(mClientWidth,mClientHeight); audio->playCue(MUSIC); //input->initialize(this->getMainWnd(), false); //sound object /*testSound = new SoundItem(audio,Vector3(0,0,0),50); static string sounds[] = {"gun_sound_effect","Light Bulb Breaking-SoundBible.com-53066515"}; testSound->setSounds(sounds,2);*/ }
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> bool EventParameters::updateChild(Object* child) { Pick* pickChild = Pick::Cast(child); if ( pickChild != NULL ) { Pick* pickElement = Pick::Cast(PublicObject::Find(pickChild->publicID())); if ( pickElement && pickElement->parent() == this ) { *pickElement = *pickChild; return true; } return false; } Amplitude* amplitudeChild = Amplitude::Cast(child); if ( amplitudeChild != NULL ) { Amplitude* amplitudeElement = Amplitude::Cast(PublicObject::Find(amplitudeChild->publicID())); if ( amplitudeElement && amplitudeElement->parent() == this ) { *amplitudeElement = *amplitudeChild; return true; } return false; } Reading* readingChild = Reading::Cast(child); if ( readingChild != NULL ) { Reading* readingElement = Reading::Cast(PublicObject::Find(readingChild->publicID())); if ( readingElement && readingElement->parent() == this ) { *readingElement = *readingChild; return true; } return false; } Origin* originChild = Origin::Cast(child); if ( originChild != NULL ) { Origin* originElement = Origin::Cast(PublicObject::Find(originChild->publicID())); if ( originElement && originElement->parent() == this ) { *originElement = *originChild; return true; } return false; } FocalMechanism* focalMechanismChild = FocalMechanism::Cast(child); if ( focalMechanismChild != NULL ) { FocalMechanism* focalMechanismElement = FocalMechanism::Cast(PublicObject::Find(focalMechanismChild->publicID())); if ( focalMechanismElement && focalMechanismElement->parent() == this ) { *focalMechanismElement = *focalMechanismChild; return true; } return false; } Event* eventChild = Event::Cast(child); if ( eventChild != NULL ) { Event* eventElement = Event::Cast(PublicObject::Find(eventChild->publicID())); if ( eventElement && eventElement->parent() == this ) { *eventElement = *eventChild; return true; } return false; } return false; }
void ColoredCubeApp::initApp() { D3DApp::initApp(); buildFX(); buildVertexLayouts(); mBox.init(md3dDevice, 1.0f, D3DXCOLOR(0.5,0.5,0.5,1)); redBox.init(md3dDevice, 1.0f, DARKBROWN); greenBox.init(md3dDevice, 1.0f, D3DXCOLOR(0.1,0.1,0.8,1)); shootBox.init(md3dDevice, 1.0f, BEACH_SAND); line.init(md3dDevice, 1.0f, DARKBROWN); line2.init(md3dDevice, 1.0f, RED); line3.init(md3dDevice, 1.0f, GREEN); /*xLine.init(&line, mfxWVPVar, Vector3(0,0,0), 1); xLine.setPosition(Vector3(0,0,0)); yLine.init(&line, mfxWVPVar, Vector3(0,0,0), 1); yLine.setPosition(Vector3(0,0,0)); yLine.setRotationZ(ToRadian(90)); zLine.init(&line, mfxWVPVar, Vector3(0,0,0), 1); zLine.setPosition(Vector3(0,0,0)); zLine.setRotationY(ToRadian(90));*/ shootCube.init(&shootBox,mfxWVPVar,sqrt(2.0f),Vector3(10,0,10),Vector3(0,0,0),0,Vector3(1,1,1)); //shootCube.setRotation(Vector3(ToRadian(-20),ToRadian(45),0)); leftWall.init(&redBox,mfxWVPVar,sqrt(2.0f),Vector3(20,0,0),Vector3(0,0,0),0,Vector3(0.5,20,100)); //leftWall.setRotation(Vector3(ToRadian(-20),ToRadian(45),0)); floor.init(&redBox,mfxWVPVar,sqrt(2.0f),Vector3(0,-5,0),Vector3(0,0,0),0,Vector3(20,0.2,20)); //floor.setRotation(Vector3(ToRadian(-26),ToRadian(45),0)); ceiling.init(&mBox,mfxWVPVar,sqrt(2.0f),Vector3(0,20,0),Vector3(0,0,0),0,Vector3(20,0.2,100)); ceiling.setRotation(Vector3(ToRadian(-20),ToRadian(45),0)); rightWall.init(&redBox,mfxWVPVar,sqrt(2.0f),Vector3(-20,0,0),Vector3(0,0,0),0,Vector3(0.5,20,100)); //rightWall.setRotation(Vector3(ToRadian(-20),ToRadian(45),0)); //srand(time(0)); for(int i = 0; i < 20; i++) { tiles[i].init(&greenBox,mfxWVPVar,sqrt(2.0f),Vector3((-5+rand()%10)*3,-100,(-5+rand()%10)*3),Vector3(0,0,0),0,Vector3(1,1,1)); } origin.init(&line,&line2,&line3,mfxWVPVar,10); quad1.init(md3dDevice, 10, CYAN); quad1.setPosition(Vector3(0,0,0)); spinAmount = 0; // init sound system audio = new Audio(); if (*WAVE_BANK != '\0' && *SOUND_BANK != '\0') // if sound files defined { if( FAILED( hr = audio->initialize() ) ) { exit(1); //if( hr == HRESULT_FROM_WIN32( ERROR_FILE_NOT_FOUND ) ) // throw(GameError(gameErrorNS::FATAL_ERROR, "Failed to initialize sound system because media file not found.")); //else // throw(GameError(gameErrorNS::FATAL_ERROR, "Failed to initialize sound system.")); } } hitCubes = new CubeHoard(100,10,5,5,1,-15,15,-15,15,-100,40); hitCubes->init(&redBox,mfxWVPVar,sqrt(4.0f),Vector3(0,0,0),Vector3(0,100,0),70,Vector3(2,2,2)); avoidCubes = new CubeHoard(100,20,10,10,1,-20,20,-20,20,-100,50); avoidCubes->init(&greenBox,mfxWVPVar,sqrt(4.0f),Vector3(0,0,0),Vector3(0,100,0),70,Vector3(2,2,2)); audio->playCue(MUSIC); //input->initialize(this->getMainWnd(), false); }
void ColoredCubeApp::drawScene() { D3DApp::drawScene(); // Restore default states, input layout and primitive topology // because mFont->DrawText changes them. Note that we can // restore the default states by passing null. md3dDevice->OMSetDepthStencilState(0, 0); float blendFactors[] = {0.0f, 0.0f, 0.0f, 0.0f}; md3dDevice->OMSetBlendState(0, blendFactors, 0xffffffff); md3dDevice->IASetInputLayout(mVertexLayout); mfxEyePosVar->SetRawValue(&player.getPosition(), 0, sizeof(D3DXVECTOR3)); //set the number of lights to use mfxNumLights->SetInt(numLights); // set the light array lights[0] = flashLightObject.lightSource; //lights[2] = lightObject1.getLight(); if(gamestate == level2) { for(int i = 0; i < ghosts.getNumEnemies(); i++) { lights[2+i] = ghosts.getEnemies()[i].getLight(); } } for(int i = 0; i < numLightObjects; i++) { lights[2+ghosts.getNumEnemies()+i] = lamps[i].getLight(); } lights[numLights-1] = endLight; mfxLightVar->SetRawValue(&lights[0], 0, numLights*sizeof(Light)); // Don't transform texture coordinates, so just use identity transformation. D3DXMATRIX texMtx; D3DXMatrixIdentity(&texMtx); mfxTexMtxVar->SetMatrix((float*)&texMtx); // set the point to the shader technique D3D10_TECHNIQUE_DESC techDesc; mTech->GetDesc(&techDesc); //draw the maze maze.draw(mTech,mView,mProj); //draw the keys if(gamestate == level1) { for(int i = 0; i < totalKeys; i++) { keyObject[i].draw(mView,mProj,mTech); } } //draw the end cube endCube.draw(mView,mProj,mTech); //draw the origin origin.draw(mView, mProj, mTech); for(int i = 0; i < numLightObjects; i++) { lamps[i].draw(mView,mProj,mTech); } for(int i = 0; i < numBatteries; i++) { batteries[i].draw(mView,mProj,mTechColor2); } //flashLightObject.draw(mView,mProj,mTechColor2); //flashLightObject.hitBox.draw(mView,mProj,mTechColor2); //batteryObject.draw(mView,mProj,mTechColor2); //player.draw(mView,mProj,mTechColor2); ghosts.draw(mView,mProj,mTech); /*floor.draw(mView, mProj, mTech); wall1.draw(mView, mProj, mTech); wall2.draw(mView, mProj, mTech); wall3.draw(mView, mProj, mTech); wall4.draw(mView, mProj, mTech);*/ //lightObject1.draw(mView,mProj,mTech); // We specify DT_NOCLIP, so we do not care about width/height of the rect. RECT R = {5, 5, 0, 0}; mFont->DrawText(0, mTimer.c_str(), -1, &R, DT_NOCLIP, BLUE); mSwapChain->Present(0, 0); }
/** * @brief Processes and modifies an event. It checks the current * location against the configured regions and sets the * type to OUTSIDE_OF_NETWORK_INTEREST if the location is not * inside in any of the regions. * @param event The event to be processed * @return Update flag: true, if the event has been updated, false * otherwise. */ bool process(Event *event) { Origin *org = Origin::Find(event->preferredOriginID()); if ( !org ) { SEISCOMP_WARNING("%s: RC: no origin information", event->publicID().c_str()); return false; } try { if ( org->evaluationMode() == DataModel::MANUAL ){ SEISCOMP_DEBUG("evrc plugin found %s preferred origin %s: " "do not change the event status", org->evaluationMode().toString(), org->publicID().c_str()); return false; } } catch ( ... ) {} GeoCoordinate location; try { location.set(org->latitude().value(), org->longitude().value()); } catch ( ... ) { SEISCOMP_WARNING("%s: RC: no lat/lon information available", event->publicID().c_str()); return false; } SEISCOMP_DEBUG("%s: RC: checking regions for location %f / %f", event->publicID().c_str(), location.lat, location.lon); OPT(EventType) currentType; try { currentType = event->type(); } catch ( ... ) {} bool isInside = false; for ( size_t i = 0; i < _regions.size(); ++i ) { bool isInsideRegion; if ( _regions[i].first ) isInsideRegion = _regions[i].first->contains(location); else isInsideRegion = true; if ( _regions[i].second ) { // Positive region if ( isInsideRegion ) { // Inside of network interest isInside = true; SEISCOMP_DEBUG("%s: RC: region '%s' matches", event->publicID().c_str(), (_regions[i].first ? _regions[i].first->name().c_str() : "world")); // If there are possible negative regions following this // match then continue. if ( !_hasNegativeRegions ) break; } } else { // Negative region if ( isInsideRegion ) { // Outside of network interest isInside = false; SEISCOMP_DEBUG("%s: RC: region '%s' matches and it is a negative region", event->publicID().c_str(), (_regions[i].first ? _regions[i].first->name().c_str() : "world")); // Continue with checking as there might follow a positive // region that overrides again that result unless there // are only negative regions configured if ( !_hasPositiveRegions ) break; } } } if ( !isInside ) { if ( !currentType || (currentType && *currentType != OUTSIDE_OF_NETWORK_INTEREST) ) { SEISCOMP_DEBUG("%s: RC: event is out of network interest", event->publicID().c_str()); event->setType(EventType(OUTSIDE_OF_NETWORK_INTEREST)); return true; } } else { if ( currentType && *currentType == OUTSIDE_OF_NETWORK_INTEREST ) { SEISCOMP_DEBUG("%s: RC: event is inside of network interest: removing type", event->publicID().c_str()); event->setType(Core::None); return true; } } return false; }
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> bool Comment::detachFrom(PublicObject* object) { if ( object == NULL ) return false; // check all possible parents MomentTensor* momentTensor = MomentTensor::Cast(object); if ( momentTensor != NULL ) { // If the object has been added already to the parent locally // just remove it by pointer if ( object == parent() ) return momentTensor->remove(this); // The object has not been added locally so it must be looked up else { Comment* child = momentTensor->comment(index()); if ( child != NULL ) return momentTensor->remove(child); else { SEISCOMP_DEBUG("Comment::detachFrom(MomentTensor): comment has not been found"); return false; } } } FocalMechanism* focalMechanism = FocalMechanism::Cast(object); if ( focalMechanism != NULL ) { // If the object has been added already to the parent locally // just remove it by pointer if ( object == parent() ) return focalMechanism->remove(this); // The object has not been added locally so it must be looked up else { Comment* child = focalMechanism->comment(index()); if ( child != NULL ) return focalMechanism->remove(child); else { SEISCOMP_DEBUG("Comment::detachFrom(FocalMechanism): comment has not been found"); return false; } } } Amplitude* amplitude = Amplitude::Cast(object); if ( amplitude != NULL ) { // If the object has been added already to the parent locally // just remove it by pointer if ( object == parent() ) return amplitude->remove(this); // The object has not been added locally so it must be looked up else { Comment* child = amplitude->comment(index()); if ( child != NULL ) return amplitude->remove(child); else { SEISCOMP_DEBUG("Comment::detachFrom(Amplitude): comment has not been found"); return false; } } } Magnitude* magnitude = Magnitude::Cast(object); if ( magnitude != NULL ) { // If the object has been added already to the parent locally // just remove it by pointer if ( object == parent() ) return magnitude->remove(this); // The object has not been added locally so it must be looked up else { Comment* child = magnitude->comment(index()); if ( child != NULL ) return magnitude->remove(child); else { SEISCOMP_DEBUG("Comment::detachFrom(Magnitude): comment has not been found"); return false; } } } StationMagnitude* stationMagnitude = StationMagnitude::Cast(object); if ( stationMagnitude != NULL ) { // If the object has been added already to the parent locally // just remove it by pointer if ( object == parent() ) return stationMagnitude->remove(this); // The object has not been added locally so it must be looked up else { Comment* child = stationMagnitude->comment(index()); if ( child != NULL ) return stationMagnitude->remove(child); else { SEISCOMP_DEBUG("Comment::detachFrom(StationMagnitude): comment has not been found"); return false; } } } Pick* pick = Pick::Cast(object); if ( pick != NULL ) { // If the object has been added already to the parent locally // just remove it by pointer if ( object == parent() ) return pick->remove(this); // The object has not been added locally so it must be looked up else { Comment* child = pick->comment(index()); if ( child != NULL ) return pick->remove(child); else { SEISCOMP_DEBUG("Comment::detachFrom(Pick): comment has not been found"); return false; } } } Event* event = Event::Cast(object); if ( event != NULL ) { // If the object has been added already to the parent locally // just remove it by pointer if ( object == parent() ) return event->remove(this); // The object has not been added locally so it must be looked up else { Comment* child = event->comment(index()); if ( child != NULL ) return event->remove(child); else { SEISCOMP_DEBUG("Comment::detachFrom(Event): comment has not been found"); return false; } } } Origin* origin = Origin::Cast(object); if ( origin != NULL ) { // If the object has been added already to the parent locally // just remove it by pointer if ( object == parent() ) return origin->remove(this); // The object has not been added locally so it must be looked up else { Comment* child = origin->comment(index()); if ( child != NULL ) return origin->remove(child); else { SEISCOMP_DEBUG("Comment::detachFrom(Origin): comment has not been found"); return false; } } } Parameter* parameter = Parameter::Cast(object); if ( parameter != NULL ) { // If the object has been added already to the parent locally // just remove it by pointer if ( object == parent() ) return parameter->remove(this); // The object has not been added locally so it must be looked up else { Comment* child = parameter->comment(index()); if ( child != NULL ) return parameter->remove(child); else { SEISCOMP_DEBUG("Comment::detachFrom(Parameter): comment has not been found"); return false; } } } ParameterSet* parameterSet = ParameterSet::Cast(object); if ( parameterSet != NULL ) { // If the object has been added already to the parent locally // just remove it by pointer if ( object == parent() ) return parameterSet->remove(this); // The object has not been added locally so it must be looked up else { Comment* child = parameterSet->comment(index()); if ( child != NULL ) return parameterSet->remove(child); else { SEISCOMP_DEBUG("Comment::detachFrom(ParameterSet): comment has not been found"); return false; } } } Stream* stream = Stream::Cast(object); if ( stream != NULL ) { // If the object has been added already to the parent locally // just remove it by pointer if ( object == parent() ) return stream->remove(this); // The object has not been added locally so it must be looked up else { Comment* child = stream->comment(index()); if ( child != NULL ) return stream->remove(child); else { SEISCOMP_DEBUG("Comment::detachFrom(Stream): comment has not been found"); return false; } } } SensorLocation* sensorLocation = SensorLocation::Cast(object); if ( sensorLocation != NULL ) { // If the object has been added already to the parent locally // just remove it by pointer if ( object == parent() ) return sensorLocation->remove(this); // The object has not been added locally so it must be looked up else { Comment* child = sensorLocation->comment(index()); if ( child != NULL ) return sensorLocation->remove(child); else { SEISCOMP_DEBUG("Comment::detachFrom(SensorLocation): comment has not been found"); return false; } } } Station* station = Station::Cast(object); if ( station != NULL ) { // If the object has been added already to the parent locally // just remove it by pointer if ( object == parent() ) return station->remove(this); // The object has not been added locally so it must be looked up else { Comment* child = station->comment(index()); if ( child != NULL ) return station->remove(child); else { SEISCOMP_DEBUG("Comment::detachFrom(Station): comment has not been found"); return false; } } } Network* network = Network::Cast(object); if ( network != NULL ) { // If the object has been added already to the parent locally // just remove it by pointer if ( object == parent() ) return network->remove(this); // The object has not been added locally so it must be looked up else { Comment* child = network->comment(index()); if ( child != NULL ) return network->remove(child); else { SEISCOMP_DEBUG("Comment::detachFrom(Network): comment has not been found"); return false; } } } SEISCOMP_ERROR("Comment::detachFrom(%s) -> wrong class type", object->className()); return false; }