SceneManager Basics
Everything that appears on the screen is managed by the SceneManager (fancy that). When you place objects in the scene, the SceneManager is the class which keeps track of their locations. When you create Cameras to view the scene (which we will cover in a later tutorial) the SceneManager keeps track of them. When you create planes, billboards, lights...and so on, the SceneManager keeps track of them.
There are multiple types of SceneManagers. There are SceneManagers that render terrain, there is a SceneManager for rendering BSP maps, and so on. You can see the various types of SceneManagers listed here. We will cover more about other SceneManagers as we progress through the tutorials.
- 장면 관리자, 화면상에 보여지는 모든 것을 관리
- 물체(Object)를 배치하면 그들의 위치를 관리
- 카메라, 평면, 빌보드, 광원 등 또한 관리
- SceneManger의 종류 - 옥트리(Octree) 장면 관리자, 지형(Terrain) 장면 관리자, BSP(Binary Surface Partition) 장면 관리자
- 기본적으로 Octree 장면 관리자를 사용하게 되며 애드온으로 다른 장면 관리자도 사용가능
Entity Basics
An Entity is one of the types of object that you can render on a scene. You can think of an Entity as being anything that's represented by a 3D mesh. A robot would be an entity, a fish would be an entity, the terrain your characters walk on would be a very large entity. Things such as Lights, Billboards, Particles, Cameras, etc would not be entities.
One thing to note about Ogre is that it separates renderable objects from their location and orientation. This means that you cannot directly place an Entity in a scene. Instead you must attach the Entity to a SceneNode object, and this SceneNode contains the information about location and orientation.
- 엔터티는 장면에 렌더링 할 수 있는 물체의 한 종류
- 3D 메쉬로 표현할 수 있는 것이라면 Entity라고 간주( 예: 로봇, 물고기, 지형 )
- 광원, 빌보드, 파티클, 카메라 등은 Entity에 속하지 않는다.
- Ogre에서는 렌더링 되는 물체와 그들의 위치, 방향을 따로 구분한다.
- 그래서 Entity를 반드시 위치와 방향정보를 가지고 있는 SceneNode에 붙여(attach)야만 한다.
SceneNode Basics
As already mentioned, SceneNodes keep track of location and orientation for all of the objects attached to it. When you create an Entity, it is not rendered in the scene until you attach it to a SceneNode. In addition a SceneNode is not an object that is displayed on the screen. Only when you create a SceneNode and attach an Entity (or other object) to it is something actually displayed on the screen.
SceneNodes can have any number of objects attached to them. Let's say you have a character walking around on the screen and you want to have him generate a light around him. The way you do this would be to first create a SceneNode, then create an Entity for the character and attach it to the SceneNode. Then you would create a Light object and attach it to the SceneNode. SceneNodes may also be attached to other SceneNodes which allows you to create entire hierarchies of nodes. We will cover more advanced uses of SceneNode attachment in a later tutorial.
One major concept to note about SceneNodes is that a SceneNode's position is always relative to its parent SceneNode, and each SceneManager contains a root node to which all other SceneNodes are attached.
Your first Ogre application
void {PROJECT_NAME}App::createScene 함수를 수정하여 어플리케이션을 작성해본다.
최상위 씬 노드 생성
mSceneMgr->getRootSceneNode()->createChildSceneNode( );
생성된 노드에 Entity를 추가하는 방법
node1->attachObject( ent1 );
Adding another Object
- Entity *ent2 = mSceneMgr->createEntity( "Robot2", "robot.mesh" );
SceneNode *node2 = mSceneMgr->getRootSceneNode()->createChildSceneNode( "RobotNode2", Vector3( 50, 0, 0 ) );
node2->attachObject( ent2 );
SceneNodes more in Depth
-
다음의 코드를
- SceneNode *node2 = mSceneMgr->getRootSceneNode()->createChildSceneNode( "RobotNode2", Vector3( 50, 0, 0 ) );
-
아래와 같이 변경한다.
- SceneNode *node2 = node1->createChildSceneNode( "RobotNode2", Vector3( 50, 0, 0 ) );
-
아래의 코드를 추가하여 실행해본다.
- node2->translate( Vector3( 10, 0, 10 ) );
node1->translate( Vector3( 25, 0, 0 ) );
Scale
- node1->scale( 5, 1, 2 );
node2->scale( 1, 2, 1 );
Rotation
- node1->yaw( Degree( -90 ) );
- node2->pitch( Degree( -90 ) );
- node3->roll( Degree( -90 ) );