started adding bullets physics
[ltanks.git] / utils.cc
blob7244ef2efc1566a373900de9241e2db9b865d322
1 #include "utils.h"
3 using namespace Ogre;
5 // cube -size/2,-size/2,-size/2 -> size/2,size/2,size/2
6 MeshPtr createCubeMesh(SceneManager *sm, const std::string &name, const std::string &mat, Real size) {
7 ManualObject *cube = sm->createManualObject(name);
9 cube->begin(mat);
10 // front side
11 cube->position(-size/2,-size/2,-size/2);
12 cube->position(size/2,-size/2,-size/2);
13 cube->position(size/2,size/2,-size/2);
14 cube->position(-size/2,size/2,-size/2);
16 // back side
17 cube->position(-size/2,-size/2,size/2);
18 cube->position(size/2,-size/2,size/2);
19 cube->position(size/2,size/2,size/2);
20 cube->position(-size/2,size/2,size/2);
22 cube->quad(3,2,1,0); // front
23 cube->quad(4,5,6,7); // back
24 cube->quad(4,7,3,0); // left
25 cube->quad(6,5,1,2); // right
26 cube->quad(7,6,2,3); // top
27 cube->quad(0,1,5,4); // bottom
28 cube->end();
30 return cube->convertToMesh(name);
33 CEGUI::MouseButton convertButton(OIS::MouseButtonID id) {
34 switch (id) {
35 case OIS::MB_Left: return CEGUI::LeftButton;
36 break;
37 case OIS::MB_Right: return CEGUI::RightButton;
38 break;
39 case OIS::MB_Middle: return CEGUI::MiddleButton;
40 break;
41 default: return CEGUI::LeftButton;
42 break;