本文整理汇总了C++中MeshObject::SetMesh方法的典型用法代码示例。如果您正苦于以下问题:C++ MeshObject::SetMesh方法的具体用法?C++ MeshObject::SetMesh怎么用?C++ MeshObject::SetMesh使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MeshObject
的用法示例。
在下文中一共展示了MeshObject::SetMesh方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AddBox
// 添加一个盒子
void GameGrid::AddBox(const Point3& pos)
{
// 格子被占据,不添加
if (!m_World[pos.x][pos.y][pos.z].obj)
{
Vector3f p((float)pos.x - 0.5f - WORLD_SIZE / 2 + 1, (float)pos.y + 0.5f, (float)pos.z - 0.5f - WORLD_SIZE / 2 + 1);
WorldGrid* grid = &m_World[pos.x][pos.y][pos.z];
//grid->pos = pos;
MeshObject* obj = FACTORY_CREATE(m_Scene, MeshObject);
obj->SetMesh(m_MeshBox);
obj->SetPosition(p);
obj->SetMaterial(m_BoxMaterial, 0);
//obj->CreateLightableObject();
grid->obj = obj;
}
}
示例2: StartGame
void particleGame::StartGame()
{
m_Scene = new SceneGraph;
Renderer::Instance().SetAmbientColor(Color4f(0.7f, 0.7f, 0.7f));
m_Camera = static_cast<Camera*>(m_Scene->CreateSceneObject("Camera"));
m_Camera->SetPosition(Vector3f(1.0f, 0.0f, 5.0f));
m_Camera->SetFarClippingDistance(1000.0f);
m_AudioListener = static_cast<AudioListener*>(m_Scene->CreateSceneObject("AudioListener"));
m_Camera->AttachChildObject(m_AudioListener, false);
m_MatSmoke = MaterialManager::Instance().GetByName("smoke");
//m_MatSmoke->SetTexture(Renderer::Instance().GetTexture("smoke"));
//m_MatSmoke->SetLighting(false);
//m_MatSmoke->SetDepthWriting(false);
//m_MatSmoke->SetAlphaTest(true);
//m_MatSmoke->SetAlphaRef(0.2f);
//m_MatSmoke->GetTextureRenderState(0)->envMode = ENV_MODE_ADD;
m_UIFps = EGUIManager::Instance().CreateTextUIControl();
m_UIFps->SetWidth(640);
//Mesh* mesh = MeshManager::Instance().GetByName("marcus");
PrimitiveMesh* mesh = MeshManager::Instance().CreatePrimitiveMesh();
mesh->CreateBox(1.0f);
MeshObject* obj = static_cast<MeshObject*>(m_Scene->CreateSceneObject("MeshObject"));
obj->SetMesh(mesh);
ParticlePool* pool = static_cast<ParticlePool*>(m_Scene->CreateSceneObject("ParticlePool"));
pool->SetMaterial(m_MatSmoke);
for (int i=0; i<50; i++)
{
Particle p;
p.m_Active = true;
//p.m_Color = Color4f(0.0f, 0.0f, 0.0f, 0.5f);
p.m_Color = Color4f(1.0f, 1.0f, 1.0f, 0.5f);
p.scale = Math::Random(50.0f, 100.0f);
p.spin = Math::Random(-Math::kPi, Math::kPi);
p.spinInc = Math::Random(-0.1f, 0.1f);
//p.m_ScreenScaleX = Math::Random(0.5f, 1.5f);
//p.m_ScreenScaleY = Math::Random(0.5f, 1.5f);
p.m_Position = Vector3f(Math::Random(-50.0f, 50.0f), Math::Random(0.0f, 10.0f), Math::Random(-50.0f, 50.0f));
pool->AddParticle(p);
}
Material* matFlare = MaterialManager::Instance().GetByName("flare");
//ITexture* tex_flare = Renderer::Instance().GetTexture("flare");
//matFlare->SetTexture(tex_flare);
//matFlare->SetLighting(false);
//matFlare->SetDepthWriting(false);
//// 混合模式 叠加
//matFlare->GetTextureRenderState(0)->useBlending = true;
//matFlare->GetTextureRenderState(0)->srcBlendFactor = BLEND_FACTOR_ONE;
//matFlare->GetTextureRenderState(0)->dstBlendFactor = BLEND_FACTOR_ONE;
////matFlare->GetTextureRenderState(0)->envMode = ENV_MODE_ADD;
// 光晕
bb = static_cast<Billboard*>(m_Scene->CreateSceneObject("Billboard"));
bb->SetMaterial(matFlare);
bb->SetScale(10.0f);
bb->SetScreenSpaceScale(10.0f, 1.0f);
bb->SetColor(Color4f(1.0f, 0.5f, 0.0f, 1.0f));
//bb->SetRenderOrder(120);
emitter = static_cast<ParticleEmitter*>(m_Scene->CreateSceneObject("ParticleEmitter"));
emitter->SetInterval(50);
emitter->SetMaterial(m_MatSmoke);
emitter->SetEmitterShape(EMITTER_SHAPE_BOX);
emitter->SetBoxRange(Vector3f(-1.0f, -1.0f, -1.0f), Vector3f(1.0f, 1.0f, 1.0f));
//emitter->SetParticleInitStateFunc(ParticleState);
emitter->SetPosition(Vector3f(0.0f, 150.0f, 0.0f));
//emitter->SetParticleBehaviorFunc(&ParticleUpdate);
emitter->SetParticleLifetime(5000);
emitter->SetInitialScale(10.0f);
emitter->SetScaleInc(20.0f);
emitter->SetSpinVar(Math::kPi);
emitter->SetSpinIncVar(0.5f);
//m_Camera->AttachChildObject(emitter, true);
emitter->AttachChildObject(bb);
//Engine::Instance().ToggleDebugRender(true);
//IAudioBuffer* buffer = Engine::Instance().AudioSystem()->GetAudioBuffer("down");
//IAudioSource* source = Engine::Instance().AudioSystem()->CreateSourceInstance(buffer, Vector3f(0.0f, 0.0f, 0.0f));
//source->SetLooping(true);
//source->Play();
//AudioSourceObject* sound = new AudioSourceObject();
//sound->CreateAudioSource("down");
//sound->SetLooping(true);
//sound->Play();
//sound->SetVelocityFactor(1.0f);
//m_Scene->AddObject(sound);
//emitter->AttachChildObject(sound);
//.........这里部分代码省略.........