MCPcopy Create free account
hub / github.com/OpenDungeons/OpenDungeons / camera_2dPositionFromClick

Method camera_2dPositionFromClick

source/gamemap/MiniMapDrawn.cpp:96–110  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

94}
95
96Ogre::Vector2 MiniMapDrawn::camera_2dPositionFromClick(int xx, int yy)
97{
98 Ogre::Real mm, nn, oo, pp;
99 // Compute move and normalise
100 mm = (xx - mTopLeftCornerX) / static_cast<double>(mWidth) - 0.5;
101 nn = (yy - mTopLeftCornerY) / static_cast<double>(mHeight) - 0.5;
102 // Applying rotation
103 oo = nn * mSinRotation + mm * mCosRotation;
104 pp = nn * mCosRotation - mm * mSinRotation;
105 // Apply result to camera
106 mCamera_2dPosition.x += static_cast<Ogre::Real>(oo * mWidth / mGrainSize);
107 mCamera_2dPosition.y -= static_cast<Ogre::Real>(pp * mHeight / mGrainSize);
108
109 return mCamera_2dPosition;
110}
111
112void MiniMapDrawn::update(Ogre::Real timeSinceLastFrame, const std::vector<Ogre::Vector3>& cornerTiles)
113{

Callers 1

onMinimapClickMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected