IrrNetLite and PhysX Controller Update (All PhysX Updates)

Announce new projects or updates of Irrlicht Engine related tools, games, and applications.
Also check the Wiki
Post Reply
sysgod
Posts: 2
Joined: Fri Jan 29, 2010 7:45 pm

IrrNetLite and PhysX Controller Update (All PhysX Updates)

Post by sysgod »

Hi! I need some info about IrrNetLite .

I have server based physics on NVIDIA Physx engine and i need to replicate object updates

but i have a server CRASH even when i update a character O_o

my crash code is here:

//from default packet handler
case EPT_CHAR_UPDATE: // sends when character physics updates //on client

char_update=0;
packet >> char_update;
ServerMessages=" Incoming For ID="+Ogre::StringConverter::toString(char_update);//debug text

player[char_update]->UpdateCharacter(deltatime);// "char_update" is right
// and text tells that packet not lost

break;
player[char_update] exists on server

I have the same packet handlers for input but they work fine.

If somebody worked with physX and irrnetlite? tell me please what are my errors?
Viz_Fuerte
Posts: 91
Joined: Sun Oct 19, 2008 5:29 pm
Location: Valencia (Spain)
Contact:

Post by Viz_Fuerte »

:shock:
ServerMessages=" Incoming For ID="+Ogre::StringConverter::toString(char_update);//debug text

BLASPHEMY !!!

These posting a code of Ogre on this forum!
:lol:

Now really, could you post more code? seems to be missing something.
sysgod
Posts: 2
Joined: Fri Jan 29, 2010 7:45 pm

IrrNetLite and PhysX Controller Update (All PhysX Updates)

Post by sysgod »

:roll:

update function:

Code: Select all

           void myPlayer::UpdateCharacter(NxReal deltaTime)
{
          

gworldRay.orig = NxVec3(this->actor->getGlobalPosition().x,this->actor->getGlobalPosition().y,this->actor->getGlobalPosition().z);
gworldRay.dir = NxVec3(0,-1,0);
gworldRay.dir.normalize();
this->actor->getShapes()[0]->setFlag(NX_SF_DISABLE_RAYCASTING, true);
NxShape * s = gScene->raycastClosestShape(gworldRay,NX_ALL_SHAPES, hit, 1, 50000.0f, NX_RAYCAST_SHAPE | NX_RAYCAST_DISTANCE);
this->actor->getShapes()[0]->setFlag(NX_SF_DISABLE_RAYCASTING, false);

	NxVec3 disp = NxVec3(0,-9.8/2,0);

	if (this->PxPushCharacter)
	{
		
		NxVec3 horizontalDisp = this->PxCharacterVec;
		horizontalDisp.y=hit.worldImpact.y;
		
		horizontalDisp.normalize();
		NxVec3 worldVec=this->actor->getGlobalOrientation()*this->PxCharacterVec;
		disp += worldVec * this->Speed * deltaTime;//horizontalDisp
	}

NxF32 height = GetHeight(deltaTime,this->id);
	if (height != hit.worldImpact.y)
	{
		disp.y += height;
	}
	NxU32 collisionFlags;
	this->PxSelectedController->Move(disp, collisionFlags);
	
	if (collisionFlags & NXCC_COLLISION_DOWN )  
		StopJump(this->id);
	
	this->PxManager->updateControllers();
}

Works fine on clients if I use it out of this :?

Code: Select all

virtual void handlePacket(net::SInPacket& packet)
	{
		// The packets will use a single char to store
		// the packet identifier, remember to use the
		// smallest possible datatype for storing your
		// packet identifiers. c8 is a typedef for char.
		c8 packetid;
		packet >> packetid;
        int playerID = packet.getPlayerId();

		// Here we will switch based on the packet id.
		switch((E_PACKET_TYPE)packetid)
		{
		case EPT_ROTATION:
			f32 angle;
			packet >> angle;
			player[playerID]->userInput(angle);
			//
			break;
		
		case EPT_INPUT:
			player[playerID]->userInput(packet);
			break;
		case EPT_CHAR_UPDATE:	
		
			 char_update=0;
			 packet >> char_update;
			 ServerMessages=" Incoming Update For ID="+Ogre::StringConverter::toString(char_update);
			break;
		}
   
	
	}
Idea to Update from player's packet grown in my "broken mind" after attemp to update all controllers in "for" loop as I did with rigid bodies...

second or 3rd idea was to make a loop with "if" searching a Online player slots

somthing like:
for bla..bla..bla
{
if (Online[ind]==1) player[ind]->UpdateCharacter(deltatime);
}
//endfor :)

No one moved....

then I do such a thing ... I added my Update function to the end of input ...and what do u think happens? Players move if I hold a key I can hold "Jump" and player updates but if i unhold key it stacks in air forever..

this is my Input function (for testing only):

Code: Select all

 void myPlayer::userInput(net::SInPacket& packet)
	{
		Real step;
		Vector3 WallRaYDirection;
		Vector3 PlayerOldPosition=this->plNode->getPosition();
//-----------------звуковые переменные-----------------
FMOD_VECTOR pl_pos, pl_vel, pl_forward, upvector;

upvector.x=0;
upvector.y=1;
upvector.z=0;

pl_vel.x=0;
pl_vel.y=0;
pl_vel.z=0;
//-----------------------------------------------------

        float elapsedTime=0.005;
		String AnimPose;
        

  Vector2 textpos;
  Ogre::MovableObject * SelectedNode;


            mRaySceneQuery2->setSortByDistance(true,1);
		    CEGUI::Point mousePos = CEGUI::MouseCursor::getSingleton().getPosition();	
			Ray mouseRay = PlayerCamera->getCameraToViewportRay(mousePos.d_x/win->getWidth(),mousePos.d_y/win->getHeight());//mousePos.d_x
			//mouseRay.setDirection(PlayerCamera->getDirection());
	        
            mRaySceneQuery2->setRay(mouseRay);
			
            RaySceneQueryResult &result = mRaySceneQuery2->execute();
            RaySceneQueryResult::iterator itr = result.begin();

           if (itr != result.end() && itr->movable && itr->movable->getName().substr(0, 5) != "tile["&& itr->movable->getName().substr(0, 6) != "Caelum")
			{
			Selected=itr->movable->getName();
			SelectedNode=itr->movable;
			
			getScreenspaceCoords(SelectedNode, PlayerCamera, textpos);
			TextRenderer::getSingleton().setTextXY(textpos.x,textpos.y,"Selected",Selected);
			
		   }else Selected=" ";

		mRaySceneQuery2->clearResults();

if (this->AnimationName=="Walk")
{	

	//RepeatSoundItem(GameSounds[2]);
};

// Управление построено на ID пакетов
//packetid
c8 key_pressed=0;

packet >> (c8)key_pressed;

net::SOutPacket out_packet;

if (key_pressed==KEY_FRONT)
{
			this->PxCharacterVec = NxVec3(0,0,-1); //для движения по положительной оси Z
	        this->PxPushCharacter = true; //означает что чарактер должен двигаться
		    this->AnimationName="Walk";
			pl_forward.x=0;pl_forward.y=0;pl_forward.z=-1;
			ServerMessages="PlayerID = "+Ogre::StringConverter::toString(packet.getPlayerId())+" MOVED UP";
			
};

if (key_pressed==KEY_BACK)
{      	
	        this->AnimationName="Walk";
			this->PxCharacterVec = NxVec3(0,0,1); //для движения по положительной оси Z
	        this->PxPushCharacter = true; //означает что чарактер должен двигаться
			pl_forward.x=0;pl_forward.y=0;pl_forward.z=1;
			ServerMessages="PlayerID = "+Ogre::StringConverter::toString(packet.getPlayerId())+" MOVED DOWN";
};		
if (key_pressed==KEY_STRAFE_LEFT)
{
			this->AnimationName="Walk";
			this->PxCharacterVec = NxVec3(-1,0,0); //для движения по положительной оси Z
	        this->PxPushCharacter = true; //означает что чарактер должен двигаться
			pl_forward.x=-1;pl_forward.y=0;pl_forward.z=0;
};

if (key_pressed==KEY_STRAFE_RIGHT)
{
			this->AnimationName="Walk";
			this->PxCharacterVec = NxVec3(1,0,0); //для движения по положительной оси Z
	        this->PxPushCharacter = true; //означает что чарактер должен двигаться
			pl_forward.x=this->Speed;
			pl_forward.y=0;pl_forward.z=0;
};

if (key_pressed==KEY_JUMP)
{
			StartJump(70.0f,packet.getPlayerId());
			
};
if (key_pressed==0)
      {
			this->AnimationName="Idle1";
            this->PxCharacterVec = NxVec3(0,0,0); //для движения по положительной оси Z
	        this->PxPushCharacter = false; //означает что чарактер должен двигаться
	        pl_forward.x=0;pl_forward.y=0;pl_forward.z=0;
      };


//cHeight=GetGroundHeight(Vector3 (PlayerCamera->getPosition().x,0,PlayerCamera->getPosition().z+camdist),6500)+WallHeight; 
    //высота игрока
rHeight=GetGroundHeight(Vector3 (this->actor->getGlobalPosition().x,0,this->actor->getGlobalPosition().z),6500)+WallHeight;



//PlayerCamera->setPosition(Vector3 (this->actor->getGlobalPosition().x,this->actor->getGlobalPosition().y+250+(mMos->getMouseState().Y.abs*2),this->actor->getGlobalPosition().z));
this->plNode->setPosition(Vector3 (this->actor->getGlobalPosition().x,this->actor->getGlobalPosition().y,this->actor->getGlobalPosition().z));

Ogre::Quaternion CameraOrient;
NxQuat CamOr=this->actor->getGlobalOrientation();
CameraOrient=toOgre(CamOr);

//PlayerCamera->setOrientation(CameraOrient);
//this->plNode->setOrientation(CameraOrient);	
//PlayerCamera->setOrientation(CameraOrient*(-1));

//PlayerCamera->moveRelative(Vector3(0,0,camdist));

PlayerCamera->setAutoTracking (true, this->plNode);
PlayerCamera->lookAt(Vector3(this->actor->getGlobalPosition().x,this->actor->getGlobalPosition().y+200,this->actor->getGlobalPosition().z));

Vector2 playertextname;
//getScreenspacePlayers(this, PlayerCamera, playertextname);
//"PlayerHP",    " "+Ogre::StringConverter::toString(player->HP)

//положение игрока в звуковой системе игры
pl_pos.x=this->plNode->getPosition().x;
pl_pos.y=this->plNode->getPosition().y;
pl_pos.z=this->plNode->getPosition().z;

FMOD_system->set3DListenerAttributes(1,&pl_pos,&pl_vel,&pl_forward,&upvector);
//-----------------------------------------

//TextRenderer::getSingleton().setTextXY(playertextname.x,playertextname.y,"PlayerHP",Ogre::StringConverter::toString(this->HP)+ "Step: "+Ogre::StringConverter::toString(CollisionID));//
//TextRenderer::getSingleton().setTextXY(playertextname.x-35,playertextname.y-40,"PlayerName",this->Name);
//------------------------------------------------


//отправить всем сведения о нажатых клавишах

			out_packet << (c8)EPT_INPUT;
			out_packet << packet.getPlayerId();
			out_packet << key_pressed;
			netManager->sendOutPacket(out_packet);

this->UpdateCharacter(deltatime);			
};
Post Reply