本文整理汇总了C++中RenderComponent类的典型用法代码示例。如果您正苦于以下问题:C++ RenderComponent类的具体用法?C++ RenderComponent怎么用?C++ RenderComponent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了RenderComponent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Context
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);
}
}
示例2: GetLandscape
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;
}
示例3: SkyboxRenderObject
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;
}
示例4: draw
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);
}
}
示例5: Entity
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);
}
示例6: findComponents
//---------------------------------------------------------------------------
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;
}
}
}
}
示例7: findComponents
//---------------------------------------------------------------------------
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;
}
示例8: alignRoundUp
//==============================================================================
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;
}
示例9: processEntity
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());
}
}
示例10: Citizens
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());
}
示例11: GetVisibleEntities
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());
}
}
示例12: Restart
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();
}
}
}
示例13: UpdateDurationForChildNodes
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);
}
}
}
示例14: ToWorld2F
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;
}
示例15: render_entity
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);
}
}