瀏覽代碼

core: move the Camera class from Orbital to the engine core.

legacy
Sam Hocevar sam 12 年之前
父節點
當前提交
08fc460668
共有 8 個檔案被更改,包括 133 行新增7 行删除
  1. +1
    -1
      src/Makefile.am
  2. +70
    -0
      src/camera.cpp
  3. +49
    -0
      src/camera.h
  4. +1
    -0
      src/core.h
  5. +3
    -1
      win32/lolcore.vcxproj
  6. +7
    -1
      win32/lolcore.vcxproj.filters
  7. +1
    -2
      win32/orbital.vcxproj
  8. +1
    -2
      win32/orbital.vcxproj.filters

+ 1
- 1
src/Makefile.am 查看文件

@@ -10,7 +10,7 @@ liblol_a_SOURCES = \
world.cpp world.h sample.cpp sample.h sampler.cpp sampler.h \
text.cpp text.h emitter.cpp emitter.h numeric.h hash.cpp hash.h \
worldentity.cpp worldentity.h gradient.cpp gradient.h \
platform.cpp platform.h sprite.cpp sprite.h \
platform.cpp platform.h sprite.cpp sprite.h camera.cpp camera.h \
\
lol/unit.h lol/debug.h \
lol/math/vector.h lol/math/half.h lol/math/real.h lol/math/remez.h \


+ 70
- 0
src/camera.cpp 查看文件

@@ -0,0 +1,70 @@
//
// Lol Engine
//
// Copyright: (c) 2010-2012 Sam Hocevar <sam@hocevar.net>
// This program is free software; you can redistribute it and/or
// modify it under the terms of the Do What The Fuck You Want To
// Public License, Version 2, as published by Sam Hocevar. See
// http://sam.zoy.org/projects/COPYING.WTFPL for more details.
//

#if defined HAVE_CONFIG_H
# include "config.h"
#endif

#include <cstring>
#include <cstdlib>

#include "core.h"

#if defined _WIN32 || defined _XBOX
# define strcasecmp _stricmp
#endif

namespace lol
{

Camera::Camera(vec3 const &position, vec3 const &target, vec3 const &up)
: m_target(target),
m_up(up)
{
m_gamegroup = GAMEGROUP_BEFORE;

SetPosition(position);
}

Camera::~Camera()
{
}

void Camera::SetPosition(vec3 const &pos)
{
m_position = pos;
}

mat4 const &Camera::GetViewMatrix()
{
return m_view_matrix;
}

mat4 const &Camera::GetProjMatrix()
{
return m_proj_matrix;
}

void Camera::TickGame(float deltams)
{
WorldEntity::TickGame(deltams);

m_view_matrix = mat4::lookat(m_position, m_target, m_up);
m_proj_matrix = mat4::perspective(45.0f, 640.0f, 480.0f, 1.f, 1000.0f);
//m_proj_matrix = mat4::ortho(-160, 160, -120, 120, .1f, 2000.0f);
}

void Camera::TickDraw(float deltams)
{
WorldEntity::TickDraw(deltams);
}

} /* namespace lol */


+ 49
- 0
src/camera.h 查看文件

@@ -0,0 +1,49 @@
//
// Lol Engine
//
// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net>
// This program is free software; you can redistribute it and/or
// modify it under the terms of the Do What The Fuck You Want To
// Public License, Version 2, as published by Sam Hocevar. See
// http://sam.zoy.org/projects/COPYING.WTFPL for more details.
//

//
// The Camera class
// ----------------
//

#if !defined __CAMERA_H__
#define __CAMERA_H__

#include "worldentity.h"

namespace lol
{

class Camera : public WorldEntity
{
public:
Camera(vec3 const &position, vec3 const &target, vec3 const &up);
~Camera();

char const *GetName() { return "<camera>"; }

void SetPosition(vec3 const &pos);

mat4 const &GetViewMatrix();
mat4 const &GetProjMatrix();

protected:
virtual void TickGame(float deltams);
virtual void TickDraw(float deltams);

private:
mat4 m_view_matrix, m_proj_matrix;
vec3 m_target, m_up;
};

} /* namespace lol */

#endif /* __CAMERA_H__ */


+ 1
- 0
src/core.h 查看文件

@@ -85,6 +85,7 @@ static inline int isnan(float f)
#include "entity.h"
#include "worldentity.h"

#include "camera.h"
#include "emitter.h"
#include "font.h"
#include "gradient.h"


+ 3
- 1
win32/lolcore.vcxproj 查看文件

@@ -74,6 +74,7 @@
<ItemGroup>
<ClCompile Include="..\src\application\application.cpp" />
<ClCompile Include="..\src\audio.cpp" />
<ClCompile Include="..\src\camera.cpp" />
<ClCompile Include="..\src\debug\fps.cpp" />
<ClCompile Include="..\src\debug\quad.cpp" />
<ClCompile Include="..\src\debug\record.cpp" />
@@ -128,6 +129,7 @@
<ClInclude Include="..\src\array.h" />
<ClInclude Include="..\src\audio.h" />
<ClInclude Include="..\src\bitfield.h" />
<ClInclude Include="..\src\camera.h" />
<ClInclude Include="..\src\core.h" />
<ClInclude Include="..\src\debug\fps.h" />
<ClInclude Include="..\src\debug\quad.h" />
@@ -185,4 +187,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>

+ 7
- 1
win32/lolcore.vcxproj.filters 查看文件

@@ -70,6 +70,9 @@
<ClCompile Include="..\src\audio.cpp">
<Filter>src</Filter>
</ClCompile>
<ClCompile Include="..\src\camera.cpp">
<Filter>src</Filter>
</ClCompile>
<ClCompile Include="..\src\dict.cpp">
<Filter>src</Filter>
</ClCompile>
@@ -225,6 +228,9 @@
<ClInclude Include="..\src\bitfield.h">
<Filter>src</Filter>
</ClInclude>
<ClInclude Include="..\src\camera.h">
<Filter>src</Filter>
</ClInclude>
<ClInclude Include="..\src\core.h">
<Filter>src</Filter>
</ClInclude>
@@ -365,4 +371,4 @@
<Filter>src</Filter>
</ClInclude>
</ItemGroup>
</Project>
</Project>

+ 1
- 2
win32/orbital.vcxproj 查看文件

@@ -27,7 +27,6 @@
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\orbital\camera.h" />
<ClInclude Include="..\orbital\mesh.h" />
<ClInclude Include="..\orbital\orbital.h" />
<ClInclude Include="..\orbital\particlesystem.h" />
@@ -58,4 +57,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>

+ 1
- 2
win32/orbital.vcxproj.filters 查看文件

@@ -2,7 +2,6 @@
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ClInclude Include="..\orbital\mesh.h" />
<ClInclude Include="..\orbital\camera.h" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\orbital\orbital.h" />
@@ -13,4 +12,4 @@
<ItemGroup>
<ClCompile Include="..\orbital\orbital.cpp" />
</ItemGroup>
</Project>
</Project>

Loading…
取消
儲存