bool SimInterior::onAdd() { if (Parent::onAdd() == false) return false; set(renderImage.transform, true); if (m_pFilename) { const char* pFilename = m_pFilename; m_pFilename = NULL; processArguments(1, (const char**)&pFilename); setState(m_currentState); } updateBoundingBox(); return true; }
void PCD8544::drawchar(uint8_t x, uint8_t y, char c) { if (y >= LCDHEIGHT) return; if ((x+5) >= LCDWIDTH) return; for (uint8_t i =0; i<5; i++ ) { uint8_t d = pgm_read_byte(font+(c*5)+i); for (uint8_t j = 0; j<8; j++) { if (d & _BV(j)) { my_setpixel(x+i, y+j, textcolor); } else { my_setpixel(x+i, y+j, !textcolor); } } } for (uint8_t j = 0; j<8; j++) { my_setpixel(x+5, y+j, !textcolor); } updateBoundingBox(x, y, x+5, y + 8); }
/** * @brief cwScreenCaptureManager::capturedImage * @param image */ void cwCaptureViewport::capturedImage(QImage image, int id) { Q_UNUSED(id) Q_ASSERT(CapturingImages); QPointF origin = IdToOrigin.value(id); QGraphicsItemGroup* parent = previewCapture() ? PreviewItem : Item; cwGraphicsImageItem* graphicsImage = new cwGraphicsImageItem(parent); graphicsImage->setImage(image); graphicsImage->setPos(origin); parent->addToGroup(graphicsImage); //For debugging tiles // QRectF tileRect = QRectF(origin, image.size()); // QGraphicsRectItem* rectItem = new QGraphicsRectItem(parent); // rectItem->setPen(QPen(Qt::red)); // rectItem->setRect(tileRect); // QGraphicsSimpleTextItem* textItem = new QGraphicsSimpleTextItem(parent); // textItem->setText(QString("Id:%1").arg(id)); // textItem->setPen(QPen(Qt::red)); // textItem->setPos(tileRect.center()); NumberOfImagesProcessed++; if(NumberOfImagesProcessed == Rows * Columns) { //Finished capturing images NumberOfImagesProcessed = 0; Rows = 0; Columns = 0; CapturingImages = false; if(previewCapture()) { updateBoundingBox(); } emit finishedCapture(); } }
// the most basic function, set a single pixel void PCF8814::drawPixel(int16_t x, int16_t y, uint16_t color) { if ((x < 0) || (x >= _width) || (y < 0) || (y >= _height)) return; int16_t t; switch (rotation) { case 1: t = x; x = y; y = LCD_Y_RES - 1 - t; break; case 2: x = LCD_X_RES - 1 - x; y = LCD_Y_RES - 1 - y; break; case 3: t = x; x = LCD_X_RES - 1 - y; y = t; break; } if ((x < 0) || (x >= LCD_X_RES) || (y < 0) || (y >= LCD_Y_RES)) return; uint8_t temp = lcd_memory[x][y / 8]; switch (color) { case BLACK: SetBit(temp, y % 8); // Включаем пиксел break; case WHITE: ClearBit(temp, y % 8); // Выключаем пиксел break; case INVERSE: InvBit(temp, y % 8); // Инвертируем пиксел break; } lcd_memory[x][y / 8] = temp; // Передаем байт в видеобуфер updateBoundingBox(x, y, x, y); }
// bresenham's algorithm - thx wikpedia void ST7565::drawline(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1, uint8_t color) { uint8_t steep = abs(y1 - y0) > abs(x1 - x0); if (steep) { swap(x0, y0); swap(x1, y1); } if (x0 > x1) { swap(x0, x1); swap(y0, y1); } // much faster to put the test here, since we've already sorted the points updateBoundingBox(x0, y0, x1, y1); uint8_t dx, dy; dx = x1 - x0; dy = abs(y1 - y0); int8_t err = dx / 2; int8_t ystep; if (y0 < y1) { ystep = 1; } else { ystep = -1;} for (; x0<=x1; x0++) { if (steep) { my_setpixel(y0, x0, color); } else { my_setpixel(x0, y0, color); } err -= dy; if (err < 0) { y0 += ystep; err += dx; } } }
/** * @brief cwCaptureViewport::updateScaleForItems * * This updates the scale for QGraphicsItems (Preview Item and the Full resolution item) */ void cwCaptureViewport::updateTransformForItems() { double meterToPaperUnit = cwUnits::convert(1.0, cwUnits::Meters, PaperUnit); if(CaptureCamera->projection().type() == cwProjection::Ortho) { ItemScale = ScaleOrtho->scale() * (1.0 / CaptureCamera->pixelsPerMeter()) * (meterToPaperUnit); } double paperWidth = viewport().size().width() * ItemScale; setPaperWidthOfItem(paperWidth); if(previewItem() != nullptr) { updateTransformForItem(previewItem(), ItemScale); updateBoundingBox(); } if(fullResolutionItem() != nullptr) { double hiResScale = paperSizeOfItem().width() / (ItemScale * resolution() * viewport().width()); updateTransformForItem(fullResolutionItem(), hiResScale); fullResolutionItem()->setPos(previewItem()->pos()); } }
// draw a circle outline void ST7565::drawcircle(uint8_t x0, uint8_t y0, uint8_t r, uint8_t color) { updateBoundingBox(x0-r, y0-r, x0+r, y0+r); int8_t f = 1 - r; int8_t ddF_x = 1; int8_t ddF_y = -2 * r; int8_t x = 0; int8_t y = r; my_setpixel(x0, y0+r, color); my_setpixel(x0, y0-r, color); my_setpixel(x0+r, y0, color); my_setpixel(x0-r, y0, color); while (x<y) { if (f >= 0) { y--; ddF_y += 2; f += ddF_y; } x++; ddF_x += 2; f += ddF_x; my_setpixel(x0 + x, y0 + y, color); my_setpixel(x0 - x, y0 + y, color); my_setpixel(x0 + x, y0 - y, color); my_setpixel(x0 - x, y0 - y, color); my_setpixel(x0 + y, y0 + x, color); my_setpixel(x0 - y, y0 + x, color); my_setpixel(x0 + y, y0 - x, color); my_setpixel(x0 - y, y0 - x, color); } }
void LCDfillcircle(uint8_t x0, uint8_t y0, uint8_t r, uint8_t color) { updateBoundingBox(x0-r, y0-r, x0+r, y0+r); int8_t f = 1 - r; int8_t ddF_x = 1; int8_t ddF_y = -2 * r; int8_t x = 0; int8_t y = r; uint8_t i; for (i=y0-r; i<=y0+r; i++) { my_setpixel(x0, i, color); } while (x<y) { if (f >= 0) { y--; ddF_y += 2; f += ddF_y; } x++; ddF_x += 2; f += ddF_x; for ( i=y0-y; i<=y0+y; i++) { my_setpixel(x0+x, i, color); my_setpixel(x0-x, i, color); } for ( i=y0-x; i<=y0+x; i++) { my_setpixel(x0+y, i, color); my_setpixel(x0-y, i, color); } } }
void Potion::update(const double dt_){ const int angle = 360 - 45; const double gravity = 35; updateBoundingBox(); this->animation->update(this->animationClip, dt_); const std::array<bool, CollisionSide::SOLID_TOTAL> detections = detectCollision(); handleCollision(detections); if(this->activated){ this->getAnimation()->changeAnimation(0, 0, 1, false, 0); this->flightTime +=dt_; const double speedXIdk = (this->distance/300.0)*(this->vx + this->strength * cos(angle/57.29) * flightTime); const double speedYIdk = (this->vy + this->strength * sin(angle/57.29) * flightTime - 0.5*gravity*flightTime*flightTime); if(this->isRight){ this->x += speedXIdk; } else{ this->x -= speedXIdk; } this->y -= speedYIdk; } else{ if(this->canExplode){ this->getAnimation()->changeAnimation(1, 0, 12, false, 0.8); this->canExplode = false; } if(this->getAnimation()->getCurrentFrame() == 12){ this->isExploding =false; } } }
void _C::selfUpdate(){ cloudsPathCam.update(); rotation += spinSlider->getScaledValue(); ofCamera& cam = getCameraRef(); jtn::TreeNode::terminals.clear(); vector<jtn::TreeNode*>::iterator it; for(it=rootNodes.begin();it!=rootNodes.end();it++){ (*it)->update(); } // these are separate because children are born in the previous update calls // and we want to catch them all for(it=jtn::TreeNode::all.begin();it!=jtn::TreeNode::all.end();it++){ (*it)->updateScreenSpace(cam); } updateBoundingBox(); axonThickness = axonThicknessSlider->getScaledValue(); dotSize = dotSizeSlider->getScaledValue(); alpha = alphaSlider->getScaledValue(); sway = swaySlider->getScaledValue(); nodeMax = nodeMaxSlider->getScaledValue(); rootCount = rootCountSlider->getScaledValue(); danceAmp = danceAmpSlider->getScaledValue(); danceFreq = danceFreqSlider->getScaledValue(); danceOffset = danceOffsetSlider->getScaledValue(); }
// copy of above function for list<>. // todo: make this a templated function bool basicEffect::bindWithShapes(list<basicShape *>& _shapes){ if(_shapes.size()==0) return false; bool success = true; for(auto _shape=_shapes.cbegin(); _shape!=_shapes.cend(); ++_shape){ if( *_shape == NULL ){ success = false; continue; } // prevent adding the same shape several times for(auto it=shapes.begin(); it!=shapes.end(); ++it){ if( *_shape == *it ) continue; // already exists } //shapes.push_back( *_shape ); shapes.insert(shapes.end(), *_shape); } updateBoundingBox(); return success; }
void Mesh::LoadFromFile(string & pFilePath) { ifstream file(pFilePath.c_str()); string line, id; vector <vec3> objVertices; vector <vec2> objUvs; vector <vec3> objNormals; vector <uvec3> objFaces; vector <vec3> finalVertices; vector <vec2> finalUvs; vector <vec3> finalNormals; vector <uvec3> finalFaces; while (getline(file, line)) { if (line.empty()) { continue; } stringstream data(line); data >> id; if (id == "v") { vec3 v; data >> v.x >> v.y >> v.z; objVertices.push_back(v); updateBoundingBox(v); } if (id == "vn") { vec3 vn; data >> vn.x >> vn.y >> vn.z; objNormals.push_back(vn); }
// the most basic function, set a single pixel void Adafruit_PCD8544::drawPixel(int16_t x, int16_t y, uint16_t color) { if ((x < 0) || (x >= _width) || (y < 0) || (y >= _height)) return; int16_t t; switch(rotation){ case 1: t = x; x = y; y = LCDHEIGHT - 1 - t; break; case 2: x = LCDWIDTH - 1 - x; y = LCDHEIGHT - 1 - y; break; case 3: t = x; x = LCDWIDTH - 1 - y; y = t; break; } if ((x < 0) || (x >= LCDWIDTH) || (y < 0) || (y >= LCDHEIGHT)) return; // Flip screen (Ulf 2013-01-08) x = LCDWIDTH-1-x; // x is which column if (color) pcd8544_buffer[x+ (y/8)*LCDWIDTH] |= _BV(y%8); else pcd8544_buffer[x+ (y/8)*LCDWIDTH] &= ~_BV(y%8); updateBoundingBox(x,y,x,y); }
Magic3D::XMLElement* Magic3D::Model::load(XMLElement* root) { if (root) { XMLElement* model = root->FirstChildElement(M3D_MODEL_XML); std::string name = loadString(model, M3D_MODEL_XML_FILE); if (name.compare(M3D_XML_NULL) != 0) { setFileName(name); } if (getSkeleton()) { getSkeleton()->load(model); } } Object::load(root); updateBoundingBox(); return root; }
//----------------------------------------------------------------------- const AxisAlignedBox& BillboardChain::getBoundingBox(void) const { updateBoundingBox(); return mAABB; }
void Item::update( int dT ) { pos += vel * dT / 1000.0; updateBoundingBox(); timeLived += dT; }
void QtGLComponent::addVertex(const QVector3D& vertex) { m_vertices.append(vertex); updateBoundingBox(vertex); }
Sphere::Sphere(Vector3& center, float radius) { setCenter(center); setRadius(radius); updateBoundingBox(); }
void Trophy::updatePosition() { mPosition = mMesh->mInitPosition; mPosition = mMesh->getTransform() * mMesh->getRotationTransform() * mPosition; updateBoundingBox(); }
SpineDrawable::SpineDrawable(const std::string& atlasFile, const std::string& skeletonFile): Component(TYPE) { atlas = spAtlas_createFromFile(atlasFile.c_str(), 0); if (!atlas) { ouzel::Log(ouzel::Log::Level::ERR) << "Failed to load atlas"; return; } if (skeletonFile.find(".json") != std::string::npos) { // is json format spSkeletonJson* json = spSkeletonJson_create(atlas); skeletonData = spSkeletonJson_readSkeletonDataFile(json, skeletonFile.c_str()); if (!skeletonData) { ouzel::Log(ouzel::Log::Level::ERR) << "Failed to load skeleton: " << json->error; return; } spSkeletonJson_dispose(json); } else { // binary format spSkeletonBinary* binary = spSkeletonBinary_create(atlas); skeletonData = spSkeletonBinary_readSkeletonDataFile(binary, skeletonFile.c_str()); if (!skeletonData) { ouzel::Log(ouzel::Log::Level::ERR) << "Failed to load skeleton: " << binary->error; return; } spSkeletonBinary_dispose(binary); } bounds = spSkeletonBounds_create(); skeleton = spSkeleton_create(skeletonData); animationStateData = spAnimationStateData_create(skeletonData); animationState = spAnimationState_create(animationStateData); animationState->listener = listener; animationState->rendererObject = this; spSkeleton_setToSetupPose(skeleton); spSkeleton_updateWorldTransform(skeleton); updateMaterials(); updateBoundingBox(); indexBuffer = std::make_shared<ouzel::graphics::Buffer>(*ouzel::engine->getRenderer()); indexBuffer->init(ouzel::graphics::Buffer::Usage::INDEX, ouzel::graphics::Buffer::DYNAMIC); vertexBuffer = std::make_shared<ouzel::graphics::Buffer>(*ouzel::engine->getRenderer()); vertexBuffer->init(ouzel::graphics::Buffer::Usage::VERTEX, ouzel::graphics::Buffer::DYNAMIC); whitePixelTexture = ouzel::engine->getCache().getTexture(ouzel::TEXTURE_WHITE_PIXEL); updateHandler.updateHandler = std::bind(&SpineDrawable::handleUpdate, this, std::placeholders::_1); ouzel::engine->getEventDispatcher().addEventHandler(&updateHandler); }
// clear everything void Adafruit_PCD8544::clearDisplay(void) { memset(pcd8544_buffer, 0, LCDWIDTH*LCDHEIGHT/8); updateBoundingBox(0, 0, LCDWIDTH-1, LCDHEIGHT-1); cursor_y = cursor_x = 0; }
void guiTypeTextInput::updateText() { // don't append the selected number displayText.setText( name ); updateBoundingBox(); }
void Magic3D::Object::updateBoundingBox() { updateBoundingBox(true); }
//----------------------------------------------- void guiTypeToggle::updateText(){ displayText.setText( name ); labelWidth = displayText.getTextWidth(); updateBoundingBox(); }
// clear everything void ST7565::clear(void) { memset(st7565_buffer, 0, 1024); updateBoundingBox(0, 0, LCDWIDTH-1, LCDHEIGHT-1); }
void ViewerApp::setup( ) { // Read files Scene::Collada::Importer builder( m_db ); for(auto it=m_source_files.begin(); it!=m_source_files.end(); ++it) { std::cerr << "Parsing '" << (*it) << '\'' << std::endl; if( !builder.parse( *it ) ) { std::cerr << "Error parsing '" << (*it) << "'" << std::endl; } } if( m_auto_shader ) { Scene::Tools::generateShadersFromCommon( m_db, Scene::PROFILE_GLSL | Scene::PROFILE_GLES2 ); /* for( size_t i=0; i<m_db.library<Scene::Effect>().size(); i++ ) { Scene::Effect* e = m_db.library<Scene::Effect>().get( i ); std::cerr << "Generating GLSL and GLES2 profiles for '" << e->id() << '\'' << std::endl; e->generate( Scene::PROFILE_GLSL ); e->generate( Scene::PROFILE_GLES2 ); } */ } if( m_auto_flatten ) { for( size_t i=0; i<m_db.library<Scene::Geometry>().size(); i++ ) { Scene::Geometry* g = m_db.library<Scene::Geometry>().get( i ); if( g->hasSharedInputs() ) { std::cerr << "Flattening '" << g->id() << '\'' << std::endl; g->flatten(); } } } Scene::Tools::updateBoundingBoxes( m_db ); std::cerr << "Import done." << std::endl; updateCameraInstances(); // Create application camera m_app_camera = m_db.library<Scene::Camera>().add( "app_camera" ); if( m_app_camera == NULL ) { std::cerr << "Failed to create application camera.\n"; } else { m_app_camera_node = m_db.library<Scene::Node>().add( "app_camera_node" ); if( m_app_camera_node == NULL ) { std::cerr << "Failed to create application camera node.\n"; } else { m_app_camera_node->addInstanceCamera( "", "app_camera" ); m_app_camera_node->addInstanceCamera( "", "app_camera" ); #ifdef USE_MATRIX m_app_camera_node->transformAdd( "matrix" ); #else m_app_camera_node->transformAdd( "lookat" ); #endif if( m_stereo ) { m_app_camera_node->transformAdd( "translate" ); } } } m_slave_camera = m_db.library<Scene::Camera>().add( "slave_camera" ); m_slave_camera_node = m_db.library<Scene::Node>().add( "slave_camera_node" ); m_slave_camera_node->addInstanceCamera( "", "slave_camera" ); m_slave_camera_node->transformAdd( "lookat" ); // Browse through visual scenes. All visual scenes with a 'setup'-prefix // is rendered, and all visual scenes with a 'onscreen'-prefix is added // to the 'render mode' list. m_onscreen_visual_scenes.clear(); for(size_t i=0; i<m_db.library<Scene::VisualScene>().size(); i++ ) { Scene::VisualScene* vs = m_db.library<Scene::VisualScene>().get( i ); std::cerr << vs->id() << "\n"; if( vs->evaluateScenes() == 0 ) { std::cerr << "Visual scene '" << vs->id() << "' doesn't have an evaluate block, adding a default.\n"; Scene::Node* root = m_db.library<Scene::Node>().get( vs->nodesId() ); root->addInstanceNode( "", "", "app_camera_node", "" ); root->addInstanceLight( "my_light", "" ); Scene::EvaluateScene* es = vs->addEvaluateScene(); es->setEnabled( true ); Scene::Render* ri = es->addRenderItem(); ri->setCameraNodeId( "app_camera_node" ); } std::string scene_id = m_db.library<Scene::VisualScene>().get(i)->id(); if( scene_id.substr( 0, 5 ) == "setup" ) { m_renderlist.build( scene_id ); m_renderlist.render( ); } else /*if( scene_id.substr( 0, 8 ) == "onscreen" )*/ { m_onscreen_visual_scenes.push_back( scene_id ); } } if( !m_onscreen_visual_scenes.empty() ) { m_onscreen_scene = m_onscreen_scene % m_onscreen_visual_scenes.size(); m_renderlist.build( m_onscreen_visual_scenes[ m_onscreen_scene ] ); } else { m_onscreen_scene = 0; } updateBoundingBox(); }
void Adafruit_PCD8544::begin(uint8_t contrast, uint8_t bias) { if (isHardwareSPI()) { // Setup hardware SPI. SPI.begin(); SPI.setClockDivider(PCD8544_SPI_CLOCK_DIV); SPI.setDataMode(SPI_MODE0); SPI.setBitOrder(MSBFIRST); } else { // Setup software SPI. // Set software SPI specific pin outputs. pinMode(_din, OUTPUT); pinMode(_sclk, OUTPUT); // Set software SPI ports and masks. clkport = portOutputRegister(digitalPinToPort(_sclk)); clkpinmask = digitalPinToBitMask(_sclk); mosiport = portOutputRegister(digitalPinToPort(_din)); mosipinmask = digitalPinToBitMask(_din); } // Set common pin outputs. pinMode(_dc, OUTPUT); if (_rst > 0) pinMode(_rst, OUTPUT); if (_cs > 0) pinMode(_cs, OUTPUT); // toggle RST low to reset if (_rst > 0) { digitalWrite(_rst, LOW); delay(500); digitalWrite(_rst, HIGH); } // get into the EXTENDED mode! command(PCD8544_FUNCTIONSET | PCD8544_EXTENDEDINSTRUCTION ); // LCD bias select (4 is optimal?) command(PCD8544_SETBIAS | bias); // set VOP if (contrast > 0x7f) contrast = 0x7f; command( PCD8544_SETVOP | contrast); // Experimentally determined // normal mode command(PCD8544_FUNCTIONSET); // Set display to Normal command(PCD8544_DISPLAYCONTROL | PCD8544_DISPLAYNORMAL); // initial display line // set page address // set column address // write display data // set up a bounding box for screen updates updateBoundingBox(0, 0, LCDWIDTH-1, LCDHEIGHT-1); // Push out pcd8544_buffer to the Display (will show the AFI logo) display(); }
void PhysicsObject::setRotation(float heading) { staticRotation = heading; updateBoundingBox(); }
void PhysicsObject::setSize(const ofVec3f& newSize) { size = newSize; sizeDirty = true; updateBoundingBox(); }
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; }