[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.
This commit is contained in:
parent
65cf61a6ed
commit
fc03c9f6e3
@ -5,8 +5,7 @@
|
|||||||
#include "ship.h"
|
#include "ship.h"
|
||||||
|
|
||||||
InfoView::InfoView(void) : View() {
|
InfoView::InfoView(void) : View() {
|
||||||
SetTransparency(false);
|
SetTransparency(true);
|
||||||
SetBgColor(.0, .2, .4);
|
|
||||||
|
|
||||||
float size[2];
|
float size[2];
|
||||||
GetSize(size);
|
GetSize(size);
|
||||||
@ -40,8 +39,58 @@ void InfoView::UpdateInfo(void) {
|
|||||||
info1->SetText(nfo);
|
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) {
|
void InfoView::Update(void) {
|
||||||
|
@ -254,7 +254,6 @@ void L3D::MainLoop(void) {
|
|||||||
for(;;) {
|
for(;;) {
|
||||||
frame_stat++;
|
frame_stat++;
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
|
|
||||||
current_view->Draw3D();
|
current_view->Draw3D();
|
||||||
|
@ -64,6 +64,8 @@ void SectorView::Draw3D(void) {
|
|||||||
|
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
|
glClearColor(0, 0, 0, 0);
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
|
|
||||||
char buf[80];
|
char buf[80];
|
||||||
snprintf(buf, sizeof(buf), "Sector: %d,%d", m_secx, m_secy);
|
snprintf(buf, sizeof(buf), "Sector: %d,%d", m_secx, m_secy);
|
||||||
|
@ -24,6 +24,7 @@ void Ship::UpdateMass(void) {
|
|||||||
shipstats_t s;
|
shipstats_t s;
|
||||||
CalcStats(&s);
|
CalcStats(&s);
|
||||||
dMassAdjust(&m_mass, s.total_mass*1000);
|
dMassAdjust(&m_mass, s.total_mass*1000);
|
||||||
|
dBodySetMass(m_body, &m_mass);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Ship::SetThrusterState(enum ShipType::Thruster t, float level) {
|
void Ship::SetThrusterState(enum ShipType::Thruster t, float level) {
|
||||||
|
@ -7,8 +7,8 @@ const ShipType ShipType::types[] = {
|
|||||||
* Sirius corporation make a range of lovely ships!
|
* Sirius corporation make a range of lovely ships!
|
||||||
*/
|
*/
|
||||||
"Sirius Interdictor", 10,
|
"Sirius Interdictor", 10,
|
||||||
{ 250, -250, 50, -50, -50, 50 },
|
{ 1e7, -1e7, 1e6, -1e6, -1e6, 1e6 },
|
||||||
2000.0,
|
1e7,
|
||||||
{
|
{
|
||||||
{ vector3f(0, -0.5, 0), vector3f(0, 0, -1) },
|
{ vector3f(0, -0.5, 0), vector3f(0, 0, -1) },
|
||||||
{ vector3f(0, 0, 0), vector3f(0, 0, 1) }
|
{ vector3f(0, 0, 0), vector3f(0, 0, 1) }
|
||||||
@ -22,8 +22,8 @@ const ShipType ShipType::types[] = {
|
|||||||
*/
|
*/
|
||||||
"Ladybird Starfighter",
|
"Ladybird Starfighter",
|
||||||
13,
|
13,
|
||||||
{ 250, -250, 50, -50, -50, 50 },
|
{ 1e7, -1e7, 1e6, -1e6, -1e6, 1e6 },
|
||||||
500.0,
|
1e7,
|
||||||
{
|
{
|
||||||
{ vector3f(0, -0.5, 0), vector3f(0, 0, -1) },
|
{ vector3f(0, -0.5, 0), vector3f(0, 0, -1) },
|
||||||
{ vector3f(0, 0, 0), vector3f(0, 0, 1) }
|
{ vector3f(0, 0, 0), vector3f(0, 0, 1) }
|
||||||
@ -34,8 +34,8 @@ const ShipType ShipType::types[] = {
|
|||||||
{
|
{
|
||||||
"Flowerfairy Heavy Trader",
|
"Flowerfairy Heavy Trader",
|
||||||
14,
|
14,
|
||||||
{ 250, -250, 50, -50, -50, 50 },
|
{ 1e7, -1e7, 1e6, -1e6, -1e6, 1e6 },
|
||||||
500.0,
|
1e7,
|
||||||
{
|
{
|
||||||
{ vector3f(0, -0.5, 0), vector3f(0, 0, -1) },
|
{ vector3f(0, -0.5, 0), vector3f(0, 0, -1) },
|
||||||
{ vector3f(0, 0, 0), vector3f(0, 0, 1) }
|
{ vector3f(0, 0, 0), vector3f(0, 0, 1) }
|
||||||
|
@ -160,6 +160,8 @@ void SystemView::Draw3D(void) {
|
|||||||
gluPerspective(50, L3D::GetScrAspect(), 1.0, 1000.0);
|
gluPerspective(50, L3D::GetScrAspect(), 1.0, 1000.0);
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
|
glClearColor(0, 0, 0, 0);
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
|
|
||||||
int sector_x, sector_y, system_idx;
|
int sector_x, sector_y, system_idx;
|
||||||
L3D::sector_view->GetSelectedSystem(§or_x, §or_y, &system_idx);
|
L3D::sector_view->GetSelectedSystem(§or_x, §or_y, &system_idx);
|
||||||
|
@ -54,6 +54,8 @@ void WorldView::Draw3D(void) {
|
|||||||
L3D::GetScrWidth()*.5, 100000);
|
L3D::GetScrWidth()*.5, 100000);
|
||||||
glDepthRange(-10, -100000);
|
glDepthRange(-10, -100000);
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
|
glClearColor(0, 0, 0, 0);
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
|
|
||||||
/* Make temporary camera frame at player. */
|
/* Make temporary camera frame at player. */
|
||||||
Frame* cam_frame = new Frame(L3D::player->GetFrame(), "", Frame::TEMP_VIEWING);
|
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);
|
glRotatef(180.0f, 0, 1, 0);
|
||||||
cam_frame->SetPosition(L3D::player->GetPosition());
|
cam_frame->SetPosition(L3D::player->GetPosition());
|
||||||
} else { /* CAM_EXTERNAL */
|
} else { /* CAM_EXTERNAL */
|
||||||
cam_frame->SetPosition(L3D::player->GetPosition());
|
cam_frame->SetPosition(L3D::player->GetPosition() + L3D::player->GetExternalViewTranslation());
|
||||||
L3D::player->ApplyExternalViewRotation();
|
L3D::player->ApplyExternalViewRotation();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user