virtual void execute (CCtrlBase * /* pCaller */, const string &/* Params */)
	{
		CInterfaceManager *pIM = CInterfaceManager::getInstance();
		if(pIM == NULL) return;
		CEntityCL *selection = EntitiesMngr.entity(UserEntity->selection());

		// If mode Combat (no talk, no give, no mount)
		if(UserEntity->mode()==MBEHAV::COMBAT
		|| UserEntity->mode()==MBEHAV::COMBAT_FLOAT)
		{
			return; // Cant mount
		}
		// Mount
		else if(UserEntity->isRiding())
		{
			// We are currently mounted so unmount
			pIM->runActionHandler("context_unseat",NULL);
		}
		// Not in combat mode.
		else
		{
			// check if we can mount
			if ((selection) && (selection->properties().mountable()))
			{
				CVectorD vect1 = selection->pos();
				CVectorD vect2 = UserEntity->pos();
				double distanceSquare = pow(vect1.x-vect2.x,2) + pow(vect1.y-vect2.y,2);
				if(distanceSquare <= MaxTalkingDistSquare)
				{
					// Ok lets mount
					pIM->runActionHandler("context_mount",NULL);
				}
			}
		}
	}
コード例 #2
0
ファイル: scene_parser.cpp プロジェクト: AzyxWare/ryzom
//-----------------------------------------------
// updateActors :
// Update Actors.
//-----------------------------------------------
void CSceneParser::updateActors()
{
	// All actors in the scene.
	for(map<uint, CActor>::iterator itActor = _Actors.begin(); itActor != _Actors.end(); ++itActor)
	{
		// Get a reference on the actor.
		CActor &actor = (*itActor).second;

		// If there is no actor to follow -> next actor.
		if(actor.Actor < 0)
			continue;

		// Get the entity pointer.
		CEntityCL *entity = getEntity(Sid(Sid::npc, (uint64)actor.Id));
		if(!entity)
		{
			nlwarning("CSceneParser::updateActors : Cannot get the actor %d.", actor.Id);
			continue;
		}

		// Get the target entity pointer.
		CEntityCL *entityTarget = getEntity(Sid(Sid::npc, (uint64)actor.Actor));
		if(!entityTarget)
		{
			nlwarning("CSceneParser::updateActors : Cannot get the targeted actor %d.", actor.Actor);
			continue;
		}

		// Changes the entity position.
		entity->pacsPos(entityTarget->pos());
	}
}// updateActors //
コード例 #3
0
ファイル: view_radar.cpp プロジェクト: AzyxWare/ryzom
// ----------------------------------------------------------------------------
void CViewRadar::draw ()
{
	CInterfaceManager *pIM = CInterfaceManager::getInstance();
	CViewRenderer &rVR = pIM->getViewRenderer();

	CEntityCL *user = EntitiesMngr.entity(0);
	if (user == NULL) return;

	CVectorD xyzRef = user->pos();
	const CVector dir = user->front();

	float angle = (float)(atan2(dir.y, dir.x) - (Pi / 2.0));
	CMatrix mat;
	mat.identity();
	// Scale to transform from world to interface screen
	mat.scale( CVector((float)(_WReal / _WorldSize), (float)(_HReal / _WorldSize), 1) );
	// local to user
	mat.rotateZ(-angle);
	xyzRef.z = 0;
	mat.translate(-xyzRef);

	float	maxSqrRadius= (float)sqr(_WorldSize/2);

	for (sint32 i = 1; i < 256; ++i)
	{
		CEntityCL *entity = EntitiesMngr.entity(i);
		if (entity == NULL) continue;

		// if the entity must not be shown in radar
		if(!entity->getDisplayInRadar())
			continue;

		// get entity pos
		CVectorD xyz = entity->pos();

		xyz.z = 0;
		// if the distance is too big so do not display the entity
		if ((sqr(xyz.x - xyzRef.x)+sqr(xyz.y - xyzRef.y)) > maxSqrRadius) continue;

		// Transform the dot
		xyz = mat * xyz;

		// Convert to screen
		sint32 x = OptFastFloor((float)xyz.x);
		sint32 y = OptFastFloor((float)xyz.y);

		CRGBA col = entity->getColor();

		if(getModulateGlobalColor())
			col.modulateFromColor (col, pIM->getGlobalColorForContent());
		else
			col.A = (uint8)(((sint32)col.A*((sint32)pIM->getGlobalColorForContent().A+1))>>8);

		// Select the icon to display and draw it
		uint spotId = CNPCIconCache::getInstance().getNPCIcon(entity).getSpotId();
		CRadarSpotDesc spotDesc = _SpotDescriptions[spotId];

		if (!_MissionIconsObs._displayMissionSpots)
			spotDesc = _SpotDescriptions[0];

		if (spotDesc.isMissionSpot)
			col = CRGBA(255, 255, 255, 255);

		if (entity->isTarget())
			spotId = 4; // to make it over other spots

		// Draw it (and make sure mission icons are drawn over regular dot; caution: don't exceed the render layer range)
		if (spotDesc.isMissionSpot && _MiniMissionSpotsObs._displayMiniMissionSpots)
			rVR.drawRotFlipBitmap (_RenderLayer+spotId, _XReal+x-(spotDesc.MTxW/2)+(_WReal/2), _YReal+y-(spotDesc.MTxH/2)+(_HReal/2),
								spotDesc.MTxW, spotDesc.MTxH, 0, false, spotDesc.MiniTextureId, col );
		else
			rVR.drawRotFlipBitmap (_RenderLayer+spotId, _XReal+x-(spotDesc.TxW/2)+(_WReal/2), _YReal+y-(spotDesc.TxH/2)+(_HReal/2),
							spotDesc.TxW, spotDesc.TxH, 0, false, spotDesc.TextureId, col );
	}
}
コード例 #4
0
// Constructor for moving object, it not create entity (mesh, skeleton) but build animation on pre-exist entity
CAnimatedSceneObject::CAnimatedSceneObject( const CEntityId& Id, const list < std::string >& Animations )
{
    _Id = Id;
    _ObjectName = "";
    _ClusterIG = "";
    _MeshName = "";
    _SkeletonName = "";
    _Distance = 0;

    _Skeleton = NULL;
    _Instance = NULL;

    CEntityCL *entity = getEntity(Id);
    if(entity)
    {
        _Skeleton = *entity->skeleton();
        _Transform = _Skeleton;

        _Position = _Skeleton->getPos();
        _Rotation = _Skeleton->getRotQuat();

        // create play list manager and animation set
        _PlayListManager = Scene->createPlayListManager();
        _AnimationSet = Driver->createAnimationSet();

        //fill animation set
        for( list< string >::const_iterator its = Animations.begin(); its != Animations.end(); ++its )
        {
            uint idAnim;
            try
            {
                idAnim = _AnimationSet->addAnimation( ( *its + string(".anim") ).c_str(), (*its).c_str() );
            }
            catch(Exception &)
            {
                idAnim = UAnimationSet::NotFound;
                if( idAnim == UAnimationSet::NotFound)
                {
                    nlwarning( "CAnimatedSceneObject::CAnimatedSceneObject Animation %s not found for entity CEntityId(%u,%f)", (*its).c_str(), Id.Type, (double)(sint64)Id.Id );
                    continue;
                }
            }
            _MapAnimation.insert( make_pair( *its, idAnim ) );
        }

        // build animation set
        _AnimationSet->build();

        // create playlist
        _PlayList = _PlayListManager->createPlayList( _AnimationSet );

        _Status = SAnimationStatus();
        _Status.SequenceAnim = 1;
        _Status.ApplyDisplacement = 1;

        // register skeleton in playlist
        _PlayList->registerTransform( *entity->skeleton() );

        // Snap to ground(the snap check if it's a flyer).
        entity->pacsPos(_Position);
        entity->snapToGround();
        _Position = entity->pos();

        CMatrix current;
        current.identity ();
        current.setRot (_Rotation);

        // Rotation 90 degrees
        CMatrix rot90;
        rot90.identity ();
        rot90.rotateZ (-(float)Pi/2);
        current *= rot90;

        _Transform->unfreezeHRC();

        _Transform->setPos(_Position);
        _Transform->setRotQuat(current.getRot());

        _Transform->freezeHRC();

        _IdAnimationPlayed = -1;

        if( _Id.Type == RYZOMID::npc )
        {
            sendEndSequenceMessage( _Id, 1 );
        }
    }
    else
    {
        _PlayList = NULL;
        _AnimationSet = NULL;
        _PlayListManager = NULL;
    }
}
コード例 #5
0
ファイル: scene_parser.cpp プロジェクト: AzyxWare/ryzom
//-----------------------------------------------
// updateParticlesActor :
//
//-----------------------------------------------
void CSceneParser::updateParticlesActor(float difTime, CParticle &particle, UAnimation &animation)
{
	// Get the entity pointer.
	CEntityCL *entity = getEntity(Sid(Sid::npc, (uint64)particle.Actor));
	if(!entity)
	{
		nlwarning("CSceneParser::updateParticlesActor : cannot get the actor %d.", (uint64)particle.Actor);
		return;
	}

	// If the entity has no skeleton -> Next particle.
	if(!entity->skeleton())
	{
		nlwarning("The particle follow an entity %d without a skeleton.", (uint64)particle.Actor);
		return;
	}

	// Matrix 90°
	CMatrix m90;
	m90.identity();
	m90.rotateZ((float)(Pi/2.0));

	// Matrix of the entity.
	CMatrix mChar = entity->skeleton()->getMatrix();
	mChar.setPos(entity->pos());

	// Animate all instances.
	for(uint i = 0; i < particle.IGPtr->getNumInstance(); ++i )
	{
		std::string iName = particle.IGPtr->getInstanceName(i);
		UInstance instance = particle.IGPtr->getByName(iName);

		if(!instance)
			continue;

		instance->setTransformMode(UTransformable::RotQuat);

		CMatrix mAnim;
		mAnim.identity();
		// If the animation has no track of position.
		UTrack* trackPos = animation.getTrackByName("PathPos");
		if(!trackPos)
			trackPos = animation.getTrackByName(string(iName + "." + "PathPos").c_str());
		if(trackPos)
		{
			CVector pos;
			trackPos->interpolate(difTime, pos);
			mAnim.setPos(pos);
		}

		// If the animation has no track of rotation.
		UTrack* trackRot = animation.getTrackByName("PathRotQuat");
		if(!trackRot)
			trackRot = animation.getTrackByName(string(iName + "." + "PathRotQuat").c_str());
		if(trackRot)
		{
			CQuat rot;
			trackPos->interpolate(difTime, rot);
			mAnim.setRot(rot);
		}

		CMatrix mFinal = mChar * m90 * mAnim;
		instance->setPos(mFinal.getPos());
		instance->setRotQuat(mFinal.getRot());
	}
}// updateParticlesActor //
コード例 #6
0
ファイル: group_html_webig.cpp プロジェクト: AzyxWare/ryzom
void addWebIGParams (string &url, bool trustedDomain)
{
	if(!UserEntity || !NetMngr.getLoginCookie().isValid()) return;

	uint32 cid = NetMngr.getLoginCookie().getUserId() * 16 + PlayerSelectedSlot;
	url += ((url.find('?') != string::npos) ? "&" : "?") +
		string("shardid=") + toString(CharacterHomeSessionId) +
		string("&name=") + UserEntity->getLoginName().toUtf8() +
		string("&lang=") + CI18N::getCurrentLanguageCode() +
		string("&datasetid=") + toString(UserEntity->dataSetId()) +
		string("&ig=1");
	if (trustedDomain)
	{
		url += string("&cid=") + toString(cid) +
		string("&authkey=") + getWebAuthKey();
		
		if (url.find('$') != string::npos)
		{
			strFindReplace(url, "$gender$", GSGENDER::toString(UserEntity->getGender()));
			strFindReplace(url, "$displayName$", UserEntity->getDisplayName().toString());
			strFindReplace(url, "$posx$", toString(UserEntity->pos().x));
			strFindReplace(url, "$posy$", toString(UserEntity->pos().y));
			strFindReplace(url, "$posz$", toString(UserEntity->pos().z));
			strFindReplace(url, "$post$", toString(atan2(UserEntity->front().y, UserEntity->front().x)));
			
			// Target fields
			const char *dbPath = "UI:VARIABLES:TARGET:SLOT";
			CInterfaceManager *im = CInterfaceManager::getInstance();
			CCDBNodeLeaf *node = im->getDbProp(dbPath, false);
			if (node && (uint8)node->getValue32() != (uint8) CLFECOMMON::INVALID_SLOT)
			{
				CEntityCL *target = EntitiesMngr.entity((uint) node->getValue32());
				if (target)
				{
					strFindReplace(url, "$tdatasetid$", toString(target->dataSetId()));
					strFindReplace(url, "$tdisplayName$", target->getDisplayName().toString());
					strFindReplace(url, "$tposx$", toString(target->pos().x));
					strFindReplace(url, "$tposy$", toString(target->pos().y));
					strFindReplace(url, "$tposz$", toString(target->pos().z));
					strFindReplace(url, "$tpost$", toString(atan2(target->front().y, target->front().x)));
					strFindReplace(url, "$tsheet$", target->sheetId().toString());
					string type;
					if (target->isFauna())
						type = "fauna";
					else if (target->isNPC())
						type = "npc";
					else if (target->isPlayer())
						type = "player";
					else if (target->isUser())
						type = "user";
					strFindReplace(url, "$ttype$", target->sheetId().toString());
				}
				else
				{
					strFindReplace(url, "$tdatasetid$", "");
					strFindReplace(url, "$tdisplayName$", "");
					strFindReplace(url, "$tposx$", "");
					strFindReplace(url, "$tposy$", "");
					strFindReplace(url, "$tposz$", "");
					strFindReplace(url, "$tpost$", "");
					strFindReplace(url, "$tsheet$", "");
					strFindReplace(url, "$ttype$", "");
				}
			}
		}
	}
}