diff options
Diffstat (limited to 'src')
32 files changed, 345 insertions, 198 deletions
diff --git a/src/libjin/Game/je_game.cpp b/src/libjin/Game/je_game.cpp index 6eb1d3f..7562831 100644 --- a/src/libjin/Game/je_game.cpp +++ b/src/libjin/Game/je_game.cpp @@ -12,7 +12,7 @@ namespace JinEngine { - namespace Core + namespace Game { using namespace JinEngine::Graphics; diff --git a/src/libjin/Game/je_game.h b/src/libjin/Game/je_game.h index 78c3385..2ccc428 100644 --- a/src/libjin/Game/je_game.h +++ b/src/libjin/Game/je_game.h @@ -12,7 +12,7 @@ namespace JinEngine { - namespace Core + namespace Game { /// diff --git a/src/libjin/Graphics/Font/je_texture_font.cpp b/src/libjin/Graphics/Font/je_texture_font.cpp index 30a927c..5834140 100644 --- a/src/libjin/Graphics/Font/je_texture_font.cpp +++ b/src/libjin/Graphics/Font/je_texture_font.cpp @@ -90,9 +90,9 @@ namespace JinEngine } glyph = findGlyph(c); if (glyph == nullptr) continue; - if (texture != mTexture) + if (texture != getGLTexture()) { - texture = mTexture; + texture = getGLTexture(); GlyphArrayDrawInfo info; info.start = i; info.count = 0; @@ -246,7 +246,7 @@ namespace JinEngine } TextureFont::TextureFont(const Bitmap* bitmap, const Content& codepoints, int cellw, int cellh) - : Graphic(bitmap) + : GraphicSingle(bitmap) , Font(cellh) { TextureGlyph glyph; @@ -265,9 +265,9 @@ namespace JinEngine } } } - + TextureFont::TextureFont(const Bitmap* bitmap, const Content& codepoints, Color mask, int cellh) - : Graphic(bitmap) + : GraphicSingle(bitmap) , Font(cellh) { TextureGlyph glyph; diff --git a/src/libjin/Graphics/Font/je_texture_font.h b/src/libjin/Graphics/Font/je_texture_font.h index 0cafff1..5b08747 100644 --- a/src/libjin/Graphics/Font/je_texture_font.h +++ b/src/libjin/Graphics/Font/je_texture_font.h @@ -6,7 +6,7 @@ #include "../../math/je_vector4.hpp" -#include "../je_graphic.h" +#include "../je_graphic_single.h" #include "../je_bitmap.h" #include "je_page.h" @@ -21,8 +21,7 @@ namespace JinEngine /// /// /// - class TextureFont : public Font - , public Graphic + class TextureFont : public Font , public GraphicSingle { public: diff --git a/src/libjin/Graphics/Shader/je_shader.cpp b/src/libjin/Graphics/Shader/je_shader.cpp index b0e7506..e6f82a4 100644 --- a/src/libjin/Graphics/Shader/je_shader.cpp +++ b/src/libjin/Graphics/Shader/je_shader.cpp @@ -196,7 +196,7 @@ if (success == GL_FALSE) \ } gl.activeTexUnit(unit); glUniform1i(location, unit); - gl.bindTexture(tex->getTexture()); + gl.bindTexture(tex->getGLTexture()); gl.activeTexUnit(0); } @@ -214,7 +214,7 @@ if (success == GL_FALSE) \ } glUniform1i(location, unit); glActiveTexture(GL_TEXTURE0 + unit); - gl.bindTexture(canvas->getTexture()); + gl.bindTexture(canvas->getGLTexture()); glActiveTexture(GL_TEXTURE0); } diff --git a/src/libjin/Graphics/Shader/je_default.shader.h b/src/libjin/Graphics/Shader/shaders/je_default.shader.h index 3f57c44..3f57c44 100644 --- a/src/libjin/Graphics/Shader/je_default.shader.h +++ b/src/libjin/Graphics/Shader/shaders/je_default.shader.h diff --git a/src/libjin/Graphics/Shader/je_font.shader.h b/src/libjin/Graphics/Shader/shaders/je_font.shader.h index e04c225..e04c225 100644 --- a/src/libjin/Graphics/Shader/je_font.shader.h +++ b/src/libjin/Graphics/Shader/shaders/je_font.shader.h diff --git a/src/libjin/Graphics/Shader/je_texture.shader.h b/src/libjin/Graphics/Shader/shaders/je_texture.shader.h index d1fc86f..d1fc86f 100644 --- a/src/libjin/Graphics/Shader/je_texture.shader.h +++ b/src/libjin/Graphics/Shader/shaders/je_texture.shader.h diff --git a/src/libjin/Graphics/animation/je_animation.h b/src/libjin/Graphics/animation/je_animation.h index ca5758f..aa4c93f 100644 --- a/src/libjin/Graphics/animation/je_animation.h +++ b/src/libjin/Graphics/animation/je_animation.h @@ -1,11 +1,10 @@ #ifndef __JE_ANIMATION_H #define __JE_ANIMATION_H -#include <map> #include <vector> #include <string> -#include "je_clip.h" +#include "../je_sprite.h" namespace JinEngine { @@ -13,32 +12,41 @@ namespace JinEngine { /// - /// + /// Animation clip with key. /// class Animation { public: - void addClip(const std::string& key, Clip* clip); - bool hasKey(const std::string& key); + void onUpdate(float dt); - void play(); - void switchClipByKey(const std::string& key); - void switchClip(const Clip* clip); + void start(); + void pause(); + void stop(); + void rewind(); + void setSpeed(float speed); /// - /// Control clips. + /// Get current frame index. /// - void stopClip(); - void pauseClip(); - void rewindClip(); - void startClip(); + uint getCurrentFrame(); + + /// + /// Set current frame index. + /// + /// @param frame Current frame to play. + /// + void setCurrentFrame(uint frame); private: /// - /// Map a key to clips. + /// Key frames. + /// + std::vector<Sprite*> mFrames; + + /// + /// Animation playing speed. /// - std::map<std::string, Clip*> mClips; - Clip* mCurrentClip; + float mSpeed; }; diff --git a/src/libjin/Graphics/animation/je_clip.cpp b/src/libjin/Graphics/animation/je_animator.cpp index e69de29..e69de29 100644 --- a/src/libjin/Graphics/animation/je_clip.cpp +++ b/src/libjin/Graphics/animation/je_animator.cpp diff --git a/src/libjin/Graphics/animation/je_animator.h b/src/libjin/Graphics/animation/je_animator.h new file mode 100644 index 0000000..973ff58 --- /dev/null +++ b/src/libjin/Graphics/animation/je_animator.h @@ -0,0 +1,48 @@ +#ifndef __JE_ANIMATOR_H +#define __JE_ANIMATOR_H + +#include <map> +#include <vector> +#include <string> + +#include "je_animation.h" + +namespace JinEngine +{ + namespace Graphics + { + + /// + /// + /// + class Animator + { + public: + void addAnimation(const std::string& key, Animation* clip); + bool hasKey(const std::string& key); + + void play(); + void switchAnimationByKey(const std::string& key); + void switchAnimation(const Animation* clip); + + /// + /// Control clips. + /// + void stopAnimation(); + void pauseAnimation(); + void rewindAnimation(); + void startAnimation(); + + private: + /// + /// Map a key to clips. + /// + std::map<std::string, Animation*> mAnimations; + Animation* mCurrentAnimation; + + }; + + } // namespace Graphics +} // namespace JinEngine + +#endif
\ No newline at end of file diff --git a/src/libjin/Graphics/animation/je_clip.h b/src/libjin/Graphics/animation/je_clip.h deleted file mode 100644 index 6b6b0df..0000000 --- a/src/libjin/Graphics/animation/je_clip.h +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef __JE_CLIP_H -#define __JE_CLIP_H - -#include <vector> -#include <string> - -#include "../je_sprite.h" - -namespace JinEngine -{ - namespace Graphics - { - - /// - /// Animation clip with key. - /// - class Clip - { - public: - void onUpdate(float dt); - - void start(); - void pause(); - void stop(); - void rewind(); - void setSpeed(float speed); - - private: - /// - /// Key frames. - /// - std::vector<Sprite*> mFrames; - - /// - /// Clip playing speed. - /// - float mSpeed; - - }; - - } // namespace Graphics -} // namespace JinEngine - -#endif
\ No newline at end of file diff --git a/src/libjin/Graphics/je_canvas.cpp b/src/libjin/Graphics/je_canvas.cpp index 7e0858b..417127d 100644 --- a/src/libjin/Graphics/je_canvas.cpp +++ b/src/libjin/Graphics/je_canvas.cpp @@ -18,13 +18,13 @@ namespace JinEngine return new Canvas(w, h); } - Canvas::Canvas(GLuint n) - : fbo(n) - { - } + Canvas::Canvas(GLuint n) + : fbo(n) + { + } Canvas::Canvas(int w, int h) - : Graphic(w, h) + : GraphicSingle(w, h) { GLint current_fbo; glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, ¤t_fbo); @@ -33,14 +33,13 @@ namespace JinEngine fbo = gl.genFrameBuffer(); gl.bindFrameBuffer(fbo); - // Generate texture save target - mTexture = gl.genTexture(); - gl.bindTexture(mTexture); + GLuint texture = getGLTexture(); + gl.bindTexture(texture); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); gl.texImage(GL_RGBA8, w, h, GL_RGBA, GL_UNSIGNED_BYTE, NULL); gl.bindTexture(0); - glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, mTexture, 0); + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0); GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER); diff --git a/src/libjin/Graphics/je_canvas.h b/src/libjin/Graphics/je_canvas.h index f39b0de..ddfd092 100644 --- a/src/libjin/Graphics/je_canvas.h +++ b/src/libjin/Graphics/je_canvas.h @@ -3,7 +3,7 @@ #include "../core/je_configuration.h" #if defined(jin_graphics) -#include "je_graphic.h" +#include "je_graphic_single.h" namespace JinEngine { @@ -14,7 +14,7 @@ namespace JinEngine /// /// A canvas is a rendering target. /// - class Canvas: public Graphic + class Canvas: public GraphicSingle { public: /// diff --git a/src/libjin/Graphics/je_graphic.cpp b/src/libjin/Graphics/je_graphic.cpp index cce0c74..86b6bf4 100644 --- a/src/libjin/Graphics/je_graphic.cpp +++ b/src/libjin/Graphics/je_graphic.cpp @@ -17,32 +17,14 @@ namespace JinEngine : mTexture(0) , mSize(w, h) { - mVertexCoords[0] = 0; mVertexCoords[1] = 0; - mVertexCoords[2] = 0; mVertexCoords[3] = h; - mVertexCoords[4] = w; mVertexCoords[5] = h; - mVertexCoords[6] = w; mVertexCoords[7] = 0; - - mTextureCoords[0] = 0; mTextureCoords[1] = 0; - mTextureCoords[2] = 0; mTextureCoords[3] = 1; - mTextureCoords[4] = 1; mTextureCoords[5] = 1; - mTextureCoords[6] = 1; mTextureCoords[7] = 0; + mTexture = gl.genTexture(); } Graphic::Graphic(const Bitmap* bitmap) : mTexture(0) { - uint32 w = mSize.w = bitmap->getWidth(); - uint32 h = mSize.h = bitmap->getHeight(); - - mVertexCoords[0] = 0; mVertexCoords[1] = 0; - mVertexCoords[2] = 0; mVertexCoords[3] = h; - mVertexCoords[4] = w; mVertexCoords[5] = h; - mVertexCoords[6] = w; mVertexCoords[7] = 0; - - mTextureCoords[0] = 0; mTextureCoords[1] = 0; - mTextureCoords[2] = 0; mTextureCoords[3] = 1; - mTextureCoords[4] = 1; mTextureCoords[5] = 1; - mTextureCoords[6] = 1; mTextureCoords[7] = 0; + mSize.w = bitmap->getWidth(); + mSize.h = bitmap->getHeight(); const Color* pixels = bitmap->getPixels(); @@ -50,7 +32,7 @@ namespace JinEngine gl.bindTexture(mTexture); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - gl.texImage(GL_RGBA8, w, h, GL_RGBA, GL_UNSIGNED_BYTE, pixels); + gl.texImage(GL_RGBA8, mSize.w, mSize.h, GL_RGBA, GL_UNSIGNED_BYTE, pixels); gl.bindTexture(0); } @@ -59,53 +41,6 @@ namespace JinEngine glDeleteTextures(1, &mTexture); } - void Graphic::render(int x, int y, float sx, float sy, float r, float ox, float oy) - { - gl.ModelMatrix.setTransformation(x, y, r, sx, sy, ox, oy); - - Shader* shader = Shader::getCurrentShader(); - shader->sendMatrix4(SHADER_MODEL_MATRIX, &gl.ModelMatrix); - shader->sendMatrix4(SHADER_PROJECTION_MATRIX, &gl.ProjectionMatrix); - shader->bindVertexPointer(2, GL_FLOAT, 0, mVertexCoords); - shader->bindUVPointer(2, GL_FLOAT, 0, mTextureCoords); - - gl.bindTexture(mTexture); - gl.drawArrays(GL_QUADS, 0, 4); - gl.bindTexture(0); - } - - void Graphic::render(const Math::Quad& slice, int x, int y, float sx, float sy, float r, float ax, float ay) - { - float vertCoords[8] = { - 0, 0, - 0, slice.h, - slice.w, slice.h, - slice.w, 0 - }; - float slx = slice.x / mSize.w; - float sly = slice.y / mSize.h; - float slw = slice.w / mSize.w; - float slh = slice.h / mSize.h; - float texCoords[8] = { - slx, sly, - slx, sly + slh, - slx + slw, sly + slh, - slx + slw, sly - }; - - gl.ModelMatrix.setTransformation(x, y, r, sx, sy, ax, ay); - - Shader* shader = Shader::getCurrentShader(); - shader->sendMatrix4(SHADER_MODEL_MATRIX, &gl.ModelMatrix); - shader->sendMatrix4(SHADER_PROJECTION_MATRIX, &gl.ProjectionMatrix); - shader->bindVertexPointer(2, GL_FLOAT, 0, vertCoords); - shader->bindUVPointer(2, GL_FLOAT, 0, texCoords); - - gl.bindTexture(mTexture); - gl.drawArrays(GL_QUADS, 0, 4); - gl.bindTexture(0); - } - //void Graphic::setFilter(GLint min, GLint max) //{ // glTexParameteri(GL_) diff --git a/src/libjin/Graphics/je_graphic.h b/src/libjin/Graphics/je_graphic.h index 3410d61..2ed028d 100644 --- a/src/libjin/Graphics/je_graphic.h +++ b/src/libjin/Graphics/je_graphic.h @@ -16,9 +16,8 @@ namespace JinEngine // // Graphic - // |-Texture - // |-Canvas - // |-TextureFont + // |- GraphicSingle + // |- GraphicBatch // /// @@ -28,7 +27,7 @@ namespace JinEngine { public: /// - /// + /// /// Graphic(int w = 0, int h = 0); @@ -45,16 +44,6 @@ namespace JinEngine /// /// /// - void render(int x, int y, float sx = 1, float sy = 1, float r = 0, float ox = 0, float oy = 0); - - /// - /// - /// - void render(const Math::Quad& slice, int x, int y, float sx = 1, float sy = 1, float r = 0, float ox = 0, float oy = 0); - - /// - /// - /// inline int getWidth() const { return mSize.w; } /// @@ -63,9 +52,11 @@ namespace JinEngine inline int getHeight() const { return mSize.h; } /// - /// + /// Get opengl texture token. + /// + /// @return OpenGL texture token. /// - inline GLuint getTexture() const { return mTexture; } + inline GLuint getGLTexture() const { return mTexture; } /// /// @@ -73,14 +64,11 @@ namespace JinEngine void setFilter(GLint min, GLint max); protected: - GLuint mTexture; + JinEngine::Math::Vector2<uint> mSize; private: - JinEngine::Math::Vector2<uint> mSize; - // Screen coordinates and uv coordinates. - float mVertexCoords[8]; - float mTextureCoords[8]; - + GLuint mTexture; + }; } // namespace Graphics diff --git a/src/libjin/Graphics/je_graphic_batch.cpp b/src/libjin/Graphics/je_graphic_batch.cpp index e69de29..1b8601a 100644 --- a/src/libjin/Graphics/je_graphic_batch.cpp +++ b/src/libjin/Graphics/je_graphic_batch.cpp @@ -0,0 +1,11 @@ +#include "je_graphic_batch.h" + +namespace JinEngine +{ + namespace Graphics + { + + + + } // namespace Graphics +} // namespace JinEngine
\ No newline at end of file diff --git a/src/libjin/Graphics/je_graphic_batch.h b/src/libjin/Graphics/je_graphic_batch.h index ebe63f9..274ce4d 100644 --- a/src/libjin/Graphics/je_graphic_batch.h +++ b/src/libjin/Graphics/je_graphic_batch.h @@ -1,20 +1,31 @@ #ifndef __JE_GRAPHIC_BATCH_H #define __JE_GRAPHIC_BATCH_H +#include "je_graphic_single.h" + namespace JinEngine { namespace Graphics { + // + // GraphicsBatch + // + /// - /// For reducing draw call. + /// For reducing draw call. Draw a bunch of graphic. /// - class GraphicBatch + class GraphicBatch : public GraphicSingle { + public: + void add(int x, int y, float sx = 1, float sy = 1, float r = 0, float ox = 0, float oy = 0); + + private: + }; - } // Graphics + } // namespace Graphics } // namespace JinEngine #endif
\ No newline at end of file diff --git a/src/libjin/Graphics/je_graphic_sheet.cpp b/src/libjin/Graphics/je_graphic_sheet.cpp new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/src/libjin/Graphics/je_graphic_sheet.cpp diff --git a/src/libjin/Graphics/je_graphic_sheet.h b/src/libjin/Graphics/je_graphic_sheet.h new file mode 100644 index 0000000..72c038f --- /dev/null +++ b/src/libjin/Graphics/je_graphic_sheet.h @@ -0,0 +1,22 @@ +#ifndef __JE_GRAPHIC_SHEET +#define __JE_GRAPHIC_SHEET + +#include "je_graphic.h" + +namespace JinEngine +{ + namespace Graphics + { + + /// + /// A graphic sheet is a atlas. + /// + class GraphicSheet : public Graphic + { + + }; + + } // namespace Graphics +} // namespace JinEngine + +#endif
\ No newline at end of file diff --git a/src/libjin/Graphics/je_graphic_single.cpp b/src/libjin/Graphics/je_graphic_single.cpp new file mode 100644 index 0000000..0784409 --- /dev/null +++ b/src/libjin/Graphics/je_graphic_single.cpp @@ -0,0 +1,81 @@ +#include "shader/je_shader.h" + +#include "je_graphic_single.h" + +namespace JinEngine +{ + namespace Graphics + { + + GraphicSingle::GraphicSingle(int w, int h) + : Graphic(w, h) + { + } + + GraphicSingle::GraphicSingle(const Bitmap* bitmap) + : Graphic(bitmap) + { + } + + void GraphicSingle::render(int x, int y, float sx, float sy, float r, float ox, float oy) + { + gl.ModelMatrix.setTransformation(x, y, r, sx, sy, ox, oy); + int w = getWidth(), h = getHeight(); + static float vertexCoords[8]; + static float textureCoords[8]; + // Set vertex coordinates. + vertexCoords[0] = 0; vertexCoords[1] = 0; + vertexCoords[2] = 0; vertexCoords[3] = h; + vertexCoords[4] = w; vertexCoords[5] = h; + vertexCoords[6] = w; vertexCoords[7] = 0; + // Set texture coordinates. + textureCoords[0] = 0; textureCoords[1] = 0; + textureCoords[2] = 0; textureCoords[3] = 1; + textureCoords[4] = 1; textureCoords[5] = 1; + textureCoords[6] = 1; textureCoords[7] = 0; + // Set shader. + Shader* shader = Shader::getCurrentShader(); + shader->sendMatrix4(SHADER_MODEL_MATRIX, &gl.ModelMatrix); + shader->sendMatrix4(SHADER_PROJECTION_MATRIX, &gl.ProjectionMatrix); + shader->bindVertexPointer(2, GL_FLOAT, 0, vertexCoords); + shader->bindUVPointer(2, GL_FLOAT, 0, textureCoords); + + gl.bindTexture(getGLTexture()); + gl.drawArrays(GL_QUADS, 0, 4); + gl.bindTexture(0); + } + + void GraphicSingle::render(const Math::Quad& slice, int x, int y, float sx, float sy, float r, float ax, float ay) + { + float vertCoords[8] = { + 0, 0, + 0, slice.h, + slice.w, slice.h, + slice.w, 0 + }; + float slx = slice.x / mSize.w; + float sly = slice.y / mSize.h; + float slw = slice.w / mSize.w; + float slh = slice.h / mSize.h; + float texCoords[8] = { + slx, sly, + slx, sly + slh, + slx + slw, sly + slh, + slx + slw, sly + }; + + gl.ModelMatrix.setTransformation(x, y, r, sx, sy, ax, ay); + + Shader* shader = Shader::getCurrentShader(); + shader->sendMatrix4(SHADER_MODEL_MATRIX, &gl.ModelMatrix); + shader->sendMatrix4(SHADER_PROJECTION_MATRIX, &gl.ProjectionMatrix); + shader->bindVertexPointer(2, GL_FLOAT, 0, vertCoords); + shader->bindUVPointer(2, GL_FLOAT, 0, texCoords); + + gl.bindTexture(getGLTexture()); + gl.drawArrays(GL_QUADS, 0, 4); + gl.bindTexture(0); + } + + } // namespace Graphics +} // namespace JinEngine
\ No newline at end of file diff --git a/src/libjin/Graphics/je_graphic_single.h b/src/libjin/Graphics/je_graphic_single.h new file mode 100644 index 0000000..ca2864b --- /dev/null +++ b/src/libjin/Graphics/je_graphic_single.h @@ -0,0 +1,53 @@ +#ifndef __JE_GRAPHIC_SINGLE_H +#define __JE_GRAPHIC_SINGLE_H + +#include "../math/je_quad.h" + +#include "je_graphic.h" + +namespace JinEngine +{ + namespace Graphics + { + // + // GraphicSingle + // |- Canvas + // |- Texture + // |- TextureFont + // + + /// + /// Single graphic, comparing to graphics batch, a single graphic need assign it's vertex and screen uv. + /// For example, a texture and canvas should be a graphic single. + /// + class GraphicSingle : public Graphic + { + public: + /// + /// + /// + GraphicSingle(const Bitmap* bitmap); + + /// + /// + /// + GraphicSingle(int w = 0, int h = 0); + + /// + /// Render graphic single with given coordinates. + /// + void render(int x, int y, float sx = 1, float sy = 1, float r = 0, float ox = 0, float oy = 0); + + /// + /// Render part of graphic single with given coordinates. + /// + void render(const Math::Quad& slice, int x, int y, float sx = 1, float sy = 1, float r = 0, float ox = 0, float oy = 0); + + private: + + }; + + } // namespace Graphics +} // namespace JinEngine + +#endif
\ No newline at end of file diff --git a/src/libjin/Graphics/je_graphics.h b/src/libjin/Graphics/je_graphics.h index 2ba003d..e2e9a2d 100644 --- a/src/libjin/Graphics/je_graphics.h +++ b/src/libjin/Graphics/je_graphics.h @@ -17,5 +17,7 @@ #include "font/je_text.h" #include "font/je_texture_font.h" +#include "particle/je_particle_system.h" + #endif // defined(jin_graphics) #endif // __JE_GRAPHICS_H
\ No newline at end of file diff --git a/src/libjin/Graphics/je_sprite.h b/src/libjin/Graphics/je_sprite.h index ffc992a..94c39cd 100644 --- a/src/libjin/Graphics/je_sprite.h +++ b/src/libjin/Graphics/je_sprite.h @@ -31,12 +31,15 @@ namespace JinEngine void onRender(); private: - Math::Vector2<int> mPosition; + /// + /// Origin must be 0~1 float value. + /// + Math::Vector2<float> mPosition; Math::Vector2<float> mOrigin; Math::Vector2<float> mScale; Color mColor; Shader* mShader; - Graphic* mGraphic; + GraphicSingle* mGraphic; }; diff --git a/src/libjin/Graphics/je_texture.cpp b/src/libjin/Graphics/je_texture.cpp index 8aa3f9a..ff07748 100644 --- a/src/libjin/Graphics/je_texture.cpp +++ b/src/libjin/Graphics/je_texture.cpp @@ -30,7 +30,7 @@ namespace JinEngine } Texture::Texture(const Bitmap* bitmap) - : Graphic(bitmap) + : GraphicSingle(bitmap) { } diff --git a/src/libjin/Graphics/je_texture.h b/src/libjin/Graphics/je_texture.h index ddc8cfc..656ccd7 100644 --- a/src/libjin/Graphics/je_texture.h +++ b/src/libjin/Graphics/je_texture.h @@ -6,7 +6,7 @@ #include "../3rdparty/GLee/GLee.h" #include "je_color.h" -#include "je_graphic.h" +#include "je_graphic_single.h" #include "je_bitmap.h" namespace JinEngine @@ -17,7 +17,7 @@ namespace JinEngine /// /// /// - class Texture: public Graphic + class Texture: public GraphicSingle { public: /// diff --git a/src/libjin/Graphics/particle/je_particle.h b/src/libjin/Graphics/particle/je_particle.h index cb176bb..089bf35 100644 --- a/src/libjin/Graphics/particle/je_particle.h +++ b/src/libjin/Graphics/particle/je_particle.h @@ -8,7 +8,7 @@ namespace JinEngine namespace Graphics { - class ParticleSystem; + class ParticleEmitter; struct LifeTimeDef { @@ -23,6 +23,11 @@ namespace JinEngine } life; }; + struct LinearAccelaration + { + + }; + struct SpeedOverTimeDef { bool enable = false; @@ -74,8 +79,14 @@ namespace JinEngine /// struct ParticleDef { + private: + friend class ParticleEmitter; + + public: + // Basic definitions. LifeTimeDef lifeTimeDef; ///< // Optional definitions. + SpeedOverTimeDef speedOverTimeDef; ///< SizeOverTimeDef sizeOverTimeDef; ///< ColorOverTime colorOverTimeDef; ///< @@ -87,6 +98,7 @@ namespace JinEngine /// struct Particle { + Particle(const ParticleDef& particleDef); /// /// Whole life time. /// diff --git a/src/libjin/Graphics/particle/je_particle_emitter.cpp b/src/libjin/Graphics/particle/je_particle_emitter.cpp index e69de29..0ab9cf1 100644 --- a/src/libjin/Graphics/particle/je_particle_emitter.cpp +++ b/src/libjin/Graphics/particle/je_particle_emitter.cpp @@ -0,0 +1,14 @@ +#ifndef __JE_PARTICLE_SYSTEM_H +#define __JE_PARTICLE_SYSTEM_H + +namespace JinEngine +{ + namespace Graphics + { + + + + } +} + +#endif
\ No newline at end of file diff --git a/src/libjin/Graphics/particle/je_particle_emitter.h b/src/libjin/Graphics/particle/je_particle_emitter.h index e700f16..5e4316d 100644 --- a/src/libjin/Graphics/particle/je_particle_emitter.h +++ b/src/libjin/Graphics/particle/je_particle_emitter.h @@ -61,10 +61,6 @@ namespace JinEngine PositionDef positionDef; ///< Emit position(relativily to the particle system center). DirectionDef directionDef; ///< Emit direction. EmitRateDef emitRateDef; ///< Emit rate. - /// - /// Particle definition. - /// - ParticleDef particleDef; ///< Particle definition. }; /// @@ -73,18 +69,24 @@ namespace JinEngine class ParticleEmitter { public: - ParticleEmitter(const ParticleEmitterDef& def); - /// - /// Emit a particle, particle system should assign particle value to the particle in particle pool, - /// but not use this return particle. + /// ParticleEmitter constructor. + /// + /// @param emitterDef Definition of particle emitter. + /// @param particleDef Definition of particle. /// - Particle emit(); + ParticleEmitter(const ParticleEmitterDef& emitterDef, const ParticleDef& particleDef); /// + /// Emit a particle according to emitter definition and particle definition, particle system should + /// assign particle value to the particle in particle pool, but not use this return particle. /// - /// + Particle emit(); + + private: float mDirection; + ParticleEmitterDef mEmitterDef; + ParticleDef mParticleDef; }; diff --git a/src/libjin/Graphics/particle/je_particle_system.h b/src/libjin/Graphics/particle/je_particle_system.h index 9ccb8df..270d9a8 100644 --- a/src/libjin/Graphics/particle/je_particle_system.h +++ b/src/libjin/Graphics/particle/je_particle_system.h @@ -22,10 +22,10 @@ namespace JinEngine /// struct ParticleSystemDef : public Temporary { - uint maxParticleCount = 1; ///< Max count of particles in pool. 1 by default. - - ParticleEmitter emitterDef; + uint maxParticleCount = 1; ///< Max count of particles in pool. 1 by default. + ParticleEmitterDef emitterDef; ///< Particle emitter definition. + ParticleDef particleDef; ///< Particle definition. }; /// @@ -64,6 +64,9 @@ namespace JinEngine void releaseParticle(); private: + // Disable default constructor. + ParticleSystem(); + /// /// Sprite to be drawn. /// diff --git a/src/libjin/Math/je_math.h b/src/libjin/Math/je_math.h index e7c3ec5..6a05c44 100644 --- a/src/libjin/Math/je_math.h +++ b/src/libjin/Math/je_math.h @@ -71,7 +71,7 @@ namespace JinEngine return a + t * (b - a); } - float lerp(float a, float b, float f) + inline float lerp(float a, float b, float f) { f = clamp<float>(f, 0, 1); return a + f * (b - a); diff --git a/src/lua/modules/net/je_lua_buffer.cpp b/src/lua/modules/net/je_lua_buffer.cpp index ddfbd6b..d2342f3 100644 --- a/src/lua/modules/net/je_lua_buffer.cpp +++ b/src/lua/modules/net/je_lua_buffer.cpp @@ -2,7 +2,7 @@ #include "lua/modules/types.h" #include "lua/common/common.h" #include "libjin/jin.h" -#include "Buffer.h" +#include "je_lua_buffer.h" namespace JinEngine { |