Exemplo n.º 1
0
void Tank::deathEffects(){
	Teline3List *tell = w->getTeline3d();

	Vec3d gravity = w->accel(this->pos, this->velo);
	if(tell){
		int j;
		for(j = 0; j < 20; j++){
			Vec3d velo(
				150. * (w->rs.nextd() - .5),
				150. * (w->rs.nextd() - .5),
				150. * (w->rs.nextd() - .5));
			AddTeline3D(tell, this->pos, velo, .0025, quat_u, vec3_000, gravity,
				j % 2 ? COLOR32RGBA(255,255,255,255) : COLOR32RGBA(255,191,63,255), TEL3_HEADFORWARD | TEL3_FADEEND | TEL3_REFLECT, 1. + .5 * w->rs.nextd());
		}
/*			for(j = 0; j < 10; j++){
			double velo[3];
			velo[0] = .025 * (drseq(&gsrs) - .5);
			velo[1] = .025 * (drseq(&gsrs));
			velo[2] = .025 * (drseq(&gsrs) - .5);
			AddTefpol3D(w->tepl, pt->pos, velo, gravity, &cs_firetrail,
				TEP3_REFLECT | TEP_THICK | TEP_ROUGH, 3. + 1.5 * drseq(&gsrs));
		}*/

		{/* explode shockwave thingie */
			AddTeline3D(tell, this->pos, vec3_000, 100., Quatd::rotation(M_PI * 0.5, 1, 0, 0), vec3_000, vec3_000, COLOR32RGBA(255,191,63,255), TEL3_EXPANDISK/*/TEL3_EXPANDTORUS*/ | TEL3_NOLINE, 1.);
#if 0 // Scorch mark should be rendered in ground's rendering pass.
			if(pt->pos[1] <= 0.) /* no scorch in midair */
				AddTeline3D(tell, pt->pos, NULL, .01, pyr, NULL, NULL, COLOR32RGBA(0,0,0,255), TEL3_STATICDISK | TEL3_NOLINE, 20.);
#endif
		}

		WarSpace *ws = *w;
		if(ws->gibs && model){
			int m = model->n;
			int n = m <= TANK_MAX_GIBS ? m : TANK_MAX_GIBS;
			int base = m <= TANK_MAX_GIBS ? 0 : w->rs.next() % m;
			for(int i = 0; i < n; i++){
				j = (base + i) % m;
				Vec3d velo(
					this->velo[0] + (w->rs.nextd() - .5) * 100.,
					this->velo[1] + (w->rs.nextd() - .5) * 100.,
					this->velo[2] + (w->rs.nextd() - .5) * 100.);
				Vec3d omg(
					3. * 2 * M_PI * (w->rs.nextd() - .5),
					3. * 2 * M_PI * (w->rs.nextd() - .5),
					3. * 2 * M_PI * (w->rs.nextd() - .5));
				AddTelineCallback3D(ws->gibs, this->pos, velo, 10., quat_u, omg, gravity, gib_draw, (void*)j, TEL3_NOLINE | TEL3_REFLECT, 1.5 + w->rs.nextd());
			}
		}
	}
}
Exemplo n.º 2
0
	//Xボタンハンドラ
	void Player::OnPushX() {
		auto XAPtr = App::GetApp()->GetXAudio2Manager();
		XAPtr->Start(L"cursor");

		auto Ptr = GetComponent<Transform>();
		Vec3 Pos = Ptr->GetPosition();
		Pos.y += 0.3f;
		Quat Qt = Ptr->GetQuaternion();
		Vec3 Rot = Qt.toRotVec();
		float RotY = Rot.y;
		Vec3 velo(sin(RotY), 0.05f, cos(RotY));
		velo.normalize();
		velo *= 20.0f;
		auto Group = GetStage()->GetSharedObjectGroup(L"ShellGroup");
		for (size_t i = 0; i < Group->size(); i++) {
			auto shptr = dynamic_pointer_cast<ShellSphere>(Group->at(i));
			if (shptr && !shptr->IsUpdateActive()) {
				//空きが見つかった
				shptr->Reset(Pos, velo);
				return;
			}
		}
		//ここまで来てれば空きがない
		GetStage()->AddGameObject<ShellSphere>(Pos, velo);
	}
Exemplo n.º 3
0
 void System::addBall(int nn, float4 center, float radius, bool scaled, float4 color, float mass)
 {
     float scale = 1.0f;
     vector<float4> sphere = addSphere(nn, center, radius, spacing, scale);
     float4 velo(0, 0, 0, 0);
     pushParticles(sphere,velo,color, mass);
 }
Exemplo n.º 4
0
 //----------------------------------------------------------------------
 int System::addBox(int nn, float4 min, float4 max, bool scaled, float4 color, float mass)
 {
     float scale = 1.0f;
     vector<float4> rect = addRect(nn, min, max, spacing, scale);
     float4 velo(0, 0, 0, 0);
     pushParticles(rect, velo, color, mass);
     return rect.size();
 }
Exemplo n.º 5
0
void M3Truck::deathEffects(){
	Teline3List *tell = w->getTeline3d();

	Vec3d gravity = w->accel(this->pos, this->velo);
	if(tell){
		int j;
		for(j = 0; j < 20; j++){
			Vec3d velo(
				150. * (w->rs.nextd() - .5),
				150. * (w->rs.nextd() - .5),
				150. * (w->rs.nextd() - .5));
			AddTeline3D(tell, this->pos, velo, 2.5, quat_u, vec3_000, gravity,
				j % 2 ? COLOR32RGBA(255,255,255,255) : COLOR32RGBA(255,191,63,255), TEL3_HEADFORWARD | TEL3_FADEEND | TEL3_REFLECT, 1. + .5 * w->rs.nextd());
		}

		/* explode shockwave thingie */
		AddTeline3D(tell, this->pos, vec3_000, 100., Quatd::rotation(M_PI * 0.5, 1, 0, 0), vec3_000, vec3_000, COLOR32RGBA(255,191,63,255), TEL3_EXPANDISK/*/TEL3_EXPANDTORUS*/ | TEL3_NOLINE, 1.);
	}
}
void DetourCrowdComponent::update( dtCrowd* crowd)
{
	if( m_pendingAddToSim )
	{
		addBackToSim();
		return;
	}
	const dtCrowdAgent* ag = crowd->getAgent(m_crowdId);
	if( ag->active && m_isInCrowd )
	{
		const float* pos = ag->npos;
		const float* vel = ag->vel;
		Vec3f velo( vel[0], vel[1], vel[2] );
		Vec3f veloRot = velo.toRotation();
		
		// Scenegraph expects degree, Bullet radians. This should be fixed in those components.
		// Rotate: degree (Scenegraph)
		float yrot = radToDeg(veloRot.y);
		yrot -= 180.f;
		// Rotate: radian (Bullet Physics)
		//float yrot = veloRot.y - Math::Pi;

		//const float* trans = GameEngine::getEntityTransformation(m_owner->worldId());

		// The entity travels on the navigation mesh.
		GameEngine::setEntityTranslation( m_owner->worldId(), pos[0], pos[1] + m_yOffset, pos[2] );
		GameEngine::setEntityRotation( m_owner->worldId(), 0, yrot, 0);

		Vec3f tpos(ag->targetPos[0],ag->targetPos[1],ag->targetPos[2]);
		Vec3f vpos(ag->npos[0],ag->npos[1],ag->npos[2]);
		Vec3f curEntityToTargetVec =  tpos - vpos;

		if( curEntityToTargetVec.length() < m_targetRadius )
		{
			// Target reached. Remove from sim and add obstacle.
			tempRemoveFromSim();
			GameEvent targetReachedEv( GameEvent::E_TARGET_REACHED, 0, 0 );
			GameEngine::sendEvent( m_worldId, &targetReachedEv );
		}
	}
}
Exemplo n.º 7
0
void EventData::write(Xml& xml) const
      {
      switch(_type) {
            case ME_NOTE:
                  xml.tagE(QString("note  tick=\"%1\" channel=\"%2\" len=\"%3\" pitch=\"%4\" velo=\"%5\"")
                     .arg(_ontime).arg(_channel).arg(_duration).arg(pitch()).arg(velo()));
                  break;

            case ME_NOTEON:
                  xml.tagE(QString("note-on  tick=\"%1\" channel=\"%2\" pitch=\"%3\" velo=\"%4\"")
                     .arg(_ontime).arg(_channel).arg(pitch()).arg(velo()));
                  break;

            case ME_NOTEOFF:
                  xml.tagE(QString("note-off  tick=\"%1\" channel=\"%2\" pitch=\"%3\" velo=\"%4\"")
                     .arg(_ontime).arg(_channel).arg(pitch()).arg(velo()));
                  break;

            case ME_CONTROLLER:
                  if (controller() == CTRL_PROGRAM) {
                        if ((_ontime == -1) && (_channel == 0)) {
                              xml.tagE(QString("program value=\"%1\"").arg(value()));
                              }
                        else {
                              xml.tagE(QString("program tick=\"%1\" channel=\"%2\" value=\"%3\"")
                                 .arg(ontime()).arg(channel()).arg(value()));
                              }
                        }
                  else {
                        if ((ontime() == -1) && (channel() == 0)) {
                              xml.tagE(QString("controller ctrl=\"%1\" value=\"%2\"")
                                 .arg(controller()).arg(value()));
                              }
                        else {
                              xml.tagE(QString("controller tick=\"%1\" channel=\"%2\" ctrl=\"%3\" value=\"%4\"")
                                 .arg(ontime()).arg(channel()).arg(controller()).arg(value()));
                              }
                        }
                  break;

            case ME_SYSEX:
                  xml.stag(QString("sysex tick=\"%1\" len=\"%2\"").arg(ontime()).arg(_len));
                  xml.dump(_len, _data);
                  xml.etag();
                  break;

            case ME_META:
                  switch(metaType()) {
                        case META_TRACK_NAME:
                              xml.tag(QString("TrackName tick=\"%1\"").arg(ontime()), QString((char*)(data())));
                              break;

                        case META_LYRIC:
                              xml.tag(QString("Lyric tick=\"%1\"").arg(ontime()), QString((char*)(data())));
                              break;

                        case META_KEY_SIGNATURE:
                              {
                              const char* keyTable[] = {
                                    "Ces", "Ges", "Des", "As", "Es", "Bes", "F",
                                    "C",
                                    "G", "D", "A", "E", "B", "Fis", "Cis"
                                    };
                              int key = (char)(_data[0]) + 7;
                              if (key < 0 || key > 14) {
                                    qDebug("bad key signature %d\n", key);
                                    key = 0;
                                    }
                              QString sex(_data[1] ? "Minor" : "Major");
                              QString keyName(keyTable[key]);
                              xml.tag(QString("Key tick=\"%1\" key=\"%2\" sex=\"%3\"").arg(ontime()).arg(_data[0]).arg(_data[1]),
                                 QString("%1 %2").arg(keyName).arg(sex));
                              }
                              break;

                        case META_TIME_SIGNATURE:
                              xml.tagE(QString("TimeSig tick=\"%1\" num=\"%2\" denom=\"%3\" metro=\"%4\" quarter=\"%5\"")
                                 .arg(ontime())
                                 .arg(int(_data[0]))
                                 .arg(int(_data[1]))
                                 .arg(int(_data[2]))
                                 .arg(int(_data[3])));
                              break;

                        case META_TEMPO:
                              {
                              unsigned tempo = _data[2] + (_data[1] << 8) + (_data[0] << 16);
                              xml.tagE(QString("Tempo tick=\"%1\" value=\"%2\"").arg(ontime()).arg(tempo));
                              }
                              break;

                        default:
                              xml.stag(QString("Meta tick=\"%1\" type=\"%2\" len=\"%3\" name=\"%4\"")
                                 .arg(ontime()).arg(metaType()).arg(_len).arg(midiMetaName(metaType())));
                              xml.dump(_len, _data);
                              xml.etag();
                              break;
                        }
                  break;
            }
      }
Exemplo n.º 8
0
bool MidiEventBase::isNoteOff() const
{
	return (type() == Note && (velo() == 0));
}
Exemplo n.º 9
0
    void PhysicsWorld::CheckCollisions()
    {
    //
    //  Note: detectors are called bodies here; bodies are called parents

        Detector *body, *antiBody;
        DetectorID id, antiID;
        PhysicsBodyObject *parent, *antiParent;
        BodyType type, antiType;
        bool isKine, antiIsKine;
        PhysicsBodyKinematic *kpar, *akpar;
        G3Vector velo, antiVelo;
        CollisionCombo combo;
        DetectType detected;
        ColPair* registered;
        bool flipRegister;
        G2Vector direction;
        RSKMAP_ITERATE( m_Bodies )
        {
            body = iter->second;
            if( !body->Active() )
                continue;
            parent = body->GetBody();
            type   = parent->Type();
            if( type == BodyType::Terrain ) // Let resters trigger terrain collision (small optimization)
                continue;
            isKine = type >= BodyType::Kinematic;
            id = body->GetID();
            for( auto antiIter = m_Bodies.Begin(); antiIter != end; ++antiIter )
            {
                antiBody = antiIter->second;
                if( !antiBody->Active() )
                    continue;
            //
            //  Check if they belong to the same parent
                antiParent = antiBody->GetBody();
                if( parent == antiParent )
                    continue;
            //
            //  Filter out unnecessary collisions (ex. a wall resting on the ground)
                antiType = antiBody->GetBodyType();
                combo    = type | antiType;
                if( FilterCollision( combo ) )
                    continue;
                antiIsKine = antiType >= BodyType::Kinematic;
            //
            //  Check if pair was already registered and skip if it was refreshed this frame
                antiID = antiBody->GetID();
                flipRegister = GetRegistered( registered, id, antiID );
                if( registered && registered->refreshed )
                    continue;
            //
            //  Check if boxes overlap. Get velocities for prediction first.
            //  Prediction lacks accuracy when frametime varies
            //  because it tries to predict next frame's motion using this frame's time.
                if( isKine )
                {
                    kpar = (PhysicsBodyKinematic*)parent;
                    velo( kpar->Velocity2D(), kpar->VelocityZ() );
                    velo *= m_FrameTime;
                }
                else
                    velo(ZOYAPHYSICS_PENETRATE_TOL);
                if( antiIsKine )
                {
                    akpar = (PhysicsBodyKinematic*)antiParent;
                    antiVelo( akpar->Velocity2D(), akpar->VelocityZ() );
                    antiVelo *= m_FrameTime;
                }
                else
                    antiVelo(ZOYAPHYSICS_PENETRATE_TOL);

                detected = body->Detect( m_FrameTime, antiBody, antiParent, antiType, velo, antiVelo );
                if( detected == DetectType::NotDetected )
                    continue;
            //
            //  Check if actual shapes overlap
                if( !body->DetectCollision( antiBody, G2Vector(velo.x,velo.y), G2Vector(antiVelo.x,antiVelo.y), direction ) )
                    continue;
            //
            //  Full collision, refresh registered pair or register new pair to be handled
                if( registered )
                {
                //  Pair may have been detected in the opposite order previously
                    if( flipRegister )
                    {
                        direction = -direction;
                        switch( detected )
                        {
                        case DetectType::RestOn:   detected = DetectType::RestedOn; break;
                        case DetectType::RestedOn: detected = DetectType::RestOn;   break;
                        }
                    }

                    registered->direction = direction;
                    registered->detected  = detected;
                    registered->refreshed = true;
                    registered->newpair   = false;
                    continue;
                }

                m_Pairs.Add( ColPairKey( id, antiID ),
                             ColPair( body, antiBody, combo, direction, detected ) );

            } // for anti

        } // iterate
    }