-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathButton.h
More file actions
79 lines (73 loc) · 2.38 KB
/
Button.h
File metadata and controls
79 lines (73 loc) · 2.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
///////////////////////////////////////////////////////////////////////
// BUTTON
//// Started 25.02.2010
//// by Sgw32 (all
//rights reserved)//
///////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////
///////////////Original file by:Fyodor Zagumennov aka Sgw32//////////
///////////////Copyright(c) 2010 Fyodor Zagumennov //////////
/////////////////////////////////////////////////////////////////////
#pragma once
#include "ButtonContactMatCallback.h"
#include "global.h"
#include <Ogre.h>
#include <OgreNewt.h>
using namespace Ogre;
using namespace OgreNewt;
using namespace std;
namespace Run3 {
class Button {
public:
Button();
~Button();
void init(SceneNode *node, int type);
void initMovable(SceneNode *node, int type, Real mass);
void init(SceneNode *node, int type, SceneNode *parent);
void use();
void setCallback(String luaScript);
void Button::camera_force_callback(OgreNewt::Body *me);
void dispose() {
showFrame = false;
String name = mNode->getName();
mNode->detachAllObjects();
if (mSceneMgr->hasEntity(name))
mSceneMgr->destroyEntity(name);
mSceneMgr->destroySceneNode(mNode);
delete bod;
}
bool frameStarted(const Ogre::FrameEvent &evt);
void setAlarmOnContact() {
if (bod) {
// Bomb, for example.
// "Use" on contact.
mPhysCallback = new ButtonContactMatCallback();
OgreNewt::World *mWorld = global::getSingleton().getWorld();
mMatDefault = global::getSingleton().getPlayer()->getPlayerMat();
neutralMat = new OgreNewt::MaterialID(mWorld);
mMatPair = new OgreNewt::MaterialPair(mWorld, mMatDefault, neutralMat);
mMatPair->setContactCallback(mPhysCallback);
mMatPair = new OgreNewt::MaterialPair(
mWorld, mWorld->getDefaultMaterialID(), neutralMat);
mMatPair->setContactCallback(mPhysCallback);
mMatPair->setDefaultFriction(0, 0);
bod->setMaterialGroupID(neutralMat);
}
}
private:
const OgreNewt::MaterialID *mMatDefault;
OgreNewt::MaterialPair *mMatPair;
const OgreNewt::MaterialID *neutralMat;
ButtonContactMatCallback *mPhysCallback;
bool showFrame;
World *mWorld;
SceneManager *mSceneMgr;
OgreNewt::Body *bod;
String mLuaScript;
lua_State *pLuaState;
SceneNode *mNode;
SceneNode *mparent;
bool p;
Vector3 d_b;
};
} // namespace Run3