[DEV] basic FPS view with so beautifull grass
This commit is contained in:
parent
cc07a77377
commit
57c22f93ef
@ -14,8 +14,8 @@
|
|||||||
void game::Camera::Update(void)
|
void game::Camera::Update(void)
|
||||||
{
|
{
|
||||||
m_matrix.Identity();
|
m_matrix.Identity();
|
||||||
//m_matrix.Rotate(vec3(0,0,1), M_PI/2.0 );
|
m_matrix.Rotate(vec3(0,0,1), M_PI/2.0 );
|
||||||
//m_matrix.Rotate(vec3(0,1,0), M_PI/2.0 );
|
m_matrix.Rotate(vec3(0,1,0), M_PI/2.0 );
|
||||||
m_matrix.Rotate(vec3(1,0,0), m_angles.x );
|
m_matrix.Rotate(vec3(1,0,0), m_angles.x );
|
||||||
m_matrix.Rotate(vec3(0,1,0), m_angles.y );
|
m_matrix.Rotate(vec3(0,1,0), m_angles.y );
|
||||||
m_matrix.Rotate(vec3(0,0,1), m_angles.z );
|
m_matrix.Rotate(vec3(0,0,1), m_angles.z );
|
||||||
|
@ -16,6 +16,7 @@ static int32_t uniqueId = 0;
|
|||||||
|
|
||||||
game::Element::Element(etk::UString meshResource) :
|
game::Element::Element(etk::UString meshResource) :
|
||||||
m_resource(NULL),
|
m_resource(NULL),
|
||||||
|
m_scale(1,1,1),
|
||||||
m_mass(0.0f),
|
m_mass(0.0f),
|
||||||
m_uniqueId(uniqueId),
|
m_uniqueId(uniqueId),
|
||||||
m_groupId(0),
|
m_groupId(0),
|
||||||
@ -29,9 +30,6 @@ game::Element::Element(etk::UString meshResource) :
|
|||||||
m_resource = tmpObject;
|
m_resource = tmpObject;
|
||||||
}
|
}
|
||||||
uniqueId++;
|
uniqueId++;
|
||||||
|
|
||||||
//Scale(vec3(100,100,100) );
|
|
||||||
//Translate(vec3(0.0,0.0,-10.0));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
game::Element::~Element(void)
|
game::Element::~Element(void)
|
||||||
@ -46,6 +44,7 @@ game::Element::~Element(void)
|
|||||||
void game::Element::Draw(void)
|
void game::Element::Draw(void)
|
||||||
{
|
{
|
||||||
if (NULL != m_resource) {
|
if (NULL != m_resource) {
|
||||||
|
//EWOL_DEBUG("draw " << m_uniqueId);
|
||||||
m_resource->Draw(GetMatrix());
|
m_resource->Draw(GetMatrix());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,11 +36,11 @@ extern const float game::GravityConst = 0.0000000000667f;
|
|||||||
// Earth
|
// Earth
|
||||||
extern const float game::earthMass = 5973600000000000000000000.0f; // in kg
|
extern const float game::earthMass = 5973600000000000000000000.0f; // in kg
|
||||||
extern const float game::earthRadius = 6378137.0f; // in meter
|
extern const float game::earthRadius = 6378137.0f; // in meter
|
||||||
extern const game::Gravity game::gravityEarth(true, earthMass, vec3(0, -(float)((GravityConst*earthMass)/(earthRadius*earthRadius)), 0) );
|
extern const game::Gravity game::gravityEarth(true, earthMass, vec3(0, 0, -(float)((GravityConst*earthMass)/(earthRadius*earthRadius))) );
|
||||||
// Mars
|
// Mars
|
||||||
extern const float game::marsMass = 25000000000000000.0f; // in kg
|
extern const float game::marsMass = 25000000000000000.0f; // in kg
|
||||||
extern const float game::marsRadius = 3396200.0f; // in meter
|
extern const float game::marsRadius = 3396200.0f; // in meter
|
||||||
extern const game::Gravity game::gravityMars(true, marsMass, vec3(0, -(float)((GravityConst*marsMass)/(marsRadius*marsRadius)), 0) );
|
extern const game::Gravity game::gravityMars(true, marsMass, vec3(0, 0, -(float)((GravityConst*marsMass)/(marsRadius*marsRadius))) );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#include <ewol/renderer/openGL.h>
|
#include <ewol/renderer/openGL.h>
|
||||||
|
|
||||||
etk::Vector<mat4> l_matrixList;
|
etk::Vector<mat4> l_matrixList;
|
||||||
|
mat4 l_matrixCamera;
|
||||||
|
|
||||||
void ewol::openGL::Init(void)
|
void ewol::openGL::Init(void)
|
||||||
{
|
{
|
||||||
@ -18,12 +19,14 @@ void ewol::openGL::Init(void)
|
|||||||
l_matrixList.Clear();
|
l_matrixList.Clear();
|
||||||
mat4 tmpMat;
|
mat4 tmpMat;
|
||||||
l_matrixList.PushBack(tmpMat);
|
l_matrixList.PushBack(tmpMat);
|
||||||
|
l_matrixCamera.Identity();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ewol::openGL::UnInit(void)
|
void ewol::openGL::UnInit(void)
|
||||||
{
|
{
|
||||||
l_matrixList.Clear();
|
l_matrixList.Clear();
|
||||||
|
l_matrixCamera.Identity();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ewol::openGL::SetBasicMatrix(mat4& newOne)
|
void ewol::openGL::SetBasicMatrix(mat4& newOne)
|
||||||
@ -64,9 +67,11 @@ void ewol::openGL::Pop(void)
|
|||||||
l_matrixList.Clear();
|
l_matrixList.Clear();
|
||||||
mat4 tmp;
|
mat4 tmp;
|
||||||
l_matrixList.PushBack(tmp);
|
l_matrixList.PushBack(tmp);
|
||||||
|
l_matrixCamera.Identity();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
l_matrixList.PopBack();
|
l_matrixList.PopBack();
|
||||||
|
l_matrixCamera.Identity();
|
||||||
}
|
}
|
||||||
|
|
||||||
mat4& ewol::openGL::GetMatrix(void)
|
mat4& ewol::openGL::GetMatrix(void)
|
||||||
@ -79,3 +84,12 @@ mat4& ewol::openGL::GetMatrix(void)
|
|||||||
return l_matrixList[l_matrixList.Size()-1];
|
return l_matrixList[l_matrixList.Size()-1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mat4& ewol::openGL::GetCameraMatrix(void)
|
||||||
|
{
|
||||||
|
return l_matrixCamera;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ewol::openGL::SetCameraMatrix(mat4& newOne)
|
||||||
|
{
|
||||||
|
l_matrixCamera = newOne;
|
||||||
|
}
|
||||||
|
@ -83,6 +83,16 @@ namespace ewol {
|
|||||||
* @return The requested matrix.
|
* @return The requested matrix.
|
||||||
*/
|
*/
|
||||||
mat4& GetMatrix(void);
|
mat4& GetMatrix(void);
|
||||||
|
/**
|
||||||
|
* @brief Get a reference on the current matrix camera destinate to opengl renderer.
|
||||||
|
* @return The requested matrix.
|
||||||
|
*/
|
||||||
|
mat4& GetCameraMatrix(void);
|
||||||
|
/**
|
||||||
|
* @brief Set a reference on the current camera to opengl renderer.
|
||||||
|
* @param[in] newOne The requested matrix.
|
||||||
|
*/
|
||||||
|
void SetCameraMatrix(mat4& newOne);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -130,11 +130,11 @@ void ewolProcessEvents(void)
|
|||||||
break;
|
break;
|
||||||
case THREAD_KEYBORAD_KEY:
|
case THREAD_KEYBORAD_KEY:
|
||||||
case THREAD_KEYBORAD_MOVE:
|
case THREAD_KEYBORAD_MOVE:
|
||||||
EWOL_DEBUG("Receive MSG : THREAD_KEYBORAD_KEY");
|
//EWOL_DEBUG("Receive MSG : THREAD_KEYBORAD_KEY");
|
||||||
{
|
{
|
||||||
ewol::SpecialKey& specialCurrentKey = ewol::GetCurrentSpecialKeyStatus();
|
ewol::SpecialKey& specialCurrentKey = ewol::GetCurrentSpecialKeyStatus();
|
||||||
specialCurrentKey = data.keyboardSpecial;
|
specialCurrentKey = data.keyboardSpecial;
|
||||||
EWOL_DEBUG("newStatus Key" << specialCurrentKey);
|
//EWOL_DEBUG("newStatus Key" << specialCurrentKey);
|
||||||
}
|
}
|
||||||
if (NULL != windowsCurrent) {
|
if (NULL != windowsCurrent) {
|
||||||
if (false==windowsCurrent->OnEventShortCut(data.keyboardSpecial,
|
if (false==windowsCurrent->OnEventShortCut(data.keyboardSpecial,
|
||||||
|
@ -764,7 +764,9 @@ void X11_Run(void)
|
|||||||
EWOL_INFO("X11 event : " << event.type << " = \"KeyPress/KeyRelease\" ");
|
EWOL_INFO("X11 event : " << event.type << " = \"KeyPress/KeyRelease\" ");
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
EWOL_DEBUG("eventKey : " << event.xkey.keycode << " state : " << event.xkey.state);
|
#ifdef DEBUG_X11_EVENT
|
||||||
|
EWOL_DEBUG("eventKey : " << event.xkey.keycode << " state : " << event.xkey.state);
|
||||||
|
#endif
|
||||||
if (event.xkey.state & (1<<0) ) {
|
if (event.xkey.state & (1<<0) ) {
|
||||||
//EWOL_DEBUG(" Special Key : SHIFT");
|
//EWOL_DEBUG(" Special Key : SHIFT");
|
||||||
guiKeyBoardMode.shift = true;
|
guiKeyBoardMode.shift = true;
|
||||||
|
@ -39,12 +39,6 @@ ewol::Mesh::~Mesh(void)
|
|||||||
|
|
||||||
void ewol::Mesh::Draw(mat4& positionMatrix)
|
void ewol::Mesh::Draw(mat4& positionMatrix)
|
||||||
{
|
{
|
||||||
static float rotx = 0;
|
|
||||||
static float roty = 0;
|
|
||||||
static float rotz = 0;
|
|
||||||
rotx += 0.01;
|
|
||||||
roty += 0.02;
|
|
||||||
rotz += 0.005;
|
|
||||||
if (m_object.m_vertices.Size()<=0) {
|
if (m_object.m_vertices.Size()<=0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -60,8 +54,9 @@ void ewol::Mesh::Draw(mat4& positionMatrix)
|
|||||||
//EWOL_DEBUG(" Display " << m_coord.Size() << " elements" );
|
//EWOL_DEBUG(" Display " << m_coord.Size() << " elements" );
|
||||||
m_GLprogram->Use();
|
m_GLprogram->Use();
|
||||||
// set Matrix : translation/positionMatrix
|
// set Matrix : translation/positionMatrix
|
||||||
mat4 tmpMatrix = ewol::openGL::GetMatrix();
|
mat4 projMatrix = ewol::openGL::GetMatrix();
|
||||||
tmpMatrix = tmpMatrix * positionMatrix;
|
mat4 camMatrix = ewol::openGL::GetCameraMatrix();
|
||||||
|
mat4 tmpMatrix = projMatrix * camMatrix * positionMatrix;
|
||||||
m_GLprogram->UniformMatrix4fv(m_GLMatrix, 1, tmpMatrix.m_mat);
|
m_GLprogram->UniformMatrix4fv(m_GLMatrix, 1, tmpMatrix.m_mat);
|
||||||
// TextureID
|
// TextureID
|
||||||
m_GLprogram->SetTexture0(m_GLtexID, m_texture1->GetId());
|
m_GLprogram->SetTexture0(m_GLtexID, m_texture1->GetId());
|
||||||
|
@ -14,10 +14,18 @@
|
|||||||
#undef __class__
|
#undef __class__
|
||||||
#define __class__ "Scene"
|
#define __class__ "Scene"
|
||||||
|
|
||||||
|
#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)
|
||||||
|
|
||||||
|
|
||||||
widget::Scene::Scene(game::Engine* gameEngine) :
|
widget::Scene::Scene(game::Engine* gameEngine) :
|
||||||
m_gameEngine(gameEngine),
|
m_gameEngine(gameEngine),
|
||||||
m_isRunning(true),
|
m_isRunning(true),
|
||||||
m_lastCallTime(-1),
|
m_lastCallTime(-1),
|
||||||
|
m_walk(0),
|
||||||
modeMoving(0)
|
modeMoving(0)
|
||||||
{
|
{
|
||||||
SetCanHaveFocus(true);
|
SetCanHaveFocus(true);
|
||||||
@ -70,9 +78,46 @@ void widget::Scene::OnDraw(ewol::DrawProperty& displayProp)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#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)
|
||||||
|
|
||||||
void widget::Scene::PeriodicCall(int64_t localTime)
|
void widget::Scene::PeriodicCall(int64_t localTime)
|
||||||
{
|
{
|
||||||
|
if (m_walk!=0) {
|
||||||
|
if ( (m_walk&(WALK_FLAG_FORWARD|WALK_FLAG_BACK))!=0) {
|
||||||
|
// request back and forward in the same time ... this is really bad ....
|
||||||
|
} else if ( (m_walk&WALK_FLAG_FORWARD)!=0) {
|
||||||
|
vec3 angles = m_camera.GetAngle();
|
||||||
|
angles.x = cosf(angles.z);
|
||||||
|
angles.y = sinf(angles.z);
|
||||||
|
angles.z = 0;
|
||||||
|
vec3 pos = m_camera.GetPosition();
|
||||||
|
pos += angles;
|
||||||
|
EWOL_DEBUG("walk = " << angles);
|
||||||
|
m_camera.SetPosition(pos);
|
||||||
|
} else if ( (m_walk&WALK_FLAG_BACK)!=0) {
|
||||||
|
vec3 angles = m_camera.GetAngle();
|
||||||
|
angles.x = cosf(angles.z);
|
||||||
|
angles.y = sinf(angles.z);
|
||||||
|
angles.z = 0;
|
||||||
|
vec3 pos = m_camera.GetPosition();
|
||||||
|
pos -= angles;
|
||||||
|
EWOL_DEBUG("walk = " << angles*-1);
|
||||||
|
m_camera.SetPosition(pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( (m_walk&(WALK_FLAG_LEFT|WALK_FLAG_RIGHT))!=0) {
|
||||||
|
// request left and right in the same time ... this is really bad ....
|
||||||
|
} else if ( (m_walk&WALK_FLAG_LEFT)!=0) {
|
||||||
|
|
||||||
|
} else if ( (m_walk&WALK_FLAG_RIGHT)!=0) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
double curentTime=(double)localTime/1000000.0;
|
double curentTime=(double)localTime/1000000.0;
|
||||||
// small hack to change speed ...
|
// small hack to change speed ...
|
||||||
if (m_ratioTime != 1) {
|
if (m_ratioTime != 1) {
|
||||||
@ -113,11 +158,12 @@ void widget::Scene::GenDraw(ewol::DrawProperty displayProp)
|
|||||||
m_size.y);
|
m_size.y);
|
||||||
float ratio = m_size.x / m_size.y;
|
float ratio = m_size.x / m_size.y;
|
||||||
//EWOL_INFO("ratio : " << ratio);
|
//EWOL_INFO("ratio : " << ratio);
|
||||||
mat4 tmpProjection = etk::matPerspective( M_PI/2.0, ratio, -1, 1);
|
mat4 tmpProjection = etk::matPerspective( M_PI/2.0, ratio, 1, 4000);
|
||||||
|
ewol::openGL::SetCameraMatrix(m_camera.GetMatrix());
|
||||||
mat4 tmpMat = tmpProjection * m_camera.GetMatrix();
|
//mat4 tmpMat = tmpProjection * m_camera.GetMatrix();
|
||||||
// set internal matrix system :
|
// set internal matrix system :
|
||||||
ewol::openGL::SetMatrix(tmpMat);
|
//ewol::openGL::SetMatrix(tmpMat);
|
||||||
|
ewol::openGL::SetMatrix(tmpProjection);
|
||||||
|
|
||||||
// Call the widget drawing methode
|
// Call the widget drawing methode
|
||||||
displayProp.m_origin = m_origin;
|
displayProp.m_origin = m_origin;
|
||||||
@ -164,7 +210,7 @@ bool widget::Scene::OnEventInput(ewol::keyEvent::type_te type, int32_t IdInput,
|
|||||||
{
|
{
|
||||||
vec2 relativePos = RelativePosition(pos);
|
vec2 relativePos = RelativePosition(pos);
|
||||||
//EWOL_DEBUG("type : " << type << " IdInput=" << IdInput << " " << "status=" << statusEvent << " RelPos=" << relativePos);
|
//EWOL_DEBUG("type : " << type << " IdInput=" << IdInput << " " << "status=" << statusEvent << " RelPos=" << relativePos);
|
||||||
|
KeepFocus();
|
||||||
if (type == ewol::keyEvent::typeMouse) {
|
if (type == ewol::keyEvent::typeMouse) {
|
||||||
if (4 == IdInput && ewol::keyEvent::statusUp == statusEvent) {
|
if (4 == IdInput && ewol::keyEvent::statusUp == statusEvent) {
|
||||||
vec3 oldPos = m_camera.GetPosition();
|
vec3 oldPos = m_camera.GetPosition();
|
||||||
@ -183,8 +229,8 @@ bool widget::Scene::OnEventInput(ewol::keyEvent::type_te type, int32_t IdInput,
|
|||||||
} else if (modeMoving==1 && ewol::keyEvent::statusMove == statusEvent) {
|
} else if (modeMoving==1 && ewol::keyEvent::statusMove == statusEvent) {
|
||||||
vec2 offset = relativePos - oldCursorPos;
|
vec2 offset = relativePos - oldCursorPos;
|
||||||
vec3 oldPos = m_camera.GetPosition();
|
vec3 oldPos = m_camera.GetPosition();
|
||||||
oldPos.x -= offset.x/50.0;
|
oldPos.x += offset.x/50.0;
|
||||||
oldPos.y -= offset.y/50.0;
|
oldPos.y += offset.y/50.0;
|
||||||
m_camera.SetPosition(oldPos);
|
m_camera.SetPosition(oldPos);
|
||||||
oldCursorPos = relativePos;
|
oldCursorPos = relativePos;
|
||||||
}
|
}
|
||||||
@ -198,8 +244,8 @@ bool widget::Scene::OnEventInput(ewol::keyEvent::type_te type, int32_t IdInput,
|
|||||||
vec2 offset = relativePos - oldCursorPos;
|
vec2 offset = relativePos - oldCursorPos;
|
||||||
offset *= M_PI/(360.0f*6);
|
offset *= M_PI/(360.0f*6);
|
||||||
vec3 oldAngles = m_camera.GetAngle();
|
vec3 oldAngles = m_camera.GetAngle();
|
||||||
oldAngles.x -= offset.y;
|
oldAngles.z -= offset.x;
|
||||||
oldAngles.y += offset.x;
|
oldAngles.y += offset.y;
|
||||||
m_camera.SetAngle(oldAngles);
|
m_camera.SetAngle(oldAngles);
|
||||||
oldCursorPos = relativePos;
|
oldCursorPos = relativePos;
|
||||||
}
|
}
|
||||||
@ -221,18 +267,99 @@ bool widget::Scene::OnEventKb(ewol::keyEvent::status_te statusEvent, uniChar_t u
|
|||||||
|
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
if( unicodeData == 'z'
|
||||||
|
|| unicodeData == 'Z') {
|
||||||
|
if (statusEvent == ewol::keyEvent::statusDown) {
|
||||||
|
m_walk |= WALK_FLAG_FORWARD;
|
||||||
|
}
|
||||||
|
if (statusEvent == ewol::keyEvent::statusUp) {
|
||||||
|
if ((m_walk&WALK_FLAG_FORWARD) != 0) {
|
||||||
|
m_walk -= WALK_FLAG_FORWARD;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if( unicodeData == 's'
|
||||||
|
|| unicodeData == 'S') {
|
||||||
|
if (statusEvent == ewol::keyEvent::statusDown) {
|
||||||
|
m_walk |= WALK_FLAG_BACK;
|
||||||
|
}
|
||||||
|
if (statusEvent == ewol::keyEvent::statusUp) {
|
||||||
|
if ((m_walk&WALK_FLAG_BACK) != 0) {
|
||||||
|
m_walk -= WALK_FLAG_BACK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if( unicodeData == 'q'
|
||||||
|
|| unicodeData == 'Q') {
|
||||||
|
if (statusEvent == ewol::keyEvent::statusDown) {
|
||||||
|
m_walk |= WALK_FLAG_LEFT;
|
||||||
|
}
|
||||||
|
if (statusEvent == ewol::keyEvent::statusUp) {
|
||||||
|
if ((m_walk&WALK_FLAG_LEFT) != 0) {
|
||||||
|
m_walk -= WALK_FLAG_LEFT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if( unicodeData == 'd'
|
||||||
|
|| unicodeData == 'D') {
|
||||||
|
if (statusEvent == ewol::keyEvent::statusDown) {
|
||||||
|
m_walk |= WALK_FLAG_RIGHT;
|
||||||
|
}
|
||||||
|
if (statusEvent == ewol::keyEvent::statusUp) {
|
||||||
|
if ((m_walk&WALK_FLAG_RIGHT) != 0) {
|
||||||
|
m_walk -= WALK_FLAG_RIGHT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
EWOL_DEBUG("m_walk=" << m_walk);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool widget::Scene::OnEventKbMove(ewol::keyEvent::status_te statusEvent, ewol::keyEvent::keyboard_te specialKey)
|
bool widget::Scene::OnEventKbMove(ewol::keyEvent::status_te statusEvent, ewol::keyEvent::keyboard_te specialKey)
|
||||||
{
|
{
|
||||||
/*
|
if (specialKey == ewol::keyEvent::keyboardUp) {
|
||||||
if (statusEvent == ewol::ewol::keyEvent::statusDown) {
|
EWOL_DEBUG("test ..." << specialKey << " " << statusEvent);
|
||||||
MarkToRedraw();
|
if (statusEvent == ewol::keyEvent::statusDown) {
|
||||||
|
m_walk |= WALK_FLAG_FORWARD;
|
||||||
|
}
|
||||||
|
if (statusEvent == ewol::keyEvent::statusUp) {
|
||||||
|
if ((m_walk&WALK_FLAG_FORWARD) != 0) {
|
||||||
|
m_walk -= WALK_FLAG_FORWARD;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true;
|
if (specialKey == ewol::keyEvent::keyboardDown) {
|
||||||
*/
|
if (statusEvent == ewol::keyEvent::statusDown) {
|
||||||
|
m_walk |= WALK_FLAG_BACK;
|
||||||
|
}
|
||||||
|
if (statusEvent == ewol::keyEvent::statusUp) {
|
||||||
|
if ((m_walk&WALK_FLAG_BACK) != 0) {
|
||||||
|
m_walk -= WALK_FLAG_BACK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (specialKey == ewol::keyEvent::keyboardLeft) {
|
||||||
|
if (statusEvent == ewol::keyEvent::statusDown) {
|
||||||
|
m_walk |= WALK_FLAG_LEFT;
|
||||||
|
}
|
||||||
|
if (statusEvent == ewol::keyEvent::statusUp) {
|
||||||
|
if ((m_walk&WALK_FLAG_LEFT) != 0) {
|
||||||
|
m_walk -= WALK_FLAG_LEFT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (specialKey == ewol::keyEvent::keyboardRight) {
|
||||||
|
if (statusEvent == ewol::keyEvent::statusDown) {
|
||||||
|
m_walk |= WALK_FLAG_RIGHT;
|
||||||
|
}
|
||||||
|
if (statusEvent == ewol::keyEvent::statusUp) {
|
||||||
|
if ((m_walk&WALK_FLAG_RIGHT) != 0) {
|
||||||
|
m_walk -= WALK_FLAG_RIGHT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
EWOL_DEBUG("m_walk=" << m_walk);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,6 +28,7 @@ namespace widget {
|
|||||||
bool m_isRunning; //!< the display is running (not in pause)
|
bool m_isRunning; //!< the display is running (not in pause)
|
||||||
double m_lastCallTime; //!< previous call Time
|
double m_lastCallTime; //!< previous call Time
|
||||||
float m_ratioTime; //!< Ratio time for the speed of the game ...
|
float m_ratioTime; //!< Ratio time for the speed of the game ...
|
||||||
|
uint32_t m_walk; //!< Wolk properties
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief Main scene constructor
|
* @brief Main scene constructor
|
||||||
|
@ -32,12 +32,13 @@ static const char * l_eventAddSphere = "event-add-sphere";
|
|||||||
static const char * l_eventRotationX = "event-rotation-X";
|
static const char * l_eventRotationX = "event-rotation-X";
|
||||||
static const char * l_eventRotationY = "event-rotation-Y";
|
static const char * l_eventRotationY = "event-rotation-Y";
|
||||||
static const char * l_eventRotationZ = "event-rotation-Z";
|
static const char * l_eventRotationZ = "event-rotation-Z";
|
||||||
|
static const char * l_eventRotation0 = "event-rotation-0";
|
||||||
static const char * l_eventLunch = "event-lunch";
|
static const char * l_eventLunch = "event-lunch";
|
||||||
static const char * l_eventChangeTimeSpeed2 = "event-speed2";
|
static const char * l_eventChangeTimeSpeed2 = "event-speed2";
|
||||||
static const char * l_eventChangeTimeSpeed0 = "event-speed0.5";
|
static const char * l_eventChangeTimeSpeed0 = "event-speed0.5";
|
||||||
static const char * l_eventChangeTimeSpeed1 = "event-speed1";
|
static const char * l_eventChangeTimeSpeed1 = "event-speed1";
|
||||||
|
static const char * l_eventUp = "event-up";
|
||||||
|
static const char * l_eventDown = "event-down";
|
||||||
|
|
||||||
|
|
||||||
#undef __class__
|
#undef __class__
|
||||||
@ -45,6 +46,9 @@ static const char * l_eventChangeTimeSpeed1 = "event-speed1";
|
|||||||
|
|
||||||
TestScene::TestScene(void)
|
TestScene::TestScene(void)
|
||||||
{
|
{
|
||||||
|
m_ground = new game::Element("DATA:grass.obj");
|
||||||
|
m_gameEngine.AddElement(m_ground, true);
|
||||||
|
|
||||||
APPL_CRITICAL("Create "__class__" (start)");
|
APPL_CRITICAL("Create "__class__" (start)");
|
||||||
widget::SizerVert* mySizerVert2 = NULL;
|
widget::SizerVert* mySizerVert2 = NULL;
|
||||||
widget::SizerHori* mySizerHori = NULL;
|
widget::SizerHori* mySizerHori = NULL;
|
||||||
@ -81,6 +85,27 @@ TestScene::TestScene(void)
|
|||||||
myButton->RegisterOnEvent(this, ewolEventButtonPressed, l_eventRotationZ);
|
myButton->RegisterOnEvent(this, ewolEventButtonPressed, l_eventRotationZ);
|
||||||
mySizerHori->SubWidgetAdd(myButton);
|
mySizerHori->SubWidgetAdd(myButton);
|
||||||
}
|
}
|
||||||
|
myButton = new widget::Button("Rotation -");
|
||||||
|
if (NULL != myButton) {
|
||||||
|
myButton->RegisterOnEvent(this, ewolEventButtonPressed, l_eventRotation0);
|
||||||
|
mySizerHori->SubWidgetAdd(myButton);
|
||||||
|
}
|
||||||
|
myButton = new widget::Button("UP");
|
||||||
|
if (NULL != myButton) {
|
||||||
|
myButton->RegisterOnEvent(this, ewolEventButtonPressed, l_eventUp);
|
||||||
|
mySizerHori->SubWidgetAdd(myButton);
|
||||||
|
}
|
||||||
|
myButton = new widget::Button("DOWN");
|
||||||
|
if (NULL != myButton) {
|
||||||
|
myButton->RegisterOnEvent(this, ewolEventButtonPressed, l_eventDown);
|
||||||
|
mySizerHori->SubWidgetAdd(myButton);
|
||||||
|
}
|
||||||
|
mySizerHori = new widget::SizerHori();
|
||||||
|
if (NULL == mySizerHori) {
|
||||||
|
APPL_DEBUG("Allocation error mySizerHori");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
SubWidgetAdd(mySizerHori);
|
||||||
myButton = new widget::Button("lunch object");
|
myButton = new widget::Button("lunch object");
|
||||||
if (NULL != myButton) {
|
if (NULL != myButton) {
|
||||||
myButton->RegisterOnEvent(this, ewolEventButtonPressed, l_eventLunch);
|
myButton->RegisterOnEvent(this, ewolEventButtonPressed, l_eventLunch);
|
||||||
@ -179,6 +204,7 @@ TestScene::~TestScene(void)
|
|||||||
#include <ewol/game/Element.h>
|
#include <ewol/game/Element.h>
|
||||||
|
|
||||||
vec3 baseRotationVect;
|
vec3 baseRotationVect;
|
||||||
|
vec3 baseMove;
|
||||||
class stupidCube : public game::Element
|
class stupidCube : public game::Element
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -194,6 +220,10 @@ class stupidCube : public game::Element
|
|||||||
if (baseRotationVect != vec3(0,0,0) ) {
|
if (baseRotationVect != vec3(0,0,0) ) {
|
||||||
Rotate(baseRotationVect, 0.01);
|
Rotate(baseRotationVect, 0.01);
|
||||||
}
|
}
|
||||||
|
if (baseMove != vec3(0,0,0) ) {
|
||||||
|
Translate(baseMove);
|
||||||
|
baseMove = vec3(0,0,0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -219,7 +249,9 @@ void TestScene::OnReceiveMessage(ewol::EObject * CallerObject, const char * even
|
|||||||
stupidCube * tmpp = new stupidCube();
|
stupidCube * tmpp = new stupidCube();
|
||||||
static bool firstTime = true;
|
static bool firstTime = true;
|
||||||
if (firstTime==false) {
|
if (firstTime==false) {
|
||||||
tmpp->Translate(vec3(etk::tool::frand(-1,1),etk::tool::frand(-1,1),etk::tool::frand(-1,1)));
|
vec3 newPos = vec3(etk::tool::frand(-20,20),etk::tool::frand(-20,20),etk::tool::frand(1,8));
|
||||||
|
APPL_DEBUG("add a box at the pos : " << newPos);
|
||||||
|
tmpp->Translate(newPos);
|
||||||
}
|
}
|
||||||
firstTime = false;
|
firstTime = false;
|
||||||
m_gameEngine.AddElement(tmpp, true);
|
m_gameEngine.AddElement(tmpp, true);
|
||||||
@ -227,15 +259,21 @@ void TestScene::OnReceiveMessage(ewol::EObject * CallerObject, const char * even
|
|||||||
if (NULL!=m_testWidget) {
|
if (NULL!=m_testWidget) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
} else if (eventId == l_eventUp) {
|
||||||
|
baseMove = vec3(0.1,0,0);
|
||||||
|
} else if (eventId == l_eventDown) {
|
||||||
|
baseMove = vec3(-0.1,0,0);
|
||||||
} else if (eventId == l_eventRotationX) {
|
} else if (eventId == l_eventRotationX) {
|
||||||
baseRotationVect = vec3(1,0,0);
|
baseRotationVect = vec3(1,0,0);
|
||||||
} else if (eventId == l_eventRotationY) {
|
} else if (eventId == l_eventRotationY) {
|
||||||
baseRotationVect = vec3(0,1,0);
|
baseRotationVect = vec3(0,1,0);
|
||||||
} else if (eventId == l_eventRotationZ) {
|
} else if (eventId == l_eventRotationZ) {
|
||||||
baseRotationVect = vec3(0,0,1);
|
baseRotationVect = vec3(0,0,1);
|
||||||
|
} else if (eventId == l_eventRotation0) {
|
||||||
|
baseRotationVect = vec3(0,0,0);
|
||||||
} else if (eventId == l_eventLunch) {
|
} else if (eventId == l_eventLunch) {
|
||||||
stupidCube * tmpp = new stupidCube(250);
|
stupidCube * tmpp = new stupidCube(250);
|
||||||
tmpp->SetSpeed(vec3(10,50,0));
|
tmpp->SetSpeed(vec3(10,10,50));
|
||||||
m_gameEngine.AddElement(tmpp, true);
|
m_gameEngine.AddElement(tmpp, true);
|
||||||
} else if (eventId == l_eventChangeTimeSpeed1) {
|
} else if (eventId == l_eventChangeTimeSpeed1) {
|
||||||
if (NULL!=m_testWidget) {
|
if (NULL!=m_testWidget) {
|
||||||
|
@ -18,6 +18,8 @@
|
|||||||
class TestScene : public widget::SizerVert
|
class TestScene : public widget::SizerVert
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
game::Element* m_ground;
|
||||||
|
//game::Element m_sky;
|
||||||
game::Engine m_gameEngine;
|
game::Engine m_gameEngine;
|
||||||
widget::Scene* m_testWidget;
|
widget::Scene* m_testWidget;
|
||||||
public:
|
public:
|
||||||
|
@ -52,7 +52,7 @@ void APP_Init(void)
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
etk::InitDefaultFolder(PROJECT_NAME);
|
etk::InitDefaultFolder(PROJECT_NAME);
|
||||||
ewol::ChangeSize(ivec2(800, 600));
|
ewol::ChangeSize(ivec2(800, 300));
|
||||||
#ifdef __TARGET_OS__Android
|
#ifdef __TARGET_OS__Android
|
||||||
ewol::config::FontSetDefault("FreeSerif", 19);
|
ewol::config::FontSetDefault("FreeSerif", 19);
|
||||||
#else
|
#else
|
||||||
|
18
test/human/data/grass.obj
Normal file
18
test/human/data/grass.obj
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
# done myself
|
||||||
|
v 100.0 -100.0 0.0
|
||||||
|
v 100.0 100.0 0.0
|
||||||
|
v -100.0 100.0 0.0
|
||||||
|
v -100.0 -100.0 0.0
|
||||||
|
|
||||||
|
vt 0.0 0.0
|
||||||
|
vt 100.0 0.0
|
||||||
|
vt 100.0 100.0
|
||||||
|
vt 0.0 100.0
|
||||||
|
|
||||||
|
vn 0.000000 0.000000 1.000000
|
||||||
|
|
||||||
|
usemtl grass.png
|
||||||
|
|
||||||
|
f 1/1/1 2/2/1 3/3/1
|
||||||
|
f 1/1/1 3/3/1 4/4/1
|
||||||
|
|
BIN
test/human/data/grass.png
Normal file
BIN
test/human/data/grass.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 532 B |
@ -15,4 +15,5 @@ FILE_LIST:= appl/Debug.cpp \
|
|||||||
|
|
||||||
LOCAL_COPY_FOLDERS := data/icon.*:theme/default \
|
LOCAL_COPY_FOLDERS := data/icon.*:theme/default \
|
||||||
data/cube.*: \
|
data/cube.*: \
|
||||||
|
data/grass.*: \
|
||||||
data/stone*: \
|
data/stone*: \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user