本文整理汇总了C++中ogre::SceneManager::createManualObject方法的典型用法代码示例。如果您正苦于以下问题:C++ SceneManager::createManualObject方法的具体用法?C++ SceneManager::createManualObject怎么用?C++ SceneManager::createManualObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::SceneManager
的用法示例。
在下文中一共展示了SceneManager::createManualObject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: drawRaycast
// Dibujado de raycast para depurar
void CShootRaycast::drawRaycast(const Ray& raycast) {
Graphics::CScene *scene = Graphics::CServer::getSingletonPtr()->getActiveScene();
Ogre::SceneManager *mSceneMgr = scene->getSceneMgr();
std::stringstream aux;
aux << "laser" << _nameWeapon << _temporal;
++_temporal;
std::string laser = aux.str();
Ogre::ManualObject* myManualObject = mSceneMgr->createManualObject(laser);
Ogre::SceneNode* myManualObjectNode = mSceneMgr->getRootSceneNode()->createChildSceneNode(laser+"_node");
myManualObject->begin("laser", Ogre::RenderOperation::OT_LINE_STRIP);
Vector3 v = raycast.getOrigin();
myManualObject->position(v.x,v.y,v.z);
for(int i=0; i < _distance;++i){
Vector3 v = raycast.getPoint(i);
myManualObject->position(v.x,v.y,v.z);
// etc
}
myManualObject->end();
myManualObjectNode->attachObject(myManualObject);
}// drawRaycast
示例2: debugDrawClassification
void NavigationCell::debugDrawClassification( Ogre::Vector3 start, Ogre::Vector3 end )
{
Ogre::Root *root = Ogre::Root::getSingletonPtr();
Ogre::SceneManager* mgr = root->getSceneManager( "SceneManagerInstance" );
Ogre::ManualObject* debug;
Ogre::SceneNode* node;
if( mgr->hasManualObject( "debugDrawClassification" ) )
debug = mgr->getManualObject( "debugDrawClassification" );
else
{
debug = mgr->createManualObject( "debugDrawClassification" );
node = mgr->getRootSceneNode()->createChildSceneNode();
node->attachObject( debug );
node->translate( 0, 1, 0 );
debug->setQueryFlags( 0 );
debug->setRenderQueueGroup( Ogre::RENDER_QUEUE_OVERLAY );
}
debug->begin( "debug/blue", Ogre::RenderOperation::OT_LINE_LIST );
debug->position( start );
debug->position( end );
debug->end();
// debugDrawCell( debug, "debug/yellow", "debug/blue" );
}
示例3: createBeamGun
Entity* EntityFactory::createBeamGun(const BeamGunConfig& config)
{
EntityManager* entityMgr = engine_->entityMgr_;
Entity* entity = entityMgr->create();
float y = 0.1f;
b2BodyDef bd;
bd.type = b2_dynamicBody;
bd.position.Set(config.posX_, config.posY_);
b2Body* body = engine_->sysPhysics_->getWorld()->CreateBody(&bd);
b2PolygonShape shape;
b2Vec2 vertices[4];
vertices[0].Set(0, y);
vertices[1].Set(0, -y);
vertices[2].Set(config.beamRange_, -y);
vertices[3].Set(config.beamRange_, y);
shape.Set(vertices, 4);
b2FixtureDef sd;
sd.shape = &shape;
sd.density = 0;
sd.filter.categoryBits = ComPhysics::CATEG_PlayerBeam;
sd.filter.maskBits = ComPhysics::MASK_PlayerBeam;
body->CreateFixture(&sd);
ComPhysics* comPhysics = entityMgr->assignComponent<ComPhysics>(entity);
comPhysics->setMainBody(body, entity);
Ogre::SceneManager* sceneMgr = engine_->sysGraphics_->getSceneManager();
Ogre::ManualObject* manual = sceneMgr->createManualObject();
manual->begin("beam", Ogre::RenderOperation::OT_LINE_STRIP);
manual->position(0, y, 0);
manual->position(0, -y, 0);
manual->position(config.beamRange_, -y, 0);
manual->position(config.beamRange_, y, 0);
manual->position(0, y, 0);
manual->end();
Ogre::SceneNode* node = engine_->sysGraphics_->getSceneRoot()->createChildSceneNode(
Ogre::Vector3(config.posX_, config.posY_, 0));
node->attachObject(manual);
ComGraphics* comGraphics = entityMgr->assignComponent<ComGraphics>(entity);
comGraphics->sceneNode_ = node;
return entity;
}
示例4: IComponent
EC_SelectionBox::EC_SelectionBox(Scene* scene) :
IComponent(scene),
selectionBox_(0)
{
if (scene)
world_ = scene->GetWorld<OgreWorld>();
OgreWorldPtr world = world_.lock();
Ogre::SceneManager* sceneMgr = world->GetSceneManager();
selectionBox_ = sceneMgr->createManualObject(world->GetUniqueObjectName("EC_Selected"));
selectionBox_->setRenderQueueGroup(Ogre::RENDER_QUEUE_OVERLAY);
selectionBox_->setUseIdentityProjection(true);
selectionBox_->setUseIdentityView(true);
selectionBox_->setQueryFlags(0);
sceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(selectionBox_);
}
示例5: debugDrawCellAndNeigbours
void NavigationCell::debugDrawCellAndNeigbours()
{
Ogre::Root *root = Ogre::Root::getSingletonPtr();
Ogre::SceneManager* mgr = root->getSceneManager( "SceneManagerInstance" );
Ogre::ManualObject* debug;
Ogre::SceneNode* debugNode;
if( mgr->hasSceneNode( "debugDrawNode" ) )
{
debugNode = mgr->getSceneNode( "debugDrawNode" );
}
else
{
debugNode = mgr->getRootSceneNode()->createChildSceneNode( "debugDrawNode" );
debugNode->translate( 0, 1, 0 ); // Move up slightly to see lines better.
}
if( mgr->hasManualObject( "debugDraw" ) )
debug = mgr->getManualObject( "debugDraw" );
else
{
debug = mgr->createManualObject( "debugDraw" );
debugNode->attachObject( debug );
debug->setQueryFlags( 0 );
debug->setRenderQueueGroup( Ogre::RENDER_QUEUE_OVERLAY );
}
for( int i = 0; i < 3; i++ )
{
if( mLinks[i] )
{
debug->begin( "debug/blue", Ogre::RenderOperation::OT_LINE_STRIP );
debug->position( mLinks[i]->mVertices[0] );
debug->position( mLinks[i]->mVertices[1] );
debug->position( mLinks[i]->mVertices[2] );
debug->position( mLinks[i]->mVertices[0] );
debug->end();
}
}
debug->begin( "debug/yellow", Ogre::RenderOperation::OT_LINE_STRIP );
debug->position( mVertices[0].x, mVertices[0].y+1, mVertices[0].z );
debug->position( mVertices[1].x, mVertices[1].y+1, mVertices[1].z );
debug->position( mVertices[2].x, mVertices[2].y+1, mVertices[2].z );
debug->position( mVertices[0].x, mVertices[0].y+1, mVertices[0].z );
debug->end();
}
示例6: setShow
void NavigationMesh::setShow( bool show )
{
Ogre::Root *root = Ogre::Root::getSingletonPtr();
Ogre::SceneManager* mgr = root->getSceneManager( "SceneManagerInstance" );
Ogre::ManualObject* debug;
Ogre::SceneNode* debugNode;
mShow = show;
if( mgr->hasSceneNode( "debugDrawNode2" ) )
{
debugNode = mgr->getSceneNode( "debugDrawNode2" );
}
else
{
debugNode = mgr->getRootSceneNode()->createChildSceneNode( "debugDrawNode2" );
debugNode->translate( 0, 1, 0 ); // Move up slightly to see lines better.
}
if( mgr->hasManualObject( "debugDraw2" ) )
debug = mgr->getManualObject( "debugDraw2" );
else
{
debug = mgr->createManualObject( "debugDraw2" );
debugNode->attachObject( debug );
debug->setQueryFlags( 0 );
debug->setRenderQueueGroup( Ogre::RENDER_QUEUE_OVERLAY );
}
if( !mShow )
{
mgr->destroyManualObject( debug );
return;
}
for( CellVector::iterator i = mCells.begin(); i != mCells.end(); i++ )
{
i->debugDrawCell( debug, "debug/yellow", "debug/blue" );
}
return;
}
示例7: realizeMesh
Ogre::MeshPtr Path::realizeMesh(const std::string& name)
{
Ogre::SceneManager *smgr = Ogre::Root::getSingleton().getSceneManagerIterator().begin()->second;
Ogre::ManualObject * manual = smgr->createManualObject();
manual->begin("BaseWhiteNoLighting", Ogre::RenderOperation::OT_LINE_STRIP);
for (std::vector<Ogre::Vector3>::iterator itPos = mPoints.begin(); itPos != mPoints.end(); itPos++)
manual->position(*itPos);
if (mClosed)
manual->position(*(mPoints.begin()));
manual->end();
Ogre::MeshPtr mesh;
if (name=="")
mesh = manual->convertToMesh(Utils::getName());
else
mesh = manual->convertToMesh(name);
return mesh;
}
示例8:
InfluenceMapDrawer::InfluenceMapDrawer(Ogre::SceneManager& sceneManager)
{
manualObject_ = sceneManager.createManualObject();
manualObjectNode =
sceneManager.getRootSceneNode()->createChildSceneNode();
manualObjectNode->attachObject(manualObject_);
manualObject_->setDynamic(true);
manualObject_->begin("debug_draw", Ogre::RenderOperation::OT_LINE_LIST);
manualObject_->position(Ogre::Vector3::ZERO);
manualObject_->colour(Ogre::ColourValue::ZERO);
manualObject_->index(0);
manualObject_->end();
manualObject_->begin("debug_draw", Ogre::RenderOperation::OT_TRIANGLE_LIST);
manualObject_->position(Ogre::Vector3::ZERO);
manualObject_->colour(Ogre::ColourValue::ZERO);
manualObject_->index(0);
manualObject_->end();
manualObject_->setBoundingBox(Ogre::AxisAlignedBox::BOX_INFINITE);
manualObjectNode->_updateBounds();
}
示例9: createTriangleScene
/**
* This is the most basic "triangle" example, done as a Scene in Ogre.
*/
Ogre::SceneManager* createTriangleScene() {
Ogre::SceneManager* scene = mRoot->createSceneManager(Ogre::ST_GENERIC);
// Configure camera (~ view & projection transforms, i.e. gluLookAt + glOrtho)
Ogre::Camera* camera = scene->createCamera("MainCamera"); // We can use an arbitrary name here
camera->setProjectionType(Ogre::PT_ORTHOGRAPHIC);
camera->setOrthoWindow(2, 2); // ~ glOrtho(-1, 1, -1, 1)
camera->setAspectRatio((float) mWindow->getWidth() / mWindow->getHeight());
camera->setNearClipDistance(0.5);
camera->setPosition(Ogre::Vector3(0,0,1)); // Move camera away from (0, 0, 0), otherwise the triangle at z=0 will be clipped
// Now add some geometry to the scene
Ogre::ManualObject* triangle = scene->createManualObject("Triangle");
// ~ glBegin, glVertex, glEnd
// "BaseWhiteNoLighting" is a built-in name for a basic non-lit material
triangle->begin("BaseWhiteNoLighting", Ogre::RenderOperation::OT_TRIANGLE_LIST);
triangle->position(0, 0.5, 0); // ~ glVertex.
// Contrary to OpenGL we *first* must create the vertex
triangle->colour(Ogre::ColourValue::Red); // .. and then provide its attributes such as color (~ glColor)
triangle->position(-0.5, -0.5, 0);
triangle->colour(Ogre::ColourValue::Green);
triangle->position(0.5, -0.5, 0);
triangle->colour(Ogre::ColourValue::Blue);
triangle->end();
// Add the created triangle object to the scene graph
// For this we create a SceneNode object, which will combine information about
// the object's geometry with its modeling transform
// (see frameRenderingQueued to understand how to rotate the triangle by changing this transform)
scene->getRootSceneNode()->createChildSceneNode("Triangle")->attachObject(triangle);
// Exercise 1: Create new object, add vertices, attach the object to a new SceneNode
// ...
return scene;
}
示例10: cosf
Ogre::ManualObject * CCone::CreateCone(Ogre::Real Intensity)
{
Ogre::ManualObject *Cone = NULL;
Ogre::SceneManager *SceneManager = Ogre::Root::getSingleton().getSceneManager("DynamicEffects");
Cone = SceneManager->createManualObject("Cone");
Cone->setDynamic(false);
Cone->begin("BaseWhiteNoLighting", Ogre::RenderOperation::OT_TRIANGLE_LIST);
Ogre::Real deltaAngle = (Ogre::Math::TWO_PI / m_BaseSegments);
Ogre::Real deltaHeight = m_Height/(Ogre::Real)m_HeightSegments;
Ogre::Vector3 Normal = Ogre::Vector3(m_Radius, m_Height, 0.f).normalisedCopy();
Ogre::Quaternion Quaternion;
int Offset = 0;
for (int HeightSegmentIndex = 0; HeightSegmentIndex <= m_HeightSegments; HeightSegmentIndex++)
{
Ogre::Real Radius = m_Radius * (1 - HeightSegmentIndex / (Ogre::Real)m_HeightSegments);
for (int BaseSegmentIndex = 0; BaseSegmentIndex <= m_BaseSegments; BaseSegmentIndex++)
{
Ogre::Real x = Radius* cosf(BaseSegmentIndex * deltaAngle);
Ogre::Real z = Radius * sinf(BaseSegmentIndex * deltaAngle);
Cone->position(x, HeightSegmentIndex * deltaHeight, z);
Cone->colour(Intensity, Intensity, 0.0, 1.0);
Quaternion.FromAngleAxis(Ogre::Radian(-BaseSegmentIndex*deltaAngle), Ogre::Vector3::NEGATIVE_UNIT_Y);
Cone->normal(Quaternion * Normal);
Cone->textureCoord(BaseSegmentIndex / (Ogre::Real)m_BaseSegments, HeightSegmentIndex / (Ogre::Real)m_HeightSegments);
if (HeightSegmentIndex != m_HeightSegments && BaseSegmentIndex != m_BaseSegments)
{
Cone->index(Offset + m_BaseSegments + 2);
Cone->index(Offset);
Cone->index(Offset + m_BaseSegments + 1);
Cone->index(Offset + m_BaseSegments + 2);
Cone->index(Offset + 1);
Cone->index(Offset);
}
Offset++;
}
}
int centerIndex = Offset;
Cone->position(0,0,0);
Cone->normal(Ogre::Vector3::NEGATIVE_UNIT_Y);
Cone->textureCoord(0.0,1);
Offset++;
for (int BaseSegmentIndex=0; BaseSegmentIndex <= m_BaseSegments; BaseSegmentIndex++)
{
Ogre::Real x = m_Radius * cosf(BaseSegmentIndex*deltaAngle);
Ogre::Real z = m_Radius * sinf(BaseSegmentIndex*deltaAngle);
Cone->position(x, 0.0f, z);
Cone->colour(Intensity, Intensity, 0.0, 0.0);
Cone->normal(Ogre::Vector3::NEGATIVE_UNIT_Y);
Cone->textureCoord(BaseSegmentIndex/(Ogre::Real)m_BaseSegments,0.0);
if (BaseSegmentIndex != m_BaseSegments)
{
Cone->index(centerIndex);
Cone->index(Offset);
Cone->index(Offset+1);
}
Offset++;
}
Cone->end();
return Cone;
}
示例11: pos
CFootballPlayer::CFootballPlayer(CSimulationManager *simulationManager, const CPfTeamPlayers *teamPlayer, int number, CTeam *team, bool sideLeft)
:CMovingEntity()
{
m_simulationManager = simulationManager;
Ogre::SceneManager *scnMgr = Ogre::Root::getSingletonPtr()->getSceneManager(SIMULATION_SCENE_MANAGER_NODE_NAME);
m_teamPlayer = new CPfTeamPlayers(*teamPlayer);
m_stateMachine = new CStateMachine<CFootballPlayer>(this);
Ogre::String id;
char charId[20];
m_centerOfMassOffset.setOrigin(btVector3(0,-0.9,0));
m_sideLeft = sideLeft;
m_team = team;
m_number = number; //TODO
m_lastKickBallCycle = -1;
//m_direction.normalize();
sprintf(charId,"%s%d", team->getName().c_str(), m_number);
id = charId;
m_entity = scnMgr->createEntity("Player"+id, "Human.mesh");
if(sideLeft) {
if(m_number == 1) {
m_entity->setMaterialName("goalie_red");
} else {
m_entity->setMaterialName("player_red");
}
} else {
if(m_number == 1) {
m_entity->setMaterialName("goalie_yellow");
} else {
m_entity->setMaterialName("player_yellow");
}
}
btVector3 *initialPos = team->getPlayerStrategicPosition(m_number)->getInitialPosition();
btVector3 pos(initialPos->x(), initialPos->y(), initialPos->z());
if(!m_sideLeft) {
pos.setX(-pos.x());
pos.setZ(-pos.z());
}
m_node = scnMgr->getRootSceneNode()->createChildSceneNode("PlayerNode"+id, Ogre::Vector3(pos.x(), pos.y(), pos.z()));
m_node->attachObject(m_entity);
m_shape = new btCylinderShape(btVector3(btScalar(0.5),btScalar(0.9),btScalar(0.5)));
btScalar mass(70.0);
//rigidbody is dynamic if and only if mass is non zero, otherwise static
bool isDynamic = (mass != 0.f);
btVector3 localInertia(0,0,0);
if (isDynamic)
m_shape->calculateLocalInertia(mass,localInertia);
btRigidBody::btRigidBodyConstructionInfo rbInfo(mass,this,m_shape,localInertia);
m_body = new btRigidBody(rbInfo);
m_body->setAngularFactor(btScalar(0));
m_body->setActivationState(DISABLE_DEACTIVATION);
m_steeringBehavior = new CSteeringBehaviors(this);
//Draw Circle
Ogre::ManualObject * circle = scnMgr->createManualObject("circle_name"+id);
float const radius = 1.5,
thickness = 0.7, // Of course this must be less than the radius value.
accuracy = 5,
height = 0.01;
Ogre::MaterialPtr matptr;
Ogre::Pass* pass;
if(sideLeft) {
matptr = Ogre::MaterialManager::getSingleton().createOrRetrieve("Red"+id, "General").first;
matptr->setReceiveShadows(true);
pass = matptr->getTechnique(0)->getPass(0);
Ogre::ColourValue colour = Ogre::ColourValue::Red;
pass->setDiffuse(colour);
pass->setAmbient(colour);
pass->setSpecular(colour);
pass->setSelfIllumination(colour);
//pass->setEmissive(ColourValue(0,0,0,colour.a));
pass->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA);
pass->setDepthWriteEnabled(false);
} else {
matptr = Ogre::MaterialManager::getSingleton().createOrRetrieve("Blue"+id, "General").first;
matptr->setReceiveShadows(true);
pass = matptr->getTechnique(0)->getPass(0);
Ogre::ColourValue colour = Ogre::ColourValue::Blue;
pass->setDiffuse(colour);
pass->setAmbient(colour);
pass->setSpecular(colour);
pass->setSelfIllumination(colour);
//pass->setEmissive(ColourValue(0,0,0,colour.a));
pass->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA);
pass->setDepthWriteEnabled(false);
}
circle->begin(matptr->getName(), Ogre::RenderOperation::OT_TRIANGLE_LIST);
unsigned point_index = 0;
for(float theta = 0; theta <= 2 * Ogre::Math::PI; theta += Ogre::Math::PI / (radius * accuracy)) {
circle->position(radius * cos(theta),
//.........这里部分代码省略.........
示例12: EngineSetup
void CSceletalAnimationView::EngineSetup(void)
{
Ogre::Root *Root = ((CSceletalAnimationApp*)AfxGetApp())->m_Engine->GetRoot();
Ogre::SceneManager *SceneManager = NULL;
SceneManager = Root->createSceneManager(Ogre::ST_GENERIC, "Animation");
//
// Create a render window
// This window should be the current ChildView window using the externalWindowHandle
// value pair option.
//
Ogre::NameValuePairList parms;
parms["externalWindowHandle"] = Ogre::StringConverter::toString((long)m_hWnd);
parms["vsync"] = "true";
CRect rect;
GetClientRect(&rect);
Ogre::RenderTarget *RenderWindow = Root->getRenderTarget("Mouse Input");
if (RenderWindow == NULL)
{
try
{
m_RenderWindow = Root->createRenderWindow("Mouse Input", rect.Width(), rect.Height(), false, &parms);
}
catch(...)
{
MessageBox("Cannot initialize\nCheck that graphic-card driver is up-to-date", "Initialize Render System", MB_OK | MB_ICONSTOP);
exit(EXIT_SUCCESS);
}
}
// Load resources
Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
// Create the camera
m_Camera = SceneManager->createCamera("Camera");
m_Camera->setNearClipDistance(0.5);
m_Camera->setFarClipDistance(5000);
m_Camera->setCastShadows(false);
m_Camera->setUseRenderingDistance(true);
m_Camera->setPosition(Ogre::Vector3(5.0, 5.0, 10.0));
Ogre::SceneNode *CameraNode = NULL;
CameraNode = SceneManager->getRootSceneNode()->createChildSceneNode("CameraNode");
Ogre::Viewport* Viewport = NULL;
if (0 == m_RenderWindow->getNumViewports())
{
Viewport = m_RenderWindow->addViewport(m_Camera);
Viewport->setBackgroundColour(Ogre::ColourValue(0.8f, 0.8f, 0.8f));
}
// Alter the camera aspect ratio to match the viewport
m_Camera->setAspectRatio(Ogre::Real(rect.Width()) / Ogre::Real(rect.Height()));
m_Camera->lookAt(Ogre::Vector3(0.5, 0.5, 0.5));
m_Camera->setPolygonMode(Ogre::PolygonMode::PM_WIREFRAME);
Ogre::ManualObject* ManualObject = NULL;
ManualObject = SceneManager->createManualObject("Animation");
ManualObject->setDynamic(false);
ManualObject->begin("BaseWhiteNoLighting", Ogre::RenderOperation::OT_TRIANGLE_LIST);
//face 1
ManualObject->position(0, 0, 0);//0
ManualObject->position(1, 0, 0);//1
ManualObject->position(1, 1, 0);//2
ManualObject->triangle(0, 1, 2);//3
ManualObject->position(0, 0, 0);//4
ManualObject->position(1, 1, 0);//5
ManualObject->position(0, 1, 0);//6
ManualObject->triangle(3, 4, 5);//7
//face 2
ManualObject->position(0, 0, 1);//8
ManualObject->position(1, 0, 1);//9
ManualObject->position(1, 1, 1);//10
ManualObject->triangle(6, 7, 8);//11
ManualObject->position(0, 0, 1);//12
ManualObject->position(1, 1, 1);//13
ManualObject->position(0, 1, 1);//14
ManualObject->triangle(9, 10, 11);//15
//face 3
ManualObject->position(0, 0, 0);//16
ManualObject->position(1, 0, 0);//17
ManualObject->position(1, 0, 1);//18
ManualObject->triangle(12, 13, 14);//19
ManualObject->position(0, 0, 0);
ManualObject->position(1, 0, 1);
ManualObject->position(0, 1, 1);
ManualObject->triangle(15, 16, 17);
//face 4
ManualObject->position(1, 0, 0);
ManualObject->position(1, 1, 0);
ManualObject->position(1, 1, 1);
ManualObject->triangle(18, 19, 20);
ManualObject->position(1, 0, 0);
ManualObject->position(1, 1, 1);
//.........这里部分代码省略.........
开发者ID:southerlies,项目名称:OGRE-3D-1.7-Application-Development-Cookbook-Code,代码行数:101,代码来源:SceletalAnimationView.cpp
示例13: createScene
// funcion donde se coloca lo que se desea desplegar.
void createScene(){
_sceneManager->setAmbientLight(Ogre::ColourValue(0.2,0.2,0.2));
_sceneManager->setShadowTechnique(Ogre::SHADOWTYPE_STENCIL_ADDITIVE);
// LUZ
Ogre::Light* LuzPuntual01 = _sceneManager->createLight("Luz01");
LuzPuntual01->setType(Ogre::Light::LT_DIRECTIONAL);
LuzPuntual01->setDiffuseColour(1.0,1.0,1.0);
LuzPuntual01->setDirection(Ogre::Vector3( 1, -1, -1 ));
Ogre::Light* LuzPuntual02 = _sceneManager->createLight("Luz02");
LuzPuntual02->setType(Ogre::Light::LT_DIRECTIONAL);
LuzPuntual02->setDiffuseColour(1.0,1.0,1.0);
LuzPuntual02->setDirection(Ogre::Vector3( -1, -1, -1 ));
//Chasis Carro
_nodeChasisCarro = _sceneManager->createSceneNode("ChasisCarro");
_sceneManager->getRootSceneNode()->addChild(_nodeChasisCarro);
Ogre::Entity* _entChasisCarro = _sceneManager->createEntity("ChasisCarro", "chasisCarro.mesh");
_nodeChasisCarro->attachObject(_entChasisCarro);
/* Ruedas Izquierdas */
_nodeRuedaSimple0 = _sceneManager->createSceneNode("RuedaSimple0");
_sceneManager->getRootSceneNode()->addChild(_nodeRuedaSimple0);
// _nodeRuedaSimple00 = _nodeRuedaSimple0->createChildSceneNode("RuedaSimple00");
// _sceneManager->getRootSceneNode()->addChild(_nodeRuedaSimple00);
Ogre::Entity* _entRuedaSimple0 = _sceneManager->createEntity("RuedaSimple0", "RuedaDetallada.mesh");
_nodeRuedaSimple0->attachObject(_entRuedaSimple0);
// _nodeRuedaSimple00->attachObject(_entRuedaSimple0);
_nodeRuedaSimple0->translate(9,3,5);
_nodeRuedaSimple2 = _sceneManager->createSceneNode("RuedaSimple2");
_sceneManager->getRootSceneNode()->addChild(_nodeRuedaSimple2);
// _nodeRuedaSimple22 = _nodeRuedaSimple2->createChildSceneNode("RuedaSimple22");
// _sceneManager->getRootSceneNode()->addChild(_nodeRuedaSimple22);
Ogre::Entity* _entRuedaSimple2 = _sceneManager->createEntity("RuedaSimple2", "RuedaDetallada.mesh");
_nodeRuedaSimple2->attachObject(_entRuedaSimple2);
// _nodeRuedaSimple22->attachObject(_entRuedaSimple2);
_nodeRuedaSimple2->translate(9,3,-5);
/* Ruedas Derechas */
_nodeRuedaSimple1 = _sceneManager->createSceneNode("RuedaSimple1");
_sceneManager->getRootSceneNode()->addChild(_nodeRuedaSimple1);
// _nodeRuedaSimple11 = _nodeRuedaSimple1->createChildSceneNode("RuedaSimple11");
// _sceneManager->getRootSceneNode()->addChild(_nodeRuedaSimple11);
Ogre::Entity* _entRuedaSimple1 = _sceneManager->createEntity("RuedaSimple1", "RuedaDetallada.mesh");
_nodeRuedaSimple1->attachObject(_entRuedaSimple1);
// _nodeRuedaSimple11->attachObject(_entRuedaSimple1);
_nodeRuedaSimple1->translate(-7,3,5);
_nodeRuedaSimple3 = _sceneManager->createSceneNode("RuedaSimple3");
_sceneManager->getRootSceneNode()->addChild(_nodeRuedaSimple3);
// _nodeRuedaSimple33 = _nodeRuedaSimple3->createChildSceneNode("RuedaSimple33");
//_sceneManager->getRootSceneNode()->addChild(_nodeRuedaSimple33);
Ogre::Entity* _entRuedaSimple3 = _sceneManager->createEntity("RuedaSimple3", "RuedaDetallada.mesh");
_nodeRuedaSimple3->attachObject(_entRuedaSimple3);
//_nodeRuedaSimple33->attachObject(_entRuedaSimple3);
_nodeRuedaSimple3->translate(-7,3,-5);
/* ALA DERECHA INFERIOR
Se crea el nodo padre de la nave llamado eje */
eje = _sceneManager->getRootSceneNode()->createChildSceneNode("eje");
padreDI = eje->createChildSceneNode("padreDI");
Ogre::ManualObject* alad = _sceneManager->createManualObject("alad");
alad->begin("BaseWhiteNoLighting", Ogre::RenderOperation::OT_TRIANGLE_FAN);
alad->colour(Ogre::ColourValue(0.0, 0.5, 0.0, 0.0));
alad->position(4.0, -0.5, 0.0);
alad->position(15.0, -0.5, 0.0);
alad->position(15.0, 0.0, 0.0);
alad->position(5.0, 0.0, 0.0);
alad->index(0);
//.........这里部分代码省略.........
示例14: EngineSetup
void CTransparentMaterialView::EngineSetup(void)
{
Ogre::Root *Root = ((CTransparentMaterialApp*)AfxGetApp())->m_Engine->GetRoot();
Ogre::SceneManager *SceneManager = NULL;
SceneManager = Root->createSceneManager(Ogre::ST_GENERIC, "MFCOgre");
//
// Create a render window
// This window should be the current ChildView window using the externalWindowHandle
// value pair option.
//
Ogre::NameValuePairList parms;
parms["externalWindowHandle"] = Ogre::StringConverter::toString((long)m_hWnd);
parms["vsync"] = "true";
CRect rect;
GetClientRect(&rect);
Ogre::RenderTarget *RenderWindow = Root->getRenderTarget("Ogre in MFC");
if (RenderWindow == NULL)
{
try
{
m_RenderWindow = Root->createRenderWindow("Ogre in MFC", rect.Width(), rect.Height(), false, &parms);
}
catch(...)
{
MessageBox("Cannot initialize\nCheck that graphic-card driver is up-to-date", "Initialize Render System", MB_OK | MB_ICONSTOP);
exit(EXIT_SUCCESS);
}
}
// Load resources
Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
// Create the camera
m_Camera = SceneManager->createCamera("Camera");
m_Camera->setNearClipDistance(0.5);
m_Camera->setFarClipDistance(5000);
m_Camera->setCastShadows(false);
m_Camera->setUseRenderingDistance(true);
m_Camera->setPosition(Ogre::Vector3(320.0, 240.0, 500.0));
Ogre::SceneNode *CameraNode = NULL;
CameraNode = SceneManager->getRootSceneNode()->createChildSceneNode("CameraNode");
Ogre::Viewport* Viewport = NULL;
if (0 == m_RenderWindow->getNumViewports())
{
Viewport = m_RenderWindow->addViewport(m_Camera);
Viewport->setBackgroundColour(Ogre::ColourValue(0.8f, 1.0f, 0.8f));
}
// Alter the camera aspect ratio to match the viewport
m_Camera->setAspectRatio(Ogre::Real(rect.Width()) / Ogre::Real(rect.Height()));
Ogre::ManualObject *Screen = SceneManager->createManualObject("Screen");
Screen->setDynamic(true);
Screen->begin("window", Ogre::RenderOperation::OT_TRIANGLE_LIST);
Screen->position(-100,-100,50);
Screen->textureCoord(0,0);
Screen->position(300,-100,50);
Screen->textureCoord(1,0);
Screen->position(300,300,50);
Screen->textureCoord(1,1);
Screen->triangle(0, 1, 2);
Screen->position(-100,-100,50);
Screen->textureCoord(0,0);
Screen->position(300,300,50);
Screen->textureCoord(1,1);
Screen->position(-100,300,50);
Screen->textureCoord(0,1);
Screen->triangle(3, 4, 5);
Screen->end();
Ogre::Entity *RobotEntity = SceneManager->createEntity("Robot", "robot.mesh");
Ogre::SceneNode *RobotNode = SceneManager->getRootSceneNode()->createChildSceneNode();
RobotNode->attachObject(RobotEntity);
Ogre::SceneNode *WindowNode = SceneManager->getRootSceneNode()->createChildSceneNode();
WindowNode->attachObject(Screen);
}
开发者ID:southerlies,项目名称:OGRE-3D-1.7-Application-Development-Cookbook-Code,代码行数:94,代码来源:TransparentMaterialView.cpp
示例15: btHeightfieldTerrainShape
/* -----------------------------------------------------------------------
| build bullet height field shape and generate ogre mesh from grayscale image
|
| @param in :
| @param out: raw data of height field terrain
| ToDo: adjest grid scale, grid height, local scale, max/min height
----------------------------------------------------------------------- */
bool
buildHeightFieldTerrainFromImage(const Ogre::String& filename,
btDynamicsWorld* dynamicsWorld,
btAlignedObjectArray<btCollisionShape*>& collisionShapes,
void* &data)
{
Ogre::Image img;
try
{
img.load(filename, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
}
catch(Ogre::Exception err)
{
LOG(err.what());
return false;
}
size_t grid_w = 65, grid_h = 65; // must be (2^N) + 1
size_t grid_max_w = 129, grid_max_h = 129; // must be (2^N) + 1
size_t img_w = img.getWidth();
size_t img_h = img.getHeight();
// validate image size is (2^N) + 1
if ((img_w-1) & (img_w-2)) img_w = grid_w;
if ((img_h-1) & (img_h-2)) img_h = grid_h;
//if (img_w > grid_max_w) img_w = grid_max_w;
//if (img_h > grid_max_h) img_h = grid_max_h;
LOG("LoadImage name=%s, width=%d, height=%d, width^2+1=%d, height^2+1=%d",
filename.c_str(), img.getWidth(), img.getHeight(), img_w, img_h);
img.resize(img_w, img_h);
size_t pixelSize = Ogre::PixelUtil::getNumElemBytes(img.getFormat());
size_t bufSize = img.getSize() / pixelSize;
data = new Ogre::Real[ bufSize ];
Ogre::Real* dest = static_cast<Ogre::Real*>(data);
memset(dest, 0, bufSize);
/*
| @ Notice the alignment problem
| - uchar to float alignment
| - pixel format in bytes as rawdata type, also affects alignment
*/
Ogre::uchar* src = img.getData();
for (size_t i=0;i<bufSize;++i)
{
dest[i] = ((Ogre::Real)src[i * pixelSize] - 127.0f)/16.0f;
}
// parameter
int upAxis = 1;
btScalar gridSpacing = 5.0f;
btScalar gridHeightScale = 0.2f;
btScalar minHeight = -10.0f;
btScalar maxHeight = 10.0f;
btScalar defaultContactProcessingThreshold = BT_LARGE_FLOAT;
btHeightfieldTerrainShape *heightfieldShape =
new btHeightfieldTerrainShape(img_w, img_h,
dest,
gridHeightScale,
minHeight, maxHeight,
upAxis, PHY_FLOAT, false);
btAssert(heightfieldShape && "null heightfield");
// shape
btVector3 localScaling(1.0f, 1.0f, 1.0f);
heightfieldShape->setLocalScaling(localScaling);
collisionShapes.push_back(heightfieldShape);
// rigidBody
btDefaultMotionState* motionState = new btDefaultMotionState(btTransform(btQuaternion(0,0,0,1),btVector3(0,0,0)));
btRigidBody::btRigidBodyConstructionInfo cInfo(0, motionState, heightfieldShape, btVector3(0,0,0));
btRigidBody* rigidBody = new btRigidBody(cInfo);
rigidBody->setContactProcessingThreshold(defaultContactProcessingThreshold);
int flags = rigidBody->getCollisionFlags();
rigidBody->setCollisionFlags(flags | btCollisionObject::CF_DISABLE_VISUALIZE_OBJECT);
dynamicsWorld->addRigidBody(rigidBody);
// add ogre height field mesh
Ogre::SceneManager* sceneMgr = Ogre::Root::getSingletonPtr()->getSceneManager("DefaultSceneManager");
btAssert(sceneMgr);
Ogre::ManualObject* obj = sceneMgr->createManualObject("btHeightFieldEntity");
btVector3 aabbMin, aabbMax;
heightfieldShape->getAabb(btTransform(btQuaternion(0,0,0,1),btVector3(0,0,0)), aabbMin, aabbMax);
btHeightFieldProcessor callback(obj, "DefaultPlane");
heightfieldShape->processAllTriangles(&callback, aabbMin, aabbMax);
sceneMgr->getRootSceneNode()->attachObject(obj);
//.........这里部分代码省略.........