From fc03c9f6e32af21959a0c6aea3c01534c27a07e2 Mon Sep 17 00:00:00 2001 From: Rtch90 Date: Mon, 13 Nov 2017 22:12:02 +0000 Subject: [PATCH] [Fix] Fixed external view, forgot to add players external veiw translation to camera frame's position. [Fix] Correctly apply ship masses. [Add] A nice rotating ship in the infoview pane. --- src/info_view.cpp | 55 ++++++++++++++++++++++++++++++++++++++++++--- src/main.cpp | 1 - src/sector_view.cpp | 2 ++ src/ship.cpp | 1 + src/ship_type.cpp | 12 +++++----- src/system_view.cpp | 2 ++ src/world_view.cpp | 4 +++- 7 files changed, 66 insertions(+), 11 deletions(-) diff --git a/src/info_view.cpp b/src/info_view.cpp index 273121d..7b1bbb6 100644 --- a/src/info_view.cpp +++ b/src/info_view.cpp @@ -5,8 +5,7 @@ #include "ship.h" InfoView::InfoView(void) : View() { - SetTransparency(false); - SetBgColor(.0, .2, .4); + SetTransparency(true); float size[2]; GetSize(size); @@ -40,8 +39,58 @@ void InfoView::UpdateInfo(void) { info1->SetText(nfo); } -void InfoView::Draw3D(void) { +static ObjParams params = { + { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, + /* pColor[3] */ + { + { { 1.0f, 0.0f, 1.0f }, { 0, 0, 0 }, { 0, 0, 0 }, 0 }, + { { 0.8f, 0.6f, 0.5f }, { 0, 0, 0 }, { 0, 0, 0 }, 0 }, + { { 0.5f, 0.5f, 0.5f }, { 0, 0, 0 }, { 0, 0, 0 }, 0 } + }, + + /* pText[3][256] */ + { "IR-L33T", "ME TOO" }, +}; + +void InfoView::Draw3D(void) { + static float rot1, rot2; + rot1 += .5*L3D::GetFrameTime(); + rot2 += L3D::GetFrameTime(); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glFrustum(-L3D::GetScrWidth() *.5, L3D::GetScrWidth()* .5, + -L3D::GetScrHeight()*.5, L3D::GetScrHeight()*.5, + L3D::GetScrWidth()* .5, 100000); + glDepthRange(-10, -100000); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glClearColor(0, .2, .4, 0); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + float lightCol[] = { 1, 1, 1 }; + float lightDir[] = { 1, 0, 0 }; + + glPushAttrib(GL_ALL_ATTRIB_BITS); + sbreSetDirLight(lightCol, lightDir); + sbreSetViewport(L3D::GetScrWidth(), L3D::GetScrHeight(), + L3D::GetScrWidth()*0.5, 5.0f, 100000.0f, 0.0f, 1.0f); + /* Psht, go away sbre. I want my own viewport! */ + glViewport(L3D::GetScrWidth()/4, 0, L3D::GetScrWidth(), L3D::GetScrHeight()); + + Vector p; p.x = 0; p.y = 0; p.z = 100; + matrix4x4d rot = matrix4x4d::RotateXMatrix(rot1); + rot.RotateY(rot2); + Matrix m; + m.x1 = rot[0]; m.x2 = rot[4]; m.x3 = -rot[ 8]; + m.y1 = rot[1]; m.y2 = rot[5]; m.y3 = -rot[ 9]; + m.z1 = -rot[2]; m.z2 = -rot[6]; m.z3 = rot[10]; + const ShipType& stype = L3D::player->GetShipType(); + + sbreRenderModel(&p, &m, stype.sbreModel, ¶ms); + glPopAttrib(); } void InfoView::Update(void) { diff --git a/src/main.cpp b/src/main.cpp index 8d95fe9..46c2027 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -254,7 +254,6 @@ void L3D::MainLoop(void) { for(;;) { frame_stat++; glMatrixMode(GL_MODELVIEW); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); current_view->Draw3D(); diff --git a/src/sector_view.cpp b/src/sector_view.cpp index baea27b..08ef450 100644 --- a/src/sector_view.cpp +++ b/src/sector_view.cpp @@ -64,6 +64,8 @@ void SectorView::Draw3D(void) { glMatrixMode(GL_MODELVIEW); glLoadIdentity(); + glClearColor(0, 0, 0, 0); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); char buf[80]; snprintf(buf, sizeof(buf), "Sector: %d,%d", m_secx, m_secy); diff --git a/src/ship.cpp b/src/ship.cpp index 063b606..180df29 100644 --- a/src/ship.cpp +++ b/src/ship.cpp @@ -24,6 +24,7 @@ void Ship::UpdateMass(void) { shipstats_t s; CalcStats(&s); dMassAdjust(&m_mass, s.total_mass*1000); + dBodySetMass(m_body, &m_mass); } void Ship::SetThrusterState(enum ShipType::Thruster t, float level) { diff --git a/src/ship_type.cpp b/src/ship_type.cpp index 755f977..5f2bea4 100644 --- a/src/ship_type.cpp +++ b/src/ship_type.cpp @@ -7,8 +7,8 @@ const ShipType ShipType::types[] = { * Sirius corporation make a range of lovely ships! */ "Sirius Interdictor", 10, - { 250, -250, 50, -50, -50, 50 }, - 2000.0, + { 1e7, -1e7, 1e6, -1e6, -1e6, 1e6 }, + 1e7, { { vector3f(0, -0.5, 0), vector3f(0, 0, -1) }, { vector3f(0, 0, 0), vector3f(0, 0, 1) } @@ -22,8 +22,8 @@ const ShipType ShipType::types[] = { */ "Ladybird Starfighter", 13, - { 250, -250, 50, -50, -50, 50 }, - 500.0, + { 1e7, -1e7, 1e6, -1e6, -1e6, 1e6 }, + 1e7, { { vector3f(0, -0.5, 0), vector3f(0, 0, -1) }, { vector3f(0, 0, 0), vector3f(0, 0, 1) } @@ -34,8 +34,8 @@ const ShipType ShipType::types[] = { { "Flowerfairy Heavy Trader", 14, - { 250, -250, 50, -50, -50, 50 }, - 500.0, + { 1e7, -1e7, 1e6, -1e6, -1e6, 1e6 }, + 1e7, { { vector3f(0, -0.5, 0), vector3f(0, 0, -1) }, { vector3f(0, 0, 0), vector3f(0, 0, 1) } diff --git a/src/system_view.cpp b/src/system_view.cpp index 5ebf558..35af569 100644 --- a/src/system_view.cpp +++ b/src/system_view.cpp @@ -160,6 +160,8 @@ void SystemView::Draw3D(void) { gluPerspective(50, L3D::GetScrAspect(), 1.0, 1000.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); + glClearColor(0, 0, 0, 0); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); int sector_x, sector_y, system_idx; L3D::sector_view->GetSelectedSystem(§or_x, §or_y, &system_idx); diff --git a/src/world_view.cpp b/src/world_view.cpp index 0d413a8..549e391 100644 --- a/src/world_view.cpp +++ b/src/world_view.cpp @@ -54,6 +54,8 @@ void WorldView::Draw3D(void) { L3D::GetScrWidth()*.5, 100000); glDepthRange(-10, -100000); glMatrixMode(GL_MODELVIEW); + glClearColor(0, 0, 0, 0); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); /* Make temporary camera frame at player. */ Frame* cam_frame = new Frame(L3D::player->GetFrame(), "", Frame::TEMP_VIEWING); @@ -64,7 +66,7 @@ void WorldView::Draw3D(void) { glRotatef(180.0f, 0, 1, 0); cam_frame->SetPosition(L3D::player->GetPosition()); } else { /* CAM_EXTERNAL */ - cam_frame->SetPosition(L3D::player->GetPosition()); + cam_frame->SetPosition(L3D::player->GetPosition() + L3D::player->GetExternalViewTranslation()); L3D::player->ApplyExternalViewRotation(); }