Changeset 1301


Ignore:
Timestamp:
Apr 26, 2012, 8:20:53 PM (9 years ago)
Author:
sam
Message:

orbital: create a Camera class where we will hide the complexity.

Location:
trunk
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/orbital/Makefile.am

    r1286 r1301  
    33
    44orbital_SOURCES = \
    5     orbital.cpp orbital.h mesh.h particlesystem.h
     5    orbital.cpp orbital.h mesh.h particlesystem.h camera.h
    66orbital_CPPFLAGS = @LOL_CFLAGS@ @PIPI_CFLAGS@
    77orbital_LDADD =
  • trunk/orbital/orbital.cpp

    r1296 r1301  
    2626#include "mesh.h"
    2727#include "particlesystem.h"
     28#include "camera.h"
    2829
    2930Orbital::Orbital()
     
    6263    m.SendCommand("sc0,1,1,scb0,0,0,1,ac5,15,0,1.5,0,1,ac7,35,1.1,4,0,1,rx90,t-3,0,27,mx");
    6364
    64     new ParticleSystem();
     65    m_particlesystem = new ParticleSystem();
     66    m_camera = new Camera(vec3(0, 0, -4),
     67                          vec3(0, 1, 0),
     68                          vec3(0, 2, 0));
    6569
    6670    m_angle = 0;
    6771
    6872    m_ready = false;
     73
     74    Ticker::Ref(m_particlesystem);
     75    Ticker::Ref(m_camera);
    6976}
    7077
     
    7986    mat4 model = mat4::translate(vec3(0, 0, -4.5))
    8087               * mat4::scale(vec3(0.025));
    81     mat4 view = mat4::lookat(vec3(0, 2, 0), vec3(0, 0, -4), vec3(0, 1, 0));
    82     mat4 proj = mat4::perspective(45.0f, 640.0f, 480.0f, 0.1f, 10.0f);
    8388
    84     m_modelview = view * model * anim;
    85     m_proj = proj;
     89    m_modelview = m_camera->GetViewMatrix() * model * anim;
     90    m_proj = m_camera->GetProjMatrix();
    8691    m_normalmat = transpose(inverse(mat3(m_modelview)));
    8792}
     
    106111Orbital::~Orbital()
    107112{
    108     ;
     113    Ticker::Unref(m_particlesystem);
     114    Ticker::Unref(m_camera);
    109115}
    110116
  • trunk/orbital/orbital.h

    r1286 r1301  
    44#include "mesh.h"
    55#include "particlesystem.h"
     6#include "camera.h"
    67
    78class Orbital : public WorldEntity
     
    2324    mat3 m_normalmat;
    2425
     26    ParticleSystem *m_particlesystem;
     27    Camera *m_camera;
     28
    2529    bool m_ready;
    2630};
  • trunk/win32/orbital.vcxproj

    r1286 r1301  
    2828  </ItemGroup>
    2929  <ItemGroup>
     30    <ClInclude Include="..\orbital\camera.h" />
    3031    <ClInclude Include="..\orbital\mesh.h" />
    3132    <ClInclude Include="..\orbital\orbital.h" />
  • trunk/win32/orbital.vcxproj.filters

    r1286 r1301  
    33  <ItemGroup>
    44    <ClInclude Include="..\orbital\mesh.h" />
     5    <ClInclude Include="..\orbital\camera.h" />
    56  </ItemGroup>
    67  <ItemGroup>
Note: See TracChangeset for help on using the changeset viewer.