[DEV] Start dev of the physic engine

This commit is contained in:
Edouard DUPIN 2012-12-13 22:50:30 +01:00
parent 28a044fb00
commit b6d11d78e2
8 changed files with 32 additions and 34 deletions

2
external/etk vendored

@ -1 +1 @@
Subproject commit 74a6e35fa3de3bc5b2b0dc89992e6610db2014c2 Subproject commit e6af555b152d01a561526bc8c5515338cec464fe

View File

@ -33,19 +33,19 @@ void ewol::Compositing::ResetMatrix(void)
void ewol::Compositing::Translate(vec3 vect) void ewol::Compositing::Translate(vec3 vect)
{ {
m_matrixApply *= mat4::Translate(vect); m_matrixApply *= etk::matTranslate(vect);
} }
void ewol::Compositing::Rotate(vec3 vect, float angle) void ewol::Compositing::Rotate(vec3 vect, float angle)
{ {
m_matrixApply *= mat4::Rotate(vect, angle); m_matrixApply *= etk::matRotate(vect, angle);
} }
void ewol::Compositing::Scale(vec3 vect) void ewol::Compositing::Scale(vec3 vect)
{ {
m_matrixApply *= mat4::Scale(vect); m_matrixApply *= etk::matScale(vect);
} }

View File

@ -45,7 +45,7 @@ void ewol::Mesh::Draw(void)
rotx += 0.01; rotx += 0.01;
roty += 0.02; roty += 0.02;
rotz += 0.005; rotz += 0.005;
if (m_vertices.Size()<=0) { if (m_object.m_vertices.Size()<=0) {
return; return;
} }
if (NULL == m_texture1) { if (NULL == m_texture1) {
@ -61,23 +61,23 @@ void ewol::Mesh::Draw(void)
m_GLprogram->Use(); m_GLprogram->Use();
// set Matrix : translation/positionMatrix // set Matrix : translation/positionMatrix
mat4 tmpMatrix = ewol::openGL::GetMatrix(); mat4 tmpMatrix = ewol::openGL::GetMatrix();
tmpMatrix = mat4::Scale(vec3(100,100,100) ) tmpMatrix = etk::matScale(vec3(100,100,100) )
* mat4::Rotate(vec3(1,0,0), rotx) * etk::matRotate(vec3(1,0,0), rotx)
* mat4::Rotate(vec3(0,1,0), roty)/* * etk::matRotate(vec3(0,1,0), roty)/*
* mat4::Translate(vec3(0.01,0.0,0.0)) * etk::matTranslate(vec3(0.01,0.0,0.0))
* mat4::Rotate(vec3(0,0,1), rotz)*/ * etk::matRotate(vec3(0,0,1), rotz)*/
* tmpMatrix; * tmpMatrix;
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());
// position : // position :
m_GLprogram->SendAttribute(m_GLPosition, 3/*x,y,z*/, &m_vertices[0]); m_GLprogram->SendAttribute(m_GLPosition, 3/*x,y,z*/, &m_object.m_vertices[0]);
// Texture : // Texture :
m_GLprogram->SendAttribute(m_GLtexture, 2/*u,v*/, &m_uvTextures[0]); m_GLprogram->SendAttribute(m_GLtexture, 2/*u,v*/, &m_object.m_uvTextures[0]);
// color : // color :
m_GLprogram->SendAttribute(m_GLColor, 4/*r,g,b,a*/, &m_coordColor[0]); m_GLprogram->SendAttribute(m_GLColor, 4/*r,g,b,a*/, &m_coordColor[0]);
// Request the draw od the elements : // Request the draw od the elements :
glDrawArrays(GL_TRIANGLES, 0, m_vertices.Size()); glDrawArrays(GL_TRIANGLES, 0, m_object.m_vertices.Size());
m_GLprogram->UnUse(); m_GLprogram->UnUse();
glDisable(GL_DEPTH_TEST); glDisable(GL_DEPTH_TEST);
} }

View File

@ -14,6 +14,7 @@
#include <ewol/renderer/resources/Image.h> #include <ewol/renderer/resources/Image.h>
#include <ewol/renderer/resources/Shader.h> #include <ewol/renderer/resources/Shader.h>
#include <ewol/renderer/resources/Program.h> #include <ewol/renderer/resources/Program.h>
#include <ePhysics/MeshObject.h>
namespace ewol namespace ewol
{ {
@ -26,10 +27,7 @@ namespace ewol
int32_t m_GLColor; int32_t m_GLColor;
int32_t m_GLtexture; int32_t m_GLtexture;
int32_t m_GLtexID; int32_t m_GLtexID;
etk::Vector<uint32_t> m_indices; ephysics::MeshObject m_object;
etk::Vector< vec3 > m_vertices;
etk::Vector< vec2 > m_uvTextures;
etk::Vector< vec3 > m_normals;
ewol::TextureFile* m_texture1; ewol::TextureFile* m_texture1;
etk::Vector<draw::Colorf> m_coordColor; //!< internal color of the different point etk::Vector<draw::Colorf> m_coordColor; //!< internal color of the different point
public: public:

View File

@ -128,9 +128,9 @@ ewol::MeshObj::MeshObj(etk::UString _fileName) :
uint32_t normalIndex = indicesNormal[iii]; uint32_t normalIndex = indicesNormal[iii];
// Put the attributes in buffers // Put the attributes in buffers
m_vertices.PushBack(vertices[vertexIndex-1]); m_object.m_vertices.PushBack(vertices[vertexIndex-1]);
m_uvTextures.PushBack(uvTextures[uvIndex-1]); m_object.m_uvTextures.PushBack(uvTextures[uvIndex-1]);
m_normals.PushBack(normals[normalIndex-1]); m_object.m_normals.PushBack(normals[normalIndex-1]);
draw::Color tmpppp(0xFFFFFFFF); draw::Color tmpppp(0xFFFFFFFF);
draw::Colorf tmppppp(tmpppp); draw::Colorf tmppppp(tmpppp);
m_coordColor.PushBack(tmppppp); m_coordColor.PushBack(tmppppp);

View File

@ -153,12 +153,12 @@ void widget::Scene::GenDraw(ewol::DrawProperty displayProp)
mat4 tmpProjection; mat4 tmpProjection;
if (ratio >= 1.0) { if (ratio >= 1.0) {
tmpProjection = etk::Matrix4::Perspective(-ratio, ratio, -1, 1, -1, 1); tmpProjection = etk::matPerspective(-ratio, ratio, -1, 1, -1, 1);
} else { } else {
ratio = 1.0/ratio; ratio = 1.0/ratio;
tmpProjection = etk::Matrix4::Perspective(-1, 1, -ratio, ratio, -1, 1); tmpProjection = etk::matPerspective(-1, 1, -ratio, ratio, -1, 1);
} }
mat4 tmpScale = etk::Matrix4::Scale(vec3(m_zoom, m_zoom, m_zoom) ); mat4 tmpScale = etk::matScale(vec3(m_zoom, m_zoom, m_zoom) );
mat4 tmpMat = tmpProjection * tmpScale; mat4 tmpMat = tmpProjection * tmpScale;
// set internal matrix system : // set internal matrix system :
ewol::openGL::SetMatrix(tmpMat); ewol::openGL::SetMatrix(tmpMat);

View File

@ -137,9 +137,9 @@ void ewol::Widget::GenDraw(DrawProperty displayProp)
tmpOriginY, tmpOriginY,
tmpclipX, tmpclipX,
m_size.y); m_size.y);
mat4 tmpTranslate = etk::Matrix4::Translate(vec3((float)(-tmpclipX/2 - (tmpOriginX-m_origin.x)), (float)(-m_size.y/2.0), -1.0f)); mat4 tmpTranslate = etk::matTranslate(vec3((float)(-tmpclipX/2 - (tmpOriginX-m_origin.x)), (float)(-m_size.y/2.0), -1.0f));
mat4 tmpScale = etk::Matrix4::Scale(vec3(m_zoom, m_zoom, 1.0f)); mat4 tmpScale = etk::matScale(vec3(m_zoom, m_zoom, 1.0f));
mat4 tmpProjection = etk::Matrix4::Perspective(-tmpclipX/2, tmpclipX/2, -m_size.y/2, m_size.y/2, -1, 1); mat4 tmpProjection = etk::matPerspective(-tmpclipX/2, tmpclipX/2, -m_size.y/2, m_size.y/2, -1, 1);
mat4 tmpMat = tmpProjection * tmpScale * tmpTranslate; mat4 tmpMat = tmpProjection * tmpScale * tmpTranslate;
// set internal matrix system : // set internal matrix system :
ewol::openGL::SetMatrix(tmpMat); ewol::openGL::SetMatrix(tmpMat);
@ -154,9 +154,9 @@ void ewol::Widget::GenDraw(DrawProperty displayProp)
m_origin.y, m_origin.y,
m_size.x, m_size.x,
m_size.y); m_size.y);
mat4 tmpTranslate = etk::Matrix4::Translate(vec3(-m_size.x/2, -m_size.y/2, -1.0f)); mat4 tmpTranslate = etk::matTranslate(vec3(-m_size.x/2, -m_size.y/2, -1.0f));
mat4 tmpScale = etk::Matrix4::Scale(vec3(m_zoom, m_zoom, 1.0f)); mat4 tmpScale = etk::matScale(vec3(m_zoom, m_zoom, 1.0f));
mat4 tmpProjection = etk::Matrix4::Perspective(-m_size.x/2, m_size.x/2, -m_size.y/2, m_size.y/2, -1, 1); mat4 tmpProjection = etk::matPerspective(-m_size.x/2, m_size.x/2, -m_size.y/2, m_size.y/2, -1, 1);
mat4 tmpMat = tmpProjection * tmpScale * tmpTranslate; mat4 tmpMat = tmpProjection * tmpScale * tmpTranslate;
// set internal matrix system : // set internal matrix system :
ewol::openGL::SetMatrix(tmpMat); ewol::openGL::SetMatrix(tmpMat);

View File

@ -351,9 +351,9 @@ void widget::WidgetScrooled::GenDraw(ewol::DrawProperty displayProp)
m_origin.y, m_origin.y,
m_size.x, m_size.x,
m_size.y); m_size.y);
mat4 tmpProjection = etk::Matrix4::Perspective(-m_size.x/2, m_size.x/2, -m_size.y/2, m_size.y/2, -1, 1); mat4 tmpProjection = etk::matPerspective(-m_size.x/2, m_size.x/2, -m_size.y/2, m_size.y/2, -1, 1);
mat4 tmpScale = etk::Matrix4::Scale(vec3(m_zoom, m_zoom, 1.0) ); mat4 tmpScale = etk::matScale(vec3(m_zoom, m_zoom, 1.0) );
mat4 tmpTranslate = etk::Matrix4::Translate(vec3(-m_maxSize.x/2, -m_maxSize.y/2, -1.0) ); mat4 tmpTranslate = etk::matTranslate(vec3(-m_maxSize.x/2, -m_maxSize.y/2, -1.0) );
mat4 tmpMat = tmpProjection * tmpScale * tmpTranslate; mat4 tmpMat = tmpProjection * tmpScale * tmpTranslate;
// set internal matrix system : // set internal matrix system :
ewol::openGL::SetMatrix(tmpMat); ewol::openGL::SetMatrix(tmpMat);
@ -366,8 +366,8 @@ void widget::WidgetScrooled::GenDraw(ewol::DrawProperty displayProp)
m_size.x, m_size.x,
m_size.y); m_size.y);
mat4 tmpProjection = etk::Matrix4::Perspective(-m_size.x/2, m_size.x/2, -m_size.y/2, m_size.y/2, -1, 1); mat4 tmpProjection = etk::matPerspective(-m_size.x/2, m_size.x/2, -m_size.y/2, m_size.y/2, -1, 1);
mat4 tmpTranslate = etk::Matrix4::Translate(vec3( -m_maxSize.x/2, -m_maxSize.y/2, -1.0) ); mat4 tmpTranslate = etk::matTranslate(vec3( -m_maxSize.x/2, -m_maxSize.y/2, -1.0) );
mat4 tmpMat = tmpProjection * tmpTranslate; mat4 tmpMat = tmpProjection * tmpTranslate;
// set internal matrix system : // set internal matrix system :
ewol::openGL::SetMatrix(tmpMat); ewol::openGL::SetMatrix(tmpMat);