void RDirNode::move(float dt) { //the root node is the centre of the world if(parent == 0) { pos = vec2f(0.0f, 0.0f); return; } //initial position if(!empty() && !position_initialized) { setInitialPosition(); } pos += accel * dt; if(gGourceElasticity>0.0f) { vec2f diff = (accel - prev_accel); float m = dt * gGourceElasticity; vec2f accel3 = prev_accel * (1.0f-m) + diff * m; pos += accel3; prev_accel = accel3; } //accel = accel * std::max(0.0f, (1.0f - dt*10.0f)); accel = vec2f(0.0, 0.0); }
void BoneVertex::readFromFile(FILE *fp, float scale) { char nameCurrent[512]; float posx, posy, posz; float angle; float axisx, axisy, axisz; readString(fp, nameCurrent); posx = readFloat(fp) * scale; posy = readFloat(fp) * scale; posz = readFloat(fp) * scale; angle = readFloat(fp); axisx = readFloat(fp); axisy = readFloat(fp); axisz = readFloat(fp); setName(nameCurrent); setInitialPosition(posx, posy, posz); setInitialRotation(angle, axisx, axisy, axisz); int cpt = readInt(fp); // Number of children for (int i=0; i<cpt; i++) { BoneVertex *tmp = new BoneVertex(); addChild(tmp); tmp->readFromFile(fp); } compileChildList(); }
//---------- Start/Pause/Reset buttons ----------// void Controller::on_startButton_toggled(bool checked) { if (checked) { runFlag = 1; if (ui->modeTabs->currentIndex() == 0) ui->simpgaits->setEnableGaitButtons(0); else if (ui->modeTabs->currentIndex() == 1) ui->advgaits->activateTabs(0); activateTabs(0); setInitialPosition(); timer->start(); snakeRunning = std::thread(&Controller::runSnake, this); } }
OrganicRoadPattern::OrganicRoadPattern() : RoadLSystem() { setAxiom("[[[-_E]+_E]_E]++_E"); // Rules addRule('E', "[[-_E]+_E]_E"); // addRule('E', "[[-_E]+_E]"); // addRule('E', "_E"); setInitialPosition(Point(0,0)); setInitialDirection(Vector(1,0)); setTurnAngle(60, 90); }
void Controller::on_resetButton_toggled(bool checked) { if (checked) { msecElapsed = 0; if (runFlag) { runFlag = 0; if (ui->modeTabs->currentIndex() == 0) ui->simpgaits->setEnableGaitButtons(1); else if (ui->modeTabs->currentIndex() == 1) ui->advgaits->activateTabs(1); activateTabs(1); snakeRunning.join(); timer->invalidate(); } if (ui->modeTabs->currentIndex() == 0) ui->simpgaits->switch2Home(1); else ui->advgaits->resetParams(); setInitialPosition(); } }
void ofxGamepadCamera::setInitialPosition(float x, float y, float z) { setInitialPosition(ofVec3f(x, y, z)); }
void Creature::onHitTheGround() { setInitialPosition(getRoot().getRigidBody()->getCenterOfMassPosition()); }