diff --git a/screenshot/aabb.png b/screenshot/aabb.png new file mode 100644 index 0000000..24ab8f8 Binary files /dev/null and b/screenshot/aabb.png differ diff --git a/screenshot/barnardc.png b/screenshot/barnardc.png new file mode 100644 index 0000000..d258344 Binary files /dev/null and b/screenshot/barnardc.png differ diff --git a/screenshot/barnards_star.png b/screenshot/barnards_star.png new file mode 100644 index 0000000..7193ac7 Binary files /dev/null and b/screenshot/barnards_star.png differ diff --git a/screenshot/dfighters_point.png b/screenshot/dfighters_point.png new file mode 100644 index 0000000..81d9775 Binary files /dev/null and b/screenshot/dfighters_point.png differ diff --git a/screenshot/dfighters_point_landed.png b/screenshot/dfighters_point_landed.png new file mode 100644 index 0000000..8f54354 Binary files /dev/null and b/screenshot/dfighters_point_landed.png differ diff --git a/screenshot/lmenu2.png b/screenshot/lmenu2.png new file mode 100644 index 0000000..c992ad1 Binary files /dev/null and b/screenshot/lmenu2.png differ diff --git a/screenshot/multiple_ports.png b/screenshot/multiple_ports.png new file mode 100644 index 0000000..a2c8b7c Binary files /dev/null and b/screenshot/multiple_ports.png differ diff --git a/src/custom_starsystems.cpp b/src/custom_starsystems.cpp index e0378be..49500af 100644 --- a/src/custom_starsystems.cpp +++ b/src/custom_starsystems.cpp @@ -23,6 +23,36 @@ const CustomSBody sol_system[] = { 0, fixed(1,1), fixed(1,1), 288, fixed(1,1), fixed(167,10000), 0, fixed(1,1) }, + + { + "Mexico City", StarSystem::TYPE_STARPORT_SURFACE, + 3, 0, 0, 0, 0, 0, DEG2RAD(19) + }, + + { + "Shanghai", StarSystem::TYPE_STARPORT_SURFACE, + 3, 0, 0, 0, 0, 0, DEG2RAD(31) + }, + + { + "London", StarSystem::TYPE_STARPORT_SURFACE, + 3, 0, 0, 0, 0, 0, DEG2RAD(51) + }, + + { + "Moscow", StarSystem::TYPE_STARPORT_SURFACE, + 3, 0, 0, 0, 0, 0, DEG2RAD(55) + }, + + { + "Brasilia", StarSystem::TYPE_STARPORT_SURFACE, + 3, 0, 0, 0, 0, 0, DEG2RAD(-15.5) + }, + + { + "Los Angeles", StarSystem::TYPE_STARPORT_SURFACE, + 3, 0, 0, 0, 0, 0, DEG2RAD(34) + }, { "Moon", StarSystem::TYPE_PLANET_DWARF, @@ -62,13 +92,13 @@ const CustomSBody sol_system[] = { /* Moons of jupiter. */ { "Io", StarSystem::TYPE_PLANET_HIGHLY_VOLCANIC, - 6, fixed(286,1000), fixed(15,1000), 130, + 12, fixed(286,1000), fixed(15,1000), 130, fixed(282,100000), fixed(41,10000), DEG2RAD(2.21), fixed(177, 100) }, { "Europa", StarSystem::TYPE_PLANET_WATER, - 6, fixed(245,1000), fixed(8,1000), 102, + 12, fixed(245,1000), fixed(8,1000), 102, fixed(441,100000), fixed(9,1000), 0.0, fixed(355, 100) }, { 0 } diff --git a/src/l3d.h b/src/l3d.h index dbe1113..c0b87ff 100644 --- a/src/l3d.h +++ b/src/l3d.h @@ -40,6 +40,7 @@ class Frame; class L3D { public: static void Init(IniConfig& config); + static void Start(void); static void MainLoop(void); static void Quit(void); static float GetFrameTime(void) { return frameTime; } diff --git a/src/main.cpp b/src/main.cpp index d8fb78e..e0c7af3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -106,6 +106,8 @@ void L3D::Init(IniConfig& config) { dInitODE(); GLFTInit(); Space::Init(); + + Gui::Init(scrWidth, scrHeight, 800, 600); } void L3D::InitOpenGL() { @@ -212,60 +214,46 @@ void L3D::HandleEvents(void) { } } -void L3D::MainLoop(void) { +static void draw_intro(float _time) { + static float lightCol[4] = { 1, 1, 1, 0 }; + static float lightDir[4] = { 0, 1, 0, 0 }; + + static ObjParams params = { + { 0.5, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0.0f, 0.0f, 0.1f}, { 0.0f, 0.0f, 0.0f }, + /* pColor[3] */ + { + { { 1.0f, 1.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 }, + }, + { "LEPHISTO" }, + }; + glRotatef(_time*10, 1, 0, 0); + L3D::worldView->DrawBgStars(); + glPushAttrib(GL_ALL_ATTRIB_BITS); + sbreSetViewport(L3D::GetScrWidth(), L3D::GetScrHeight(), L3D::GetScrWidth()*0.5, 1.0f, 1000.0f, 0.0f, 1.0f); + sbreSetDirLight(lightCol, lightDir); + matrix4x4d rot = matrix4x4d::RotateYMatrix(_time) * matrix4x4d::RotateZMatrix(0.6*_time) * + matrix4x4d::RotateXMatrix(_time*.7); + Matrix m; + Vector p; + 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]; + p.x = 0; p.y = 0; p.z = 80; + sbreRenderModel(&p, &m, 61, ¶ms); + glPopAttrib(); +} + +void L3D::Start(void) { + player = new Player(ShipType::SLEEK); player->SetLabel("Me"); Space::AddBody(player); - StarSystem s(0, 0, 1); - HyperspaceTo(&s); - - const float zpos = EARTH_RADIUS * 3; - //Frame* pframe = *(++(++(Space::rootFrame->m_children.begin()))); - Frame* pframe = *(Space::rootFrame->m_children.begin()); - -#if 0 - Frame* stationFrame = new Frame(pframe, "Station frame.."); - stationFrame->SetRadius(5000); - stationFrame->m_sbody = 0; - stationFrame->SetPosition(vector3d(0, 0, zpos)); - stationFrame->SetAngVelocity(vector3d(0,0,0.5)); - - for(int i = 0; i < 4; i++) { - Ship* body = new Ship(ShipType::SLEEK/*LADYBIRD*/); - char buf[64]; - snprintf(buf, sizeof(buf), "X%c-0%02d", "A"+i, i); - body->SetLabel(buf); - body->SetFrame(stationFrame); - body->SetPosition(vector3d(200*(i+1), 0, 2000)); - Space::AddBody(body); - } - - SpaceStation* station = new SpaceStation(SpaceStation::JJHOOP); - station->SetLabel("Poemi-chan's Folly"); - station->SetFrame(stationFrame); - station->SetPosition(vector3d(0,0,0)); - Space::AddBody(station); - - SpaceStation* station2 = new SpaceStation(SpaceStation::GROUND_FLAVOURED); - station2->SetLabel("Dfighter's point"); - station2->SetFrame(*pframe->m_children.begin()); /* Rotating frame of planet. */ - station2->OrientOnSurface(EARTH_RADIUS, M_PI/4, M_PI/4); - Space::AddBody(station2); -#endif - - player->SetFrame(pframe); - //player->SetPosition(vector3d(0,0,0)); - //player->OrientOnSurface(EARTH_RADIUS*1.001, M_PI/4, M_PI/4); - //player->OrientOnSurface(EARTH_RADIUS*1.001, M_PI/4, M_PI/4); - player->SetPosition(vector3d(0, 0, EARTH_RADIUS)); - //player->SetPosition(vector3d(0,0,2000)); - //player->SetFrame(pframe); - - Gui::Init(scrWidth, scrHeight, 800, 600); - cpan = new ShipCpanel(); - cpan->ShowAll(); sectorView = new SectorView(); systemView = new SystemView(); @@ -275,8 +263,83 @@ void L3D::MainLoop(void) { spaceStationView = new SpaceStationView(); infoView = new InfoView(); + Gui::Fixed* splash = new Gui::Fixed(Gui::Screen::GetWidth(), Gui::Screen::GetHeight()); + Gui::Screen::AddBaseWidget(splash, 0, 0); + splash->SetTransparency(true); + + const float w = Gui::Screen::GetWidth() / 2; + const float h = Gui::Screen::GetHeight() / 2; + const int OPTS = 3; + Gui::ToggleButton* opts[OPTS]; + opts[0] = new Gui::ToggleButton(); opts[0]->SetShortcut(SDLK_1, KMOD_NONE); + opts[1] = new Gui::ToggleButton(); opts[1]->SetShortcut(SDLK_2, KMOD_NONE); + opts[2] = new Gui::ToggleButton(); opts[2]->SetShortcut(SDLK_3, KMOD_NONE); + splash->Add(opts[0], w, h+64); + splash->Add(new Gui::Label("New game starting on Earth"), w+32, h+64); + splash->Add(opts[1], w, h+32); + splash->Add(new Gui::Label("New game starting on debug point"), w+32, h+32); + splash->Add(opts[2], w, h); + splash->Add(new Gui::Label("Quit"), w+32, h); + + splash->ShowAll(); + + int choice = 0; + Uint32 last_time = SDL_GetTicks(); + float _time = 0; + do { + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glClearColor(0,0,0,0); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + L3D::HandleEvents(); + SDL_ShowCursor(1); + SDL_WM_GrabInput(SDL_GRAB_OFF); + + draw_intro(_time); + Gui::Draw(); + glFlush(); + SDL_GL_SwapBuffers(); + + L3D::frameTime = 0.001*(SDL_GetTicks() - last_time); + _time += L3D::frameTime; + last_time = SDL_GetTicks(); + + /* Poll ui instead of using callbacks. :D */ + for(int i = 0; i < OPTS; i++) if(opts[i]->GetPressed()) choice = i+1; + } while(!choice); + splash->HideAll(); + + if(choice == 1) { + /* Earth start point. */ + StarSystem s(0,0,0); + HyperspaceTo(&s); + //Frame* pframe = *(++(++(Space::rootFrame->m_children.begin()))); + //player->SetFrame(pframe); + /* TODO: There isn't a sensible way to find stations for a planet. */ + SpaceStation* station = 0; + for(Space::bodiesIter_t i = Space::bodies.begin(); i!=Space::bodies.end(); i++) { + if((*i)->GetType() == Object::SPACESTATION) { station = (SpaceStation*)*i; break; } + } + assert(station); + player->SetFrame(station->GetFrame()); + player->SetDockedWith(station, 0); + MainLoop(); + } else if(choice == 2) { + /* Debug start point. */ + StarSystem s(0,0,1); + HyperspaceTo(&s); + Frame* pframe = *(Space::rootFrame->m_children.begin()); + player->SetFrame(pframe); + player->SetPosition(vector3d(0,0,EARTH_RADIUS)); + MainLoop(); + } +} + +void L3D::MainLoop(void) { + cpan->ShowAll(); + SetView(worldView); - //player->SetDockedWith(station2, 0); Uint32 last_stats = SDL_GetTicks(); int frame_stat = 0; @@ -409,7 +472,8 @@ int main(int argc, char** argv) { IniConfig cfg("config.ini"); L3D::Init(cfg); - L3D::MainLoop(); + L3D::Start(); + L3D::Quit(); return 0; } diff --git a/src/star_system.cpp b/src/star_system.cpp index 250cc4f..e67e4db 100644 --- a/src/star_system.cpp +++ b/src/star_system.cpp @@ -630,6 +630,7 @@ void StarSystem::MakePlanetsAround(SBody* primary) { SBody* planet = new SBody; planet->type = TYPE_PLANET_DWARF; planet->seed = rand.Int32(); + planet->humanActivity = m_humanInfested * rand.Fixed(); planet->tmp = 0; planet->parent = primary; //planet->radius = EARTH_RADIUS*bodyTypeInfo[type].radius; @@ -769,6 +770,7 @@ void StarSystem::SBody::PickPlanetType(StarSystem* system, SBody* star, const fi moon->parent = this; //moon->radius = EARTH_RADIUS*bodyTypeInfo[type].radius; moon->rotationPeriod = fixed(rand.Int32(1,200), 24); + moon->humanActivity = system->m_humanInfested * rand.Fixed(); moon->mass = mass; fixed ecc = rand.NFixed(3); @@ -800,7 +802,7 @@ void StarSystem::SBody::PickPlanetType(StarSystem* system, SBody* star, const fi } /* Starports - orbital. */ if((genMoons) && (averageTemp < CELSIUS+100) && (averageTemp > 100) && - (rand.Fixed() < system->m_humanInfested)) { + (rand.Fixed() < humanActivity)) { SBody* sp = new SBody; sp->type = TYPE_STARPORT_ORBITAL; sp->seed = rand.Int32(); @@ -810,6 +812,7 @@ void StarSystem::SBody::PickPlanetType(StarSystem* system, SBody* star, const fi sp->averageTemp = this->averageTemp; sp->mass = 0; sp->name = "Starport"; + sp->humanActivity = humanActivity; fixed semiMajorAxis; if(children.size()) { semiMajorAxis = fixed(1,2) * children[0]->orbMin; @@ -824,7 +827,7 @@ void StarSystem::SBody::PickPlanetType(StarSystem* system, SBody* star, const fi sp->orbMin = semiMajorAxis; sp->orbMax = semiMajorAxis; - if(rand.Fixed() < system->m_humanInfested) { + if(rand.Fixed() < humanActivity) { SBody* sp2 = new SBody; *sp2 = *sp; sp2->orbit.rotMatrix = matrix4x4d::RotateZMatrix(M_PI); @@ -840,14 +843,18 @@ void StarSystem::SBody::PickPlanetType(StarSystem* system, SBody* star, const fi (type == TYPE_PLANET_METHANE) || (type == TYPE_PLANET_INDIGENOUS_LIFE)) { + fixed activ = humanActivity; + if(type == TYPE_PLANET_INDIGENOUS_LIFE) humanActivity *= 2; + int max = 6; - while((max-- > 0) && (rand.Fixed() < system->m_humanInfested)) { + while((max-- > 0) && (rand.Fixed() < activ)) { SBody* sp = new SBody; sp->type = TYPE_STARPORT_SURFACE; sp->seed = rand.Int32(); sp->tmp = 0; sp->parent = this; sp->averageTemp = this->averageTemp; + sp->humanActivity = activ; sp->mass = 0; sp->name = "Starport"; /* Used for orientation on planet surface. */ diff --git a/src/star_system.h b/src/star_system.h index c832080..7f7ad50 100644 --- a/src/star_system.h +++ b/src/star_system.h @@ -121,6 +121,7 @@ public: fixed mass; /* Earth masses if planet, solar masses if star. */ fixed orbMin, orbMax; /* Periapsism, Apoapsis in AUs. */ fixed rotationPeriod; /* In days. */ + fixed humanActivity; /* 0 - 1 */ int averageTemp; BodySuperType supertype; diff --git a/src/world_view.cpp b/src/world_view.cpp index 2dd4439..1a341c9 100644 --- a/src/world_view.cpp +++ b/src/world_view.cpp @@ -53,20 +53,20 @@ WorldView::WorldView(void): View() { glNewList(m_bgstarsDlist, GL_COMPILE); + glPushAttrib(GL_ENABLE_BIT); glDisable(GL_LIGHTING); glDisable(GL_DEPTH_TEST); glPointSize(1.0); glBegin(GL_POINTS); for(int i = 0; i < BG_STAR_MAX; i++) { - float col = 0.05+L3D::rng.NDouble(4); + float col = 0.05+L3D::rng.NDouble(3); col = CLAMP(col, 0, 1); glColor3f(col, col, col); glVertex3f(1000-L3D::rng.Double(2000.0), 1000-L3D::rng.Double(2000.0), 1000-L3D::rng.Double(2000.0)); } glEnd(); - glEnable(GL_DEPTH_TEST); - glEnable(GL_LIGHTING); + glPopAttrib(); glEndList(); } @@ -93,6 +93,10 @@ void WorldView::OnClickHyperspace(void) { } } +void WorldView::DrawBgStars(void) { + glCallList(m_bgstarsDlist); +} + void WorldView::Draw3D(void) { glMatrixMode(GL_PROJECTION); glLoadIdentity(); @@ -133,7 +137,7 @@ void WorldView::Draw3D(void) { trans2bg.ClearToRotOnly(); glPushMatrix(); glMultMatrixd(&trans2bg[0]); - glCallList(m_bgstarsDlist); + DrawBgStars(); glPopMatrix(); /* Position light at sol. */ matrix4x4d m; diff --git a/src/world_view.h b/src/world_view.h index ed71573..a5ff2e5 100644 --- a/src/world_view.h +++ b/src/world_view.h @@ -13,6 +13,7 @@ public: static const float PICK_OBJECT_RECT_SIZE; void UpdateCommsOptions(void); bool GetShowLabels(void) { return labelsOn; } + void DrawBgStars(void); private: Gui::Button* AddCommsOption(const std::string msg, int ypos); void OnClickHyperspace(void);