[DEV] plop
This commit is contained in:
parent
eefbe48546
commit
327367b1a7
@ -277,7 +277,76 @@ static void DrawShape(const btCollisionShape* _shape,
|
||||
}
|
||||
case CONVEX_HULL_SHAPE_PROXYTYPE: {
|
||||
// Convex Hull collision shape ...
|
||||
EGE_DEBUG(" Draw (06): CYLINDER_SHAPE_PROXYTYPE");
|
||||
EGE_DEBUG(" Draw (06): CONVEX_HULL_SHAPE_PROXYTYPE");
|
||||
if (_shape->isConvex()) {
|
||||
EGE_DEBUG(" shape->isConvex()");
|
||||
const btConvexPolyhedron* poly = _shape->isPolyhedral() ? ((btPolyhedralConvexShape*) _shape)->getConvexPolyhedron() : 0;
|
||||
if (NULL!=poly) {
|
||||
EGE_DEBUG(" have poly");
|
||||
/*
|
||||
glBegin(GL_TRIANGLES);
|
||||
for (int32_t iii=0 ; iii<poly->m_faces.size() ; iii++) {
|
||||
btVector3 centroid(0,0,0);
|
||||
int numVerts = poly->m_faces[iii].m_indices.size();
|
||||
if (numVerts>2) {
|
||||
btVector3 v1 = poly->m_vertices[poly->m_faces[iii].m_indices[0]];
|
||||
for (int32_t vvv=0;vvv<poly->m_faces[iii].m_indices.size()-2;vvv++) {
|
||||
btVector3 v2 = poly->m_vertices[poly->m_faces[iii].m_indices[vvv+1]];
|
||||
btVector3 v3 = poly->m_vertices[poly->m_faces[iii].m_indices[vvv+2]];
|
||||
btVector3 normal = (v3-v1).cross(v2-v1);
|
||||
normal.normalize ();
|
||||
|
||||
glNormal3f(normal.getX(),normal.getY(),normal.getZ());
|
||||
glVertex3f (v1.x(), v1.y(), v1.z());
|
||||
glVertex3f (v2.x(), v2.y(), v2.z());
|
||||
glVertex3f (v3.x(), v3.y(), v3.z());
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
glEnd();
|
||||
*/
|
||||
} else {
|
||||
// TODO : Set it back ...
|
||||
/*
|
||||
ShapeCache* sc=cache((btConvexShape*)_shape);
|
||||
//glutSolidCube(1.0);
|
||||
btShapeHull* hull = &sc->m_shapehull;
|
||||
if (hull->numTriangles () > 0) {
|
||||
int index = 0;
|
||||
const unsigned int* idx = hull->getIndexPointer();
|
||||
const btVector3* vtx = hull->getVertexPointer();
|
||||
glBegin (GL_TRIANGLES);
|
||||
for (int i = 0; i < hull->numTriangles(); i++) {
|
||||
int i1 = index++;
|
||||
int i2 = index++;
|
||||
int i3 = index++;
|
||||
btAssert(i1 < hull->numIndices() &&
|
||||
i2 < hull->numIndices() &&
|
||||
i3 < hull->numIndices());
|
||||
int index1 = idx[i1];
|
||||
int index2 = idx[i2];
|
||||
int index3 = idx[i3];
|
||||
btAssert(index1 < hull->numVertices() &&
|
||||
index2 < hull->numVertices() &&
|
||||
index3 < hull->numVertices());
|
||||
btVector3 v1 = vtx[index1];
|
||||
btVector3 v2 = vtx[index2];
|
||||
btVector3 v3 = vtx[index3];
|
||||
btVector3 normal = (v3-v1).cross(v2-v1);
|
||||
normal.normalize();
|
||||
glNormal3f(normal.getX(),normal.getY(),normal.getZ());
|
||||
glVertex3f (v1.x(), v1.y(), v1.z());
|
||||
glVertex3f (v2.x(), v2.y(), v2.z());
|
||||
glVertex3f (v3.x(), v3.y(), v3.z());
|
||||
}
|
||||
glEnd ();
|
||||
}
|
||||
*/
|
||||
}
|
||||
} else {
|
||||
EGE_DEBUG(" !!! shape is NOT Convex() !!!");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case COMPOUND_SHAPE_PROXYTYPE: {
|
||||
@ -339,17 +408,26 @@ void ege::ElementGame::DrawDebug(ewol::Colored3DObject* _draw, const ege::Camera
|
||||
|
||||
void ege::ElementGame::DynamicEnable(void)
|
||||
{
|
||||
if (false == m_elementInPhysicsSystem) {
|
||||
if (true == m_elementInPhysicsSystem) {
|
||||
return;
|
||||
}
|
||||
if(NULL!=m_body) {
|
||||
m_env.GetDynamicWorld()->addRigidBody(m_body);
|
||||
}
|
||||
m_elementInPhysicsSystem = true;
|
||||
if(NULL!=m_IA) {
|
||||
m_env.GetDynamicWorld()->addAction(m_IA);
|
||||
}
|
||||
m_elementInPhysicsSystem = true;
|
||||
}
|
||||
|
||||
void ege::ElementGame::DynamicDisable(void)
|
||||
{
|
||||
if (true == m_elementInPhysicsSystem) {
|
||||
if (false == m_elementInPhysicsSystem) {
|
||||
return;
|
||||
}
|
||||
if(NULL!=m_IA) {
|
||||
m_env.GetDynamicWorld()->removeAction(m_IA);
|
||||
}
|
||||
if(NULL!=m_body) {
|
||||
// Unlink element from the engine
|
||||
m_env.GetDynamicWorld()->removeRigidBody(m_body);
|
||||
@ -357,7 +435,6 @@ void ege::ElementGame::DynamicDisable(void)
|
||||
}
|
||||
m_elementInPhysicsSystem = false;
|
||||
}
|
||||
}
|
||||
|
||||
void ege::ElementGame::IAEnable(void)
|
||||
{
|
||||
@ -365,14 +442,15 @@ void ege::ElementGame::IAEnable(void)
|
||||
// IA already started ...
|
||||
return;
|
||||
}
|
||||
DynamicEnable();
|
||||
m_IA = new localIA(*this);
|
||||
if (NULL == m_IA) {
|
||||
EGE_ERROR("Can not start the IA ==> allocation error");
|
||||
return;
|
||||
}
|
||||
if (true == m_elementInPhysicsSystem) {
|
||||
m_env.GetDynamicWorld()->addAction(m_IA);
|
||||
}
|
||||
}
|
||||
|
||||
void ege::ElementGame::IADisable(void)
|
||||
{
|
||||
@ -380,7 +458,9 @@ void ege::ElementGame::IADisable(void)
|
||||
// IA already stopped ...
|
||||
return;
|
||||
}
|
||||
if (true == m_elementInPhysicsSystem) {
|
||||
m_env.GetDynamicWorld()->removeAction(m_IA);
|
||||
}
|
||||
// Remove IA :
|
||||
delete(m_IA);
|
||||
m_IA = NULL;
|
||||
|
@ -236,3 +236,24 @@ void ege::Environement::GetOrderedElementForDisplay(etk::Vector<ege::Environemen
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ege::Environement::GenerateInteraction(ege::ElementInteraction& _event)
|
||||
{
|
||||
// inform the element that an element has been removed ==> this permit to keep pointer on elements ...
|
||||
for (int32_t iii=0; iii<m_listElementGame.Size() ; iii++) {
|
||||
if (NULL == m_listElementGame[iii]) {
|
||||
continue;
|
||||
}
|
||||
_event.ApplyEvent(*m_listElementGame[iii]);
|
||||
/*
|
||||
vec3 destPosition = m_listElementGame[iii]->GetPosition();
|
||||
float dist = btDistance(sourcePosition, destPosition);
|
||||
if (dist==0 || dist>decreasePower) {
|
||||
continue;
|
||||
}
|
||||
float inpact = (decreasePower-dist)/decreasePower * power;
|
||||
g_listElementGame[iii]->SetFireOn(groupIdSource, type, -inpact, sourcePosition);
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,35 @@ namespace ege {
|
||||
class Environement;
|
||||
typedef ege::ElementGame* (*createElement_tf)(ege::Environement& _env, const etk::UString& _description);
|
||||
|
||||
class ElementInteraction
|
||||
{
|
||||
protected:
|
||||
int32_t m_type;
|
||||
public:
|
||||
int32_t GetType(void) { return m_type; };
|
||||
protected:
|
||||
int32_t m_groupSource;
|
||||
public:
|
||||
int32_t GetSourceGroup(void) { return m_groupSource; };
|
||||
protected:
|
||||
etk::Vector<int32_t> m_groupDestination;
|
||||
public:
|
||||
const etk::Vector<int32_t>& GetDestinationGroup(void) { return m_groupDestination; };
|
||||
void AddGroupDestination(int32_t _id) { m_groupDestination.PushBack(_id); };
|
||||
protected:
|
||||
vec3 m_positionSource;
|
||||
public:
|
||||
const vec3& GetSourcePosition(void) { return m_positionSource; };
|
||||
public:
|
||||
ElementInteraction(int32_t _type, int32_t _groupSource, const vec3& _pos) :
|
||||
m_type(_type),
|
||||
m_groupSource(_groupSource),
|
||||
m_positionSource(_pos)
|
||||
{ };
|
||||
public:
|
||||
virtual void ApplyEvent(ege::ElementGame& _element) { };
|
||||
};
|
||||
|
||||
class Environement
|
||||
{
|
||||
private:
|
||||
@ -94,6 +123,11 @@ namespace ege {
|
||||
* @param[in] _direction Camera direction of the view.
|
||||
*/
|
||||
void GetOrderedElementForDisplay(etk::Vector<ege::Environement::ResultNearestElement>& _resultList, const vec3& _position, const vec3& _direction);
|
||||
/**
|
||||
* @brief Generate an event on all the sub element of the game ==> usefull for explosion, or lazer fire ...
|
||||
* @param[in] _event event that might be apply ...
|
||||
*/
|
||||
void GenerateInteraction(ege::ElementInteraction& _event);
|
||||
};
|
||||
};
|
||||
|
||||
|
347
ege/Scene.cpp
347
ege/Scene.cpp
@ -35,25 +35,13 @@ const char * const ege::Scene::eventPlayTimeChange = "event-scene-play-time-chan
|
||||
const char * const ege::Scene::eventKillEnemy = "event-scene-kill-ennemy";
|
||||
|
||||
|
||||
#define WALK_FLAG_FORWARD (1<<0)
|
||||
#define WALK_FLAG_BACK (1<<1)
|
||||
#define WALK_FLAG_LEFT (1<<2)
|
||||
#define WALK_FLAG_RIGHT (1<<3)
|
||||
#define WALK_FLAG_CAUTION (1<<4)
|
||||
|
||||
ege::Scene::Scene(btDefaultCollisionConfiguration* _collisionConfiguration,
|
||||
btCollisionDispatcher* _dispatcher,
|
||||
btBroadphaseInterface* _broadphase,
|
||||
btConstraintSolver* _solver,
|
||||
btDynamicsWorld* _dynamicsWorld,
|
||||
ege::Camera* _camera) :
|
||||
ege::Scene::Scene(bool _setAutoBullet, bool _setAutoCamera) :
|
||||
m_gameTime(0),
|
||||
m_angleView(M_PI/3.0),
|
||||
m_finger_DoubleTouch(false),
|
||||
m_dynamicsWorld(NULL),
|
||||
m_camera(NULL),
|
||||
m_isRunning(true),
|
||||
m_walk(0),
|
||||
m_debugMode(false),
|
||||
m_debugDrawing(NULL)
|
||||
{
|
||||
@ -66,6 +54,20 @@ ege::Scene::Scene(btDefaultCollisionConfiguration* _collisionConfiguration,
|
||||
ewol::resource::Keep(m_debugDrawing);
|
||||
|
||||
m_ratioTime = 1.0f;
|
||||
if (_setAutoBullet==true) {
|
||||
SetBulletConfig();
|
||||
}
|
||||
if (_setAutoCamera==true) {
|
||||
SetCamera();
|
||||
}
|
||||
}
|
||||
|
||||
void ege::Scene::SetBulletConfig(btDefaultCollisionConfiguration* _collisionConfiguration,
|
||||
btCollisionDispatcher* _dispatcher,
|
||||
btBroadphaseInterface* _broadphase,
|
||||
btConstraintSolver* _solver,
|
||||
btDynamicsWorld* _dynamicsWorld)
|
||||
{
|
||||
if (NULL != _collisionConfiguration) {
|
||||
m_collisionConfiguration = _collisionConfiguration;
|
||||
} else {
|
||||
@ -100,6 +102,10 @@ ege::Scene::Scene(btDefaultCollisionConfiguration* _collisionConfiguration,
|
||||
|
||||
m_env.SetDynamicWorld(m_dynamicsWorld);
|
||||
|
||||
}
|
||||
|
||||
void ege::Scene::SetCamera(ege::Camera* _camera)
|
||||
{
|
||||
if (NULL != _camera) {
|
||||
m_camera = _camera;
|
||||
} else {
|
||||
@ -109,7 +115,6 @@ ege::Scene::Scene(btDefaultCollisionConfiguration* _collisionConfiguration,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ege::Scene::~Scene(void)
|
||||
{
|
||||
ewol::resource::Release(m_debugDrawing);
|
||||
@ -242,18 +247,9 @@ btRigidBody& btActionInterface::getFixedBody()
|
||||
return s_fixed;
|
||||
}
|
||||
|
||||
#define WALK_FLAG_FORWARD (1<<0)
|
||||
#define WALK_FLAG_BACK (1<<1)
|
||||
#define WALK_FLAG_LEFT (1<<2)
|
||||
#define WALK_FLAG_RIGHT (1<<3)
|
||||
#define WALK_FLAG_CAUTION (1<<4)
|
||||
|
||||
static const float l_walkRatio = 15;
|
||||
static const float l_walkLateralRatio = 15;
|
||||
|
||||
void ege::Scene::PeriodicCall(const ewol::EventTime& _event)
|
||||
{
|
||||
|
||||
float curentDelta=_event.GetDeltaCall();
|
||||
// small hack to change speed ...
|
||||
if (m_ratioTime != 1) {
|
||||
@ -274,8 +270,9 @@ void ege::Scene::PeriodicCall(const ewol::EventTime& _event)
|
||||
//EWOL_DEBUG("Time: m_lastCallTime=" << m_lastCallTime << " deltaTime=" << deltaTime);
|
||||
|
||||
// update camera positions:
|
||||
if (NULL != m_camera) {
|
||||
m_camera->PeriodicCall(curentDelta);
|
||||
|
||||
}
|
||||
//EGE_DEBUG("stepSimulation (start)");
|
||||
///step the simulation
|
||||
if (m_dynamicsWorld) {
|
||||
@ -306,48 +303,6 @@ void ege::Scene::PeriodicCall(const ewol::EventTime& _event)
|
||||
}
|
||||
}
|
||||
MarkToRedraw();
|
||||
if (m_walk!=0) {
|
||||
float walkValue = 0;
|
||||
if( (m_walk&WALK_FLAG_FORWARD)!=0
|
||||
&& (m_walk&WALK_FLAG_BACK)!=0) {
|
||||
// request back and forward in the same time ... this is really bad ....
|
||||
walkValue = 0;
|
||||
} else if ( (m_walk&WALK_FLAG_FORWARD)!=0) {
|
||||
walkValue = 1;
|
||||
} else if ( (m_walk&WALK_FLAG_BACK)!=0) {
|
||||
walkValue = -1;
|
||||
}
|
||||
if (walkValue!=0) {
|
||||
float angleZ = m_camera->GetAngleZ();
|
||||
vec3 offsetPosition( cosf(angleZ-M_PI/2.0)*walkValue,
|
||||
-sinf(angleZ-M_PI/2.0)*walkValue,
|
||||
0);
|
||||
//EWOL_DEBUG("Walk : " << ((int32_t)(angles.z/M_PI*180+180)%360-180) << " ==> " << angles);
|
||||
// walk is 6 km/h
|
||||
vec3 pos = m_camera->GetEye() + offsetPosition*l_walkRatio*curentDelta;
|
||||
m_camera->SetEye(pos);
|
||||
}
|
||||
walkValue=0;
|
||||
if( (m_walk&WALK_FLAG_LEFT)!=0
|
||||
&& (m_walk&WALK_FLAG_RIGHT)!=0) {
|
||||
// request left and right in the same time ... this is really bad ....
|
||||
walkValue=0;
|
||||
} else if ( (m_walk&WALK_FLAG_LEFT)!=0) {
|
||||
walkValue = 1;
|
||||
} else if ( (m_walk&WALK_FLAG_RIGHT)!=0) {
|
||||
walkValue = -1;
|
||||
}
|
||||
if (walkValue != 0) {
|
||||
float angleZ = m_camera->GetAngleZ();
|
||||
vec3 offsetPosition( cosf(angleZ)*walkValue,
|
||||
-sinf(angleZ)*walkValue,
|
||||
0);
|
||||
//EWOL_DEBUG("Walk : " << ((int32_t)(angles.z/M_PI*180+180)%360-180) << " ==> " << angles);
|
||||
// lateral walk is 4 km/h
|
||||
vec3 pos = m_camera->GetEye() + offsetPosition*l_walkLateralRatio*curentDelta;
|
||||
m_camera->SetEye(pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#define GAME_Z_NEAR (1)
|
||||
@ -428,265 +383,5 @@ vec3 ege::Scene::ConvertScreenPositionInMapPosition(const vec2& posScreen)
|
||||
return m_camera->projectOnZGround(CalculateDeltaAngle(posScreen));
|
||||
}
|
||||
|
||||
bool ege::Scene::OnEventInput(const ewol::EventInput& _event)
|
||||
{
|
||||
//EWOL_DEBUG("Input event : " << _event);
|
||||
vec2 relPos = RelativePosition(_event.GetPos());
|
||||
/*
|
||||
* *
|
||||
* |\
|
||||
* | \
|
||||
* | \
|
||||
* | \
|
||||
* | \
|
||||
* | \
|
||||
* *------*
|
||||
* \ \
|
||||
* \ \
|
||||
* \ \
|
||||
* *-*
|
||||
*/
|
||||
if (_event.GetType() == ewol::keyEvent::typeMouse) {
|
||||
if (0 != _event.GetId()) {
|
||||
KeepFocus();
|
||||
}
|
||||
//EGE_DEBUG("Move mouse at position = " << relPos << " ==> " << curentCreatingPosition );
|
||||
if (1 == _event.GetId()) {
|
||||
|
||||
} else if (2 == _event.GetId()) {
|
||||
// center button : change the angle the camara
|
||||
if (ewol::keyEvent::statusMove == _event.GetStatus()) {
|
||||
vec2 tmppPos = relPos-m_centerButtonStartPos;
|
||||
tmppPos *= M_PI/(360.0f*6);
|
||||
m_camera->SetAngleZ(m_camera->GetAngleZ()- tmppPos.x());
|
||||
m_camera->SetAngleTeta(m_camera->GetAngleTeta()-tmppPos.y());
|
||||
}
|
||||
// update register position ...
|
||||
m_centerButtonStartPos = relPos;
|
||||
} else if (3 == _event.GetId()) {
|
||||
// center button : change the angle the camara
|
||||
if (ewol::keyEvent::statusMove == _event.GetStatus()) {
|
||||
vec3 nextPosition = ConvertScreenPositionInMapPosition(relPos);
|
||||
vec3 tmppPos = nextPosition-m_finger_StartPosMoving;
|
||||
vec3 oldposition = m_camera->GetEye();
|
||||
// update the camera positions:
|
||||
oldposition.setX(oldposition.x() - tmppPos.x());
|
||||
oldposition.setY(oldposition.y() - tmppPos.y());
|
||||
// set the new position
|
||||
m_camera->SetEye(oldposition);
|
||||
}
|
||||
// update register position ...
|
||||
m_leftButtonStartPos = relPos;
|
||||
m_finger_StartPosMoving = ConvertScreenPositionInMapPosition(relPos);
|
||||
} else if (4 == _event.GetId()) {
|
||||
if (ewol::keyEvent::statusSingle == _event.GetStatus()) {
|
||||
// scrool input
|
||||
float cameraDistance = m_camera->GetDistance()-3;
|
||||
EGE_DEBUG("New camera distance : " << etk_avg(10, cameraDistance, 100));
|
||||
m_camera->SetDistance(etk_avg(10, cameraDistance, 100));
|
||||
}
|
||||
} else if (5 == _event.GetId()) {
|
||||
if (ewol::keyEvent::statusSingle == _event.GetStatus()) {
|
||||
// scrool output
|
||||
float cameraDistance = m_camera->GetDistance()+3;
|
||||
EGE_DEBUG("New camera distance : " << etk_avg(10, cameraDistance, 100));
|
||||
m_camera->SetDistance(etk_avg(10, cameraDistance, 100));
|
||||
}
|
||||
}
|
||||
/*
|
||||
*
|
||||
* ---
|
||||
* / \
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* | | --- --- ---
|
||||
* | |/ \/ \/ \
|
||||
* | |
|
||||
* /| |
|
||||
* / | |
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* \ /
|
||||
* \ /
|
||||
* \ /
|
||||
* \ /
|
||||
*/
|
||||
} else if (_event.GetType() == ewol::keyEvent::typeFinger) {
|
||||
KeepFocus();
|
||||
if (1 == _event.GetId()) {
|
||||
if (m_finger_DoubleTouch==false) {
|
||||
|
||||
} else {
|
||||
if (ewol::keyEvent::statusMove == _event.GetStatus()) {
|
||||
m_finger_1Position = relPos;
|
||||
if (m_finger_2Position.x() > -10000) {
|
||||
vec2 distance = m_finger_1Position-m_finger_2Position;
|
||||
float realDistance = distance.length();
|
||||
float fingerAngle = acosf(etk_avg(-1.0f, (distance.x()/realDistance), 1.0f) );
|
||||
if (distance.y()<0){
|
||||
fingerAngle *=-1;
|
||||
}
|
||||
realDistance /= 2.0f;
|
||||
if (m_finger_oldDistance>=0) {
|
||||
float distanceDelta = m_finger_oldDistance-realDistance;
|
||||
m_camera->SetDistance(etk_avg(10,m_camera->GetDistance()+distanceDelta/3.0f,100));
|
||||
float angleDelta = m_finger_oldAngle - fingerAngle;
|
||||
m_camera->SetAngleZ(m_camera->GetAngleZ()+angleDelta);
|
||||
}
|
||||
m_finger_oldDistance = realDistance;
|
||||
m_finger_oldAngle = fingerAngle;
|
||||
}
|
||||
}
|
||||
}
|
||||
m_finger_StartPosMoving = ConvertScreenPositionInMapPosition(relPos);
|
||||
if (ewol::keyEvent::statusUp == _event.GetStatus()) {
|
||||
m_finger_DoubleTouch = false;
|
||||
}
|
||||
} else if (2 == _event.GetId()) {
|
||||
if (ewol::keyEvent::statusDown == _event.GetStatus()) {
|
||||
m_finger_DoubleTouch = true;
|
||||
m_finger_1Position = vec2(-500000,-500000);
|
||||
m_finger_2Position = vec2(-500000,-500000);
|
||||
m_finger_oldDistance = -1;
|
||||
m_finger_oldAngle = 0;
|
||||
} else if (ewol::keyEvent::statusMove == _event.GetStatus()) {
|
||||
m_finger_2Position = relPos;
|
||||
if (m_finger_1Position.x() > -10000) {
|
||||
vec2 distance = m_finger_1Position-m_finger_2Position;
|
||||
float realDistance = distance.length();
|
||||
float fingerAngle = acosf(etk_avg(-1.0f, (distance.x()/realDistance), 1.0f) );
|
||||
if (distance.y()<0){
|
||||
fingerAngle *=-1;
|
||||
}
|
||||
realDistance /= 2.0f;
|
||||
if (m_finger_oldDistance>=0) {
|
||||
float distanceDelta = m_finger_oldDistance-realDistance;
|
||||
m_camera->SetDistance(etk_avg(10,m_camera->GetDistance()+distanceDelta/3.0f,100));
|
||||
float angleDelta = m_finger_oldAngle - fingerAngle;
|
||||
m_camera->SetAngleZ(m_camera->GetAngleZ()+angleDelta);
|
||||
}
|
||||
m_finger_oldDistance = realDistance;
|
||||
m_finger_oldAngle = fingerAngle;
|
||||
}
|
||||
} else if (ewol::keyEvent::statusUp == _event.GetStatus()) {
|
||||
m_finger_DoubleTouch = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool ege::Scene::OnEventEntry(const ewol::EventEntry& _event)
|
||||
{
|
||||
if (_event.GetType() == ewol::keyEvent::keyboardChar) {
|
||||
EWOL_DEBUG("Entry enevnt : " << _event );
|
||||
|
||||
if( _event.GetChar() == 'z'
|
||||
|| _event.GetChar() == 'Z') {
|
||||
if (_event.GetStatus() == ewol::keyEvent::statusDown) {
|
||||
m_walk |= WALK_FLAG_FORWARD;
|
||||
}
|
||||
if (_event.GetStatus() == ewol::keyEvent::statusUp) {
|
||||
if ((m_walk&WALK_FLAG_FORWARD) != 0) {
|
||||
m_walk -= WALK_FLAG_FORWARD;
|
||||
}
|
||||
}
|
||||
}
|
||||
if( _event.GetChar() == 's'
|
||||
|| _event.GetChar() == 'S') {
|
||||
if (_event.GetStatus() == ewol::keyEvent::statusDown) {
|
||||
m_walk |= WALK_FLAG_BACK;
|
||||
}
|
||||
if (_event.GetStatus() == ewol::keyEvent::statusUp) {
|
||||
if ((m_walk&WALK_FLAG_BACK) != 0) {
|
||||
m_walk -= WALK_FLAG_BACK;
|
||||
}
|
||||
}
|
||||
}
|
||||
if( _event.GetChar() == 'q'
|
||||
|| _event.GetChar() == 'Q') {
|
||||
if (_event.GetStatus() == ewol::keyEvent::statusDown) {
|
||||
m_walk |= WALK_FLAG_LEFT;
|
||||
}
|
||||
if (_event.GetStatus() == ewol::keyEvent::statusUp) {
|
||||
if ((m_walk&WALK_FLAG_LEFT) != 0) {
|
||||
m_walk -= WALK_FLAG_LEFT;
|
||||
}
|
||||
}
|
||||
}
|
||||
if( _event.GetChar() == 'd'
|
||||
|| _event.GetChar() == 'D') {
|
||||
if (_event.GetStatus() == ewol::keyEvent::statusDown) {
|
||||
m_walk |= WALK_FLAG_RIGHT;
|
||||
}
|
||||
if (_event.GetStatus() == ewol::keyEvent::statusUp) {
|
||||
if ((m_walk&WALK_FLAG_RIGHT) != 0) {
|
||||
m_walk -= WALK_FLAG_RIGHT;
|
||||
}
|
||||
}
|
||||
}
|
||||
EWOL_DEBUG("m_walk=" << m_walk);
|
||||
return false;
|
||||
}
|
||||
// Move event ...
|
||||
if (_event.GetType() == ewol::keyEvent::keyboardUp) {
|
||||
if (_event.GetStatus() == ewol::keyEvent::statusDown) {
|
||||
m_walk |= WALK_FLAG_FORWARD;
|
||||
}
|
||||
if (_event.GetStatus() == ewol::keyEvent::statusUp) {
|
||||
if ((m_walk&WALK_FLAG_FORWARD) != 0) {
|
||||
m_walk -= WALK_FLAG_FORWARD;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (_event.GetType() == ewol::keyEvent::keyboardDown) {
|
||||
if (_event.GetStatus() == ewol::keyEvent::statusDown) {
|
||||
m_walk |= WALK_FLAG_BACK;
|
||||
}
|
||||
if (_event.GetStatus() == ewol::keyEvent::statusUp) {
|
||||
if ((m_walk&WALK_FLAG_BACK) != 0) {
|
||||
m_walk -= WALK_FLAG_BACK;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (_event.GetType() == ewol::keyEvent::keyboardLeft) {
|
||||
if (_event.GetStatus() == ewol::keyEvent::statusDown) {
|
||||
m_walk |= WALK_FLAG_LEFT;
|
||||
}
|
||||
if (_event.GetStatus() == ewol::keyEvent::statusUp) {
|
||||
if ((m_walk&WALK_FLAG_LEFT) != 0) {
|
||||
m_walk -= WALK_FLAG_LEFT;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (_event.GetType() == ewol::keyEvent::keyboardRight) {
|
||||
if (_event.GetStatus() == ewol::keyEvent::statusDown) {
|
||||
m_walk |= WALK_FLAG_RIGHT;
|
||||
}
|
||||
if (_event.GetStatus() == ewol::keyEvent::statusUp) {
|
||||
if ((m_walk&WALK_FLAG_RIGHT) != 0) {
|
||||
m_walk -= WALK_FLAG_RIGHT;
|
||||
}
|
||||
}
|
||||
}
|
||||
EWOL_DEBUG("m_walk=" << m_walk);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void ege::Scene::OnGetFocus(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ege::Scene::OnLostFocus(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
27
ege/Scene.h
27
ege/Scene.h
@ -46,28 +46,21 @@ namespace ege {
|
||||
* @brief Constructor of the widget classes
|
||||
* @return (no execption generated (not managed in embended platform))
|
||||
*/
|
||||
Scene(btDefaultCollisionConfiguration* _collisionConfiguration=NULL,
|
||||
btCollisionDispatcher* _dispatcher=NULL,
|
||||
btBroadphaseInterface* _broadphase=NULL,
|
||||
btConstraintSolver* _solver=NULL,
|
||||
btDynamicsWorld* _dynamicsWorld=NULL,
|
||||
ege::Camera* _camera=NULL);
|
||||
Scene(bool _setAutoBullet=true, bool _setAutoCamera=true);
|
||||
/**
|
||||
* @brief Destructor of the widget classes
|
||||
*/
|
||||
virtual ~Scene(void);
|
||||
void SetBulletConfig(btDefaultCollisionConfiguration* _collisionConfiguration=NULL,
|
||||
btCollisionDispatcher* _dispatcher=NULL,
|
||||
btBroadphaseInterface* _broadphase=NULL,
|
||||
btConstraintSolver* _solver=NULL,
|
||||
btDynamicsWorld* _dynamicsWorld=NULL);
|
||||
void SetCamera(ege::Camera* _camera=NULL);
|
||||
private:
|
||||
float m_gameTime; //!< time of the game running
|
||||
protected:
|
||||
float m_angleView;
|
||||
vec2 m_centerButtonStartPos;
|
||||
vec2 m_leftButtonStartPos;
|
||||
vec3 m_finger_StartPosMoving;
|
||||
bool m_finger_DoubleTouch;
|
||||
vec2 m_finger_1Position;
|
||||
vec2 m_finger_2Position;
|
||||
float m_finger_oldDistance;
|
||||
float m_finger_oldAngle;
|
||||
///this is the most important class
|
||||
btDefaultCollisionConfiguration* m_collisionConfiguration;
|
||||
btCollisionDispatcher* m_dispatcher;
|
||||
@ -76,11 +69,9 @@ namespace ege {
|
||||
btDynamicsWorld* m_dynamicsWorld;
|
||||
// camera section
|
||||
ege::Camera* m_camera; //!< Display point of view.
|
||||
vec3 m_cameraMovePointStart; //!< Position where the mouse start to move
|
||||
// Other elements
|
||||
bool m_isRunning; //!< the display is running (not in pause)
|
||||
float m_ratioTime; //!< Ratio time for the speed of the game ...
|
||||
uint32_t m_walk; //!< Wolk properties
|
||||
// Note : This is only for temporary elements : on the display
|
||||
etk::Vector<ege::Environement::ResultNearestElement> m_displayElementOrdered;
|
||||
public:
|
||||
@ -136,10 +127,6 @@ namespace ege {
|
||||
virtual void SystemDraw(const ewol::DrawProperty& _displayProp);
|
||||
virtual void OnRegenerateDisplay(void);
|
||||
virtual void PeriodicCall(const ewol::EventTime& _event);
|
||||
virtual bool OnEventInput(const ewol::EventInput& _event);
|
||||
virtual bool OnEventEntry(const ewol::EventEntry& _event);
|
||||
virtual void OnGetFocus(void);
|
||||
virtual void OnLostFocus(void);
|
||||
};
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user