int main(int argc, char *argv[])
   {
   // setup Panda3d
   PandaFramework pandaFramework;
   pandaFramework.open_framework(argc, argv);
   PT(WindowFramework) windowFramework = pandaFramework.open_window();
   if(windowFramework == NULL)
      {
      nout << "ERROR: could not open the WindowFramework." << endl;
      return 1; // error
      }

   // Note: optional, reduce CPU use when the window is minimized.
   SleepWhenMinimized sleepWhenMinimized(windowFramework);

   // Make an instance of our class
   World world(windowFramework);

   // and run the world
   pandaFramework.main_loop();

   // quit Panda3d
   pandaFramework.close_framework();
   return 0; // success
   }
int main(int argc, char *argv[])
   {
   // setup Panda3d
   PandaFramework pandaFramework;
   pandaFramework.open_framework(argc, argv);
   PT(WindowFramework) windowFrameworkPtr = pandaFramework.open_window();
   if(windowFrameworkPtr == NULL)
      {
      nout << "ERROR: could not open the WindowFramework." << endl;
      return 1; // error
      }

   // Tell Panda3D to use OpenAL, not FMOD
   load_prc_file_data("", "audio-library-name p3openal_audio");

   // Create an instance of our class
   World world(windowFrameworkPtr);

   // Run the simulation
   pandaFramework.main_loop();

   // quit Panda3d
   pandaFramework.close_framework();
   return 0; // success
   }
Esempio n. 3
0
void
TestScene3::runPanda(int argc, char** argv)
{
	// initialize framework
	PandaFramework framework;
	framework.open_framework(argc, argv);
	// open window
	WindowProperties windowProp;
	framework.get_default_window_props(windowProp);
	windowProp.set_size(800, 600);
	auto window = framework.open_window(windowProp, GraphicsPipe::BF_require_window);
	// adjust camera
	auto camera = window->get_camera_group();
	camera.set_pos(2000, -2000, 2000);
	camera.look_at(0, 0, 0);
	// loop
	framework.main_loop();
}
int main(int argc, char *argv[])
   {
   // setup Panda3d
   PandaFramework pandaFramework;
   pandaFramework.open_framework(argc, argv);
   PT(WindowFramework) windowFrameworkPtr = pandaFramework.open_window();
   if(windowFrameworkPtr == NULL)
      {
      nout << "ERROR: could not open the WindowFramework." << endl;
      return 1; // error
      }

   // Create an instance of our class
   World world(windowFrameworkPtr);

   // Run the simulation
   pandaFramework.main_loop();

   // quit Panda3d
   pandaFramework.close_framework();
   return 0; // success
   }
Esempio n. 5
0
void
TestScene5::runPanda(int argc, char** argv)
{
	// initialize framework
	PandaFramework framework;
	framework.open_framework(argc, argv);
	// open window
	WindowProperties windowProp;
	framework.get_default_window_props(windowProp);
	windowProp.set_size(800, 600);
	auto window = framework.open_window(windowProp, GraphicsPipe::BF_require_window);
	// adjust camera
	auto camera = window->get_camera_group();
	camera.set_pos(2000, -2000, 2000);
	camera.look_at(LPoint3(0, 0, 0));
	// load & integrate model
	auto model = window->load_model(framework.get_models(), "panda-model");
	model.set_pos(-2000, 2000, -2000);
	model.reparent_to(window->get_render());
	// loop
	framework.main_loop();
}
Esempio n. 6
0
// The initialization method caused when a world object is created
World6::World6(WindowFramework* windowFrameworkPtr)
   : m_windowFramework(windowFrameworkPtr),
     m_title("title", COnscreenText::TS_plain),
     m_sizescale(1),
     m_sky(),
     m_skyTex(NULL),
     m_sun(),
     m_sunTex(NULL),
     m_orbitscale(1),
     m_orbitRootMercury(),
     m_orbitRootVenus(),
     m_orbitRootMars(),
     m_orbitRootEarth(),
     m_orbitRootMoon(),
     m_mercury(),
     m_mercuryTex(NULL),
     m_venus(),
     m_venusTex(NULL),
     m_mars(),
     m_marsTex(NULL),
     m_earth(),
     m_earthTex(NULL),
     m_moon(),
     m_moonTex(NULL),
     m_yearscale(1),
     m_dayscale(1),
     m_dayPeriodSun(NULL),
     m_orbitPeriodMercury(NULL),
     m_dayPeriodMercury(NULL),
     m_orbitPeriodVenus(NULL),
     m_dayPeriodVenus(NULL),
     m_orbitPeriodEarth(NULL),
     m_dayPeriodEarth(NULL),
     m_orbitPeriodMoon(NULL),
     m_dayPeriodMoon(NULL),
     m_orbitPeriodMars(NULL),
     m_dayPeriodMars(NULL),
     m_mouse1EventText("label"),
     m_skeyEventText("label"),
     m_ykeyEventText("label"),
     m_vkeyEventText("label"),
     m_ekeyEventText("label"),
     m_mkeyEventText("label"),
     m_yearCounterText("label"),
     m_yearCounter(0),
     m_simRunning(true)
   {
   // The standard camera position and background initialization
   m_windowFramework->get_graphics_window()->get_active_display_region(0)->
      set_clear_color(Colorf(0, 0, 0, 0));
   // base.disableMouse() // Note: mouse ain't enable by default in C++
   NodePath camera = m_windowFramework->get_camera_group();
   camera.set_pos(0, 0, 45);
   camera.set_hpr(0, -90, 0);

   // The global variables we used to control the speed and size of objects
   m_yearscale = 60;
   m_dayscale = m_yearscale / 365.0 * 5;
   m_orbitscale = 10;
   m_sizescale = 0.6;

   load_planets();            // Load, texture, and position the planets
   rotate_planets();          // Set up the motion to start them moving

   // The standard title text that's in every tutorial
   // Things to note:
   // -fg represents the forground color of the text in (r,g,b,a) format
   // -pos  represents the position of the text on the screen.
   //       The coordinate system is a x-y based wih 0,0 as the center of the
   //       screen
   // -align sets the alingment of the text relative to the pos argument.
   //       Default is center align.
   // -scale set the scale of the text
   // -mayChange argument lets us change the text later in the program.
   //        By default mayChange is set to 0. Trying to change text when
   //        mayChange is set to 0 will cause the program to crash.
   m_title.set_text("Panda3D: Tutorial 1 - Solar System");
   m_title.set_fg(Colorf(1, 1, 1, 1));
   m_title.set_pos(LVecBase2f(0.8, -0.95));
   m_title.set_scale(0.07);
   m_title.reparent_to(m_windowFramework->get_aspect_2d());
   m_mouse1EventText = gen_label_text(
     "Mouse Button 1: Toggle entire Solar System [RUNNING]", 0);
   m_skeyEventText = gen_label_text("[S]: Toggle Sun [RUNNING]", 1);
   m_ykeyEventText = gen_label_text("[Y]: Toggle Mercury [RUNNING]", 2);
   m_vkeyEventText = gen_label_text("[V]: Toggle Venus [RUNNING]", 3);
   m_ekeyEventText = gen_label_text("[E]: Toggle Earth [RUNNING]", 4);
   m_mkeyEventText = gen_label_text("[M]: Toggle Mars [RUNNING]", 5);
   m_yearCounterText = gen_label_text("0 Earth years completed", 6);

   m_yearCounter = 0;            // year counter for earth years
   m_simRunning = true;          // boolean to keep track of the
                                    // state of the global simulation

   // Events
   // Each self.accept statement creates an event handler object that will call
   // the specified function when that event occurs.
   // Certain events like "mouse1", "a", "b", "c" ... "z", "1", "2", "3"..."0"
   // are references to keyboard keys and mouse buttons. You can also define
   // your own events to be used within your program. In this tutorial, the
   // event "newYear" is not tied to a physical input device, but rather
   // is sent by the function that rotates the Earth whenever a revolution
   // completes to tell the counter to update
   // Note: need to listen to input events
   m_windowFramework->enable_keyboard();
   PandaFramework* pfw = m_windowFramework->get_panda_framework();
   // Exit the program when escape is pressed
   pfw->define_key("escape", "sysExit", sys_exit, NULL);
   pfw->define_key("mouse1", "handleMouseClick", call_handle_mouse_click, this);
   pfw->define_key("e", "handleEarth", call_handle_earth, this);
   pfw->define_key("s",                   // message name
         "togglePlanetSun",           // Note: event description
         call_toggle_planet<P_sun>,   // function to call
         this);                       // arguments to be passed to togglePlanet
                                      // See togglePlanet's definition below for
                                      // an explanation of what they are
   // Repeat the structure above for the other planets
   pfw->define_key("y", "togglePlanetMercury",
      call_toggle_planet<P_mercury>, this);
   pfw->define_key("v", "togglePlanetVenus",
      call_toggle_planet<P_venus>, this);
   pfw->define_key("m", "togglePlanetMars",
      call_toggle_planet<P_mars>, this);
   EventHandler::get_global_event_handler()->add_hook("newYear",
                                                       call_inc_year,
                                                       this);
   }