15 #include "windowFramework.h" 16 #include "pandaFramework.h" 17 #include "displayRegion.h" 18 #include "buttonThrower.h" 19 #include "transform2sg.h" 20 #include "dSearchPath.h" 23 #include "keyboardButton.h" 25 #include "geomTriangles.h" 26 #include "geomTristrips.h" 27 #include "geomVertexData.h" 28 #include "geomVertexFormat.h" 29 #include "geomVertexWriter.h" 30 #include "texturePool.h" 31 #include "textureAttrib.h" 32 #include "colorAttrib.h" 33 #include "perspectiveLens.h" 34 #include "orthographicLens.h" 35 #include "auto_bind.h" 36 #include "ambientLight.h" 37 #include "directionalLight.h" 38 #include "lightAttrib.h" 39 #include "boundingSphere.h" 40 #include "deg_2_rad.h" 41 #include "config_framework.h" 42 #include "cullFaceAttrib.h" 43 #include "rescaleNormalAttrib.h" 44 #include "shadeModelAttrib.h" 48 #include "texturePool.h" 49 #include "loaderFileTypeRegistry.h" 51 #include "virtualFileSystem.h" 52 #include "string_utils.h" 54 #include "staticTextFont.h" 55 #include "mouseButton.h" 59 #include "rock_floor.rgb_src.c" 64 #include "shuttle_controls.bam_src.c" 68 static const int override_priority = 100;
70 PT(
TextFont) WindowFramework::_shuttle_controls_font = NULL;
80 _panda_framework(panda_framework)
82 _got_keyboard =
false;
83 _got_trackball =
false;
85 _anim_controls_enabled =
false;
87 _wireframe_enabled =
false;
88 _wireframe_filled =
false;
89 _texture_enabled =
true;
90 _two_sided_enabled =
false;
91 _one_sided_reverse_enabled =
false;
92 _lighting_enabled =
false;
93 _perpixel_enabled =
false;
94 _background_type = BT_default;
104 _panda_framework(copy._panda_framework),
105 _window(copy._window),
106 _display_region_3d(display_region)
108 _got_keyboard =
false;
109 _got_trackball =
false;
111 _anim_controls_enabled =
false;
113 _wireframe_enabled =
false;
114 _texture_enabled =
true;
115 _two_sided_enabled =
false;
116 _one_sided_reverse_enabled =
false;
117 _lighting_enabled =
false;
118 _perpixel_enabled =
false;
119 _background_type = BT_default;
124 _display_region_3d->set_camera(camera_np);
149 static int next_window_index = 1;
151 stream <<
"window" << next_window_index;
153 string name = stream.str();
158 props, flags, gsg, NULL);
169 _window->set_clear_depth_active(
false);
170 _window->set_clear_stencil_active(
false);
174 _display_region_3d->set_camera(camera_np);
178 if (show_frame_rate_meter) {
180 _frame_rate_meter->setup_window(_window);
182 if (show_scene_graph_analyzer_meter) {
184 _scene_graph_analyzer_meter->setup_window(_window);
197 void WindowFramework::
207 _got_keyboard =
false;
208 _got_trackball =
false;
211 _wireframe_enabled =
false;
212 _texture_enabled =
true;
213 _two_sided_enabled =
false;
214 _one_sided_reverse_enabled =
false;
215 _lighting_enabled =
false;
216 _perpixel_enabled =
false;
219 _frame_rate_meter->clear_window();
240 return _camera_group;
254 _render.
node()->
set_attrib(ShadeModelAttrib::make(ShadeModelAttrib::M_smooth));
283 PN_stdfloat l, r, b, t;
284 _display_region_3d->get_dimensions(l, r, b, t);
285 _display_region_2d = _window->make_mono_display_region(l, r, b, t);
286 _display_region_2d->set_sort(10);
294 static const PN_stdfloat left = -1.0f;
295 static const PN_stdfloat right = 1.0f;
296 static const PN_stdfloat bottom = -1.0f;
297 static const PN_stdfloat top = 1.0f;
299 lens->set_film_offset((right + left) * 0.5, (top + bottom) * 0.5);
300 lens->set_near_far(-1000, 1000);
302 camera->set_lens(lens);
303 _display_region_2d->set_camera(camera_np);
324 if (mouse_node->
is_of_type(MouseWatcher::get_class_type())) {
328 PN_stdfloat this_aspect_ratio = aspect_ratio;
329 if (this_aspect_ratio == 0.0f) {
331 this_aspect_ratio = 1.0f;
333 if (_window->has_size()) {
334 int x_size = _window->get_sbs_left_x_size();
335 int y_size = _window->get_sbs_left_y_size();
337 this_aspect_ratio = (PN_stdfloat)x_size / (PN_stdfloat)y_size;
342 _aspect_2d.
set_scale(1.0f / this_aspect_ratio, 1.0f, 1.0f);
361 _pixel_2d.set_pos(-1, 0, 1);
363 if (_window->has_size()) {
364 int x_size = _window->get_sbs_left_x_size();
365 int y_size = _window->get_sbs_left_y_size();
367 _pixel_2d.set_sx(2.0f / (
float)x_size);
369 _pixel_2d.set_sy(1.0f);
371 _pixel_2d.set_sz(2.0f / (
float)y_size);
400 if (_window->get_side_by_side_stereo()) {
406 mw->set_display_region(_window->get_overlay_display_region());
422 return _button_thrower;
437 if (_window->is_of_type(GraphicsWindow::get_class_type()) &&
450 bt->set_modifier_buttons(mods);
454 _got_keyboard =
true;
464 if (_got_trackball) {
468 if (_window->is_of_type(GraphicsWindow::get_class_type()) &&
478 tball2cam->set_node(camera.
node());
479 _trackball->add_child(tball2cam);
482 _got_trackball =
true;
500 nassertv(volume->is_of_type(GeometricBoundingVolume::get_class_type()));
503 if (
object.has_parent()) {
504 CPT(TransformState) net_transform =
object.get_parent().get_net_transform();
506 new_gbv->xform(net_transform->get_mat());
511 if (gbv->is_infinite()) {
512 framework_cat.warning()
513 <<
"Infinite bounding volume for " <<
object <<
"\n";
517 if (gbv->is_empty()) {
518 framework_cat.warning()
519 <<
"Empty bounding volume for " <<
object <<
"\n";
526 if (!sphere->extend_by(gbv)) {
527 framework_cat.warning()
528 <<
"Cannot determine bounding volume of " <<
object <<
"\n";
532 LPoint3 center = sphere->get_center();
533 PN_stdfloat radius = sphere->get_radius();
535 PN_stdfloat distance = 50.0f;
541 if (!_cameras.empty()) {
542 Cameras::const_iterator ci;
543 for (ci = _cameras.begin();
544 ci != _cameras.end() && lens == (
Lens *)NULL;
546 lens = (*ci)->get_lens();
550 if (lens != (
Lens *)NULL) {
552 distance = radius / ctan(deg_2_rad(min(fov[0], fov[1]) / 2.0f));
555 PN_stdfloat ideal_far_plane = distance + radius * 1.5;
559 PN_stdfloat ideal_near_plane = distance - radius;
563 _trackball->set_origin(center);
568 _trackball->set_forward_scale(distance * 0.006);
585 for (
int i = first_arg; i < argc && argv[i] != (
char *)NULL; i++) {
606 for (fi = files.begin(); fi != files.end(); ++fi) {
626 framework_cat.info() <<
"Loading " << filename <<
"\n";
635 bool is_image =
false;
638 if (extension ==
"pz") {
645 if (!extension.empty()) {
652 if (extension ==
"txo" || downcase(extension) ==
"dds") {
668 options.set_flags(options.get_flags() | LoaderOptions::LF_search);
670 options.set_flags(options.get_flags() & ~
LoaderOptions::LF_search);
676 node = load_image_as_model(filename);
678 node = loader.load_sync(filename, options);
683 if (node == (
PandaNode *)NULL && !is_image && model_type == NULL) {
689 nout <<
"Unable to load " << filename <<
"\n";
706 CPT(
RenderState) state = RenderState::make_empty();
708 state = state->add_attrib(ColorAttrib::make_flat(
LColor(0.5, 0.5, 1.0, 1.0)));
712 string rock_floor_string((
const char *)rock_floor, rock_floor_len);
715 if (rock_floor_pnm.
read(rock_floor_strm,
"rock-floor.rgb")) {
717 tex->set_name(
"rock-floor.rgb");
718 tex->load(rock_floor_pnm);
719 tex->set_minfilter(SamplerState::FT_linear);
720 tex->set_magfilter(SamplerState::FT_linear);
721 state = state->add_attrib(TextureAttrib::make(tex));
727 (
"tri", GeomVertexFormat::get_v3n3cpt2(),
733 vertex.add_data3(LVertex::rfu(0.0, 0.0, 0.0));
734 vertex.add_data3(LVertex::rfu(1.0, 0.0, 0.0));
735 vertex.add_data3(LVertex::rfu(0.0, 0.0, 1.0));
741 texcoord.add_data2(0.0, 0.0);
742 texcoord.add_data2(1.0, 0.0);
743 texcoord.add_data2(0.0, 1.0);
746 tri->add_consecutive_vertices(0, 3);
747 tri->close_primitive();
750 geom->add_primitive(tri);
769 auto_bind(
get_render().node(), _anim_controls, hierarchy_match_flags);
785 double r = (double)rand() / (double)RAND_MAX;
803 if (_anim_controls_enabled) {
804 destroy_anim_controls();
819 create_anim_controls();
839 _anim_controls_enabled = enable;
840 if (_anim_controls_enabled) {
841 create_anim_controls();
844 destroy_anim_controls();
860 PN_stdfloat this_aspect_ratio = aspect_ratio;
862 int x_size = 0, y_size = 0;
863 if (_window->has_size()) {
864 x_size = _window->get_sbs_left_x_size();
865 y_size = _window->get_sbs_left_y_size();
868 if (this_aspect_ratio == 0.0f) {
870 this_aspect_ratio = 1.0f;
872 this_aspect_ratio = (float)x_size / (
float)y_size;
877 _aspect_2d.
set_scale(1.0f / this_aspect_ratio, 1.0f, 1.0f);
883 _pixel_2d.set_sx(2.0f / (
float)x_size);
885 _pixel_2d.set_sy(1.0f);
887 _pixel_2d.set_sz(2.0f / (
float)y_size);
891 Cameras::iterator ci;
892 for (ci = _cameras.begin(); ci != _cameras.end(); ++ci) {
893 Lens *lens = (*ci)->get_lens();
894 if (lens != (
Lens *)NULL) {
918 if (split_type == ST_default) {
922 if (_display_region_3d->get_pixel_width() >
923 _display_region_3d->get_pixel_height()) {
924 split_type = ST_horizontal;
926 split_type = ST_vertical;
930 PN_stdfloat left, right, bottom, top;
931 _display_region_3d->get_dimensions(left, right, bottom, top);
934 if (split_type == ST_vertical) {
935 _display_region_3d->
set_dimensions(left, right, bottom, (top + bottom) / 2.0f);
937 _display_region_2d->set_dimensions(left, right, bottom, (top + bottom) / 2.0f);
940 new_region->
set_dimensions(left, right, (top + bottom) / 2.0f, top);
943 _display_region_3d->set_dimensions(left, (left + right) / 2.0f, bottom, top);
945 _display_region_2d->set_dimensions(left, (left + right) / 2.0f, bottom, top);
948 new_region->
set_dimensions((left + right) / 2.0f, right, bottom, top);
952 _panda_framework->_windows.push_back(wf);
965 if (enable == _wireframe_enabled && filled == _wireframe_filled) {
971 if (!_two_sided_enabled) {
977 render.set_attrib(RenderModeAttrib::make(
978 RenderModeAttrib::M_filled_wireframe,
979 1.4f,
false,
LColor(1, 1, 1, .5f)),
991 if (_one_sided_reverse_enabled) {
992 CPT(
RenderAttrib) attrib = CullFaceAttrib::make_reverse();
998 _wireframe_enabled = enable;
999 _wireframe_filled = filled;
1010 if (enable == _texture_enabled) {
1022 _texture_enabled = enable;
1033 if (enable == _two_sided_enabled) {
1042 if (!_wireframe_enabled) {
1047 _two_sided_enabled = enable;
1048 _one_sided_reverse_enabled =
false;
1060 if (enable == _one_sided_reverse_enabled) {
1066 if (!_wireframe_enabled) {
1068 CPT(
RenderAttrib) attrib = CullFaceAttrib::make_reverse();
1075 _two_sided_enabled =
false;
1076 _one_sided_reverse_enabled = enable;
1086 if (enable == _lighting_enabled) {
1102 _lighting_enabled = enable;
1112 if (enable == _perpixel_enabled) {
1119 render.set_shader_auto();
1121 render.set_shader_off();
1124 _perpixel_enabled = enable;
1137 _background_type = type;
1143 switch (_background_type) {
1148 _display_region_3d->set_clear_color_active(
true);
1149 _display_region_3d->set_clear_depth_active(
true);
1150 _display_region_3d->set_clear_stencil_active(
true);
1151 _display_region_3d->set_clear_color(_window->get_clear_color());
1152 _display_region_3d->set_clear_depth(_window->get_clear_depth());
1153 _display_region_3d->set_clear_stencil(_window->get_clear_stencil());
1157 _display_region_3d->set_clear_color_active(
true);
1158 _display_region_3d->set_clear_depth_active(
true);
1159 _display_region_3d->set_clear_stencil_active(
true);
1160 _display_region_3d->set_clear_color(
LColor(0.0f, 0.0f, 0.0f, 0.0f));
1161 _display_region_3d->set_clear_depth(1.0f);
1162 _display_region_3d->set_clear_stencil(0);
1166 _display_region_3d->set_clear_color_active(
true);
1167 _display_region_3d->set_clear_depth_active(
true);
1168 _display_region_3d->set_clear_stencil_active(
true);
1169 _display_region_3d->set_clear_color(
LColor(0.3, 0.3, 0.3, 0.0f));
1170 _display_region_3d->set_clear_depth(1.0f);
1171 _display_region_3d->set_clear_stencil(0);
1175 _display_region_3d->set_clear_color_active(
true);
1176 _display_region_3d->set_clear_depth_active(
true);
1177 _display_region_3d->set_clear_stencil_active(
true);
1178 _display_region_3d->set_clear_color(
LColor(1.0f, 1.0f, 1.0f, 0.0f));
1179 _display_region_3d->set_clear_depth(1.0f);
1180 _display_region_3d->set_clear_stencil(0);
1184 _display_region_3d->set_clear_color_active(
false);
1185 _display_region_3d->set_clear_depth_active(
false);
1186 _display_region_3d->set_clear_stencil_active(
false);
1199 if (_shuttle_controls_font == (
TextFont *)NULL) {
1202 string shuttle_controls_string((
const char *)shuttle_controls, shuttle_controls_len);
1205 if (bam_file.
open_read(in,
"shuttle_controls font stream")) {
1206 PT(
PandaNode) node = bam_file.read_node();
1213 return _shuttle_controls_font;
1226 _cameras.push_back(camera);
1230 if (aspect_ratio != 0.0) {
1237 if (_window->has_size()) {
1238 int x_size = _window->get_sbs_left_x_size();
1239 int y_size = _window->get_sbs_left_y_size();
1246 camera->set_lens(lens);
1257 void WindowFramework::
1286 load_image_as_model(
const Filename &filename) {
1293 tex->set_minfilter(SamplerState::FT_linear_mipmap_linear);
1294 tex->set_magfilter(SamplerState::FT_linear);
1295 tex->set_wrap_u(SamplerState::WM_clamp);
1296 tex->set_wrap_v(SamplerState::WM_clamp);
1297 tex->set_wrap_w(SamplerState::WM_clamp);
1300 bool has_alpha =
true;
1301 LVecBase2 tex_scale = tex->get_tex_scale();
1305 int x_size = tex->get_orig_file_x_size();
1306 int y_size = tex->get_orig_file_y_size();
1309 PN_stdfloat left,right,top,bottom;
1310 static const PN_stdfloat scale = 10.0;
1311 if (x_size > y_size) {
1314 top = (scale * y_size) / x_size;
1315 bottom = -(scale * y_size) / x_size;
1316 }
else if (y_size != 0) {
1317 left = -(scale * x_size) / y_size;
1318 right = (scale * x_size) / y_size;
1322 framework_cat.warning()
1323 <<
"Texture size is 0 0: " << *tex <<
"\n";
1332 card_node->set_attrib(TextureAttrib::make(tex));
1334 card_node->set_attrib(TransparencyAttrib::make(TransparencyAttrib::M_alpha));
1338 if (tex->get_texture_type() == Texture::TT_3d_texture ||
1339 tex->get_texture_type() == Texture::TT_cube_map) {
1344 CPT(GeomVertexFormat) vformat;
1347 vformat = GeomVertexFormat::get_v3t2();
1351 vformat = GeomVertexFormat::register_format
1352 (
new GeomVertexArrayFormat
1353 (InternalName::get_vertex(), 3,
1354 GeomEnums::NT_stdfloat, GeomEnums::C_point,
1355 InternalName::get_texcoord(), 3,
1356 GeomEnums::NT_stdfloat, GeomEnums::C_texcoord));
1360 (
"card", vformat, Geom::UH_static);
1366 vertex.add_data3(LVertex::rfu(left, 0.02, top));
1367 vertex.add_data3(LVertex::rfu(left, 0.02, bottom));
1368 vertex.add_data3(LVertex::rfu(right, 0.02, top));
1369 vertex.add_data3(LVertex::rfu(right, 0.02, bottom));
1371 texcoord.add_data2(0.0f, tex_scale[1]);
1372 texcoord.add_data2(0.0f, 0.0f);
1373 texcoord.add_data2(tex_scale[0], tex_scale[1]);
1374 texcoord.add_data2(tex_scale[0], 0.0f);
1378 vertex.add_data3(-1.0f, -1.0f, 1.0f);
1379 vertex.add_data3(-1.0f, -1.0f, -1.0f);
1380 vertex.add_data3(1.0f, -1.0f, -1.0f);
1381 vertex.add_data3(1.0f, -1.0f, 1.0f);
1382 vertex.add_data3(1.0f, 1.0f, 1.0f);
1383 vertex.add_data3(1.0f, 1.0f, -1.0f);
1384 vertex.add_data3(-1.0f, 1.0f, -1.0f);
1385 vertex.add_data3(-1.0f, 1.0f, 1.0f);
1387 texcoord.add_data3(-1.0f, -1.0f, 1.0f);
1388 texcoord.add_data3(-1.0f, -1.0f, -1.0f);
1389 texcoord.add_data3(1.0f, -1.0f, -1.0f);
1390 texcoord.add_data3(1.0f, -1.0f, 1.0f);
1391 texcoord.add_data3(1.0f, 1.0f, 1.0f);
1392 texcoord.add_data3(1.0f, 1.0f, -1.0f);
1393 texcoord.add_data3(-1.0f, 1.0f, -1.0f);
1394 texcoord.add_data3(-1.0f, 1.0f, 1.0f);
1401 strip->add_consecutive_vertices(0, 4);
1402 strip->close_primitive();
1406 strip->add_vertex(7);
1407 strip->add_vertex(0);
1408 strip->add_vertex(4);
1409 strip->add_vertex(3);
1410 strip->close_primitive();
1412 strip->add_vertex(1);
1413 strip->add_vertex(6);
1414 strip->add_vertex(2);
1415 strip->add_vertex(5);
1416 strip->close_primitive();
1418 strip->add_vertex(5);
1419 strip->add_vertex(4);
1420 strip->add_vertex(2);
1421 strip->add_vertex(3);
1422 strip->add_vertex(1);
1423 strip->add_vertex(0);
1424 strip->add_vertex(6);
1425 strip->add_vertex(7);
1426 strip->add_vertex(5);
1427 strip->add_vertex(4);
1428 strip->close_primitive();
1432 geom->add_primitive(strip);
1434 card_node->add_geom(geom);
1436 return card_node.p();
1445 void WindowFramework::
1446 create_anim_controls() {
1447 destroy_anim_controls();
1451 style.
set_type(PGFrameStyle::T_flat);
1453 group->set_frame(-1.0f, 1.0f, 0.0f, 0.2);
1454 group->set_frame_style(0, style);
1455 group->set_suppress_flags(MouseWatcherRegion::SF_mouse_button);
1456 group->set_active(
true);
1459 _anim_controls_group.set_pos(0.0f, 0.0f, -0.9f);
1463 label->set_align(TextNode::A_center);
1464 label->set_text(
"No animation.");
1466 tnp.set_pos(0.0f, 0.0f, 0.07f);
1483 label->set_align(TextNode::A_center);
1484 label->set_text(text.str());
1486 tnp.set_pos(0.0f, 0.0f, 0.07f);
1493 label->set_align(TextNode::A_left);
1496 tnp.set_pos(-0.95f, 0.0f, 0.15f);
1500 _anim_slider->setup_slider(
false, 1.9f, 0.1f, 0.005f);
1501 _anim_slider->set_suppress_flags(MouseWatcherRegion::SF_mouse_button);
1502 _anim_slider->get_thumb_button()->set_suppress_flags(MouseWatcherRegion::SF_mouse_button);
1504 _anim_slider->set_range(0.0f, (PN_stdfloat)(control->
get_num_frames() - 1));
1505 _anim_slider->set_scroll_size(0.0f);
1506 _anim_slider->set_page_size(1.0f);
1508 snp.set_pos(0.0f, 0.0f, 0.06f);
1510 _frame_number =
new TextNode(
"frame_number");
1511 _frame_number->set_text_color(0.0f, 0.0f, 0.0f, 1.0f);
1512 _frame_number->set_align(TextNode::A_center);
1513 _frame_number->set_text(format_string(control->
get_frame()));
1514 NodePath fnp =
NodePath(_anim_slider->get_thumb_button()).attach_new_node(_frame_number);
1516 fnp.set_pos(0.0f, 0.0f, -0.01f);
1518 _play_rate_slider =
new PGSliderBar(
"play_rate_slider");
1519 _play_rate_slider->setup_slider(
false, 0.4, 0.05f, 0.005f);
1520 _play_rate_slider->set_suppress_flags(MouseWatcherRegion::SF_mouse_button);
1521 _play_rate_slider->get_thumb_button()->set_suppress_flags(MouseWatcherRegion::SF_mouse_button);
1524 pnp.set_pos(0.75f, 0.0f, 0.15f);
1528 setup_shuttle_button(
"9", 0, st_back_button);
1529 setup_shuttle_button(
";", 1, st_pause_button);
1530 setup_shuttle_button(
"4", 2, st_play_button);
1531 setup_shuttle_button(
":", 3, st_forward_button);
1533 _update_anim_controls_task =
new GenericAsyncTask(
"controls", st_update_anim_controls, (
void *)
this);
1542 void WindowFramework::
1543 destroy_anim_controls() {
1544 if (!_anim_controls_group.
is_empty()) {
1548 if (_update_anim_controls_task != NULL) {
1550 _update_anim_controls_task.clear();
1561 void WindowFramework::
1562 update_anim_controls() {
1566 if (_anim_slider != NULL) {
1567 if (_anim_slider->is_button_down()) {
1568 control->
pose((
int)(_anim_slider->get_value() + 0.5));
1570 _anim_slider->set_value((PN_stdfloat)control->
get_frame());
1574 if (_frame_number != NULL) {
1575 _frame_number->set_text(format_string(control->
get_frame()));
1587 void WindowFramework::
1588 setup_shuttle_button(
const string &label,
int index,
1589 EventHandler::EventCallbackFunction *func) {
1591 button->set_frame(-0.05f, 0.05f, 0.0f, 0.07f);
1593 PN_stdfloat bevel = 0.005f;
1596 style.
set_color(0.8f, 0.8f, 0.8f, 1.0f);
1599 style.
set_type(PGFrameStyle::T_bevel_out);
1600 button->set_frame_style(PGButton::S_ready, style);
1602 style.
set_type(PGFrameStyle::T_bevel_in);
1603 button->set_frame_style(PGButton::S_depressed, style);
1605 style.
set_color(0.9f, 0.9f, 0.9f, 1.0f);
1606 style.
set_type(PGFrameStyle::T_bevel_out);
1607 button->set_frame_style(PGButton::S_rollover, style);
1611 tn->set_align(TextNode::A_center);
1613 tn->set_text(label);
1614 tn->set_text_color(0.0f, 0.0f, 0.0f, 1.0f);
1617 tn->set_transform(xform);
1619 button->get_state_def(PGButton::S_ready).attach_new_node(tn);
1620 button->get_state_def(PGButton::S_depressed).attach_new_node(tn);
1621 button->get_state_def(PGButton::S_rollover).attach_new_node(tn);
1625 np.set_pos(0.1f * index - 0.15f, 0.0f, 0.12);
1635 void WindowFramework::
1647 void WindowFramework::
1659 void WindowFramework::
1663 control->
loop(
false);
1671 void WindowFramework::
1684 AsyncTask::DoneStatus WindowFramework::
1687 self->update_anim_controls();
1688 return AsyncTask::DS_cont;
1697 void WindowFramework::
1698 st_back_button(
const Event *,
void *data) {
1700 self->back_button();
1708 void WindowFramework::
1709 st_pause_button(
const Event *,
void *data) {
1711 self->pause_button();
1719 void WindowFramework::
1720 st_play_button(
const Event *,
void *data) {
1722 self->play_button();
1730 void WindowFramework::
1731 st_forward_button(
const Event *,
void *data) {
1733 self->forward_button();
The principle public interface to reading and writing Bam disk files.
A light shining from infinitely far away in a particular direction, like sunlight.
void clear_two_sided()
Completely removes any two-sided adjustment that may have been set on this node via set_two_sided()...
The "top" node of the new Panda GUI system.
This TFormer maintains a list of rectangular regions on the screen that are considered special mouse ...
void set_depth_test(bool depth_test, int priority=0)
Specifically sets or disables the testing of the depth buffer on this particular node.
A basic node of the scene graph or data graph.
This object provides a high-level interface for quickly writing a sequence of numeric values from a v...
NodePath get_render_2d()
Returns the root of the 2-d scene graph.
void set_width(PN_stdfloat x, PN_stdfloat y)
Sets the width parameter, which has meaning only for certain frame types.
void stagger_animations()
Walks through all the animations that were bound by loop_animations() and staggers their play rate sl...
This is the base class for all three-component vectors and points.
bool open_read(const Filename &bam_filename, bool report_errors=true)
Attempts to open the indicated filename for reading.
This is a special TextNode that automatically updates itself with output from a SceneGraphAnalyzer in...
bool remove(AsyncTask *task)
Removes the indicated task from the active queue.
The name of this class derives from the fact that we originally implemented it as a layer on top of t...
void loop_animations(int hierarchy_match_flags=PartGroup::HMF_ok_part_extra|PartGroup::HMF_ok_anim_extra)
Looks for characters and their matching animation files in the scene graph; binds and loops any match...
This is the base class for a number of render attributes (other than transform) that may be set on sc...
static LMatrix4f scale_mat(const LVecBase3f &scale)
Returns a matrix that applies the indicated scale in each of the three axes.
void set_perpixel(bool enable)
Turns per-pixel lighting on (true) or off (false).
A base class for any number of different kinds of lenses, linear and otherwise.
NodePath get_pixel_2d()
Returns a special root that uses units in pixels that are relative to the window. ...
This is the base class for all the various kinds of gui widget objects.
void set_depth_write(bool depth_write, int priority=0)
Specifically sets or disables the writing to the depth buffer on this particular node.
An optional parameter associated with an event.
NodePath get_render()
Returns the root of the 3-d scene graph.
bool is_empty() const
Returns true if the NodePath contains no nodes.
Specifies parameters that may be passed to the loader.
void clear_window()
Undoes the effect of a previous call to setup_window().
void set_far(PN_stdfloat far_distance)
Defines the position of the far plane (or cylinder, sphere, whatever).
A hierarchy of directories and files that appears to be one continuous file system, even though the files may originate from several different sources that may not be related to the actual OS's file system.
NodePath get_aspect_2d()
Returns the node under the 2-d scene graph that is scaled to suit the window's aspect ratio...
static LoaderFileTypeRegistry * get_global_ptr()
Returns a pointer to the global LoaderFileTypeRegistry object.
const LVecBase2 & get_fov() const
Returns the horizontal and vertical film size of the virtual film.
This defines a bounding sphere, consisting of a center and a radius.
void set_film_size(PN_stdfloat width)
Sets the horizontal size of the film without changing its shape.
void set_dimensions(PN_stdfloat l, PN_stdfloat r, PN_stdfloat b, PN_stdfloat t)
Changes the portion of the framebuffer this DisplayRegion corresponds to.
bool read(const Filename &filename, PNMFileType *type=NULL, bool report_unknown_type=true)
Reads the indicated image filename.
void set_scale(PN_stdfloat scale)
Sets the scale component of the transform, leaving translation and rotation untouched.
Represents a texture object, which is typically a single 2-d image but may also represent a 1-d or 3-...
bool add_hook(const string &event_name, EventFunction *function)
Adds the indicated function to the list of those that will be called when the named event is thrown...
void loop(bool restart)
Starts the entire animation looping.
This encapsulates the data that is normally associated with a single window, or with a single display...
void set_type(Type type)
Sets the basic type of frame.
void set_clear_color_active(bool clear_color_active)
Toggles the flag that indicates whether the color buffer should be cleared every frame.
Trackball acts like Performer in trackball mode.
A convenient class for loading models from disk, in bam or egg format (or any of a number of other fo...
void set_anim_controls(bool enable)
Creates an onscreen animation slider for frame-stepping through the animations.
void set_lighting(bool enable)
Turns lighting on (true) or off (false).
Defines a series of triangle strips.
A light source that seems to illuminate all points in space at once.
void stop()
Stops a currently playing or looping animation right where it is.
This is a three-component point in space (as opposed to a three-component vector, which represents a ...
void loop_all(bool restart)
Starts all animations looping.
string get_anim_name(int n) const
Returns the name of the nth AnimControl associated with this collection.
bool is_fully_qualified() const
Returns true if the filename is fully qualified, e.g.
string get_extension() const
Returns the file extension.
void set_play_rate(double play_rate)
Changes the rate at which the animation plays.
NodePath load_default_model(const NodePath &parent)
Loads our favorite blue triangle.
DisplayRegion * make_display_region()
Creates a new DisplayRegion that covers the entire window.
GraphicsOutput * get_window() const
Returns the GraphicsOutput that this DisplayRegion is ultimately associated with, or NULL if no windo...
static LVector3f back(CoordinateSystem cs=CS_default)
Returns the back vector for the given coordinate system.
static PN_stdfloat get_default_far()
Returns the default far plane distance that will be assigned to each newly-created lens...
A window, fullscreen or on a desktop, into which a graphics device sends its output for interactive d...
void set_wireframe(bool enable, bool filled=false)
Forces wireframe state (true) or restores default rendering (false).
void set_one_sided_reverse(bool enable)
Toggles one-sided reverse mode.
static LVector3f forward(CoordinateSystem cs=CS_default)
Returns the forward vector for the given coordinate system.
An encapsulation of a font; i.e.
void set_aspect_ratio(PN_stdfloat aspect_ratio)
Sets the aspect ratio of the lens.
NodePath get_mouse()
Returns the node in the data graph corresponding to the mouse associated with this window...
This is an abstract class for any volume in any sense which can be said to define the locality of ref...
void clear_light()
Completely removes any lighting operations that may have been set via set_light() or set_light_off() ...
A StaticTextFont is loaded up from a model that was previously generated via egg-mkfont, and contains all of its glyphs already generated and available for use.
NodePath load_model(const NodePath &parent, Filename filename)
Loads up the indicated model and returns the new NodePath, or the empty NodePath if the model could n...
AnimControl * get_anim(int n) const
Returns the nth AnimControl associated with this collection.
This is another abstract class, for a general class of bounding volumes that actually enclose points ...
A container for the various kinds of properties we might ask to have on a graphics window before we o...
bool exists(const Filename &filename) const
Convenience function; returns true if the named file exists.
NodePath get_mouse(GraphicsOutput *window)
Returns a NodePath to the MouseAndKeyboard associated with the indicated GraphicsWindow object...
bool remove_hooks_with(void *data)
Removes all CallbackFunction hooks that have the indicated pointer as the associated data pointer...
The name of a file, such as a texture file or an Egg file.
void set_two_sided(bool enable)
Forces two-sided rendering (true) or restores default rendering (false).
void add(AsyncTask *task)
Adds the indicated task to the active queue.
NodePath attach_new_node(PandaNode *node, int sort=0, Thread *current_thread=Thread::get_current_thread()) const
Attaches a new node, with or without existing parents, to the scene graph below the referenced node o...
This is a 4-by-4 transform matrix.
void adjust_dimensions()
Reevaluates the dimensions of the window, presumably after the window has been resized by the user or...
MakeTextureFunc * get_texture_type(const string &extension) const
Returns the factory function to construct a new texture of the type appropriate for the indicated fil...
void center_trackball(const NodePath &object)
Centers the trackball on the indicated object, and scales the trackball motion suitably.
void set_color(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a)
Sets the dominant color of the frame.
A perspective-type lens: a normal camera.
void clear_render_mode()
Completely removes any render mode adjustment that may have been set on this node via set_render_mode...
void next_anim_control()
Rotates the animation controls through all of the available animations.
This defines the actual numeric vertex data stored in a Geom, in the structure defined by a particula...
An object to create GraphicsOutputs that share a particular 3-D API.
LoaderFileType * get_type_from_extension(const string &extension)
Determines the type of the file based on the indicated extension (without a leading dot)...
static VirtualFileSystem * get_global_ptr()
Returns the default global VirtualFileSystem.
A container for geometry primitives.
This is the base class for all two-component vectors and points.
Associates a generic C-style function pointer with an AsyncTask object.
void clear_color_scale()
Completely removes any color scale from the referenced node.
static PN_stdfloat get_default_near()
Returns the default near plane distance that will be assigned to each newly-created lens...
void enable_keyboard()
Creates a ButtonThrower to listen to button presses and throw them as events.
NodePath make_camera()
Makes a new 3-d camera for the window.
static Texture * load_texture(const Filename &filename, int primary_file_num_channels=0, bool read_mipmaps=false, const LoaderOptions &options=LoaderOptions())
Loads the given filename up into a texture, if it has not already been loaded, and returns the new te...
int get_num_anims() const
Returns the number of AnimControls associated with this collection.
AsyncTaskManager & get_task_mgr()
Returns the Task Manager object that manages tasks in the framework.
This class maintains the set of all known LoaderFileTypes in the universe.
string get_basename_wo_extension() const
Returns the basename part of the filename, without the file extension.
void clear_texture()
Completely removes any texture adjustment that may have been set via set_texture() or set_texture_off...
void clear()
Sets this NodePath to the empty NodePath.
This is a base class for the various different classes that represent the result of a frame of render...
GraphicsOutput * make_output(GraphicsPipe *pipe, const string &name, int sort, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, GraphicsStateGuardian *gsg=NULL, GraphicsOutput *host=NULL)
Creates a new window (or buffer) and returns it.
static TexturePool * get_global_ptr()
Initializes and/or returns the global pointer to the one TexturePool object in the system...
void set_attrib(const RenderAttrib *attrib, int override=0)
Adds the indicated render attribute to the scene graph on this node.
This represents a unique collection of RenderAttrib objects that correspond to a particular renderabl...
void set_light(const NodePath &light, int priority=0)
Adds the indicated Light or PolylightNode to the list of lights that illuminate geometry at this node...
static TextFont * get_shuttle_controls_font()
Returns a font that contains the shuttle controls icons.
This is the base class for all three-component vectors and points.
void set_background_type(BackgroundType type)
Sets the background of the window to one of the pre-canned background types (or to BT_other...
void set_texture_off(int priority=0)
Sets the geometry at this level and below to render using no texture, on any stage.
static NodePath not_found()
Creates a NodePath with the ET_not_found error type set.
EventHandler & get_event_handler()
Returns the EventHandler object that serves events in the framework.
void set_hpr(PN_stdfloat h, PN_stdfloat p, PN_stdfloat r)
Sets the rotation component of the transform, leaving translation and scale untouched.
void set_render_mode_wireframe(int priority=0)
Sets up the geometry at this level and below (unless overridden) to render in wireframe mode...
PandaNode * node() const
Returns the referenced node of the path.
void set_texture(bool enable)
Forces textures off (false) or restores default rendering (true).
NodePath get_button_thrower()
Returns the node in the data graph corresponding to the ButtonThrower object associated with this win...
This is the base class for a family of scene-graph file types that the Loader supports.
A named event, possibly with parameters.
void remove_node(Thread *current_thread=Thread::get_current_thread())
Disconnects the referenced node from the scene graph.
bool load_models(const NodePath &parent, int argc, char *argv[], int first_arg=1)
Loads up all the model files listed in the indicated argument list.
void set_material_off(int priority=0)
Sets the geometry at this level and below to render using no material.
The primary interface to this module.
Encapsulates all the communication with a particular instance of a given rendering backend...
This is a special TextNode that automatically updates itself with the current frame rate...
Defines a series of disconnected triangles.
virtual int get_num_frames() const
Returns the number of frames in the animation.
void pose(double frame)
Sets the animation to the indicated frame and holds it there.
WindowFramework * split_window(SplitType split_type=ST_default)
Divides the window into two display regions, each of which gets its own trackball and keyboard events...
Controls the timing of a character animation.
A rectangular subregion within a window for rendering into.
bool is_of_type(TypeHandle handle) const
Returns true if the current object is or derives from the indicated type.
void set_row(int row, const LVecBase4f &v)
Replaces the indicated row of the matrix.
double get_play_rate() const
Returns the rate at which the animation plays.
This class serves to provide a high-level framework for basic applications that use Panda in simple w...
This class is the main interface to controlling the render process.
void setup_trackball()
Sets up the mouse to trackball around the camera.
This is the preferred interface for loading textures from image files.
TypeHandle is the identifier used to differentiate C++ class types.
A container for the various kinds of properties we might ask to have on a graphics frameBuffer before...
A node that can be positioned around in the scene graph to represent a point of view for rendering a ...
void write_texture_types(ostream &out, int indent_level) const
Outputs a list of the available texture types to the indicated output stream.
int get_frame() const
Returns the current integer frame number.
NodePath get_camera_group()
Returns the node above the collection of 3-d cameras in the scene graph.
void set_two_sided(bool two_sided, int priority=0)
Specifically sets or disables two-sided rendering mode on this particular node.
void set_color(const LColor &color)
Sets the basic color of the light.
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
A node that holds Geom objects, renderable pieces of geometry.
void set_color_scale(const LVecBase4 &scale, int priority=0)
Sets the color scale component of the transform, leaving translation and rotation untouched...
void add_geom(Geom *geom, const RenderState *state=RenderState::make_empty())
Adds a new Geom to the node.
void set_mouse_watcher(MouseWatcher *watcher)
Sets the MouseWatcher pointer that the PGTop object registers its PG items with.
void set_near(PN_stdfloat near_distance)
Defines the position of the near plane (or cylinder, sphere, whatever).
This is a particular kind of PGItem that draws a little bar with a slider that moves from left to rig...
static Filename from_os_specific(const string &os_specific, Type type=T_general)
This named constructor returns a Panda-style filename (that is, using forward slashes, and no drive letter) based on the supplied filename string that describes a filename in the local system conventions (for instance, on Windows, it may use backslashes or begin with a drive letter and a colon).