[1.10] Intermediate Tutorials update

Anything and everything that's related to OGRE or the wider graphics field that doesn't fit into the other forums.
pierrea
Gnoblar
Posts: 8
Joined: Fri May 13, 2016 3:11 pm

[1.10] Intermediate Tutorials update

Post by pierrea »

Hello everyone,

I would like to propose a few updates concerning the intermediate tutorials for Ogre 1.10 while I am following them. I guess it might help future newbies like me :D
The report page issue link on the tutorials tells me I do not have any rights so I start posting everything here.

Please do not hesitate to tell me if my updates are not correct.

INTRODUCTION
1 Mouse events
In the provided code (BasicApp.cpp), the methods concerning mouse movements must be updated. For example in BasicApp::MouseMoved(const OIS::MouseEvent& me):

Code: Select all

mCameraMan->injectMouseMove(me);
must be updated to

Code: Select all

mCameraMan->injectPointerMove(me);
This operation must be repeated for MousePressed and MouseReleased (changing Mouse by Pointer in inject methods).

As OIS implementation seems to have changed through time, a quick modification is required on the Samples/includes/SdkCameraMan.h. I already proposed a solution through a merge request, in case it is not accepted (or not prioritized, no offense) the solution is here http://www.ogre3d.org/forums/viewtopic.php?f=2&t=85807

2 Headers
To compile, BasicApp.cpp also requires the following includes:

Code: Select all

#include <OgreLogManager.h>
#include <OgreTextureManager.h>
3 BLANK STRING
In BasicApp.ccp, the two occurences of Ogre::StringUtil::BLANK (constructor) must be replaced by Ogre::BLANKSTRING.

INTERMEDIATE TUTORIAL 1
nextLocation() methods is missing. I am not sure yet (since I did not finish all the tutorials yet) if it should be put in the code provided in the introduction or only in this tutorial.
My personnal solution was to add in the private section of the header:

Code: Select all

bool nextLocation();
and in the ccp:

Code: Select all

bool BasicApp::nextLocation()
{
    return true;
}
(the tutorial asks you to modify it later)

INTERMEDIATE TUTORIAL 2
1 Headers
When inserting the code relative to terrain, headers should be updated from:

Code: Select all

#include <OgreTerrain.h>
#include <OgreTerrainGroup.h>
to

Code: Select all

#include <Terrain/OgreTerrain.h>
#include <Terrain/OgreTerrainGroup.h>
2 Hidde/show mouse cursor (CEGUI 0.8.x/tested with CEGUI 0.8.7)

Code: Select all

CEGUI::MouseCursor::getSingleton().hide();
has to be replaced by

Code: Select all

CEGUI::System::getSingleton().getDefaultGUIContext().getMouseCursor().hide();
Same operation must be done for the show method

3 Ray casting/selecting terrain target
We are asked to insert these 2 lines in the mousePressed method:

Code: Select all

CEGUI::GUIContext& context = CEGUI::System::getSingleton().getDefaultGUIContext();
CEGUI::Vector2f mousePos = context.getMouseCursor().getPosition();
the first line was previously set, so we just need

Code: Select all

CEGUI::Vector2f mousePos = context.getMouseCursor().getPosition();
(ok, this is a detail ;) )

4 Moving robots before releasing mouse button
The tutorial states that we should be able to move the robot between mousePressed and mouseReleased.
To do so, this following code must be added in the mouseMove method in the portion corresponding to mLMouseDown:

Code: Select all

CEGUI::Vector2f mousePos = context.getMouseCursor().getPosition();

    Ogre::Ray mouseRay =
      mCamera->getCameraToViewportRay(
        mousePos.d_x / float(me.state.width),
        mousePos.d_y / float(me.state.height));

    Ogre::TerrainGroup::RayResult result = mTerrainGroup->rayIntersects(mouseRay);

    if (result.terrain)
    {
      mCurObject->setPosition(result.position);
    }
INTERMEDIATE TUTORIAL 3
1 Ninjas!
The last code modification contains a syntax mistake:

Code: Select all

if (mRobotMode)
has to be replaced by

Code: Select all

if (bRobotMode)
2 Selecting entities
Another syntax mistake, when ray casting:

Code: Select all

Ogre::RaySceneQueryResult& result = mRaySceneQuery->execute();
must be replaced by

Code: Select all

Ogre::RaySceneQueryResult& result = mRayScnQuery->execute();
In setup() method, before returning true, the following line must be added:

Code: Select all

mRayScnQuery = mSceneMgr->createRayQuery(Ogre::Ray());
3 Selecting specific types of entities
Another syntax mistake:

Code: Select all

mRayScnQuery->setQueryMask(mRobotMode ? ROBOT_MODE : NINJA_MASK);
must be replaced with

Code: Select all

mRayScnQuery->setQueryMask(mRobotMode ? ROBOT_MASK : NINJA_MASK);
INTERMEDIATE TUTORIAL 4
1 SelectionBox class
The following header is required:

Code: Select all

#include <OgreRenderQueue.h>
This code

Code: Select all

clear();
begin("Examples/KnotTexture", Ogre::RenderOperation::OT_LINE_STRIP);
position(left, top, -1);
position(right, top, -1);
position(left, bottom, -1);
position(left, top, -1);
end();
must be modified to this (otherwise the selection will be shown as a triangle)

Code: Select all

  clear();
  begin("Examples/KnotTexture", Ogre::RenderOperation::OT_LINE_STRIP);
  position(left, top, -1);
  position(right, top, -1);
  position(right, bottom, -1);
  position(left, bottom, -1);
  position(left, top, -1);
  end();
2 Box Selection
The following member must be added in BasicApp.h

Code: Select all

Ogre::PlaneBoundedVolumeListSceneQuery* mVolQuery;
Its purpose is defined later.

3 BoxSelection is Volume Selection
In the header, must be added:

Code: Select all

  bool mSelecting;
 Ogre::Vector2 mStart, mStop;
and initialized in constructor (at least for mSelecting)

Code: Select all

 mSelecting(false),
On mousePressed implementation:

Code: Select all

mStart.x = mouse->getPosition().d_x / (float)arg.state.width;
mStart.y = mouse->getPosition().d_y / (float)arg.state.height;
must be replaced by

Code: Select all

mStart.x = mouse->getPosition().d_x / (float)me.state.width;
mStart.y = mouse->getPosition().d_y / (float)me.state.height;
This line

Code: Select all

performSelection(mStart, mStop)
should be removed and added in next part

4 PlaneBoundedVolumeListSceneQuery
The header must be completed with

Code: Select all

void performSelection(const Ogre::Vector2& first, const Ogre::Vector2& second);
  void deselectObjects();
  void selectObject(Ogre::MovableObject* obj);

  static void swap(float& x, float& y);

  std::list<Ogre::MovableObject*> mSelected;
  Ogre::RaySceneQuery* mRayScnQuery;
From that point, the following call can be repositionned in mousePressed:

Code: Select all

performSelection(mStart, mStop)

Code: Select all

mVolQuery->setVolume(volList);
must be updated to (an s is missing :D )

Code: Select all

mVolQuery->setVolumes(volList);
and:

Code: Select all

selectObject(*iter);
must be replaced by

Code: Select all

selectObject(*it);
INTERMEDIATE TUTORIAL 5
In the header, the followings should be added:

Code: Select all

#include <OgreMeshManager.h>
#include <OgreManualObject.h>
#include <OgreStaticGeometry.h>
and in private section

Code: Select all

void createGrassMesh();
I no one mind about it, I will update this posts accordingly to my progression if I see any other updates.
Best,

Pierre
Last edited by pierrea on Sat May 21, 2016 2:38 pm, edited 3 times in total.
User avatar
areay
Bugbear
Posts: 819
Joined: Wed May 05, 2010 4:59 am
Location: Auckland, NZ
x 69

Re: [1.10] Intermediate Tutorials update

Post by areay »

Good stuff Pierre, this sort of thing is useful.
pierrea
Gnoblar
Posts: 8
Joined: Fri May 13, 2016 3:11 pm

Re: [1.10] Intermediate Tutorials update

Post by pierrea »

Well, I just understood we must login in the forum AND in the wiki so in fact I can propose tutorials update. I already did it for Intermediate Tutorials 6 and 7.
I will take time to update 1 to 5 too and notify here when it is done.