///////////////////////////////////////////////////////////////////////////////
//
// CAmbientLightAwareSensorManagerEvents::OnSensorEnter
//
// Description of function/method:
//        Implementation of ISensorManager.OnSensorEnter. Check if the sensor
//        is an Ambient Light Sensor and if so then add the sensor.
//
// Parameters:
//        ISensor* pSensor:  Sensor that has been installed
//        SensorState state: State of the sensor
//
// Return Values:
//        S_OK on success, else an error.
//
///////////////////////////////////////////////////////////////////////////////
HRESULT CAmbientLightAwareSensorManagerEvents::OnSensorEnter(ISensor* pSensor, SensorState state)
{
    HRESULT hr = S_OK;

    if (NULL != pSensor)
    {
        SENSOR_TYPE_ID idType = GUID_NULL;
        hr = pSensor->GetType(&idType);
        if (SUCCEEDED(hr))
        {
            if (IsEqualIID(idType, SENSOR_TYPE_AMBIENT_LIGHT))
            {
                hr = AddSensor(pSensor);
                if (SUCCEEDED(hr))
                {
                    if (SENSOR_STATE_READY == state)
                    {
                        hr = m_pSensorEvents->GetSensorData(pSensor);
                    }
                }
            }
        }
    }
    else
    {
        hr = E_POINTER;
    }

    return hr;
}
Пример #2
0
CMOOSNavBeacon::CMOOSNavBeacon()
{
    m_eType = FIXED;
    m_bPseudo = false;

    CMOOSNavSensor * pLBL = new CMOOSNavSensor;
    pLBL->m_sName = "LBL";
    pLBL->m_eType = CMOOSNavSensor::LBL;

    AddSensor(pLBL);

}
Пример #3
0
/**
 * INTERNAL
 */
void LiveWindow::AddSensor(std::string type, int module, int channel, LiveWindowSendable *component)
{
	std::ostringstream oss;
	oss << type << "[" << module << "," << channel << "]";
	std::string types(oss.str());
	char* cc = new char[types.size() + 1];
	types.copy(cc, types.size());
	cc[types.size()]='\0';
	AddSensor("Ungrouped", cc, component);
	if (std::find(m_sensors.begin(), m_sensors.end(), component) == m_sensors.end())
		m_sensors.push_back(component);
}
int MBSObjectFactory::AddObject(MBSObjectFactoryClass objectClass, int objectTypeId)
{
	switch(objectClass)
	{
	case OFCElement: return AddElement(objectTypeId);		// AddElement is generated automatically
	case OFCSensor: return AddSensor(objectTypeId);
	case OFCNode: return AddNode(objectTypeId); 
	case OFCLoad: return AddLoad(objectTypeId);
	case OFCMaterial:	return AddMaterial(objectTypeId);
	case OFCBeamProperties:	return AddBeamProperties(objectTypeId);
	case OFCGeomElement: return AddGeomElement(objectTypeId);
	}
	assert(0);
	return -1;
}
 void CGroundSensorEquippedEntity::AddSensorRing(const CVector2& c_center,
                                                    Real f_radius,
                                                    const CRadians& c_start_angle,
                                                    ESensorType e_type,
                                                    UInt32 un_num_sensors,
                                                    const SAnchor& s_anchor) {
    CRadians cSensorSpacing = CRadians::TWO_PI / un_num_sensors;
    CRadians cAngle;
    CVector2 cOffset;
    for(UInt32 i = 0; i < un_num_sensors; ++i) {
       cAngle = c_start_angle + i * cSensorSpacing;
       cAngle.SignedNormalize();
       cOffset.Set(f_radius, 0.0f);
       cOffset.Rotate(cAngle);
       cOffset += c_center;
       AddSensor(cOffset, e_type, s_anchor);
    }
 }
///////////////////////////////////////////////////////////////////////////////
//
// CSensorManagerEvents::OnSensorEnter
//
// Description of function/method:
//        Implementation of ISensorManager.OnSensorEnter. Check if the sensor
//        is an Ambient Light Sensor and if so then add the sensor.
//
// Parameters:
//        ISensor* pSensor:  Sensor that has been installed
//        SensorState state: State of the sensor
//
// Return Values:
//        S_OK on success, else an error.
//
///////////////////////////////////////////////////////////////////////////////
HRESULT CSensorManagerEvents::OnSensorEnter(ISensor* pSensor, SensorState state)
{
    HRESULT hr = S_OK;

    if (NULL != pSensor)
    {
        SENSOR_TYPE_ID idType = GUID_NULL;
        hr = pSensor->GetType(&idType);
        if (SUCCEEDED(hr))
        {
			hr = AddSensor(pSensor);
        }	
    }
    else
    {
        hr = E_POINTER;
    }
    return hr;
}
 void CProximitySensorEquippedEntity::AddSensorRing(const CVector3& c_center,
                                                    Real f_radius,
                                                    const CRadians& c_start_angle,
                                                    Real f_range,
                                                    UInt32 un_num_sensors,
                                                    const SAnchor& s_anchor) {
    CRadians cSensorSpacing = CRadians::TWO_PI / un_num_sensors;
    CRadians cAngle;
    CVector3 cOff, cDir;
    for(UInt32 i = 0; i < un_num_sensors; ++i) {
       cAngle = c_start_angle + i * cSensorSpacing;
       cAngle.SignedNormalize();
       cOff.Set(f_radius, 0.0f, 0.0f);
       cOff.RotateZ(cAngle);
       cOff += c_center;
       cDir.Set(f_range, 0.0f, 0.0f);
       cDir.RotateZ(cAngle);
       AddSensor(cOff, cDir, f_range, s_anchor);
    }
 }
Пример #8
0
/// <summary>
/// Update the sensor resource when sensor status changed and the new status is not NuiSensorDisconnected
/// </summary>
void KinectWindowManager::HandleSensorConnected(PCWSTR instanceName, HRESULT hrSensorCallbackStatus)
{
    auto iter = m_sensorMap.find(instanceName);

    // The changed sensor has not been saved
    if (m_sensorMap.end() == iter)
    {
        INuiSensor* pNuiSensor = nullptr;

        if (SUCCEEDED(NuiCreateSensorById(instanceName, &pNuiSensor)))
        {
            iter = AddSensor(instanceName, pNuiSensor);
        }
        else
        {
            return;
        }
    }

    // Show/Hide the Kinect window
    UpdateKinectWindow(hrSensorCallbackStatus, iter->second.NuiSensor, &(iter->second.KinectWindow));
}
///////////////////////////////////////////////////////////////////////////////
//
// CAmbientLightAwareSensorManagerEvents::Initialize
//
// Description of function/method:
//        Initialize the sensor data.
//
// Parameters:
//        none
//
// Return Values:
//        HRESULT S_OK on success
//
///////////////////////////////////////////////////////////////////////////////
HRESULT CAmbientLightAwareSensorManagerEvents::Initialize()
{
    HRESULT hr;

    hr = m_spISensorManager.CoCreateInstance(CLSID_SensorManager);
    if (SUCCEEDED(hr))
    {
        hr = m_spISensorManager->SetEventSink(this);
        if (SUCCEEDED(hr))
        {
            // Find all Ambient Light Sensors
            CComPtr<ISensorCollection> spSensors;
            hr = m_spISensorManager->GetSensorsByType(SENSOR_TYPE_AMBIENT_LIGHT, &spSensors);
            if (SUCCEEDED(hr) && NULL != spSensors)
            {
                ULONG ulCount = 0;
                hr = spSensors->GetCount(&ulCount);
                if (SUCCEEDED(hr))
                {
                    for(ULONG i=0; i < ulCount; i++)
                    {
                        CComPtr<ISensor> spSensor;
                        hr = spSensors->GetAt(i, &spSensor);
                        if (SUCCEEDED(hr))
                        {
                            hr = AddSensor(spSensor);
                            if (SUCCEEDED(hr))
                            {
                                hr = m_pSensorEvents->GetSensorData(spSensor);
                            }
                        }
                    }
                }
            }
        }
    }

    return hr;
}
Пример #10
0
TDetector::TDetector(std::string filename) : edgeLength_(0) {
  sensors_.resize(0);
  double x, y, z, permeability;
  unsigned int group;
  // open file with given filename for reading
  std::ifstream file (filename.c_str());
  // read the first line with commentary
  std::string commentLine;
  std::getline(file, commentLine);
  // read all values and put them together into a position
  while (file.good()) {
    file >> x >> y >> z >> permeability >> group;
    std::vector<double> tempPosition;
    tempPosition.push_back(x);
    tempPosition.push_back(y);
    tempPosition.push_back(z);
    // create a new sensor out of the given values and add it to the detector
    AddSensor(*(new TSensor(tempPosition, permeability, group)));
  }
  // sort sensors into groups
  GroupSensors();
  // set edgeLength_ to the highest used coordinate
  SetEdgeLength();
}
 void CProximitySensorEquippedEntity::Init(TConfigurationNode& t_tree) {
    try {
       /*
        * Parse basic entity stuff
        */
       CEntity::Init(t_tree);
       /*
        * Parse proximity sensors
        */
       /* Not adding any sensor is a fatal error */
       if(t_tree.NoChildren()) {
          THROW_ARGOSEXCEPTION("No sensors defined");
       }
       /* Go through children */
       TConfigurationNodeIterator it;
       for(it = it.begin(&t_tree); it != it.end(); ++it) {
          std::string strAnchorId;
          GetNodeAttribute(*it, "anchor", strAnchorId);
          /*
           * NOTE: here we get a reference to the embodied entity
           * This line works under the assumption that:
           * 1. the ProximitySensorEquippedEntity has a parent;
           * 2. the parent has a child whose id is "body"
           * 3. the "body" is an embodied entity
           * If any of the above is false, this line will bomb out.
           */
          CEmbodiedEntity& cBody = GetParent().GetComponent<CEmbodiedEntity>("body");
          if(it->Value() == "sensor") {
             CVector3 cOff, cDir;
             Real fRange;
             GetNodeAttribute(*it, "offset", cOff);
             GetNodeAttribute(*it, "direction", cDir);
             GetNodeAttribute(*it, "range", fRange);
             AddSensor(cOff, cDir, fRange, cBody.GetAnchor(strAnchorId));
          }
          else if(it->Value() == "ring") {
             CVector3 cRingCenter;
             GetNodeAttributeOrDefault(t_tree, "center", cRingCenter, cRingCenter);
             Real fRadius;
             GetNodeAttribute(t_tree, "radius", fRadius);
             CDegrees cRingStartAngleDegrees;
             GetNodeAttributeOrDefault(t_tree, "start_angle", cRingStartAngleDegrees, cRingStartAngleDegrees);
             CRadians cRingStartAngleRadians = ToRadians(cRingStartAngleDegrees);
             Real fRange;
             GetNodeAttribute(t_tree, "range", fRange);
             UInt32 unNumSensors;
             GetNodeAttribute(t_tree, "num_sensors", unNumSensors);
             AddSensorRing(cRingCenter,
                           fRadius,
                           cRingStartAngleRadians,
                           fRange,
                           unNumSensors,
                           cBody.GetAnchor(strAnchorId));
          }
          else {
             THROW_ARGOSEXCEPTION("Unrecognized tag \"" << it->Value() << "\"");
          }
       }
    }
    catch(CARGoSException& ex) {
       THROW_ARGOSEXCEPTION_NESTED("Initialization error in proximity sensor equipped entity", ex);
    }
 }
Пример #12
0
void NSC::Start()
{
	IOMemoryDescriptor *		theDescriptor;
	UInt32 adr = (ListenPortByte(NSC_MEM)&0xff)+((ListenPortByte(NSC_MEM+1)<<8)&0xff00)+
		((ListenPortByte(NSC_MEM+2)&0xff)<<16)+((ListenPortByte(NSC_MEM+3)&0xff)<<24);
	
	IOPhysicalAddress bar = (IOPhysicalAddress)(adr & ~0xf);
	//		IOLog("Fx3100: register space=%08lx\n", (long unsigned int)bar);
	theDescriptor = IOMemoryDescriptor::withPhysicalAddress (bar, 0x200, kIODirectionOutIn); // | kIOMapInhibitCache);
	if(theDescriptor != NULL)
	{
		mmio = theDescriptor->map ();
		if(mmio != NULL)
		{
			//		UInt32 addr = map->getPhysicalAddress();
			mmio_base = (volatile UInt8 *)mmio->getVirtualAddress();
#if 0				
			UInt32 base_phys = (UInt32)mmio->getPhysicalAddress();
			InfoLog(" Memory mapped at address %08lx\n", (long unsigned int)base_phys);
			for (int i=0; i<0x2f; i +=16) {
				IOLog("%04lx: ", (long unsigned int)i);
				for (int j=0; j<16; j += 1) {
					IOLog("%02lx ", (long unsigned int)mmio_base[i+j]);
				}
				IOLog("\n");
			}
			//mmio->release();
#endif				
		}
		else
		{
			InfoLog(" MCHBAR failed to map\n");
			return;
		}			
	}	
	
	
	// Heatsink
	AddSensor(new NSCTemperatureSensor(this, 2, KEY_CPU_HEATSINK_TEMPERATURE, TYPE_SP78, 2));
	// Northbridge
	AddSensor(new NSCTemperatureSensor(this, 0, KEY_NORTHBRIDGE_TEMPERATURE, TYPE_SP78, 2));
	// Heatsink
	AddSensor(new NSCTemperatureSensor(this, 1, KEY_DIMM_TEMPERATURE, TYPE_SP78, 2));
	// Northbridge
	AddSensor(new NSCTemperatureSensor(this, 3, KEY_AUX_TEMPERATURE, TYPE_SP78, 2));

	char key[5];
	int id=GetNextUnusedKey(KEY_FORMAT_FAN_ID, key);
	int ac=GetNextUnusedKey(KEY_FORMAT_FAN_SPEED, key);
	if (id!=-1 || ac!=-1) {
		int no=id>ac ? id : ac;
		char name[] = "System Fan"; 
		int lname = sizeof(name);
//		snprintf (name, 10, "System Fan");
		snprintf(key, 5, KEY_FORMAT_FAN_ID, no);
		FakeSMCAddKey(key, TYPE_CH8, lname, name);			
		snprintf(key, 5, KEY_FORMAT_FAN_SPEED, no);
		AddSensor(new NSCTachometerSensor(this, 4, key, TYPE_FP2E, 2));
		UpdateFNum();
		FanCount = 1;
	}	
	
}
Пример #13
0
PlayerAI::PlayerAI(Camera *cam, Geometry *c, ScoreViews *_Scores, void *_player, int chan) : Intelligence(c), Message(){ // ,KernelClient(){
//	BoostHook=CreateHook("boost");
//	YawHook=CreateHook("yaw");
//	FireHook=CreateHook("fire");
//	RateHook=CreateHook("doublerate");
	//OrientationStep=Quaternion(Euler(0,0,0));
	//OrientationAx=Quaternion(Euler(0,0,0));

	camera = cam;
	geo = c;

//	computerplayers++;
//	view = v;

	Scores = _Scores;
	player = _player;

/*
	name = Scores->GetName(player);
	sprintf(name,"a");
*/
//	Scores->SetScore(player,0);
//	Scores->Activate(player);

//	Node *n = GetNode(String("Camera"));	// fixme: Optimize!
//	pos-=Vector(n->GetPosition());	// fixme: bug! geo is 0 sometimes
	Vector pos = Vector(camera->GetPosition())+Vector(float(rand()%0xfff)*.8f,float(rand()%0xfff)*.8f,-8000);
	pos.Z = -8000;
	SetPosition(pos);

	hook		= true; //false;
	left		= false;
	right		= false;
	wrotename	= false;
	avslutt		= false;
	addchar		= false;
	subchar		= false;
	nextchar	= false;
	number		= false;
	state		= ST_PLAYING;

	Listen("/Devices/Input/Dialogic"); //Keyboard");
	Listen("/Devices/Input/Keyboard");
	AvsluttBind = AddBind = SubBind = NextBind = HookBind = NumberBind = LeftBind = RightBind = AvsluttBind = 0;

	if(chan<100){
		char str[10];
		sprintf(str,"Player%d",chan);
		Message::SetName(str);
		#ifdef PHONE_EMULATION
		AvsluttBind = new char[strlen("C##_*")+1];
		sprintf(AvsluttBind,"C%d_#",chan);
		AddBind = new char[strlen("C##_2")+1];
		sprintf(AddBind,"C%d_2",chan);
		SubBind = new char[strlen("C##_1")+1];
		sprintf(SubBind,"C%d_1",chan);
		NextBind = new char[strlen("C##_#")+1];
		sprintf(NextBind,"C%d_*",chan);
		if(chan==0){
			HookBind = new char[strlen("##")+1];
			sprintf(HookBind,"%d",chan);
			NumberBind = new char[strlen("a")+1];
			sprintf(NumberBind,"a",chan);
			LeftBind = new char[strlen("q")+1];
			sprintf(LeftBind,"q",chan);
			RightBind = new char[strlen("w")+1];
			sprintf(RightBind,"w",chan);
		}else{
			HookBind = new char[strlen("##")+1];
			sprintf(HookBind,"%d",chan);
			NumberBind = new char[strlen("k")+1];
			sprintf(NumberBind,"k",chan);
			LeftBind = new char[strlen("i")+1];
			sprintf(LeftBind,"i",chan);
			RightBind = new char[strlen("o")+1];
			sprintf(RightBind,"o",chan);
		}
		#else
		AvsluttBind = new char[strlen("C##_*")+1];
		sprintf(AvsluttBind,"C%d_#",chan);
		AddBind = new char[strlen("C##_2")+1];
		sprintf(AddBind,"C%d_2",chan);
		SubBind = new char[strlen("C##_1")+1];
		sprintf(SubBind,"C%d_1",chan);
		NextBind = new char[strlen("C##_#")+1];
		sprintf(NextBind,"C%d_*",chan);

		HookBind = new char[strlen("C##_!Hook")+1];
		sprintf(HookBind,"C%d_!Hook",chan);
		NumberBind = new char[strlen("C##_5")+1];
		sprintf(NumberBind,"C%d_5",chan);
		LeftBind = new char[strlen("C##_4")+1];
		sprintf(LeftBind,"C%d_4",chan);
		RightBind = new char[strlen("C##_6")+1];
		sprintf(RightBind,"C%d_6",chan);
		#endif
	}else printf("Warning: Too many players! I will probably crash now.\n");

	OldTime = -1.0f;

	c->Add(Vector(-200,-200,0));
	c->Add(Vector( 200,-200,0));
	c->Add(Vector( 200, 200,0));
	c->Add(Vector(-200, 200,0));
	c->Add(Vector(-300,-300,0));
	c->Add(Vector( 300,-300,0));
	c->Add(Vector( 300, 300,0));
	c->Add(Vector(-300, 300,0));
	c->Add(Vertex(0,0,0));
	c->Add(Vertex(1,1,0));
	c->Add(Vertex(2,1,1));
	c->Add(Vertex(3,0,1));
	c->Add(Vertex(4,0,0));
	c->Add(Vertex(5,1,0));
	c->Add(Vertex(6,1,1));
	c->Add(Vertex(7,0,1));
	#ifdef USE_AI
	pol1 = new IndexedPolygon(c); //c->NewIndexedPolygon();
	pol1->Add(3);
	pol1->Add(2);
	pol1->Add(1);
	pol1->Add(0);
	#endif

	OrientationStep=Euler(0,0,0);
	OrientationAx=Euler(0,0,0);
//	Velocity=Vector(0,0,0);
	Acceleration=Vector(0,0,0);
//	OldTime=Time();
//	fire=false;
//	ShipMaterial = new Material("Textures/Ship/Ship",TEXTURE_ARGB);
	ShipMaterial = new Material(names[chan%6],Texture::cARGB);
//	ShipMaterial->SetEmissiveColor(ARGB(1,1,1));
	ShipMaterial->SetMode(MATERIAL_SOURCE_DIFFUSE|MATERIAL_DEST_MULTIPLY_ONE_MINUS_ALPHA);
	ShipMaterial->CacheAll();
	LightMaterial = new Material("Textures/Ship/ship_lightmap/lm",Texture::cARGB);
	LightMaterial->SetMode(MATERIAL_SOURCE_DIFFUSE|MATERIAL_DEST_MULTIPLY_SOURCE);
	LightMaterial->CacheAll();
	char str[1024];
	sprintf(str,"Textures/interface/playernum/no%d",chan+1);
	NumberMaterial = new Material(str,Texture::cARGB);
	NumberMaterial->SetMode(MATERIAL_SOURCE_DIFFUSE|MATERIAL_DEST_MULTIPLY_ONE_MINUS_ALPHA);
	NumberMaterial->CacheAll();
	expm = new Material("Textures/Explosion/Explosion",Texture::cARGB);
	expm->SetMode(MATERIAL_SOURCE_DIFFUSE|MATERIAL_DEST_MULTIPLY_ONE_MINUS_ALPHA);
	expm->CacheAll();
/*
	num = new Number(this,input_channel-1);
*/
	num = 0;
	playernum = chan;

	GetCreatorGeometry()->Apply(ShipMaterial);
	LastFire = 0;
	health = 1.0f;
//	ExplotionMaterial = new Material("Textures/Explosion/Explosion");
//	state=false;
	#ifdef CHEAT
	rate = 0.1f;
	#else
	rate=.65f+float(rand())/1000000.0f;;
	#endif

	#ifdef USE_AI
	pol2 = c->NewIndexedPolygon();
	pol2->Apply(LightMaterial);
	pol2->Add(3);
	pol2->Add(2);
	pol2->Add(1);
	pol2->Add(0);
	IndexedPolygon *pol;
	#endif

//	pol = c->NewIndexedPolygon();
//	pol->Apply(NumberMaterial);
//	pol->Add(3);
//	pol->Add(2);
//	pol->Add(1);
//	pol->Add(0);

	shield=true;
	StartTime = -1.0f;
/*
	#ifdef USE_AI
	RedStrobe = new Geometry();
	RedStrobe->Node::Apply(new RedStrobeAI(RedStrobe));
	RedStrobe->SetPosition(Vector(0,0,0));
	c->Node::Apply(RedStrobe);
	BlueStrobe = new Geometry();
	BlueStrobe->Node::Apply(new BlueStrobeAI(BlueStrobe));
	BlueStrobe->SetPosition(Vector(0,0,0));
	c->Node::Apply(BlueStrobe);
	#else
	RedStrobe = 0;
	BlueStrobe = 0;
	#endif
*/
	Shield1 = new Material("Textures/Shield/Shield2",Texture::cRGB);
	Shield1->SetMode(MATERIAL_DEST_ADD_SOURCE);
	Shield1->CacheAll();
	Shield1->SetTransparency(0);
	shieldpol = new IndexedPolygon(c);
	shieldpol->Apply(Shield1);
	shieldpol->Add(7);
	shieldpol->Add(6);
	shieldpol->Add(5);
	shieldpol->Add(4);

	RedStrobe  = new Material("Textures/Ship/RStrobe",Texture::cRGB);
	RedStrobe->SetMode(MATERIAL_DEST_ADD_SOURCE);
	RedStrobe->CacheAll();
	redpol = new IndexedPolygon(c);
	redpol->Apply(RedStrobe);
	redpol->Add(3);
	redpol->Add(2);
	redpol->Add(1);
	redpol->Add(0);
	BlueStrobe  = new Material("Textures/Ship/BStrobe",Texture::cRGB);
	BlueStrobe->SetMode(MATERIAL_DEST_ADD_SOURCE);
	BlueStrobe->CacheAll();
	bluepol = new IndexedPolygon(c);
	bluepol->Apply(BlueStrobe);
	bluepol->Add(3);
	bluepol->Add(2);
	bluepol->Add(1);
	bluepol->Add(0);

	Boost = new Material("Textures/Boost/Flame",Texture::cRGB);
	Boost->SetMode(MATERIAL_DEST_ADD_SOURCE|MATERIAL_SOURCE_DIFFUSE);
	Boost->CacheAll();
	#ifdef DOUBLE_BOOST
	c->Add(Vector(-5*4-50, 20*4+200,0));
	c->Add(Vector( 5*4-50, 20*4+200,0));
	c->Add(Vector( 5*4-50,-20*4+200,0));
	c->Add(Vector(-5*4-50,-20*4+200,0));
	c->Add(Vector(-5*4+50, 20*4+200,0));
	c->Add(Vector( 5*4+50, 20*4+200,0));
	c->Add(Vector( 5*4+50,-20*4+200,0));
	c->Add(Vector(-5*4+50,-20*4+200,0));
	c->Add(Vertex( 4+4,0,0));
	c->Add(Vertex( 5+4,0,1));
	c->Add(Vertex( 6+4,1,1));
	c->Add(Vertex( 7+4,1,0));
	c->Add(Vertex( 8+4,0,0));
	c->Add(Vertex( 9+4,0,1));
	c->Add(Vertex(10+4,1,1));
	c->Add(Vertex(11+4,1,0));
	BoostPoly1 = new IndexedPolygon(c);
	BoostPoly1->Apply(Boost);
	BoostPoly1->Add(4+4); BoostPoly1->Add(5+4); BoostPoly1->Add(6+4); BoostPoly1->Add(7+4);
	BoostPoly2 = new IndexedPolygon(c);
	BoostPoly2->Apply(Boost);
	BoostPoly2->Add(8+4); BoostPoly2->Add(9+4); BoostPoly2->Add(10+4); BoostPoly2->Add(11+4);
	#else
	c->Add(Vector(-12*4, 20*4+200,0));
	c->Add(Vector( 12*4, 20*4+200,0));
	c->Add(Vector( 12*4,-20*4+200,0));
	c->Add(Vector(-12*4,-20*4+200,0));
	c->Add(Vertex( 4+4,0,1));
	c->Add(Vertex( 5+4,1,1));
	c->Add(Vertex( 6+4,1,0));
	c->Add(Vertex( 7+4,0,0));
	BoostPoly1 = new IndexedPolygon(c);
	BoostPoly1->Apply(Boost);
	BoostPoly1->Add(4+4); BoostPoly1->Add(5+4); BoostPoly1->Add(6+4); BoostPoly1->Add(7+4);
	#endif

//	LeftBoost = new Geometry();
//	LeftBoost->Node::Apply(new BoostAI(LeftBoost,c));
//	LeftBoost->SetPosition(Vector(50,200,0));
//	c->Node::Apply(LeftBoost);
//	RightBoost = new Geometry();
//	RightBoost->Node::Apply(new BoostAI(RightBoost,c));
//	RightBoost->SetPosition(Vector(-50,200,0));
//	c->Node::Apply(RightBoost);
/*
	Shield = new Geometry();
	shieldAI = new ShieldAI(Shield);
	Shield->Node::Apply(0,shieldAI);
	Shield->SetPosition(0,Vector(0,30,0));
	c->Node::Apply(0,Shield);
*/
//	shieldAI = new ShieldAI(geo);

//	Sound = new SoundPoint("Sound/Quake/Enforcer/Enfire.wav");
//	Sound->SetPosition(Vector(0,0,0));

//	Velocity		= Vector(0,0,0);
	Acceleration	= Vector(0,0,0);
	OrientationStep	= Euler(0,0,0);
	OrientationAx	= Euler(0,0,0);
//	SetPosition(Vector(0,0,-800000));

#if 0
	#ifdef USE_AI
	AddSensor(Vector(0,-300000,0));
	// Left
	AddSensor(Vector(0,-300000,0)*Quaternion(Euler(0,0,.05f*1.0f*1.0f)));
	AddSensor(Vector(0,-300000,0)*Quaternion(Euler(0,0,.10f*1.1f*1.1f)));
	AddSensor(Vector(0,-300000,0)*Quaternion(Euler(0,0,.15f*1.2f*1.2f)));
	AddSensor(Vector(0,-300000,0)*Quaternion(Euler(0,0,.20f*1.3f*1.3f)));
	AddSensor(Vector(0,-300000,0)*Quaternion(Euler(0,0,.25f*1.4f*1.4f)));
	AddSensor(Vector(0,-300000,0)*Quaternion(Euler(0,0,.30f*1.5f*1.5f)));
	AddSensor(Vector(0,-300000,0)*Quaternion(Euler(0,0,.35f*1.6f*1.6f)));
	AddSensor(Vector(0,-300000,0)*Quaternion(Euler(0,0,.40f*1.7f*1.7f)));
	AddSensor(Vector(0,-300000,0)*Quaternion(Euler(0,0,.45f*1.8f*1.8f)));
	AddSensor(Vector(0,-300000,0)*Quaternion(Euler(0,0,.50f*1.9f*1.9f)));
	AddSensor(Vector(0,-300000,0)*Quaternion(Euler(0,0,.55f*2.0f*2.0f)));
	// Right
	AddSensor(Vector(0,-300000,0)*Quaternion(Euler(0,0,-.05f*1.0f*1.0f)));
	AddSensor(Vector(0,-300000,0)*Quaternion(Euler(0,0,-.10f*1.1f*1.1f)));
	AddSensor(Vector(0,-300000,0)*Quaternion(Euler(0,0,-.15f*1.2f*1.2f)));
	AddSensor(Vector(0,-300000,0)*Quaternion(Euler(0,0,-.20f*1.3f*1.3f)));
	AddSensor(Vector(0,-300000,0)*Quaternion(Euler(0,0,-.25f*1.4f*1.4f)));
	AddSensor(Vector(0,-300000,0)*Quaternion(Euler(0,0,-.30f*1.5f*1.5f)));
	AddSensor(Vector(0,-300000,0)*Quaternion(Euler(0,0,-.35f*1.6f*1.6f)));
	AddSensor(Vector(0,-300000,0)*Quaternion(Euler(0,0,-.40f*1.7f*1.7f)));
	AddSensor(Vector(0,-300000,0)*Quaternion(Euler(0,0,-.45f*1.8f*1.8f)));
	AddSensor(Vector(0,-300000,0)*Quaternion(Euler(0,0,-.50f*1.9f*1.9f)));
	AddSensor(Vector(0,-300000,0)*Quaternion(Euler(0,0,-.55f*2.0f*2.0f)));
	#endif
#endif

	score = 0;
//	char str[1024];
//	sprintf(str,"%d",score);
//	view->ConsoleStream::Clear();
//	view->Print("0");
//	AddScore(0);
	bounce = false;

	Acceleration = Vector(0,0.1f,0);

	activate_shield = false;
	charge = 10.0f;

	OldVelocity = Vector(0,0,0);

	redpulse  = 0.2f+float(rand())/100000.0f;
	bluepulse = 0.2f+float(rand())/100000.0f;
	shield_active = true;
}
Пример #14
0
bool CMOOSNavEngine::Initialise(STRING_LIST  sParams)
{

    //make a store for observations..
    m_pStore = new CMOOSNavObsStore;

    //we may be being asked to map thrust to velocity
    string sVal;
    if(MOOSGetValueFromToken(sParams,"THRUST2VELOCITY",sVal))
    {
        if(MOOSStrCmp(sVal,"TRUE"))
        {
            if(MOOSGetValueFromToken(sParams,"THRUST2VELOCITY_GAIN",sVal))
            {
                m_bThrust2Vel = true;
                m_dfThrust2VelGain = atof(sVal.c_str());
            }
        }
    }



    if(MOOSGetValueFromToken(sParams,"SV",sVal))
    {
        double dfNewSV = atof(sVal.c_str());         
        if(dfNewSV !=0)
        {
            m_dfSV=dfNewSV;
        }
    }

    //set up navigation filter logging....
    bool bLog = false;
    if(MOOSGetValueFromToken(sParams,"NAV_LOG",sVal))
    {
        bLog = MOOSStrCmp(sVal,"TRUE");
    }
    if(bLog)
    {
        string sPath="";
        
        //do we have a globally defined path?
        CProcessConfigReader Reader;
        Reader.SetFile(m_sMissionFileName);

        if(!Reader.GetValue("GLOBALLOGPATH",sPath))
        {
            //no..get it locally
            MOOSGetValueFromToken(sParams,"NAV_LOG_PATH",sPath);
        }
        bool bTimeStamp=false;
        if(MOOSGetValueFromToken(sParams,"NAV_LOG_TIMESTAMP",sVal))
        {
            bTimeStamp = MOOSStrCmp(sVal,"TRUE");
        }

        
        m_Logger.Initialise(m_sName,sPath,bTimeStamp);

             
    }



    //Allocate Global states..
    SetUpGlobalStates();

    AddTheVehicle(sParams);

    //fixed observations are attached to the COG...
    AddSensor("FIXED","COG", CMOOSNavSensor::FIXED,0,0,0);

    //set our default start up state...
    //set in constructor of derived classes
    SetOnline(m_bInitialOnline);
    return true;

}