Sophie

Sophie

distrib > Mandriva > 10.0-com > i586 > by-pkgid > 06719cf03808e17ae6f0852ca1052dc2 > files > 220

libogre1-devel-0.13.0-1mdk.i586.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <style type="text/css">
	<!--
	.MainHeader {  font-weight: bold; color: #FFFFFF; background-color: #003300; font-size: 10pt}
	body {  font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10pt; color: #003300; background-color: #FFFFFF}
	.BorderHeader {  background-color: #999900; font-size: 8pt; font-weight: bold; color: #333300; text-align: center}
	.MainContent { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10pt; color: #003300}
	.BorderContent {  font-size: 8pt; color: #000000; border-color: black #666600 #666600; padding-top: 2px; padding-right: 2px; padding-bottom: 10px; padding-left: 2px; margin-bottom: 2px; border-style: solid; border-top-width: 0px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px}
	a:link {  color: #000066; text-decoration: underline}
	a:hover {  color: #0000FF; text-decoration: underline}
	a:visited {  color: #660066; text-decoration: underline}
	li {  color: #000000; list-style-type: circle; position: relative; left: -15px; clip:    rect(   )}
	.NewsDate {  color: #000000; font-weight: bold}
	td {  font-size: 10pt}
	th {  font-size: 10pt}
	.Annotation {  font-size: 10px}
	.header {  font-size: 16pt; color: #000000}
	.SectionHeader {  font-size: 14px; color: #000000; font-weight: bold}
	pre {  color: #000066; font-size: 12px}

	-->
	</style>
  <title>Creating OGRE Project Files</title>
		 		
  <meta name="generator" content="Deppo's HTML Editor v2.1 BETA 2">
		
  <meta name="keywords" content="">
		
  <meta name="description" content="">
		
  <meta name="author" content="Nicholas">
		
  <meta http-equiv="reply-to" content="vastrim@hotmail.com">
		
  <meta name="creation_date" content="Sat, 13 Jul, 2002 12:32:59 p GMT">
</head>
	 	<body bgcolor="#ffffff" text="#000000">
<p align="center" class="header">OGRE (Object-Oriented Graphics
Rendering Engine)</p>
<p align="center" class="header"> Our First Scene Node and Entity </p>
<p align="left" class="MainHeader">&nbsp;</p>
<p align="left" class="SectionHeader"> 	A ship in space</p>
<p align="left"> What use is outer space if there are no space ships in
it? Its time to make something that we can fly around in. We are going
to do this by creating instances of two object types. Entities and
Scene Nodes. </p>
<p align="left" class="SectionHeader"> 	Member variables</p>
<p align="left"> Create some member variables to store pointers to the
Scene Node and Entity for use later. </p>
<pre>	Entity* mShip;<br>	SceneNode* mShipNode;<br></pre>
<p></p>
<p align="left" class="SectionHeader"> 	Entities</p>
<p align="left"> An Entity in Ogre is a moveable object based on a mesh.
These meshes are loaded through the Resource Manager and its position
is determined by a Scene Node that it is attached to. To create our
ship, add a line into the createScene method in SpaceApplication.h
(after setting the sky box) </p>
<pre>	mShip = mSceneMgr-&gt;createEntity("razor", "razor.mesh");<br></pre>
<p></p>
<p align="left"> Just like the skybox, we supply a resource name to the
Scene Manager and it will locate it. In this case it is the name of a
mesh file (razor.mesh) which is found in the Media directory. Another
important thing to note about we just did, we gave the entity a name.
This name (razor) has to be unique within the application or the Scene
Manager will give you an error. </p>
<p align="left" class="SectionHeader"> 	The Scene Node</p>
<p align="left"> As mentioned above, Entities attach to Scene Nodes
which dictate their position in the scene. Scene Nodes can be attached
to other tree nodes to create a type of positional hierachy, but for the
purposes of this tutorial just one will do. </p>
<p align="left"> To create this Scene Node we ask the root node of the
scene to create it for us. The root node is maintained by Ogre and
every entity that is part of the scene is directly or indirectly
attached to it. When we ask the root node to create the node for us we
are saying that the root node is the node's parent. After creating it
we set its position orientation relative to the scene node (effectively
the absolute position in the scene as far as this tutorial goes, but
not necessarily true in other circumstances). </p>
<pre>	mShipNode = static_cast&lt;SceneNode*&gt;(mSceneMgr-&gt;getRootSceneNode()-&gt;createChild());<br></pre>
<p></p>
<p></p>
Note that the static_cast&lt;SceneNode*&gt;() part is required because
the createChild member of SceneNode is actually inherited (and
overridden) from Node, so this method actually returns a Node*.
However, we know that the actual instance is a SceneNode so we can cast
it safely. You might wonder why we can't just return a SceneNode*
instead; well the reason is that in C++ you cannot have 2 methods with
the same signature except for their return type: this is not a valid
overload.<br>
<br>
Almost there... attach the ship Entity to the Scene Node.
<pre>	mShipNode-&gt;attachObject(mShip);<br></pre>
<p></p>
<p align="left" class="SectionHeader"> 	Lighting</p>
<p align="left"> Lastly, we have to turn on some lights or you won't be
able to see anything. Lets just use some ambient lighting supplied by
the Scene Manager for now. Place this line at the start of createScene. </p>
<pre>	mSceneMgr-&gt;setAmbientLight(ColourValue(0.5, 0.5, 0.5));<br></pre>
<p></p>
<p align="left"> Compile and run. Have a walk around the ship. </p>
<table width="100%" border="0" cellspacing="2" cellpadding="0">
	<tbody>
    <tr>
		<td width="14%"><a href="Index.html">Back to Index</a></td>
		<td width="39%">&nbsp;</td>
		<td width="22%"><a href="SettingUpTheScene.html">&lt;&lt; Previous
section</a></td>
		<td width="25%"><a href="FrameListener.html">Next section &gt;&gt;</a></td>
	</tr>
  </tbody>
</table>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p class="SectionHeader">&nbsp;</p>
	
</body>
</html>