Changeset 1332 for trunk/orbital


Ignore:
Timestamp:
May 2, 2012, 1:47:32 PM (9 years ago)
Author:
sam
Message:

orbital: do not let the world objects know anything about the projection
or view matrix unless strictly necessary.

Location:
trunk/orbital
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/orbital/mesh.h

    r1330 r1332  
    224224    }
    225225
    226     void Render(mat4 const &modelview, mat4 const &proj)
    227     {
     226    void Render(mat4 const &model)
     227    {
     228        mat4 modelview = Scene::GetDefault()->GetViewMatrix() * model;
    228229        mat3 normalmat = transpose(inverse(mat3(modelview)));
    229230
    230231        m_gpu.shader->Bind();
    231232        m_gpu.shader->SetUniform(m_gpu.modelview, modelview);
    232         m_gpu.shader->SetUniform(m_gpu.proj, proj);
     233        m_gpu.shader->SetUniform(m_gpu.proj, Scene::GetDefault()->GetProjMatrix());
    233234        m_gpu.shader->SetUniform(m_gpu.normalmat, normalmat);
    234235        m_gpu.vdecl->SetStream(m_gpu.vbo, m_gpu.coord, m_gpu.norm, m_gpu.color);
  • trunk/orbital/orbital.cpp

    r1330 r1332  
    149149    mat4 model = mat4::translate(vec3(0));
    150150
    151     m_modelview = m_camera->GetViewMatrix() * model * anim;
    152     m_proj = m_camera->GetProjMatrix();
     151    m_model = model * anim;
    153152}
    154153
     
    167166    Video::SetClearColor(vec4(0.0f, 0.0f, 0.0f, 1.0f));
    168167
    169     m.Render(m_modelview, m_proj);
     168    m.Render(m_model);
    170169}
    171170
  • trunk/orbital/orbital.h

    r1330 r1332  
    2828    float m_auto_cam_timer;
    2929    vec3 m_angle, m_angular_velocity;
    30 
    31     mat4 m_modelview, m_proj;
     30    mat4 m_model;
    3231
    3332    ParticleSystem *m_particlesystem;
  • trunk/orbital/particlesystem.h

    r1330 r1332  
    6060            m_ready = true;
    6161        }
    62         mat4 anim = mat4::rotate(m_angle, vec3(0, 1, 0));
    63         mat4 view = mat4::lookat(vec3(0, 2, 0), vec3(0, 0, -4), vec3(0, 1, 0));
    64         mat4 proj = mat4::perspective(45.0f, 640.0f, 480.0f, 0.1f, 10.0f);
    6562
    6663        for (int i = 0; i < m_particles.Count(); i++)
    6764        {
    68             mat4 model = mat4::translate(vec3(0, 0, -4.5))
    69                        * mat4::scale(vec3(0.025))
    70                        * mat4::translate(m_particles[i].m1);
    71             mat4 modelview = view * model * anim;
     65            mat4 model = mat4::translate(vec3(0, 0, -100))
     66                       * mat4::translate(m_particles[i].m1);;
    7267
    73             m_mesh.Render(modelview, proj);
     68            m_mesh.Render(model);
    7469        }
    7570    }
Note: See TracChangeset for help on using the changeset viewer.