当前位置: 首页>>代码示例>>C++>>正文


C++ Entity类代码示例

本文整理汇总了C++中Entity的典型用法代码示例。如果您正苦于以下问题:C++ Entity类的具体用法?C++ Entity怎么用?C++ Entity使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Entity类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: SceneEntityInstance

Entity *SceneEntityInstance::loadObjectEntryIntoEntity(ObjectEntry *entry, Entity *targetEntity, int entityFileVersion) {

	Entity *entity = NULL;

	ObjectEntry *entityType = (*entry)["type"];
	if(entityType) {
        if(entityType->stringVal == "SceneEntityInstance") {
            ObjectEntry *instanceEntry = (*entry)["SceneEntityInstance"];
            String filePath = (*instanceEntry)["filePath"]->stringVal;
            SceneEntityInstance *instance = new SceneEntityInstance(parentScene, filePath);
            entity = instance;
         } else if(entityType->stringVal == "SceneCurve") {
			ObjectEntry *curveEntry = (*entry)["SceneCurve"];
             
             SceneCurve *curve = new SceneCurve();
             
            if(curveEntry) {
                curve->renderCurve = (*curveEntry)["render"]->boolVal;
                curve->curveResolution = (*curveEntry)["resolution"]->intVal;                
                parseObjectIntoCurve((*curveEntry)["curve"], curve->getCurve());
            }
             
             entity = curve;
             
         } else if(entityType->stringVal == "SceneSprite") {

			ObjectEntry *spriteEntry = (*entry)["SceneSprite"];
			String spriteSetName = (*spriteEntry)["sprite_set"]->stringVal;

             SpriteSet *spriteSet = (SpriteSet*)CoreServices::getInstance()->getResourceManager()->getResourcePoolByName(spriteSetName);
             
             if(spriteSet) {
                 SceneSprite *sprite = new SceneSprite(spriteSet);
                 
                 String spriteName = (*spriteEntry)["sprite"]->stringVal;
                 sprite->setSpriteByName(spriteName);

                 
                 String stateName = (*spriteEntry)["state"]->stringVal;
                 
                 if(sprite->getCurrentSprite()) {
                     SpriteState *state = sprite->getCurrentSprite()->getStateByName(stateName);
                     if(state) {
                         sprite->setSpriteState(state, 0, false);
                     }
                     
                     ObjectEntry *randomFrameEntry = (*spriteEntry)["random_frame"];
                     if(randomFrameEntry) {
                        sprite->setStartOnRandomFrame(randomFrameEntry->boolVal);
                     }
                     
                 }
                 
                 entity = sprite;
                 applySceneMesh((*entry)["SceneMesh"], sprite);
             }

        } else 	if(entityType->stringVal == "SceneLabel") {
			ObjectEntry *labelEntry = (*entry)["SceneLabel"];
			
			String text = (*labelEntry)["text"]->stringVal;
			String font = (*labelEntry)["font"]->stringVal;
			int size = (*labelEntry)["size"]->intVal;
            Number actualHeight = (*labelEntry)["actualHeight"]->intVal;
			int aaMode = (*labelEntry)["aaMode"]->intVal;
            
			SceneLabel *label = new SceneLabel(text, size, font, aaMode, actualHeight);
            label->setAnchorPoint(0.0, 0.0, 0.0);
            label->snapToPixels = false;
            label->positionAtBaseline = false;
            applySceneMesh((*entry)["SceneMesh"], label);
            
            // RENDERER_TODO
            /*
            if(label->getLocalShaderOptions()) {
                label->getLocalShaderOptions()->clearTexture("diffuse");
                label->getLocalShaderOptions()->addTexture("diffuse", label->getTexture());
            }
            */
            
			entity = label;
        } else if(entityType->stringVal == "SceneParticleEmitter") {
            
			ObjectEntry *emitterEntry = (*entry)["SceneParticleEmitter"];
            SceneParticleEmitter *emitter = new SceneParticleEmitter(1, 1, 1);

            emitter->setParticleType((*emitterEntry)["type"]->intVal);
            emitter->setParticleSpeed((*emitterEntry)["speed"]->NumberVal);
            emitter->setParticleCount((*emitterEntry)["count"]->intVal);
            emitter->setParticleLifetime((*emitterEntry)["lifetime"]->NumberVal);
            emitter->setParticleSize((*emitterEntry)["size"]->NumberVal);
            emitter->setParticlesInWorldSpace((*emitterEntry)["world"]->boolVal);
            emitter->setLoopParticles((*emitterEntry)["loop"]->boolVal);
            
            emitter->setParticleRotationSpeed(Vector3((*emitterEntry)["rX"]->NumberVal, (*emitterEntry)["rY"]->NumberVal, (*emitterEntry)["rZ"]->NumberVal));
            emitter->setGravity(Vector3((*emitterEntry)["gX"]->NumberVal, (*emitterEntry)["gY"]->NumberVal, (*emitterEntry)["gZ"]->NumberVal));
            emitter->setParticleDirection(Vector3((*emitterEntry)["dirX"]->NumberVal, (*emitterEntry)["dirY"]->NumberVal, (*emitterEntry)["dirZ"]->NumberVal));
            emitter->setEmitterSize(Vector3((*emitterEntry)["eX"]->NumberVal, (*emitterEntry)["eY"]->NumberVal, (*emitterEntry)["eZ"]->NumberVal));
            emitter->setDirectionDeviation(Vector3((*emitterEntry)["devX"]->NumberVal, (*emitterEntry)["devY"]->NumberVal, (*emitterEntry)["devZ"]->NumberVal));
            
//.........这里部分代码省略.........
开发者ID:carlosmarti,项目名称:Polycode,代码行数:101,代码来源:PolySceneEntityInstance.cpp

示例2: BSETTING


//.........这里部分代码省略.........
				mRefractCam->enableCustomNearClipPlane(refractionPlane);
			}
		}

		TexturePtr rttTex2Ptr = TextureManager::getSingleton().createManual("Reflection", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, TEX_TYPE_2D, 512, 512, 0, PF_R8G8B8, TU_RENDERTARGET, new ResourceBuffer());
		rttTex2 = rttTex2Ptr->getBuffer()->getRenderTarget();
		{
			mReflectCam = gEnv->sceneManager->createCamera("ReflectCam");
			mReflectCam->setNearClipDistance(mRenderCamera->getNearClipDistance());
			mReflectCam->setFarClipDistance(mRenderCamera->getFarClipDistance());
			mReflectCam->setAspectRatio(
				(Real)gEnv->renderWindow->getViewport(0)->getActualWidth() /
				(Real)gEnv->renderWindow->getViewport(0)->getActualHeight());

			vRtt2 = rttTex2->addViewport( mReflectCam );
			vRtt2->setClearEveryFrame( true );
			vRtt2->setBackgroundColour( fade );
			//            v->setBackgroundColour( ColourValue::Black );


			MaterialPtr mat ;
			if (mType==WATER_FULL_QUALITY || mType==WATER_FULL_SPEED)
			{
				mat = MaterialManager::getSingleton().getByName("Examples/FresnelReflectionRefraction");
				mat->getTechnique(0)->getPass(0)->getTextureUnitState(1)->setTextureName("Reflection");

				mat = MaterialManager::getSingleton().getByName("Examples/FresnelReflectionRefractioninverted");
				mat->getTechnique(0)->getPass(0)->getTextureUnitState(1)->setTextureName("Reflection");
			} else
			{
				mat = MaterialManager::getSingleton().getByName("Examples/FresnelReflection");
				mat->getTechnique(0)->getPass(0)->getTextureUnitState(1)->setTextureName("Reflection");
			}


			vRtt2->setOverlaysEnabled(false);

			rttTex2->addListener(&mReflectionListener);

			//optimisation
			rttTex2->setAutoUpdated(false);

			// set up linked reflection
			mReflectCam->enableReflection(waterPlane);
			// Also clip
			mReflectCam->enableCustomNearClipPlane(reflectionPlane);
		}

		mprt=MeshManager::getSingleton().createPlane("ReflectPlane",
			ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
			waterPlane,
			mapsize.x * mScale,mapsize.z * mScale,WAVEREZ,WAVEREZ,true,1,50,50,Vector3::UNIT_Z, HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY_DISCARDABLE);
		pPlaneEnt = gEnv->sceneManager->createEntity( "plane", "ReflectPlane" );
		if (mType==WATER_FULL_QUALITY || mType==WATER_FULL_SPEED)
			pPlaneEnt->setMaterialName("Examples/FresnelReflectionRefraction");
		else
			pPlaneEnt->setMaterialName("Examples/FresnelReflection");
		//        gEnv->ogreSceneManager->getRootSceneNode()->createChildSceneNode()->attachObject(pPlaneEnt);
		//position
		pTestNode = gEnv->sceneManager->getRootSceneNode()->createChildSceneNode("WaterPlane");
		pTestNode->attachObject(pPlaneEnt);
		pTestNode->setPosition( Vector3((mapsize.x * mScale)/2,0,(mapsize.z * mScale)/2) );
	}
	else
	{
		//basic Water
		waterPlane.normal = Vector3::UNIT_Y;
		waterPlane.d = -wheight;
		mprt=MeshManager::getSingleton().createPlane("WaterPlane",
			ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
			waterPlane,
			mapsize.x * mScale,mapsize.z * mScale,WAVEREZ,WAVEREZ,true,1,50,50,Vector3::UNIT_Z, HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY_DISCARDABLE);
		pPlaneEnt = gEnv->sceneManager->createEntity( "plane", "WaterPlane" );
		pPlaneEnt->setMaterialName("tracks/basicwater");
		//position
		pTestNode = gEnv->sceneManager->getRootSceneNode()->createChildSceneNode("WaterPlane");
		pTestNode->attachObject(pPlaneEnt);
		pTestNode->setPosition( Vector3((mapsize.x * mScale)/2,0,(mapsize.z * mScale)/2) );
	}
	//bottom
	bottomPlane.normal = Vector3::UNIT_Y;
	bottomPlane.d = -wbheight; //30m below waterline
	MeshManager::getSingleton().createPlane("BottomPlane",
		ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
		bottomPlane,
		mapsize.x * mScale,mapsize.z * mScale,1,1,true,1,1,1,Vector3::UNIT_Z);
	Entity *pE = gEnv->sceneManager->createEntity( "bplane", "BottomPlane" );
	pE->setMaterialName("tracks/seabottom");
	//position
	pBottomNode = gEnv->sceneManager->getRootSceneNode()->createChildSceneNode("BottomWaterPlane");
	pBottomNode->attachObject(pE);
	pBottomNode->setPosition( Vector3((mapsize.x * mScale)/2,0,(mapsize.z * mScale)/2) );
	//setup for waves
	wbuf=mprt->sharedVertexData->vertexBufferBinding->getBuffer(0);
	if (wbuf->getSizeInBytes()==(WAVEREZ+1)*(WAVEREZ+1)*32)
	{
		wbuffer=(float*)malloc(wbuf->getSizeInBytes());
		wbuf->readData(0, wbuf->getSizeInBytes(), wbuffer);
	} else wbuffer=0;
}
开发者ID:tizbac,项目名称:ror-ng,代码行数:101,代码来源:Water.cpp

示例3: Render

void RenderingEngine::Render(const Entity& object)
{
	m_renderProfileTimer.StartInvocation();
	GetTexture("displayTexture").BindAsRenderTarget();
	//m_window->BindAsRenderTarget();
	//m_tempTarget->BindAsRenderTarget();

	glClearColor(0.0f,0.0f,0.0f,0.0f);
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	object.RenderAll(m_defaultShader, *this, *m_mainCamera);
	
	for(unsigned int i = 0; i < m_lights.size(); i++)
	{
		m_activeLight = m_lights[i];
		ShadowInfo shadowInfo = m_activeLight->GetShadowInfo();
		
		int shadowMapIndex = 0;
		if(shadowInfo.GetShadowMapSizeAsPowerOf2() != 0)
			shadowMapIndex = shadowInfo.GetShadowMapSizeAsPowerOf2() - 1;
		
		assert(shadowMapIndex >= 0 && shadowMapIndex < NUM_SHADOW_MAPS);
		
		SetTexture("shadowMap", m_shadowMaps[shadowMapIndex]);
		m_shadowMaps[shadowMapIndex].BindAsRenderTarget();
		glClearColor(1.0f,1.0f,0.0f,0.0f);
		glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
		
		if(shadowInfo.GetShadowMapSizeAsPowerOf2() != 0)
		{
			m_altCamera.SetProjection(shadowInfo.GetProjection());
			ShadowCameraTransform shadowCameraTransform = m_activeLight->CalcShadowCameraTransform(m_mainCamera->GetTransform().GetTransformedPos(), 
				m_mainCamera->GetTransform().GetTransformedRot());
			m_altCamera.GetTransform()->SetPos(shadowCameraTransform.GetPos());
			m_altCamera.GetTransform()->SetRot(shadowCameraTransform.GetRot());
			
			m_lightMatrix = BIAS_MATRIX * m_altCamera.GetViewProjection();
			
			SetFloat("shadowVarianceMin", shadowInfo.GetMinVariance());
			SetFloat("shadowLightBleedingReduction", shadowInfo.GetLightBleedReductionAmount());
			bool flipFaces = shadowInfo.GetFlipFaces();
			
//			const Camera* temp = m_mainCamera;
//			m_mainCamera = m_altCamera;
			
			if(flipFaces)
			{
				glCullFace(GL_FRONT);
			}
			
			glEnable(GL_DEPTH_CLAMP);
			object.RenderAll(m_shadowMapShader, *this, m_altCamera);
			glDisable(GL_DEPTH_CLAMP);
			
			if(flipFaces) 
			{
				glCullFace(GL_BACK);
			}
			
//			m_mainCamera = temp;
			
			float shadowSoftness = shadowInfo.GetShadowSoftness();
			if(shadowSoftness != 0)
			{
				BlurShadowMap(shadowMapIndex, shadowSoftness);
			}
		}
		else
		{
			m_lightMatrix = Matrix4f().InitScale(Vector3f(0,0,0));
			SetFloat("shadowVarianceMin", 0.00002f);
			SetFloat("shadowLightBleedingReduction", 0.0f);
		}
	
		GetTexture("displayTexture").BindAsRenderTarget();
		//m_window->BindAsRenderTarget();
		
//		glEnable(GL_SCISSOR_TEST);
//		TODO: Make use of scissor test to limit light area
//		glScissor(0, 0, 100, 100);
		
		glEnable(GL_BLEND);
		glBlendFunc(GL_ONE, GL_ONE);
		glDepthMask(GL_FALSE);
		glDepthFunc(GL_EQUAL);

		object.RenderAll(m_activeLight->GetShader(), *this, *m_mainCamera);
		
		glDepthMask(GL_TRUE);
		glDepthFunc(GL_LESS);
		glDisable(GL_BLEND);
		
//		glDisable(GL_SCISSOR_TEST);
	}
	
	float displayTextureAspect = (float)GetTexture("displayTexture").GetWidth()/(float)GetTexture("displayTexture").GetHeight();
	float displayTextureHeightAdditive = displayTextureAspect * GetFloat("fxaaAspectDistortion");
	SetVector3f("inverseFilterTextureSize", Vector3f(1.0f/(float)GetTexture("displayTexture").GetWidth(), 
	                                                 1.0f/((float)GetTexture("displayTexture").GetHeight() + displayTextureHeightAdditive), 0.0f));
	m_renderProfileTimer.StopInvocation();
	
//.........这里部分代码省略.........
开发者ID:ClockTeam,项目名称:ClockworkEngine,代码行数:101,代码来源:renderingEngine.cpp

示例4: Entity

void ProvidersTest::setup()
{
    //Make a barrel with mass and burn speed properties
    m_b1 = new Entity("1", 1);
    m_barrelType = new TypeNode("barrel");
    types["barrel"] = m_barrelType;
    m_b1->setType(m_barrelType);
    m_b1->setProperty("mass", new SoftProperty(Element(30)));
    m_b1->setProperty("burn_speed", new SoftProperty(Element(0.3)));
    m_b1->setProperty("isVisible", new SoftProperty(Element(true)));

    //List properties for testing list operators
    SoftProperty* prop1 = new SoftProperty();
    prop1->set(std::vector<Element> { 25.0, 20.0 });
    m_b1->setProperty("float_list", prop1);

    SoftProperty* list_prop2 = new SoftProperty();
    list_prop2->set(std::vector<Element> { "foo", "bar" });
    m_b1->setProperty("string_list", list_prop2);

    //Make a second barrel
    m_b2 = new Entity("2", 2);
    m_b2->setProperty("mass", new SoftProperty(Element(20)));
    m_b2->setProperty("burn_speed", new SoftProperty(0.25));
    m_b2->setType(m_barrelType);
    m_b2->setProperty("isVisible", new SoftProperty(Element(false)));

    //Make first barrel contain the second barrel
    m_b1_container = new LocatedEntitySet;
    m_b1_container->insert(m_b2);
    m_b1->m_contains = m_b1_container;

    //Set bounding box properties for barrels
    BBoxProperty* bbox1 = new BBoxProperty;
    //Specify two corners of bbox in form of x, y, z coordinates
    bbox1->set((std::vector<Element> { -1, -2, -3, 1, 2, 3 }));
    m_b1->setProperty("bbox", bbox1);

    BBoxProperty* bbox2 = new BBoxProperty;
    bbox2->set(std::vector<Element> { -3, -1, -2, 1, 2, 3 });
    m_b2->setProperty("bbox", bbox2);

    ///Set up outfit testing

    //Green Cloth serves as outfit for gloves
    m_clothType = new TypeNode("cloth");
    types["cloth"] = m_clothType;

    m_cloth = new Entity("3", 3);
    m_cloth->setType(m_clothType);
    m_cloth->setProperty("color", new SoftProperty("green"));

    //Create outfit map where "thumb" outfit contains cloth
    std::map<std::string, Element> outfitMap1;
    outfitMap1.insert(std::make_pair("thumb", Element(m_cloth)));
    OutfitProperty* outfit2 = new OutfitProperty;
    outfit2->set(outfitMap1);
    m_glovesEntity = new Entity("4", 4);
    m_glovesEntity->setProperty("color", new SoftProperty("brown"));
    m_glovesEntity->setProperty("outfit", outfit2);

    //Create outfit map where hands of character contain brown gloves
    std::map<std::string, Element> outfitMap;
    outfitMap.insert(std::make_pair("hands", Element(m_glovesEntity)));
    OutfitProperty* outfit1 = new OutfitProperty;
    outfit1->set(outfitMap);

    //Create the character for testing
    m_characterType = new TypeNode("character");
    types["character"] = m_characterType;
    m_ch1 = new Entity("5", 5);
    m_ch1->setType(m_characterType);
    m_ch1->setProperty("outfit", outfit1);

    //Make second barrel contain the character
    m_b2_container = new LocatedEntitySet;
    m_b2_container->insert(m_ch1);
    m_b2->m_contains = m_b2_container;
}
开发者ID:danniellecandys,项目名称:cyphesis,代码行数:79,代码来源:EntityFilterProviderstest.cpp

示例5: operator

 bool ComponentPredicate::operator()(const Entity& entity) {
     return entity.HasComponent(type);
 }
开发者ID:panmar,项目名称:pg3,代码行数:3,代码来源:EntityPredicate.cpp

示例6: memset

/**
* First search seeds by OBA strategy, then egment region by seeds with local minimum z-value
*/
void OBAFilter::segmentRegionBySeeds(const double &seedHeightTh, const double &seedSlopeTh, const double &maxObjSize,
	const double &seedCellSize, const double &segHeightTh, const double &segSlopeTh)
{
	int ii = 0, count = 0, iy = 0, ix = 0, pos = 0, id = 0, entityID = 0;
	double ptZ = 0.0;
	bool *enter_queue = NULL;
	vector<PT> groundSeeds;
	vector<PT>::iterator ptIter;
	PT pt;
	PointType type;
	Entity* entity = NULL;
	PT3D *pt3d;

	// First dispose garbage
	this->dispose();
	count = this->_gridH * this->_gridW;
	this->_entityIDs = new int[count];
	for(ii = 0; ii < count; ++ii)
	{
		this->_entityIDs[ii] = NAN;
	}
	enter_queue = new bool[count];
	memset(enter_queue, 0, count * sizeof(bool));

	// Find ground seeds, and segment from ground seeds
	calcComplexByObj(this->_workSpace, maxObjSize, seedHeightTh, seedSlopeTh);
	SeedGenerator seedGenerator(this->_workSpace, maxObjSize, seedCellSize);
	seedGenerator.findMinSeeds(groundSeeds);
	for (ptIter = groundSeeds.begin(); ptIter != groundSeeds.end(); ++ptIter)
	{
		pt = *ptIter;
		pos = pt.y * this->_gridW + pt.x;
		if(this->_entityIDs[pos] != NAN) 
		{
			continue;
		}
		type = PointType::p_ground;
		entityID++;
		entity = new Entity(entityID, type);
		this->_queue.push_back(pt);
		enter_queue[pos] = true;

		while(!this->isQueueEmpty()) 
		{
			pt = this->popQueue();
			pos = pt.y * this->_gridW + pt.x;
			enter_queue[pos] = false;

			this->_entityIDs[pos] = entityID;
			pt3d = this->_gridIndex->getMinPT3D(pt.x, pt.y);
			entity->addPoint(pt, pt3d->z);

			this->enterQueue(pt, type, enter_queue, segHeightTh, segSlopeTh);
		}
		this->_entitys[entityID] = entity;
	}

	// Segment for the left points 
	for(iy = 0; iy < this->_gridH; ++iy)
	{
		for(ix = 0; ix < this->_gridW; ++ix) 
		{
			pos = iy * this->_gridW + ix;
			if(this->_entityIDs[pos] != NAN) 
			{
				continue;
			}

			// Set an object as an unclassified object if it is not a hole
			type = PointType::p_unclassified;
			pt3d = this->_gridIndex->getMinPT3D(ix, iy);
			if(pt3d == NULL) 
			{
				// Set an object as an created object if it is a hole
				type = PointType::p_created;
			}

			entityID++;
			entity = new Entity(entityID, type);
			pt.x = ix;
			pt.y = iy;
			this->_queue.push_back(pt);
			enter_queue[pos] = true;
			
			// When the queue is empty, a new object is derived
			while(!this->isQueueEmpty()) 
			{
				pt = this->popQueue();
				pos = pt.y * this->_gridW + pt.x;
				enter_queue[pos] = false;

				pt3d = this->_gridIndex->getMinPT3D(pt.x, pt.y);
				if(pt3d == NULL) 
				{
					ptZ = 0.0;
				}
				else
//.........这里部分代码省略.........
开发者ID:yanmenglong,项目名称:ALSDo,代码行数:101,代码来源:obafilter.cpp

示例7: run

string RocketController::run(string myState)
{
	string game_state_request;
	for(vector<Entity*>::size_type i = 0; i != controlled_entities.size(); i++) 
	{
		Entity* ent = controlled_entities[i];
		if(ent->getGameState() == myState)
			{
			if(ent->getActive())
			{
				//SUBTRACT FUEL
				SpaceshipComponent* spaceship = (SpaceshipComponent*) ent->getComponent("Spaceship");
				float current_fuel = spaceship->getCurrentFuel();

				CollectionComponent* collection = (CollectionComponent*) ent->getComponent("Collection");
				vector<Entity*> attached_entities = collection->getAttachedEntities();

				//Cycling through attached entities
				for(vector<Entity*>::size_type p = 0; p != attached_entities.size(); p++) 
				{
					Entity* attached_entity = attached_entities[p];
					attached_entity->setActive(true);

					if(attached_entity->checkIfHasComponent("Rocket"))
					{
						RocketComponent* rocket = (RocketComponent*) attached_entity->getComponent("Rocket");
						TetheredComponent* tethered = (TetheredComponent*) attached_entity->getComponent("Tethered");
						PositionComponent* position = (PositionComponent*) attached_entity->getComponent("Position");
						PhysicsComponent* physics = (PhysicsComponent*) attached_entity->getComponent("Physics");

						physics->clearForces();

						if(rocket->getOnOrOff())
						{
							if(spaceship->getCurrentFuel() - rocket->getFuelConsumption() >= 0)
							{
								//The rocket is on
								float force_exerted = rocket->getForceExerted();
								float angle = position->getAngle();

								float x =  rocket->getForceExerted()*cos(angle);
								float y =  rocket->getForceExerted()*sin(angle);
						
								physics->addTranslationalForce(x,y);

								//Angular Forces

								float distance = tethered->getDistance();
								float angular_force = distance *  rocket->getForceExerted() * -sin(tethered->getT());

								physics->addAngularForce(angular_force);

								//Burning fuel
								spaceship->subtractCurrentFuel(rocket->getFuelConsumption());
							}
						}
					}
				}
			}
			else
			{
				CollectionComponent* collection = (CollectionComponent*) ent->getComponent("Collection");
				vector<Entity*> attached_entities = collection->getAttachedEntities();

				//Cycling through attached entities
				for(vector<Entity*>::size_type p = 0; p != attached_entities.size(); p++) 
				{
					attached_entities[p]->setActive(false);
				}
			}
		}
	}
	return game_state_request;
}
开发者ID:TheNextGuy32,项目名称:Titus-Engine,代码行数:74,代码来源:RocketController.cpp

示例8: render

void RenderingEngine::render(const Entity& entity) const {
	entity.render();
}
开发者ID:oneillsimon,项目名称:GameEngine,代码行数:3,代码来源:render.cpp

示例9: LogWarning

void EC_MediaPlayer::PrepareComponent()
{
    // Don't do anything if rendering is not enabled
    if (!ViewEnabled() || GetFramework()->IsHeadless())
        return;

    // Some security checks
    if (componentPrepared_)
    {
        LogWarning("EC_MediaPlayer: Preparations seem to be done already, you might not want to do this multiple times.");
    }
    if (!mediaPlayer_)
    {
        LogError("EC_MediaPlayer: Cannot start preparing, webview object is null. This should never happen!");
        return;
    }

    // Get parent and connect to the component removed signal.
    Entity *parent = ParentEntity();
    if (parent)
        connect(parent, SIGNAL(ComponentRemoved(IComponent*, AttributeChange::Type)), SLOT(ComponentRemoved(IComponent*, AttributeChange::Type)), Qt::UniqueConnection);
    else
    {
        LogError("EC_MediaPlayer: Could not get parent entity pointer!");
        return;
    }

    // Get EC_Mesh component
    EC_Mesh *mesh = GetMeshComponent();
    if (!mesh)
    {
        // Wait for EC_Mesh to be added.
        connect(parent, SIGNAL(ComponentAdded(IComponent*, AttributeChange::Type)), SLOT(ComponentAdded(IComponent*, AttributeChange::Type)), Qt::UniqueConnection);
        return;
    }
    else
    {
        // Inspect if this mesh is ready for rendering. EC_Mesh being present != being loaded into Ogre and ready for rendering.
        if (!mesh->GetEntity())
        {
            connect(mesh, SIGNAL(MeshChanged()), SLOT(TargetMeshReady()), Qt::UniqueConnection);
            return;
        }
        else
            connect(mesh, SIGNAL(MaterialChanged(uint, const QString&)), SLOT(TargetMeshMaterialChanged(uint, const QString&)), Qt::UniqueConnection);
    }

    if (sceneCanvasName_.isEmpty())
        sceneCanvasName_ = "VlcMediaPlayerCanvas-" + QUuid::createUuid().toString().replace("{", "").replace("}", "");

    // Get or create local EC_WidgetCanvas component
    ComponentPtr iComponent = parent->GetOrCreateComponent(EC_WidgetCanvas::TypeNameStatic(), sceneCanvasName_, AttributeChange::LocalOnly, false);
    EC_WidgetCanvas *sceneCanvas = dynamic_cast<EC_WidgetCanvas*>(iComponent.get());
    if (!sceneCanvas)
    {
        LogError("EC_MediaPlayer: Could not get or create EC_WidgetCanvas component!");
        return;
    }
    sceneCanvas->SetTemporary(true);
    sceneCanvas->SetSelfIllumination(getilluminating());

    // All the needed components are present, mark prepared as true.
    componentPrepared_ = true;

    // We are now prepared, check enabled state and restore possible materials now
    if (!getenabled())
        sceneCanvas->RestoreOriginalMeshMaterials();

    // Show downloading info icon or if not downloading, 
    // ask for a image update from the player
    if (pendingMediaDownload_)
        OnFrameUpdate(downloadingLogo_);
    else
        mediaPlayer_->ForceUpdateImage();
}
开发者ID:katik,项目名称:naali,代码行数:75,代码来源:EC_MediaPlayer.cpp

示例10: LightHandle

void RiseDeadSpell::Update(float timeDelta) {
	
	if(m_creationFailed) {
		m_light = LightHandle();
		return;
	}
	
	m_duration+=200;
	
	m_fissure.Update(timeDelta);
	m_fissure.Render();
	
	if(lightHandleIsValid(m_light)) {
		EERIE_LIGHT * light = lightHandleGet(m_light);
		
		light->intensity = 0.7f + 2.3f;
		light->fallend = 500.f;
		light->fallstart = 400.f;
		light->rgb = Color3f(0.8f, 0.2f, 0.2f);
		light->duration=800;
		light->time_creation = (unsigned long)(arxtime);
	}
	
	unsigned long tim = m_fissure.ulCurrentTime;
	
	if(tim > 3000 && m_entity == EntityHandle() && !m_creationFailed) {
		ARX_SOUND_PlaySFX(SND_SPELL_ELECTRIC, &m_targetPos);
		
		Cylinder phys = Cylinder(m_targetPos, 50, -200);
		
		float anything = CheckAnythingInCylinder(phys, NULL, CFLAG_JUST_TEST);
		
		if(glm::abs(anything) < 30) {
			
			const char * cls = "graph/obj3d/interactive/npc/undead_base/undead_base";
			Entity * io = AddNPC(cls, -1, IO_IMMEDIATELOAD);
			
			if(io) {
				ARX_INTERACTIVE_HideGore(io);
				RestoreInitialIOStatusOfIO(io);
				
				io->summoner = m_caster;
				
				io->ioflags|=IO_NOSAVE;
				m_entity = io->index();
				io->scriptload=1;
				
				ARX_INTERACTIVE_Teleport(io, phys.origin);
				SendInitScriptEvent(io);
				
				if(ValidIONum(m_caster)) {
					EVENT_SENDER = entities[m_caster];
				} else {
					EVENT_SENDER = NULL;
				}
				
				SendIOScriptEvent(io,SM_SUMMONED);
					
				Vec3f pos = m_fissure.m_eSrc;
				pos += randomVec3f() * 100.f;
				pos += Vec3f(-50.f, 50.f, -50.f);
				
				MakeCoolFx(pos);
			}
			
			m_light = LightHandle();
		} else {
			ARX_SOUND_PlaySFX(SND_MAGIC_FIZZLE);
			m_creationFailed = true;
			m_duration=0;
		}
	} else if(!arxtime.is_paused() && tim < 4000) {
	  if(Random::getf() > 0.95f) {
			MakeCoolFx(m_fissure.m_eSrc);
		}
	}
}
开发者ID:grimtraveller,项目名称:ArxLibertatis,代码行数:77,代码来源:SpellsLvl06.cpp

示例11: ARX_DEAD_CODE

void CreateFieldSpell::Launch()
{
	unsigned long start = (unsigned long)(arxtime);
	if(m_flags & SPELLCAST_FLAG_RESTORE) {
		start -= std::min(start, 4000ul);
	}
	m_timcreation = start;
	
	m_duration = (m_launchDuration > -1) ? m_launchDuration : 800000;
	m_hasDuration = true;
	m_fManaCostPerSecond = 1.2f;
	
	Vec3f target;
	float beta = 0.f;
	bool displace = false;
	if(m_caster == PlayerEntityHandle) {
		target = entities.player()->pos;
		beta = player.angle.getPitch();
		displace = true;
	} else {
		if(ValidIONum(m_caster)) {
			Entity * io = entities[m_caster];
			target = io->pos;
			beta = io->angle.getPitch();
			displace = (io->ioflags & IO_NPC) == IO_NPC;
		} else {
			ARX_DEAD_CODE();
		}
	}
	if(displace) {
		target += angleToVectorXZ(beta) * 250.f;
	}
	
	ARX_SOUND_PlaySFX(SND_SPELL_CREATE_FIELD, &target);
	
	res::path cls = "graph/obj3d/interactive/fix_inter/blue_cube/blue_cube";
	Entity * io = AddFix(cls, -1, IO_IMMEDIATELOAD);
	if(io) {
		
		ARX_INTERACTIVE_HideGore(io);
		RestoreInitialIOStatusOfIO(io);
		m_entity = io->index();
		io->scriptload = 1;
		io->ioflags |= IO_NOSAVE | IO_FIELD;
		io->initpos = io->pos = target;
		SendInitScriptEvent(io);
		
		m_field.Create(target);
		m_field.SetDuration(m_duration);
		m_field.lLightId = GetFreeDynLight();
		
		if(lightHandleIsValid(m_field.lLightId)) {
			EERIE_LIGHT * light = lightHandleGet(m_field.lLightId);
			
			light->intensity = 0.7f + 2.3f;
			light->fallend = 500.f;
			light->fallstart = 400.f;
			light->rgb = Color3f(0.8f, 0.0f, 1.0f);
			light->pos = m_field.eSrc - Vec3f(0.f, 150.f, 0.f);
		}
		
		m_duration = m_field.GetDuration();
		
		if(m_flags & SPELLCAST_FLAG_RESTORE) {
			m_field.Update(4000);
		}
		
	} else {
		m_duration = 0;
	}
}
开发者ID:grimtraveller,项目名称:ArxLibertatis,代码行数:71,代码来源:SpellsLvl06.cpp

示例12: field_data_size

/** \brief  Size, in bytes, of the field data for each entity */
inline
unsigned field_data_size( const FieldBase & f , const Entity & e )
{ return field_data_size( f , e.bucket() ); }
开发者ID:haripandey,项目名称:trilinos,代码行数:4,代码来源:FieldData.hpp

示例13: field_data_valid

/** \brief  Check for existence of field data.
 *
 *  \exception std::runtime_error
 *     Thrown if required_by != NULL and the field data does not exist.
 */
inline
bool field_data_valid( const FieldBase & f ,
                       const Entity & e ,
                       const char * required_by = NULL )
{ return field_data_valid( f, e.bucket(), e.bucket_ordinal(), required_by ); }
开发者ID:haripandey,项目名称:trilinos,代码行数:10,代码来源:FieldData.hpp

示例14: join

TransformationData SharedManipulationMerger::calculateResult() {
    TransformationData result;
    unsigned temp;
    unsigned short objectType;
    unsigned short objectId;
    unsigned entityId;
    unsigned tempObjectType, tempObjectId;
    bool tempBool;
    uint64_t pipeId = inputPipeList[0].pipe->getPipeId();
    TransformationManager::unpackPipeId(pipeId, &temp, &temp, &temp, &temp, &tempObjectType,
                                        &tempObjectId, &tempBool);
    objectType = (unsigned short)tempObjectType;
    objectId = (unsigned short)tempObjectId;
    entityId = join(objectType, objectId);
    Entity* ent;

    if (inputPipeList.size() == 1) {
        // do what offset modifier does

        TransformationData resultLastStage;
        User* user = inputPipeList[0].pipe->getOwner();
        TransformationData offset = user->getAssociatedEntityOffset(entityId);
        resultLastStage = inputPipeList[0].transf;
        multiply(result, resultLastStage, offset);

        // 		dumpVec(resultLastStage.position, "SharedManipulationMerger: cursor transf");
        // 		dumpVec(offset.position, "SharedManipulationMerger: picking offset");
        // 		assert(false);

        singleUser = true;
    } else if (singleUser) {
        // got two users the first time
        assert(inputPipeList.size() == 2);

        gmtl::Vec3f center;
        gmtl::Vec3f cursor[2];
        TransformationData entTransf;
        int i;

        for (i = 0; i < 2; i++)
            cursor[i] = inputPipeList[i].transf.position;

        center = (cursor[0] + cursor[1]) * 0.5f;
        ent = WorldDatabase::getEntityWithTypeInstanceId(objectType, objectId);
        assert(ent);

        entTransf = ent->getWorldTransformation();
        scale = entTransf.scale;
        dumpTransformation(entTransf);
        dEntityOrigin = entTransf.position - center;
        axis = cursor[1] - cursor[0];
        gmtl::normalize(axis);
        orientation = entTransf.orientation;

        if (gmtl::length(cursor[0]) < 0.001f || gmtl::length(cursor[1]) < 0.001f) {
            assert(false);
        }
        singleUser = false;
        result = entTransf;

    } else {
        // multiuser
        gmtl::Vec3f center;
        gmtl::Vec3f cursor[2];
        gmtl::Vec3f axisNew;
        gmtl::Vec3f normal;
        gmtl::AxisAnglef rotAngle;
        gmtl::Quatf rotq;
        TransformationData entTransf;
        float dotProduct;
        float angle;
        int i;

        for (i = 0; i < 2; i++)
            cursor[i] = inputPipeList[i].transf.position;

        center = (cursor[0] + cursor[1]) * 0.5f;

        axisNew = cursor[1] - cursor[0];
        gmtl::normalize(axisNew);

        // 		printd("Normal = %f %f %f\n", normal[0], normal[1], normal[2]);
        // 		printd("angle = %f\n", angle);

        dotProduct = gmtl::dot(axis, axisNew);
        // 		if(fabs(dotProduct) > 1)
        // 		{
        // 			printd("axis are very similar\n");
        // 			// gmtl::Vec3f li = axis + gmtl::Vec3f(1, 0, 0);
        // 			gmtl::Vec3f li;
        // 			gmtl::Quatf invOri;
        // 			gmtl::Matrix44f rotm;
        //
        // 			invOri = orientation;
        // 			invert(invOri);
        // 			li = invOri * gmtl::Vec3f(1, 0, 0);
        // 			normalize(li);
        // 			if(fabs(gmtl::dot(li, axis)) >= 0.99999)
        // 			{
        // 				printd("ohoh right and axis are not linear independent\n");
//.........这里部分代码省略.........
开发者ID:flair2005,项目名称:inVRs,代码行数:101,代码来源:SharedManipulationMerger.cpp

示例15: notify_collision

/**
 * \brief This function is called by the engine when there is a collision with another entity.
 * \param entity_overlapping the entity overlapping the detector
 * \param collision_mode the collision mode that detected the collision
 */
void Block::notify_collision(Entity& entity_overlapping, CollisionMode /* collision_mode */) {

  entity_overlapping.notify_collision_with_block(*this);
}
开发者ID:Maxs1789,项目名称:solarus,代码行数:9,代码来源:Block.cpp


注:本文中的Entity类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。