adding simple dummy ship model.

This commit is contained in:
Andreas Ortmann 2016-09-28 14:41:15 +02:00
parent 1ad020dbd4
commit 4906777e9a
4 changed files with 55 additions and 7 deletions

View file

@ -15,7 +15,8 @@ namespace endofthejedi {
addModel("../data/mesh/small_atomic_bomb.stl", &m_missileModel);
//addModel("../data/mesh/planet_128.stl", &m_planetModel);
addModel("../data/mesh/planet_12.stl", &m_planetModel);
addModel("../data/mesh/planet_12.stl", &m_planetModel);
addModel("../data/mesh/ship.stl", &m_shipModel);
std::string vss_simple =
"#version 120\n"
@ -82,7 +83,12 @@ namespace endofthejedi {
{
m_shader.bind();
// TODO :Z?
renderPlanets(state);
renderShips(state);
renderMissiles(state);
//glColor3f(1.0, 0.0, 0.0);
//glBegin(GL_QUADS);
@ -111,10 +117,36 @@ namespace endofthejedi {
void RendererPolygon3d::renderMissiles(const game::State *state)
{
(void) state;
//m_missileModel->bind();
// TODO
//m_missileModel->render();
m_missileModel->bind();
for (const game::Player *player : state->players) {
for (const game::Missile *missile : player->missiles) {
glm::vec3 c = glm::vec3(1.0, 1.0, 0.3);
const auto &p = missile->position;
glUniform3f(m_shader.location("position"), p.x, p.y, 0.0);
glUniform3f(m_shader.location("color"), c.x, c.y, c.z);
glUniform1f(m_shader.location("scale"), 1.0);
m_missileModel->render();
}
}
}
void RendererPolygon3d::renderShips(const game::State *state)
{
m_shipModel->bind();
for (const game::Ship *ship : state->ships) {
glm::vec3 c = glm::vec3(0.1, 1.0, 0.2);
const auto &p = ship->position;
glUniform3f(m_shader.location("position"), p.x, p.y, 0.0);
glUniform3f(m_shader.location("color"), c.x, c.y, c.z);
glUniform1f(m_shader.location("scale"), 0.02);
m_shipModel->render();
}
}
void RendererPolygon3d::addModel(const std::string &filename, PolygonModel **dest)

View file

@ -24,7 +24,7 @@ namespace endofthejedi {
private:
void renderPlanets(const game::State *state);
void renderMissiles(const game::State *state);
//void renderShips(const game::State *state);
void renderShips(const game::State *state);
void addModel(const std::string &filename, PolygonModel **dest);
@ -35,6 +35,7 @@ namespace endofthejedi {
// and with a specific variable name here
PolygonModel *m_missileModel;
PolygonModel *m_planetModel;
PolygonModel *m_shipModel;
// for rendering everything
Shader m_shader;