Beispiel #1
0
void CoreScript::AddFlag(const Vector2I& _pos)
{
	Vector2I pos = _pos;
	// A little UI fixup: set the flag to a porch
	// if we click on the switch.
	Chit* building = Context()->chitBag->QueryBuilding(IString(), pos, 0);
	if (building && (building->GetItem()->IName() == ISC::switchOn || building->GetItem()->IName() == ISC::switchOff)) {
		MapSpatialComponent* msc = GET_SUB_COMPONENT(building, SpatialComponent, MapSpatialComponent);
		if (msc) {
			pos = msc->PorchPos().min;
		}
	}

	Flag f = { pos, 0 };
	if (flags.Find(f) < 0) {
		Chit* chit = Context()->chitBag->NewChit();
		RenderComponent* rc = new RenderComponent("flag");
		chit->Add(rc);
		ProcRenderInfo info;
		AssignProcedural(ISC::team,
							false,
							ParentChit()->GetItem()->ID(),
							ParentChit()->Team(),
							false,
							0,
							0,
							&info);
		rc->SetProcedural(0, info);
		chit->SetPosition(ToWorld3F(pos));
		f.chitID = chit->ID();
		flags.Push(f);
	}
}
LandscapeNode* LandscapePropertyControl::GetLandscape() const
{
	RenderComponent* component = cast_if_equal<RenderComponent*>(currentSceneNode->GetComponent(Component::RENDER_COMPONENT));
	LandscapeNode *landscape = dynamic_cast<LandscapeNode*> (component->GetRenderObject());
	DVASSERT(landscape);
	return landscape;
}
	Entity* SkyboxSystem::AddSkybox()
	{
		Entity* result = skyboxEntity;
		
		if(NULL == skyboxEntity)
		{
			SkyboxRenderObject* skyboxRenderObject = new SkyboxRenderObject();
			
			AABBox3 box = AABBox3(Vector3(-0.5f, -0.5f, -0.5f), Vector3(0.5f, 0.5f, 0.5f));
			skyboxRenderObject->Initialize(box); //first time initialization
			
			RenderComponent* renderComponent = new RenderComponent();
			renderComponent->SetRenderObject(skyboxRenderObject);
			
			
			result = new Entity();
			result->SetName("Skybox");

			result->RemoveComponent(Component::RENDER_COMPONENT);
			result->AddComponent(renderComponent);
			renderComponent->Release();

			GetScene()->AddNode(result);
			
			Matrix4 * worldTransformPointer = ((TransformComponent*)result->GetComponent(Component::TRANSFORM_COMPONENT))->GetWorldTransformPtr();
			skyboxRenderObject->SetWorldTransformPtr(worldTransformPointer);
			result->GetScene()->renderSystem->MarkForUpdate(skyboxRenderObject);
			SafeRelease(skyboxRenderObject);
			
			DVASSERT(skyboxEntity);
			result->Release();
		}
		
		return result;
	}
Beispiel #4
0
void RenderSystem::draw(GameObject* gameObject)
{
	RenderComponent* render = gameObject->getComponent<RenderComponent>();
	if (render != nullptr)
	{
		RectangleShape shape = *render->getDrawable();

		TransformComponent* transform = gameObject->getComponent<TransformComponent>();
		if (transform != nullptr)
		{
			shape.setPosition(transform->getPosition());
		}
		else
		{
			BoardComponent* boardComp = gameObject->getComponent<BoardComponent>();
			if (boardComp != nullptr && mBoard != nullptr)
			{
				Vector2i boardPos = boardComp->getPosition();
				shape.setPosition(mBoard->getTilePosition(boardPos.x, boardPos.y));
			}
		}

		mWindow->draw(shape);
	}
}
Beispiel #5
0
Skybox::Skybox(): Entity() {
  NameSystem::instance().add_name_to_entity("Skybox", this->id);
  TransformComponent transform;
  transform.scale = 50.0;
  attach_component(transform);
  RenderComponent render;
  render.set_mesh(MeshPrimitive::CubeCounterClockWinding);
  std::vector<std::string> faces = {Filesystem::base + std::string("resources/environmentmaps/garden/negx.bmp"),
                                    Filesystem::base + std::string("resources/environmentmaps/garden/posx.bmp"),
                                    Filesystem::base + std::string("resources/environmentmaps/garden/posy.bmp"),
                                    Filesystem::base + std::string("resources/environmentmaps/garden/negy.bmp"),
                                    Filesystem::base + std::string("resources/environmentmaps/garden/posz.bmp"),
                                    Filesystem::base + std::string("resources/environmentmaps/garden/negz.bmp")};
  render.set_cube_map_texture(faces);
  render.set_shading_model(ShadingModel::Unlit);
  attach_component(render);

  faces = {Filesystem::base + std::string("resources/lightmaps/garden/negx.bmp"),
           Filesystem::base + std::string("resources/lightmaps/garden/posx.bmp"),
           Filesystem::base + std::string("resources/lightmaps/garden/posy.bmp"),
           Filesystem::base + std::string("resources/lightmaps/garden/negy.bmp"),
           Filesystem::base + std::string("resources/lightmaps/garden/posz.bmp"),
           Filesystem::base + std::string("resources/lightmaps/garden/negz.bmp")};
  MeineKraft::instance().renderer->load_environment_map(faces);
}
Beispiel #6
0
//---------------------------------------------------------------------------
void Avatar::strip()
{
	RenderComponent* pRend = 0;
	findComponents(RenderComponent::getClassDef(), (Component**)&pRend);

	// clear all mountables from all slots on all mount points
	for (MountPoints::iterator it = m_mountPoints.begin(); 
		it != m_mountPoints.end(); ++it)
	{
		EquipmentSlotComponent* pSlot = it->second.m_pSlot;
		if (pSlot)
		{
			size_t numEquipment = pSlot->getNumEquipment();
			for (size_t j=0; j<numEquipment; ++j)
			{
				Mountable* pMountable = pSlot->removeEquipment(j);

				// also, need to unregister the Mountable with any RenderComponent
				// we have (for now, just register with the first one found, if any)
				if (pRend)
					pRend->removeMeshInstanceProvider(pMountable);

				// then finally, destroy and delete it
				if (pMountable)
				{
					pMountable->notifyUnmounted();
					pMountable->destroy();
				}
				delete pMountable;
			}
		}
	}
}
Beispiel #7
0
//---------------------------------------------------------------------------
bool ParticleSystem::initialize()
{
	if (!ZoneObject::initialize())
		return false;

	// early-out if we have no components to initialize (usually true on a server)
	if (!m_components.size())
		return true;

	m_particles.resize(getSystemQuota());

	std::vector<Component*> comp;
	comp.resize(m_components.size());

	// initialize our Emitters 
	size_t numEmitters = 
		findComponents(Emitter::getClassDef(), &comp[0], m_components.size(), true);

	for (size_t i=0; i<numEmitters; ++i)
	{
		Emitter* pEmitter = static_cast<Emitter*>(comp[i]);
		pEmitter->setParticleAllocator(&m_particles);
	}

	// setup our RenderComponent, if any
	RenderComponent* pRenderable = 0;
	if (findComponents(
		RenderComponent::getClassDef(), (Component**)&pRenderable))
	{
		pRenderable->setShadowCaster(false);
		pRenderable->setShadowReceiver(false);
	}

	return true;
}
Beispiel #8
0
//==============================================================================
void RenderableDrawer::setupUniforms(
	VisibleNode& visibleNode, 
	RenderComponent& renderable,
	FrustumComponent& fr,
	F32 flod)
{
	const Material& mtl = renderable.getMaterial();
	U blockSize = mtl.getDefaultBlockSize();
	U8* persistent = (U8*)m_uniformBuff.getPersistentMappingAddress();

	// Find a place to write the uniforms
	//
	U8* prevUniformPtr = m_uniformPtr;
	alignRoundUp(GlDeviceSingleton::get().getBufferOffsetAlignment(
		m_uniformBuff.getTarget()), m_uniformPtr);
	U diff = m_uniformPtr - prevUniformPtr;

	if(m_uniformPtr + blockSize >= persistent + m_uniformBuff.getSize())
	{
		// Rewind
		m_uniformPtr = persistent;
		diff = 0;
	}

	// Call the visitor
	//
	SetupRenderableVariableVisitor vis;
	
	vis.m_visibleNode = &visibleNode;
	vis.m_renderable = &renderable;
	vis.m_fr = &fr;
	vis.m_drawer = this;
	vis.m_instanceCount = visibleNode.m_spatialsCount;
	vis.m_jobs = m_jobs;
	vis.m_flod = flod;

	for(auto it = renderable.getVariablesBegin();
		it != renderable.getVariablesEnd(); ++it)
	{
		RenderComponentVariable* rvar = *it;

		vis.m_rvar = rvar;
		rvar->acceptVisitor(vis);
	}

	// Update the uniform descriptor
	//
	m_uniformBuff.bindShaderBuffer(
		m_jobs, 
		m_uniformPtr - persistent,
		mtl.getDefaultBlockSize(),
		0);

	// Advance the uniform ptr
	m_uniformPtr += blockSize;
	m_uniformsUsedSize += blockSize + diff;
}
Beispiel #9
0
void RemoveEntitySystem::processEntity(artemis::Entity &e){
	RemoveableComponent* remove = removeMapper.get(e);
	RenderComponent* render = renderMapper.get(e);
	if (!remove->isActive()) return;
	if (remove->getRemainTime() <= 0) {
		render->getView()->removeFromParent();
		world->deleteEntity(e);
	}
	else {
		remove->setRemainTime(remove->getRemainTime() - world->getDelta());
	}
}
Beispiel #10
0
int CoreScript::DoTick(U32 delta)
{
	int nScoreTicks = scoreTicker.Delta(delta);
	int nAITicks = aiTicker.Delta(delta);

	Citizens(0);	// if someone was deleted, the spawn tick will reset.
	int nSpawnTicks = spawnTick.Delta(delta);

	// Clean rock off the core.
	Vector2I pos2i = ToWorld2I(parentChit->Position());
	const WorldGrid& wg = Context()->worldMap->GetWorldGrid(pos2i);
	if (wg.RockHeight()) {
		Context()->worldMap->SetRock(pos2i.x, pos2i.y, 0, false, 0);
	}

	if (InUse()) {
		DoTickInUse(delta, nSpawnTicks);
		UpdateScore(nScoreTicks);
	}
	else {
		DoTickNeutral(delta, nSpawnTicks);
	}
	workQueue->DoTick();

	if (nAITicks) {
		UpdateAI();
	}

	for (int i = 0; i < MAX_SQUADS; ++i) {
		if (squads[i].Empty()) {
			waypoints[i].Clear();
		}
	}

	if (strategicTicker.Delta(delta)) {
		if (this->InUse() && Context()->chitBag->GetHomeCore() != this) {
			DoStrategicTick();
		}
	}

	RenderComponent* rc = parentChit->GetRenderComponent();
	if (rc) {
		int team = parentChit->Team();
		CStr<40> str = "";
		if (this->InUse() && Team::IsDenizen(team)) {
			IString teamName = Team::Instance()->TeamName(team);
			str.Format("%s", teamName.safe_str());
		}
		rc->SetDecoText(str.safe_str());
	}

	return Min(spawnTick.Next(), aiTicker.Next(), scoreTicker.Next());
}
Beispiel #11
0
 void GUIManager::GetVisibleEntities(RenderList* List)
 {
     for(i32 i = 0;i < m_Elements.size();i++)
     {
         RenderComponent* r = (RenderComponent*)m_Elements[i].get()->GetOwner()->GetComponentByType(CT_RENDER);
         if(!m_Elements[i]->GetOwner()->HasComponentType(CT_RENDER)) continue;
         if(!r->GetMesh()) continue;
         if(r->IsHidden()) continue;
         if(r->GetMesh()->NeedsSync())
         if(r->GetVertexCount() == 0) continue;
         List->AddEntity(m_Elements[i].get()->GetOwner());
     }
 }
void ParticleEffectComponent::Restart()
{
	int32 childrenCount = entity->GetChildrenCount();
	for (int32 i = 0; i < childrenCount; i ++)
	{
		RenderComponent * component = static_cast<RenderComponent*>(entity->GetChild(i)->GetComponent(Component::RENDER_COMPONENT));
		if(component && component->GetRenderObject() && component->GetRenderObject()->GetType() == RenderObject::TYPE_PARTICLE_EMTITTER)
		{
			ParticleEmitter * emitter = static_cast<ParticleEmitter*>(component->GetRenderObject());
			emitter->Restart();
		}
	}
}
void ParticleEffectComponent::UpdateDurationForChildNodes(float32 newEmitterLifeTime)
{
	int32 childrenCount = entity->GetChildrenCount();
	for (int32 i = 0; i < childrenCount; i ++)
	{
		RenderComponent * component = static_cast<RenderComponent*>(entity->GetChild(i)->GetComponent(Component::RENDER_COMPONENT));
		if(component && component->GetRenderObject() && component->GetRenderObject()->GetType() == RenderObject::TYPE_PARTICLE_EMTITTER)
		{
			ParticleEmitter * emitter = static_cast<ParticleEmitter*>(component->GetRenderObject());
			emitter->SetLifeTime(newEmitterLifeTime);
		}
	}
}
int MapSpatialComponent::DoTick(U32 delta)
{
	if (slowTick.Delta(delta)) {
		CoreScript* cs = CoreScript::GetCore(ToSector(parentChit->Position()));
		glowTarget = 0;

		if (needsCorePower) {
			if (cs && cs->InUse()) {
				Rectangle2I porch = this->PorchPos();
				if (porch.min.IsZero()) {
					// No porch. Just need core.
					glowTarget = 1;
				}
				else {
					Vector2F start = ToWorld2F(porch.min);
					Vector2F end = ToWorld2F(cs->ParentChit()->Position());
					if (Context()->worldMap->CalcPath(start, end, 0, 0, false)) {
						glowTarget = 1;
					}
				}
			}
		}
		else {
			glowTarget = 1;
			glow = 1;
		}
	}

	if (glow != glowTarget) {
		glow = TravelTo(0.7f, delta, glow, glowTarget);
	}
	if (parentChit->GetItem() && parentChit->GetItem()->IName() == ISC::core) {
		glow = glowTarget = 1;
	}

	RenderComponent* rc = parentChit->GetRenderComponent();
	if (rc) {
		const GameItem* gameItem = parentChit->GetItem();
		if (gameItem && gameItem->keyValues.GetIString(ISC::procedural) == ISC::team) {
//			int team = parentChit->Team();
			ProcRenderInfo info;
			AssignProcedural(parentChit->GetItem(), &info);
			info.color.X(Matrix4::M41) *= glow;
			info.color.X(Matrix4::M42) *= glow;
			info.color.X(Matrix4::M43) *= glow;
			rc->SetProcedural(0, info);
			rc->SetSaturation(0.5f + 0.5f*glow);
		}
	}
	return VERY_LONG_TICK;
}
    void render_entity(std::pair<Entity *, BaseComponent *> const & pair) {
        
        Entity * entity = pair.first;
        int id = entity->id;
        
        RenderComponent * render = (RenderComponent *) pair.second;
        
        TransformComponent * transform = entity->getComponent<TransformComponent>();
        
        if (transform != NULL) {
            render->draw(transform);
        }

    }
RenderObject * GetRenderObject(const Entity * fromEntity)
{
	RenderObject * object = 0;

	if(NULL != fromEntity)
	{
		RenderComponent * component = static_cast<RenderComponent*>(fromEntity->GetComponent(Component::RENDER_COMPONENT));
		if(component)
		{
			object = component->GetRenderObject();
		}
	}

	return object;
}
Beispiel #17
0
void World::AddEntity(Entity *entity) {
  entities.push_back(entity);

  // Check for RenderComponent and TransformComponent
  RenderComponent *render =
      dynamic_cast<RenderComponent *>(entity->GetComponent(RENDER_COMPONENT));
  TransformComponent *transform = dynamic_cast<TransformComponent *>(
      entity->GetComponent(TRANSFORM_COMPONENT));

  if (render != NULL && transform != NULL) {
    renderer->Add(render->GetMesh(), render->GetMaterial(), transform);
  }

  entity->Init();
}
PropertyControlCreator::ePropertyControlIDs PropertyControlCreator::DetectNodeType(SceneNode *node)
{
    if(node->GetComponent(Component::LIGHT_COMPONENT))
    {
        return EPCID_LIGHT;
    }
    
    if(node->GetComponent(Component::CAMERA_COMPONENT))
    {
        return EPCID_CAMERA;
    }
    
    if(node->GetComponent(Component::SWITCH_COMPONENT))
    {
        return EPCID_SWITCH;
    }
    
    if(GetEmitter(node))
    {
        return EPCID_PARTICLE_EMITTER;
    }
    
    if(node->GetComponent(Component::PARTICLE_EFFECT_COMPONENT))
    {
        return EPCID_PARTICLE_EFFECT;
    }

    if(node->GetComponent(Component::LOD_COMPONENT))
    {
        return EPCID_LODNODE;
    }

    
    
    RenderComponent *rc = static_cast<RenderComponent *>(node->GetComponent(Component::RENDER_COMPONENT));
    if(rc)
    {
        RenderObject *ro = rc->GetRenderObject();
        
        if(dynamic_cast<LandscapeNode *>(ro))
        {
            return EPCID_LANDSCAPE;
        }
    }
    
    
    return EPCID_NODE;
}
Beispiel #19
0
inline Landscape* Test::GetLandscape()
{
	SettingsManager* settings = SettingsManager::Instance();
	Entity* landscapeNode = GetScene()->FindByName(settings->GetLandscapeNodeName());
	Landscape* landscape = NULL;
	if (landscapeNode)
	{
		RenderComponent* renderComponent = cast_if_equal<RenderComponent*>(landscapeNode->GetComponent(Component::RENDER_COMPONENT));
		if (renderComponent)
		{
			landscape = dynamic_cast<Landscape*>(renderComponent->GetRenderObject());
		}
	}

	return landscape;
}
Beispiel #20
0
 void GUIManager::OnMouseUp(i32 Button, Vec2 cPos)
 {
     for(i32 i = (i32)m_Elements.size() - 1;i >= 0;i--)
     {
         RenderComponent* r = (RenderComponent*)m_Elements[i].get()->GetOwner()->GetComponentByType(CT_RENDER);
         if(r->IsHidden()) continue;
         Vec2 Pos = m_Elements[i].get()->GetPosition();
         Vec2 Sz  = m_Elements[i].get()->GetSize();
         if(cPos.x > Pos.x && cPos.x < Pos.x + Sz.x
         && cPos.y > Pos.y && cPos.y < Pos.y + Sz.y)
         {
             m_Elements[i].get()->OnMouseUp(Button, cPos);
             break;
         }
     }
 }
Beispiel #21
0
RenderComponent* RenderManager::CreateRenderComponent(std::string objectName)
{
	//Create a new render component and return it
	RenderComponent newComponent;

	if (objectName.compare("ball") == 0)
	{
		newComponent.SetDrawPrimitive(GL_LINES);
		newComponent.SetVertices(CreateSphere(glm::vec3(0, 0, 0), 1));
	}
	else if (objectName.compare("ground") == 0)
	{
		newComponent.SetDrawPrimitive(GL_TRIANGLES);
		newComponent.SetVertices(CreateBox(glm::vec3(0, 0, 0), 100, 6, 100));
		std::vector<glm::vec3> temp;
		temp.push_back(glm::vec3(0.f, 0.f, 1.f));
		newComponent.SetColor(temp);
	}
	else if (objectName.compare("car") == 0)
	{
		float wheelWidth = 0.4, connectionHeight = 0.5, wheelRadius = 0.4;

		newComponent.SetDrawPrimitive(GL_TRIANGLES);
		CarInfo carInfo;
		carInfo.wheelPositions.push_back(glm::vec3(1 - (0.3*wheelWidth), connectionHeight, 2 - wheelRadius));
		carInfo.wheelPositions.push_back(glm::vec3(-1 + (0.3*wheelWidth), connectionHeight, 2 - wheelRadius));
		carInfo.wheelPositions.push_back(glm::vec3(-1 + (0.3*wheelWidth),connectionHeight, -2 + wheelRadius));
		carInfo.wheelPositions.push_back(glm::vec3(1 - (0.3*wheelWidth), connectionHeight, -2 + wheelRadius));
		carInfo.bodyParameters[0] = 2.f;
		carInfo.bodyParameters[1] = 1.f;
		carInfo.bodyParameters[2] = 4.f;
		carInfo.wheelRadius = wheelRadius;
		carInfo.wheelWidth = wheelWidth;
		carInfo.wheelConnectionHeight = connectionHeight;
		newComponent.SetVertices(CreateCar(carInfo));
		std::vector<glm::vec3> color;
		color.push_back(glm::vec3(0.0f, 1.f, 0.f));
		newComponent.SetColor(color);
	}
	else
		return NULL;

	newComponent.SetProgram(m_program);

	m_renderComponents.push_back(newComponent);
	return &m_renderComponents[m_renderComponents.size() - 1];
}
Beispiel #22
0
RenderComponent* RenderManager::CreateRay(glm::vec3 start, glm::vec3 end)
{
	RenderComponent newComponent;
	std::vector<glm::vec3> temp;
	newComponent.SetDrawPrimitive(GL_LINES);

	temp.push_back(start);
	temp.push_back(end);
	newComponent.SetVertices(temp);

	temp.clear();
	temp.push_back(glm::vec3(1.f, 0.f, 0.f));
	newComponent.SetColor(temp);

	m_renderComponents.push_back(newComponent);
	return &m_renderComponents[m_renderComponents.size() - 1];
}
void ForwardAmbientLightShader::draw(const RenderComponent& renderComponent) {
	if (!renderComponent.material.hasDiffuse()) {
		return;
	}
	setMaterial(renderComponent.material);
	setUniform("modelToWorldMatrix", renderComponent.getTransformationMatrix());
	renderComponent.mesh->draw();
}
void RecursiveProcessMeshNode(Entity * curr, void * userData, void(*process)(Entity*, void *))
{
	RenderComponent * comp = (RenderComponent*)curr->GetComponent(Component::RENDER_COMPONENT);
	if (comp)
	{
		RenderObject * renderObject = comp->GetRenderObject();
		if (renderObject->GetType() == RenderObject::TYPE_MESH)
		{
			process(curr, userData);
		}
	}
	else
	{
		for (int32 i = 0; i < curr->GetChildrenCount(); i++)
			RecursiveProcessMeshNode(curr->GetChild(i), userData, process);
	}
}
Beispiel #25
0
void TextureHelper::EnumerateTextures(DAVA::Entity *forNode, Map<String, Texture *> &textures)
{
	if(!forNode)  return;

	Vector<Entity *> nodes;
	forNode->GetChildNodes(nodes);

	nodes.push_back(forNode);

	for(int32 n = 0; n < (int32)nodes.size(); ++n)
	{
		RenderComponent *rc = static_cast<RenderComponent *>(nodes[n]->GetComponent(Component::RENDER_COMPONENT));
		if(!rc) continue;

		RenderObject *ro = rc->GetRenderObject();
		if(!ro) continue;

		uint32 count = ro->GetRenderBatchCount();
		for(uint32 b = 0; b < count; ++b)
		{
			RenderBatch *renderBatch = ro->GetRenderBatch(b);

			NMaterial *material = renderBatch->GetMaterial();
			if(material)
			{
				for(int32 t = 0; t < material->GetTextureCount(); ++t)
				{
					Texture* tx = material->GetTexture(t);
					CollectTexture(textures, tx->GetPathname(), tx);
				}
			}

			/*InstanceMaterialState *instanceMaterial = renderBatch->GetMaterialInstance();
			if(instanceMaterial)
			{
				CollectTexture(textures, instanceMaterial->GetLightmapName(), instanceMaterial->GetLightmap());
			}*/
		}

		Landscape *land = dynamic_cast<Landscape *>(ro);
		if(land)
		{
			CollectLandscapeTextures(textures, land);
		}
	}
}
void SceneHelper::EnumerateDescriptors(DAVA::Entity *forNode, DAVA::Set<DAVA::FilePath> &descriptors)
{
	if(!forNode)  return;

	Vector<Entity *> nodes;
	forNode->GetChildNodes(nodes);

	nodes.push_back(forNode);

	for(int32 n = 0; n < (int32)nodes.size(); ++n)
	{
		RenderComponent *rc = static_cast<RenderComponent *>(nodes[n]->GetComponent(Component::RENDER_COMPONENT));
		if(!rc) continue;

		RenderObject *ro = rc->GetRenderObject();
		if(!ro) continue;

		uint32 count = ro->GetRenderBatchCount();
		for(uint32 b = 0; b < count; ++b)
		{
			RenderBatch *renderBatch = ro->GetRenderBatch(b);

			Material *material = renderBatch->GetMaterial();
			if(material)
			{
				for(int32 t = 0; t < Material::TEXTURE_COUNT; ++t)
				{
					CollectDescriptors(descriptors, material->GetTextureName((DAVA::Material::eTextureLevel)t));
				}
			}

			InstanceMaterialState *instanceMaterial = renderBatch->GetMaterialInstance();
			if(instanceMaterial)
			{
				CollectDescriptors(descriptors, instanceMaterial->GetLightmapName());
			}
		}

		Landscape *land = dynamic_cast<Landscape *>(ro);
		if(land)
		{
			CollectLandscapeDescriptors(descriptors, land);
		}
	}
}
Beispiel #27
0
void TestGame::Init() {
    Entity *camera = new Entity( Vector3f( 0, 5, 15 ) );
    camera->AddComponent( new FreeLookFreeMoveComponent() );
    SetCamera( camera );
    
    Planet *planet = new Planet( 12310, 4, 10.0f, 30 );
    
    Entity *entity = new Entity();
    RenderComponent* render = new RenderComponent( planet->CreateMesh() );
    render->SetShaderType( ShaderType::SHADER_COLORIZED );
    entity->AddComponent( render );
	entity->AddComponent( new PlanetColorComponent( planet ) );
    AddToScene( entity );
    
    // Entity* cube = new Entity();
    // cube->AddComponent( new RenderComponent( "cube.obj", "test.png" ) );
    // AddToScene( cube );
}
void ParticleEffectComponent::EffectUpdate(float32 timeElapsed)
{
	int32 childrenCount = entity->GetChildrenCount();
	for (int32 i = 0; i < childrenCount; i ++)
	{
		RenderComponent * component = static_cast<RenderComponent*>(entity->GetChild(i)->GetComponent(Component::RENDER_COMPONENT));
		if(component && component->GetRenderObject() && component->GetRenderObject()->GetType() == RenderObject::TYPE_PARTICLE_EMTITTER)
		{
			ParticleEmitter * emitter = static_cast<ParticleEmitter*>(component->GetRenderObject());
			if (IsStopEmitter(emitter))
			{
				emitter->Stop();
				this->emittersCurrentlyStopped++;

				// Are all the emitters finished playback? Notify user if yes.
				CheckPlaybackComplete();
			}
		}
	}
}
Beispiel #29
0
//---------------------------------------------------------------------------
bool Avatar::addToSlot(Mountable* pMountable, int slotId)
{
	// first, check to see if we have mount points; if not, store this off
	// in a delayed mount list
	if (!m_mountPoints.size())
	{
		DelayedMount delayed;
		delayed.pMountable = pMountable;
		delayed.slotId = slotId;
		m_delayedMounts.push_back(delayed);
		return true;
	}

	// look through the mount points (since it's cheaper to iterate this 
	// set than it is to look up all of the slot components) for a slot that
	// has this ID; if not found, return false
	for (MountPoints::iterator it = m_mountPoints.begin(); 
		it != m_mountPoints.end(); ++it)
	{
		EquipmentSlotComponent* pSlot = it->second.m_pSlot;
		if (pSlot && pSlot->getID() == slotId)
		{
			if (pSlot->addEquipment(pMountable))
			{
				pMountable->notifyMounted(pSlot);

				// also, need to register the Mountable with any RenderComponent
				// we have (for now, just register with the first one found, if any)
				RenderComponent* pRend = 0;
				if (findComponents(RenderComponent::getClassDef(), (Component**)&pRend))
				{
					pRend->addMeshInstanceProvider(pMountable);
				}

				return true;
			}
		}
	}

	return false;
}
void SceneValidator::ValidateRenderComponent(Entity *ownerNode, Set<String> &errorsLog)
{
    RenderComponent *rc = static_cast<RenderComponent *>(ownerNode->GetComponent(Component::RENDER_COMPONENT));
    if(!rc) return;
    
    RenderObject *ro = rc->GetRenderObject();
    if(!ro) return;
    
    uint32 count = ro->GetRenderBatchCount();
    for(uint32 b = 0; b < count; ++b)
    {
        RenderBatch *renderBatch = ro->GetRenderBatch(b);
        ValidateRenderBatch(ownerNode, renderBatch, errorsLog);
    }
    
	if(ro->GetType() == RenderObject::TYPE_LANDSCAPE)
    {
		Landscape *landscape = static_cast<Landscape *>(ro);
        ValidateLandscape(landscape, errorsLog);

		ValidateCustomColorsTexture(ownerNode, errorsLog);
    }
}