void TPZNetworkSquareMidimew :: initialize() { if( isInitializated() ) return; /* Check consistency of parameters */ if(getSizeY()!=1 ||getSizeZ()!=1) { TPZString err; err.sprintf( ERR_TPZTONET_002, (char*)getRouterId() ); err.sprintf("\nSquare Midimew Network Ysize and Zsize must be 1. Al nodes in Xsize!"); EXIT_PROGRAM(err); } if((int)ceil(sqrt((float)getSizeX()))%2 || getSizeX() < 4 ) { TPZString err; err.sprintf( ERR_TPZTONET_002, (char*)getRouterId() ); err.sprintf("\n Square Midimew Network Xsize must be an even 2's power(4,16,64,256,1024,4096...)"); EXIT_PROGRAM(err); } if( !getSizeX() || !getSizeY() || !getSizeZ() ) { TPZString err; err.sprintf(ERR_TPZTONET_001, getSizeX(), getSizeY(), getSizeZ() ); EXIT_PROGRAM(err); } /* Create the routers for each node */ int i; for( i=0; i<getSizeX(); i++ ) { TPZPosition pos(i,0,0); TPZRouter* newRouter = (TPZRouter*) (TPZRouter::routerBuilder->createComponentWithId(getRouterId(),this)); if( ! newRouter ) { TPZString err; err.sprintf( ERR_TPZTONET_002, (char*)getRouterId() ); EXIT_PROGRAM(err); } newRouter->setPosition(pos); addRouter(newRouter); } /* Connect the routers together */ for( i=0; i<getSizeX(); i++ ) { initializeConnectionsFor(TPZPosition(i,0,0)); } /* Other initialization tasks */ generateRoutingTable(); setInitializated(true); setSimulation(getSimulation()); }
void VoxelField::setSpheres( float phase ) { setAllValues( -0.5f ); float x = 0.3 * getSizeX() * sin(phase*0.1) + 0.5 * getSizeX(); float y = 0.3 * getSizeY() * cos(phase*0.2) + 0.5 * getSizeY(); float z = 0.3 * getSizeZ() * sin(1+phase*0.15) + 0.5 * getSizeZ(); float rad = getSizeX() / 3; addSphere( x, y, z, rad ); addSphere( y, z, x, rad ); addSphere( z, x, y, rad ); addSphere( z, y, x, rad ); addSphere( y, x, z, rad ); addSphere( x, z, y, rad ); }
TPZString TPZNetworkSquareMidimew :: asString() const { TPZGlobalData& data = ((TPZSimulation*)getSimulation())->globalData((TPZNetwork*)this); TPZString rs= "SquareMidimew("; rs += TPZString(getSizeX()) + "," + TPZString(getSizeY()) + "," + TPZString(getSizeZ()) + ")" + "\n Buffer control : " + data.routerBufferControl() + "\n Routing control: " + data.routerRoutingControl(); return rs; }
ome::compat::array<dimension_size_type, 3> FormatWriter::getZCTCoords(dimension_size_type index) const { assertId(currentId, true); return ome::bioformats::getZCTCoords(getDimensionOrder(), getSizeZ(), getEffectiveSizeC(), getSizeT(), getImageCount(), index); }
dimension_size_type FormatWriter::getIndex(dimension_size_type z, dimension_size_type c, dimension_size_type t) const { assertId(currentId, true); return ome::bioformats::getIndex(getDimensionOrder(), getSizeZ(), getEffectiveSizeC(), getSizeT(), getImageCount(), z, c, t); }
void Gameboard::draw(GLuint texture[], float animPos, float plantAnimPos) { UpdateSquareScreenCoordinate(); house.draw(texture, getSizeZ() * 100, getSizeZ() * 100 / 3, getSizeZ() * 100 / 3); //draw all Plants and Squares for (int i=0; i<squaresList.size(); i++) { //draw the board square squaresList[i].draw(texture); //check if the board square contain a plant if (squaresList.at(i).getPlant() != nullptr) { //check if the plant has enough HP if ((squaresList.at(i).getPlant())->getHp() > 0) { //draw the plant with the texture squaresList.at(i).getPlant()->draw(texture, plantAnimPos); }else { //erase the plant from the square squaresList.at(i).setPlant(nullptr); } } } //draw all zombies for (int j=0; j<zombiesList.size(); j++) { //check if the zombie has enough HP if (zombiesList[j]->takeDamages(0) && zombiesList[j]->getDespawn()<=0) { //delete the zombie from zombiesList zombiesList.erase(zombiesList.begin()+j); } else { //else draw the zombie with the texture zombiesList[j]->draw(texture, animPos); } } //draw all bullets shoot by peashooters for (int k=0; k<bulletsList.size(); k++) { //iterator int j=0; //check for each zombie //while the zombieslist is not empty AND do not collide with the bullet while (!zombiesList.empty() && !bulletsList.at(k).checkCollision(*zombiesList.at(j)) && j<zombiesList.size()-1 ) { //check next zombie j++; } //if there is still zombies if (!zombiesList.empty()) { //if there is a collision with a zombie OR a the border if (bulletsList.at(k).checkCollision(*zombiesList.at(j)) || bulletsList.at(k).getPosition().getX()>sizeX*BoardSquare::size) { //erase the bullet bulletsList.erase(bulletsList.begin() + k); }else { //draw the bullet bulletsList.at(k).draw(texture); } } //if there is no zombie left else { //if the bullet collide with the border if (bulletsList.at(k).getPosition().getX()>sizeX*BoardSquare::size) { //erase the bullet bulletsList.erase(bulletsList.begin() + k); }else { //draw the bullet bulletsList.at(k).draw(texture); } } } UpdateSunScreenCoordinate(); //draw all suns for (int l=0; l<sunList.size(); l++) { //if the sun has not reached his despawn time if (sunList[l].getDespawn() > 0) { //draw the sun sunList[l].draw(texture); } //if has reached else { //erase the sun sunList.erase(sunList.begin()+l); } } }
dimension_size_type FormatWriter::getImageCount() const { return getSizeZ() * getSizeT() * getEffectiveSizeC(); }
void CCylinder::drawHapticScene(bool primary_context) { hlMaterialf(HL_FRONT_AND_BACK, HL_STIFFNESS, m_stiffness); hlMaterialf(HL_FRONT_AND_BACK, HL_DAMPING, m_dampening); hlMaterialf(HL_FRONT_AND_BACK, HL_STATIC_FRICTION, m_static_friction); hlMaterialf(HL_FRONT_AND_BACK, HL_DYNAMIC_FRICTION, m_dynamic_friction); if ( !m_customRendered ) { if(primary_context) hlBeginShape(HL_SHAPE_FEEDBACK_BUFFER, m_shapeID); else hlBeginShape(HL_SHAPE_FEEDBACK_BUFFER, m_shapeID_1); drawGLScene(); hlEndShape(); } else { // Draw cylinder section if(primary_context) hlBeginShape(HL_SHAPE_CALLBACK, m_shapeID ); else hlBeginShape(HL_SHAPE_CALLBACK, m_shapeID_1 ); hlCallback(HL_SHAPE_INTERSECT_LS, (HLcallbackProc) CHapticCylinder::intersectSurface, (void *) customCylinder); hlCallback(HL_SHAPE_CLOSEST_FEATURES, (HLcallbackProc) CHapticCylinder::closestSurfaceFeatures, (void *) customCylinder); hlEndShape(); // Draw disk A if(primary_context) hlBeginShape(HL_SHAPE_CALLBACK, diskAShape->GetShapeID () ); else hlBeginShape(HL_SHAPE_CALLBACK, diskAShape->GetShapeID_1 ()); diskATrans->makeIdentity (); diskATrans->multRight ( hduMatrix::createRotation ( 1, 0, 0, 0.5*PI ) ); diskATrans->multRight ( hduMatrix::createTranslation ( 0, 0, 0.5 ) ); diskATrans->multRight ( hduMatrix::createScale ( getSizeX(), getSizeY(), getSizeZ() ) ); diskATrans->multRight ( getHduMatrix ( getRotation () ) ); diskATrans->multRight ( hduMatrix::createTranslation ( getLocationX(), getLocationY(), getLocationZ () ) ); hlCallback(HL_SHAPE_INTERSECT_LS, (HLcallbackProc) CHapticDisk::intersectSurface, (void *) diskA); hlCallback(HL_SHAPE_CLOSEST_FEATURES, (HLcallbackProc) CHapticDisk::closestSurfaceFeatures, (void *) diskA); hlEndShape(); // Draw disk B if(primary_context) hlBeginShape(HL_SHAPE_CALLBACK, diskBShape->GetShapeID () ); else hlBeginShape(HL_SHAPE_CALLBACK, diskBShape->GetShapeID_1 ()); diskBTrans->makeIdentity (); diskBTrans->multRight ( hduMatrix::createRotation ( 1, 0, 0, -0.5*PI ) ); diskBTrans->multRight ( hduMatrix::createTranslation ( 0, 0, -0.5 ) ); diskBTrans->multRight ( hduMatrix::createScale ( getSizeX(), getSizeY(), getSizeZ() ) ); diskBTrans->multRight ( getHduMatrix ( getRotation () ) ); diskBTrans->multRight ( hduMatrix::createTranslation ( getLocationX(), getLocationY(), getLocationZ () ) ); hlCallback(HL_SHAPE_INTERSECT_LS, (HLcallbackProc) CHapticDisk::intersectSurface, (void *) diskB); hlCallback(HL_SHAPE_CLOSEST_FEATURES, (HLcallbackProc) CHapticDisk::closestSurfaceFeatures, (void *) diskB); hlEndShape(); } }