Beispiel #1
0
// Constructors & Destructors
Butter::Butter(double x, double y, double z, float width, float height) {
	_width = width;
	_height = height;

	$setDrag(DRAG);
	setAABB(width/2, -width/2, height/2, -height/2);
	setPosition(x, y, z);
}
Beispiel #2
0
ofxMSAPhysics::ofxMSAPhysics() {
	verbose = false;
	setTimeStep(0.000010);
	setDrag();
	setNumIterations();
	enableCollision();
	setGravity();
	clearWorldSize();
	
#ifdef MSAPHYSICS_USE_RECORDER
	_frameCounter = 0;
	setReplayMode(OFX_MSA_DATA_IDLE);
	setReplayFilename("recordedData/physics/physics");
#endif	
}
		void Particle::init(Vec3f pos, float m, float d) {
			_params = NULL;
			_world = NULL;
			
			_pos = _oldPos = pos;
			setMass(m);
			setDrag(d);
			setBounce();
			setRadius();
			enableCollision();
			makeFree();
			_isDead = false;
			_age = 0;
			verbose = true;
			data = NULL;
			setClassName("Particle");
		}
Beispiel #4
0
// Constructors & Destructors
Cheerio::Cheerio(double x, double y, double z) {
	setAABB(0.05, -0.05, 0.05, -0.05);
	$setDrag(DRAG);
	setPosition(x, y, z);
}
Beispiel #5
0
bool Player::initResources(GameBase::GameBaseData *in_data)
{
   data = dynamic_cast<PlayerData *>(in_data);

   if(!Parent::initResources(in_data))
      return false;

	updateImageMass();
	setDrag(data->drag);
	setDensity(data->density);

	int rnode = image.shape->getShape().findNode("dummyalways root");
	const TMat3F& rmat = image.shape->getTransform(rnode);
	image.shape->insertOverride("lowerback",0,&PlayerViewOverride);
	image.shape->insertOverride("lowerback",1,const_cast<TMat3F*>(&rmat));
	image.shape->setOverride(2);

	// 
	myThread = createThread (0);
   viewThread = Parent::createThread(0);
   viewThread->setPriority(-1);

   looksSequence = viewThread->GetSequenceIndex("looks");
   crouchLooksSequence = viewThread->GetSequenceIndex("crouch looks");

   if(crouchLooksSequence == -1)
      crouchLooksSequence = looksSequence;

   AssertFatal(looksSequence != -1, "DOH!");
   viewThread->SetSequence( looksSequence, 0.0 );

   damageThread = 0;
   int i;
   for (i = 0; i < Player::NUM_ANIMS; i ++)
	{
		animIndex[i] = myThread->GetSequenceIndex((char *) data->animData[i].name);
      if(animIndex[i] == -1)
         animIndex[i] = 0;
   }

	Point3F pos;
	clearAnimTransform ();
   for (int j = 0; j < Player::NUM_ANIMS; j ++)
	{
      if((j >= ANIM_MOVE_FIRST && j <= ANIM_MOVE_LAST) ||
         (j >= ANIM_CROUCH_MOVE_FIRST && j <= ANIM_CROUCH_MOVE_LAST))
      {
   		myThread->setTimeScale(1.0);
   		myThread->SetSequence(animIndex[j]);
   		myThread->AdvanceTime(1.0);
   		myThread->UpdateSubscriberList();
			image.shape->animateRoot();
   		pos = getAnimTransform();
         offsetList[j].dist = pos.len();
         offsetList[j].dir = pos;
      	if(offsetList[j].dist >= 0.1)
         {
      	   if (data->animData[j].direction <= 0)
               offsetList[j].dir *= -1 / offsetList[j].dist;
            else
               offsetList[j].dir *= 1 / offsetList[j].dist;
         }
	   	clearAnimTransform();
         offsetList[j].hasOffset = true;
      }
      else
         offsetList[j].hasOffset = false;

		myThread->SetSequence(0);
   }
   if(currentAnimation != -1)
   {
      // it's a death animation: set it to the end
      myThread->SetSequence(animIndex[currentAnimation]);
   	if (data->animData[currentAnimation].direction > 0)
   		myThread->SetPosition (0.99f);
   	else
   		myThread->SetPosition (0);
      pickNewAnimation = false;
   }

   delete flameImage.shape;
   flameImage.shape = 0;
	flameThread = 0;

	if (isGhost()) {
		char name[256];
		strcpy(name, data->flameShapeName);
		strcat(name, ".dts");

		ResourceManager *rm = SimResource::get(manager);
		Resource<TSShape> shape = rm->load(name, true);
	   if(bool(shape))
	   {
	      flameImage.shape = new TSShapeInstance(shape, *rm);
         flameThread = flameImage.shape->CreateThread();
         flameThread->setTimeScale(1.0f);
         flameThread->SetSequence("activation");
	   }
	}
	
	// Container & Collision
	boundingBox.fMin.x = -data->boxWidth;
	boundingBox.fMin.y = -data->boxDepth;
	boundingBox.fMin.z = 0;
	boundingBox.fMax.x = data->boxWidth;
	boundingBox.fMax.y = data->boxDepth;
	boundingBox.fMax.z = data->boxNormalHeight;
	collisionImage.bbox.fMin = boundingBox.fMin;
	collisionImage.bbox.fMax = boundingBox.fMax;
	collisionImage.crouchBox.fMin = boundingBox.fMin;
	collisionImage.crouchBox.fMax = boundingBox.fMax;
	setBoundingBox ();
	collisionImage.sphere.radius = (collisionImage.bbox.fMax.z - collisionImage.bbox.fMin.z) / 2;
	collisionImage.sphere.center = Point3F(0.0f,0.0f, collisionImage.sphere.radius);
	collisionImage.shapeInst = image.shape;
	collisionImage.collisionDetail = 0;
	chaseNode = image.shape->getShape().findNode ("dummyalways chasecam");
	eyeNode = image.shape->getNodeAtCurrentDetail("dummy eye");

	// Resolve all the mount node indexes.
   for(i = 0; i < MaxMountPoints; i++) {
		image.shape->setDetailLevel(0);
      mountNode[i] = image.shape->getNodeAtCurrentDetail(NodeMountName[i]);

		// HACK Alert!
		// Lower detail nodes are patch to reference the same
		// transform as the highest detail.
		TS::ShapeInstance::NodeInstance *node = image.shape->getNode(mountNode[i]);
		for (int d = 1; d < image.shape->getShape().fDetails.size(); d++) {
			image.shape->setDetailLevel(d);
      	int dn = image.shape->getNodeAtCurrentDetail(NodeMountName[i]);
			if (dn != -1)
				image.shape->getNode(dn)->fpTransform = node->fpTransform;
		}
   }
   image.shape->setDetailLevel(0);

	// Update initial state of images transfered from the server.
	for (i = 0; i < MaxItemImages; i++) {
		ItemImageEntry& itemImage = itemImageList[i];
		if (itemImage.state == ItemImageEntry::Fire)
			setImageState(i,ItemImageEntry::Fire);
	}

   return true;
}
Beispiel #6
0
Player::Player()
{
   playerTransition.fTransform.identity();
   transitionTime = 0;

	type = SimPlayerObjectType;
   currentAnimation = -1;
	newAnimTime = 0;
	data = 0;

   jumpSurfaceNormal.set(0,0,1);
   jumpSurfaceLastContact = 100;

   detectMinSize = MIN_DETECT_SIZE;
   detectHazeFactor = 1.0f;
   m_lastJetTime = 0;
   gunPullIn = 0;
   blownUp = false;
   lastContactCount = 0;
   updateSkip = 0;	
   updateDebt = 0;
	fov = M_PI/2.0f;
	viewPitch = 0;
	bounce = 0;
	traction = 0;

   inWorld = true;
   pickNewAnimation = true;
   mount = NULL;
   aiControlled = false;

   old_fov = 0.0f;
   cos_fov = 0.0f;
   tan_fov = 0.0f;
   
	forceMask = -1;
	setMass(9.0f);
	setDrag(1.0f);
	setDensity(1.2f);
	SimMovement::flags.set( UseCurrent | UseDrag | UseFriction);
   netFlags.set( Ghostable );

	jetting = false;
	jetSound = 0;
	
	flameImage.itype = SimRenderImage::Translucent;
	flameImage.shape = NULL;
	flameImage.castShadow = false;
	flameThread = NULL;

	myThread = NULL;
	damageThread = NULL;
   serverAnimation = 0;
   dead = false;
   jetting = false;
   crouching = false;
	pdaing = false;

   falling = false;
   interpDoneTime = 0;
   hasFocus = false;
	
   damageFlash = 0;

	surfaceType = -1;

   nextSup = NULL;
   prevSup = NULL;
	supressionDist = 0;

	// Constant, should be the same for all players.
	PlayerViewOverride.set(EulerF(0,0,M_PI/2),Point3F(0,0,0));

   m_pLensFlare       = new Planet::LensFlare;
}