//=========================================================================== bool cCamera::set(const cVector3d& a_localPosition, const cVector3d& a_localLookAt, const cVector3d& a_localUp) { // copy new values to temp variables cVector3d pos = a_localPosition; cVector3d lookAt = a_localLookAt; cVector3d up = a_localUp; cVector3d Cy; // check validity of vectors if (pos.distancesq(lookAt) < CHAI_SMALL) { return (false); } if (up.lengthsq() < CHAI_SMALL) { return (false); } // compute new rotation matrix pos.sub(lookAt); pos.normalize(); up.normalize(); up.crossr(pos, Cy); if (Cy.lengthsq() < CHAI_SMALL) { return (false); } Cy.normalize(); pos.crossr(Cy,up); // update frame with new values setPos(a_localPosition); cMatrix3d localRot; localRot.setCol(pos, Cy, up); setRot(localRot); // return success return (true); }
void PhysicsNode::readXml(const Xml *xml) { Node::readXml(xml); float mass = 0.0f; int body_type = BODY_BOX; xml->getChildData("body", body_type); xml->getChildData("mass", mass); xml->getChildData("render_body", render_body); xml->getChildData("object_2d", object_2d); body->setBody(BodyType(body_type)); body->setMass(mass); const Xml *transform = xml->getChild("init_transform"); if (transform != NULL) { transform->getArg("pos", init_pos); transform->getArg("rot", init_rot); transform->getArg("scale", init_scale); do_invalidate_matrix = false; setPos(init_pos); setRot(init_rot); setScale(init_scale); do_invalidate_matrix = true; invalidateMatrix(); } invalidate(); }
void CameraNode::setRollAngle(float value) { camera.ang.y = value; doInvalidateMatrix = false; setRot(-camera.getRot(), true); doInvalidateMatrix = true; }
Beam::Beam( Vec2 lc, Vec2 at, BEAMTYPE beamtype, int base_index, int ene, int shooter_id, int client_id, int internal_id ) : Char( CAT_BEAM, lc, g_base_deck, g_char_layer, client_id, internal_id ), type(beamtype), ene(ene), shooter_id(shooter_id) { switch(beamtype) { case BEAMTYPE_NORMAL: v = lc.to(at).normalize( BEAM_NORMAL_VEL ); clean_at = 1; setIndex( base_index ); break; case BEAMTYPE_BLASTER: clean_at = 0.5; v = lc.to(at).normalize( BEAM_BLASTER_VEL ); break; } setRot(atan2( v.y, v.x )); setColor(WHITE); updateIndex(); tex_epsilon = DEFAULT_TEX_EPS; hitsz = 3 + (float)(ene/16); if( isLocal() ) realtimeNewBeamSend(this); }
Hex::Hex() { float yOff = 0.5f; float xOff = sqrtf(3)/2.0f; mesh.addVertex(ofVec3f(0.0f, 0.0f, 0.0f)); mesh.addVertex(ofVec3f(xOff, -yOff, 0.0f)); mesh.addVertex(ofVec3f(xOff, yOff, 0.0f)); mesh.addVertex(ofVec3f(0.0f, 1.0f, 0.0f)); mesh.addVertex(ofVec3f(-xOff, yOff, 0.0f)); mesh.addVertex(ofVec3f(-xOff, -yOff, 0.0f)); mesh.addVertex(ofVec3f(0.0f, -1.0f, 0.0f)); mesh.addVertex(ofVec3f(xOff, -yOff, 0.0f)); mesh.setMode(ofPrimitiveMode::OF_PRIMITIVE_TRIANGLE_FAN); color = ofColor(1.0f); for(int i = 0; i < 8; i++) { mesh.addColor(color); mesh.addIndex(i); } setPos(0,0,0); setRot(0,0,0); setScale(1.0,1.0,1.0); }
LLMatrix3::LLMatrix3(const F32 angle, const LLVector3d &vec) { LLVector3 vec_f; vec_f.setVec(vec); LLQuaternion quat(angle, vec_f); setRot(quat); }
PacketMotion::PacketMotion(int8_t x, int8_t y, int8_t z, int8_t rot) { setX(x); setY(y); setZ(z); setRot(rot); mCurrentField = 0; }
void MQObject::drawFront( Vector eye, Vector dir, Vector rot, double x, double y, double size ) { Vector dirV = Vector( dir.z ,0, -dir.x);// Vector( sin((rot.y+90)*PI/180), 0, cos((rot.y+90)*PI/180) ); rot.y += 180; setPosition( eye.x + dir.x*size + dirV.x*x, eye.y + y, eye.z + dir.z * size + dirV.z*x ); setRot( rot ); draw(); }
void Actor::detach() { if (_attachedActor != NULL) { _attachedJoint = ""; // FIXME: Use last known position of attached joint setPos(_attachedActor->_pos); setRot(0,0,0); _attachedActor = NULL; } }
void free_camera::rotate_right(float angle) { quatf rot; vec3f axis = m_up; normalize(axis); setRot(rot, AxisAnglef(angle, axis)); m_lookat_pt = xform<float>(m_lookat_pt, rot, m_lookat_pt-m_eye_pos) + m_eye_pos; apply(); }
void free_camera::rotate_up(float angle) { quatf rot; vec3f axis; cross(axis, m_up, vec3f(m_lookat_pt-m_eye_pos)); normalize(axis); setRot(rot, AxisAnglef(angle, axis)); m_lookat_pt = xform<float>(m_lookat_pt, rot, m_lookat_pt-m_eye_pos) + m_eye_pos; m_up = xform<float>(m_up, rot, m_up); apply(); }
void Player::setMountObject (GameBase *object, int in_mountPoint) { if(mount) clearNotify(mount); setMaskBits(MountMask); mount = object; mountPoint = in_mountPoint; if(mount) { deleteNotify(mount); TMat3F tmat; mount->getObjectMountTransform(mountPoint, &tmat); if (!mountPoint) { Point3F rot = getRot (); tmat.set (EulerF (rot.x, rot.y, rot.z), tmat.p); } setTransform(tmat); EulerF angles; tmat.angles(&angles); if (mountPoint < 1) setRot (Point3F (0, 0, angles.z)); else if (mountPoint == 1) setRot (Point3F (0, 0, 0)); else { Point3F rot = getRot (); rot.z -= angles.z; setRot (rot); } setImageTriggerUp(0); setLinearVelocity (Point3F (0, 0, 0)); } }
void CameraNode::update(float dt) { if (target != NULL) { camera.update(target->getPos(true), true); } else { camera.update(vec3(), false); } doInvalidateMatrix = false; setRot(-camera.getRot(), true); setPos(camera.pos, true); doInvalidateMatrix = true; }
void PhysicsNode::restore() { do_invalidate_matrix = false; setPos(init_pos); setRot(init_rot); setScale(init_scale); do_invalidate_matrix = true; do_init_state = false; invalidateMatrix(); do_init_state = true; body->clearVelocity(); body->clearOmega(); }
void PhysicsNode::getBodyMatrix() { vec3 p = body->getPos(); quat r = body->getRot(); if(r != rot || p != pos) { do_invalidate_matrix = false; setRot(r, true); setPos(p, true); do_invalidate_matrix = true; Node::invalidateMatrix(); } }
Item::Item( ITEM_ID id, Vector position, double yPos ):cnt(0) { setPosition( position ); setRadius( 50 ); itemID = id; switch ( id ) { case I_PUMPKIN: setModel( modelMap["pumpkin"] ); rotSpeed = 0; pos.y = 40; break; case I_PORTION: setModel( modelMap["portion"] ); rotSpeed = 30.0/(double)FPS; pos.y = 160; break; case I_KEY: keyCnt ++; if ( keyCnt == 3 ) setModel( modelMap["key_g"] ); else setModel( modelMap["key_s"] ); rotSpeed = 40.0/(double)FPS; setRot( 90, 0, 0 ); pos.y = 180; break; case I_PUMPKIN_BOSS: setModel( modelMap["pumpkin_boss"] ); rotSpeed = 0; pos.y = 40; setRadius( 100 ); break; default: cout << "未知のアイテム" << endl; break; } if ( yPos < 0 ) { pos.y = yPos; } if ( (id == I_PUMPKIN || id == I_PUMPKIN_BOSS )&& pos.y < yPos ) { pos.y = yPos + pos.y; } }
void Actor::attachToActor(Actor *other, const char *joint) { assert(other != NULL); if (other == _attachedActor) return; if (_attachedActor != NULL) detach(); EMICostume * cost = static_cast<EMICostume *>(other->getCurrentCostume()); assert(cost != NULL); Common::String jointStr = joint ? joint : ""; // If 'other' has a skeleton, check if it has the joint. // Some models (pile o' boulders) don't have a skeleton, // so we don't make the check in that case. if (cost->_emiSkel && cost->_emiSkel->_obj) assert(cost->_emiSkel->_obj->hasJoint(jointStr)); _attachedActor = other; _attachedJoint = jointStr; setPos(Math::Vector3d(0,0,0)); setRot(0,0,0); }
/// \todo ÜBERARBEITEN!! setZufall & co. DiaNeuesWst::DiaNeuesWst(QWidget *parent) : QDialog(parent), ui(new Ui::DiaNeuesWst) { ui->setupUi(this); //default-Einstellungen des Dialogs this->farbe = COL_ROT; this->dicke = WSTK_GUT; this->bohrung = true; this->anzahl = 1; this->anzahlZuf = 1;// ui->dsbAnteilFehlerhafte->setValue(ANTEIL_AUSSCHUSS); connect(this->ui->cbBohrung, SIGNAL(toggled(bool)), this, SLOT(setBohrung(bool))); connect(this->ui->rbSchwarz, SIGNAL(clicked()), this, SLOT(setSchwarz())); connect(this->ui->rbRot, SIGNAL(clicked()), this, SLOT(setRot())); connect(this->ui->rbMetall, SIGNAL(clicked()), this, SLOT(setMetall())); connect(this->ui->rb23mm, SIGNAL(clicked()), this, SLOT(setDuenn())); connect(this->ui->rb25mm, SIGNAL(clicked()), this, SLOT(setNormal())); connect(this->ui->rb27mm, SIGNAL(clicked()), this, SLOT(setDick())); connect(this->ui->buErstellen, SIGNAL(clicked()), this, SLOT(accept())); connect(this->ui->buVerwerfen, SIGNAL(clicked()), this, SLOT(reject())); connect(this->ui->buErstellen_2, SIGNAL(clicked()), this, SLOT(accept())); connect(this->ui->buVerwerfen_2, SIGNAL(clicked()), this, SLOT(reject())); connect(this->ui->tabWidget, SIGNAL(currentChanged(int)), this, SLOT(setZufall(int))); connect(this->ui->sbAnzahlZuf, SIGNAL(valueChanged(int)), this,SLOT(setAnzahlZuf(int))); connect(this->ui->sbAnzahl, SIGNAL(valueChanged(int)), this,SLOT(setAnzahl(int))); setZufall(ui->tabWidget->currentIndex()); connect(ui->cbAutoRefill, SIGNAL(clicked()), this, SLOT(cbAutoRefillClicked())); connect(ui->sbBefTimeout, SIGNAL(valueChanged(int)), this, SLOT(setTimeoutRefill(int))); cbAutoRefillClicked(); }
//========================================================== // Name : // Desc : 車の動き //========================================================== void CObj3dCar::move() { D3DXVECTOR3 ang = getRot(); D3DXVECTOR3 pos = getPos(); ang.y += _angVel * dt; if(boostCounter != 0) { boostCounter--; _vel = maxVel*2; } pos.x += sinf(ang.y) * _vel; pos.z += cosf(ang.y) * _vel; //pos.z += setRot(ang); setPos(pos); //camera(); }
LLMatrix3::LLMatrix3(const F32 angle, const F32 x, const F32 y, const F32 z) { LLVector3 vec(x, y, z); LLQuaternion quat(angle, vec); setRot(quat); }
void setRot(const Scalar x, const Scalar y, const Scalar z, const Scalar w) { setRot(Quat(x, y, z, w)); }
void setRot(const Quat *v) { setRot(*v); }
bool Beam::charPoll( double dt ) { // Shifter tile bends beam Cell *c = g_fld->get(loc); if( c->gt == GT_SHIFTER && c->st == ST_NONE && c->bt == BT_AIR ) { Vec2 dv = dirToVec2(c->dir) * PPC* SHIFTER_ACCEL; v += dv * dt; if( v.len() > BEAM_NORMAL_VEL ) { v = v.normalize(BEAM_NORMAL_VEL); } setRot( atan2(v.y,v.x)); // print("v:%f %f dv:%f %f d:%d",v.x,v.y, dv.x, dv.y, c->dir ); } loc += v * dt; // Stronger is bigger float s = PPC; if( ene >= 64 ) s *= 3; else if( ene >= 16 ) s *= 2; else if( ene >= 4 ) s *= 1.5; setScl(s); // Shoot on blocks Vec2 rt,lt,rb,lb; Cell *rtc = g_fld->get( rt = loc + Vec2(hitsz,hitsz)); Cell *ltc = g_fld->get( lt = loc + Vec2(-hitsz,hitsz)); Cell *rbc = g_fld->get( rb = loc + Vec2(hitsz,-hitsz)); Cell *lbc = g_fld->get( lb = loc + Vec2(-hitsz,-hitsz)); Cell *tgtc = NULL; Vec2 tgtat; Vec2 candat[4]; Cell *cands[4]; int candi=0; // if(rtc&&rtc->isBeamHit() && rtc->isImmutableAgainstBeam()==false ) { cands[candi] = rtc; candat[candi] = rt; candi++; } if(rbc&&rbc->isBeamHit() && rbc->isImmutableAgainstBeam()==false ) { cands[candi] = rbc; candat[candi] = rb; candi++; } if(ltc&<c->isBeamHit() && ltc->isImmutableAgainstBeam()==false ) { cands[candi] = ltc; candat[candi] = lt; candi++; } if(lbc&&lbc->isBeamHit() && lbc->isImmutableAgainstBeam()==false ) { cands[candi] = lbc; candat[candi] = lb; candi++; } if( candi > 0 ) { int ind = irange(0,candi); tgtc = cands[ind]; tgtat = candat[ind]; } // Out of the world if(!rtc)return false; if( rtc && rtc->gt == GT_JUNGLE && range(0,100) < 1 ) { createLeafEffect(loc); } updateIndex(); if( isRemote() ) return true; if(tgtc) { int consumed; BLOCKTYPE orig_bt = tgtc->bt; if( g_fld->damage(tgtat,ene,&consumed,this) ) { createSparkEffect(); if( orig_bt == BT_CELL || orig_bt == BT_FLYGEN ) { soundPlayAt(g_wormdamage_sound,loc,1); } else if( orig_bt != BT_SNOW && orig_bt != BT_IVY && orig_bt != BT_TREE && orig_bt != BT_BOMBFLOWER ) { soundPlayAt(g_beamhithard_sound,loc,1); } if( orig_bt == BT_BARRIER && tgtc->hyper_count > 0 ) { Vec2 tgt; if( g_fld->findEnemyAttackTarget(loc,&tgt, MACHINE_SHOOT_DISTANCE ) ) { int n = irange(1,4); for(int i=0;i<n;i++) Bullet::shootAt( BLT_SPARIO, loc, tgt ); } } ene -= consumed; if( ene <= 0 ) return false; else return true; } } else { // Immutable cells Cell *cells[4]; g_fld->getCorner4( loc, 1, &cells[0], &cells[1], &cells[2], &cells[3] ); for(int i=0;i<4;i++) { if(cells[i] && cells[i]->isImmutableAgainstBeam()) { soundPlayAt(g_beamhithard_sound,loc,1); createSparkEffect(); return false; } } } if( type == BEAMTYPE_BLASTER ) { float s = PPC; g_fld->meltSnow(loc + Vec2(-s,-s) ); g_fld->meltSnow(loc + Vec2(-s,s) ); g_fld->meltSnow(loc + Vec2(s,-s) ); g_fld->meltSnow(loc + Vec2(s,s) ); } else { if( range(0,100) < (float)(ene)/2.0 ) { g_fld->meltSnow(loc); } } // Shoot on enemies Char *cur = (Char*) g_char_layer->prop_top; while(cur) { if( cur->isEnemyCategory() ) { Enemy *e = (Enemy*) cur; if( e->hitWithFlyHeight(this,PPC/2) && e->beam_hits ) { int dmg = ene; if( dmg > e->hp ) dmg = e->hp; e->notifyHitBeam(this, dmg); createSparkEffect(); // ene -= dmg; if(ene<=0) to_clean = true; g_fld->meltSnow(loc); } } else if( cur->category == CAT_PC ) { // recharging other player characters PC *pc = (PC*) cur; if( pc->hit(this,PPC/2)) { // print("pcid:%d shooter:%d ene:%d/%d", pc->id, shooter_id, pc->ene, pc->maxene ); if( pc->id != shooter_id && shooter_id == g_pc->id ) { // print("PC:E:%d id:%d max:%d", pc->ene, pc->id, pc->maxene ); int charged = pc->charge(ene); if(charged>0) { pc->energy_chain_heat_count ++; // print("sending E-chain e:%d(%d>%d) to: %d-%d heat:%d", // ene, charged, pc->ene, pc->client_id, pc->internal_id ,pc->energy_chain_heat_count ); realtimeEnergyChainSend(pc,charged); return false; } } } } cur = (Char*) cur->next; } return true; }
void Billboard::update(Camera *cam) { Quaternion rot = cam->getRot(); rot = rot*Quaternion(rot.getUp(), pi); setRot(rot)->updateTransform(); }
void Hero::manageState() { switch( state ) { case H_NONE: stateManager++; justAtack = false; if ( stateManager == H_FRAME_SPAN_STEP ) { if ( 0 < step ) { step = 0; } } break; case H_ATACK: stateManager ++; if ( stateManager == 1 ) atack( step ); if ( stateManager == H_FRAME_SPAN_ATACK ) { step ++; setState(H_NONE); } break; case H_DAMAGE: stateManager++; if ( stateManager == H_FRAME_SPAN_DAMAGE ) { if ( HP <= 0 ) setState( H_DEAD ); else setState( H_NONE ); } break; case H_DEAD: stateManager++; if ( stateManager == 1 ) { glMatrixMode( GL_PROJECTION ); glLoadIdentity(); gluPerspective(120.0,App::getAspect(), App::getZNear(), App::getZFar()); glMatrixMode( GL_MODELVIEW ); } if ( stateManager == H_FRAME_SPAN_DEAD ) { glMatrixMode( GL_PROJECTION ); glLoadIdentity(); gluPerspective(60.0,App::getAspect(), App::getZNear(), App::getZFar() ); glMatrixMode( GL_MODELVIEW ); vanish(); } if ( stateManager < H_FRAME_SPAN_DEAD/2 ) setRot( rot.x, rot.y + 3, rot.z ); else setRot( rot.x, rot.y + 6, rot.z ); direct = Vector( sin(rot.y*PI/180), 0, cos( rot.y*PI/180) ); break; case H_GUARD: stateManager ++; break; case H_CHARGE: break; default: printf("unexpected hero state\n"); break; } }
const LLMatrix3& LLMatrix3::setRot(const F32 angle, const LLVector3 &vec) { setRot(LLQuaternion(angle, vec)); return *this; }
LLMatrix3::LLMatrix3(const LLQuaternion &q) { setRot(q); }
LLMatrix3::LLMatrix3(const F32 angle, const LLVector4 &vec) { LLQuaternion quat(angle, vec); setRot(quat); }
void Camera::rotate(Scalar a)//fix for 2d { setRot(getRot()+a); }
LLMatrix3::LLMatrix3(const F32 roll, const F32 pitch, const F32 yaw) { setRot(roll,pitch,yaw); }