| Next revision | Previous revision | 
| public:t-gede-15-1:lab6 [2015/02/23 16:34]  – created marino | public:t-gede-15-1:lab6 [2024/04/29 13:33] (current)  – external edit 127.0.0.1 | 
|---|
| ===== Discussion ===== | ===== Discussion ===== | 
|  |  | 
| Discussion thread for this lab is here: [[https://piazza.com/class/hq7dlipqggr2qe|Lab 6 Discussion Thread]] | Discussion thread for this lab is here: [[https://piazza.com/class/i4l9of1fw8j3ew?cid=52|Lab 6 Discussion Thread]] | 
|  |  | 
| ===== Goal ====== | ===== Goal ====== | 
|  |  | 
| Continue with your project or use an older version starting from lab2. | Continue with your project or use an older version starting from lab2. | 
|  |  | 
|  | For the bonus point you might have to replace the pk3 file ''/Ogre1.9_vc100/OgreSDK_vc10_v1-9-0 | 
|  | /media/packs/chiropteraDM.pk3'' **Use of course your own Ogre sdk path.** | 
|  |  | 
|  | with this pk3 file: {{:public:t-gede-14-1:chiropteradm.zip| chiropteraDM.zip}} **Rename it back to chiropteraDM.pk3, make sure to change the extension of the file to pk3** | 
|  |  | 
|  | The original file in the OgreSdk folder seemed to be missing a few textures, for this one I replaced the missing textures with one colored textures. | 
| ===== Lab Project ===== | ===== Lab Project ===== | 
|  |  | 
| Ogre::SceneNode* grassNode = _sceneManager->getRootSceneNode()->createChildSceneNode("GrassNode2"); | Ogre::SceneNode* grassNode = _sceneManager->getRootSceneNode()->createChildSceneNode("GrassNode2"); | 
| grassNode->attachObject(manual); | grassNode->attachObject(manual); | 
| </code>To add the two missing quads, use the following corner vertex positions: Quad 2 = (2.5,0,4.3),(-2.5,10,-4.3), (-2.0,0,-4.3), (2.5,10,4.3), Quad 3 = (2.5,0,-4.3),(-2.5,10,4.3),(-2.0,0,4.3),(2.5,10,-4.3). Don't forget to give the vertices texture coordinates, which are the same for all quads. Now call ''createGrass()'' from your ''createScene()'' method and you should see a single bundle of grass right in the middle of the scene. | </code>To add the two missing quads, use the following corner vertex positions: Quad 2 = (2.5,0,4.3),(-2.5,10,-4.3), (-2.5,0,-4.3), (2.5,10,4.3), Quad 3 = (2.5,0,-4.3),(-2.5,10,4.3),(-2.5,0,4.3),(2.5,10,-4.3). Don't forget to give the vertices texture coordinates, which are the same for all quads. Now call ''createGrass()'' from your ''createScene()'' method and you should see a single bundle of grass right in the middle of the scene. | 
| - **Instance Grass Object** To create multiple instances of the object you created, you need to first convert it into a proper Ogre **Mesh**. In the ''createGrass()'' method, **replace** your last two lines with the following line:<code cpp>manual->convertToMesh("BladesOfGrass"); | - **Instance Grass Object** To create multiple instances of the object you created, you need to first convert it into a proper Ogre **Mesh**. In the ''createGrass()'' method, **replace** your last two lines with the following line:<code cpp>manual->convertToMesh("BladesOfGrass"); | 
| </code> This essentially creates a new model with the name "BladesOfGrass", which you can now refer to in subsequent ''createEntity(<name>)'' calls. So do that next: Let's create 2500 instances of this model, spread across the ground in a 50x50 square patch! You can do this using a nested for-loop (over i=0-49 and j=0-49) and inside the loop do the following:<code cpp> | </code> This essentially creates a new model with the name "BladesOfGrass", which you can now refer to in subsequent ''createEntity(<name>)'' calls. So do that next: Let's create 2500 instances of this model, spread across the ground in a 50x50 square patch! You can do this using a nested for-loop (over i=0-49 and j=0-49) and inside the loop do the following:<code cpp> |