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;
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();
223 _scene_graph_analyzer_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);
290 NodePath camera_np = _render_2d.attach_new_node(camera);
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;
298 lens->set_film_size(right - left, top - bottom);
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);
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()) {
422 return _button_thrower;
437 if (_window->is_of_type(GraphicsWindow::get_class_type()) &&
450 bt->set_modifier_buttons(mods);
451 _button_thrower = mouse.attach_new_node(bt);
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;
503 if (
object.has_parent()) {
504 CPT(TransformState) net_transform =
object.get_parent().get_net_transform();
505 PT(GeometricBoundingVolume) new_gbv = DCAST(GeometricBoundingVolume, gbv->make_copy());
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") {
642 if (!extension.empty()) {
649 if (extension ==
"txo" || downcase(extension) ==
"dds") {
666 options.set_flags(options.get_flags() | LoaderOptions::LF_search);
668 options.set_flags(options.get_flags() & ~
LoaderOptions::LF_search);
674 node = load_image_as_model(filename);
676 node = loader.load_sync(filename, options);
680 nout <<
"Unable to load " << filename <<
"\n";
703 string rock_floor_string((const
char *)rock_floor, rock_floor_len);
706 if (rock_floor_pnm.read(rock_floor_strm, "rock-floor.rgb")) {
708 tex->set_name("rock-floor.rgb");
709 tex->load(rock_floor_pnm);
718 ("tri", GeomVertexFormat::get_v3n3cpt2(),
724 vertex.add_data3(LVertex::rfu(0.0, 0.0, 0.0));
725 vertex.add_data3(LVertex::rfu(1.0, 0.0, 0.0));
726 vertex.add_data3(LVertex::rfu(0.0, 0.0, 1.0));
728 normal.add_data3(
LNormal::back());
729 normal.add_data3(
LNormal::back());
730 normal.add_data3(
LNormal::back());
732 texcoord.add_data2(0.0, 0.0);
733 texcoord.add_data2(1.0, 0.0);
734 texcoord.add_data2(0.0, 1.0);
737 tri->add_consecutive_vertices(0, 3);
738 tri->close_primitive();
741 geom->add_primitive(tri);
743 geomnode->add_geom(geom, state);
745 return parent.attach_new_node(geomnode);
760 auto_bind(
get_render().node(), _anim_controls, hierarchy_match_flags);
776 double r = (double)rand() / (double)RAND_MAX;
794 if (_anim_controls_enabled) {
795 destroy_anim_controls();
810 create_anim_controls();
830 _anim_controls_enabled = enable;
831 if (_anim_controls_enabled) {
832 create_anim_controls();
835 destroy_anim_controls();
851 PN_stdfloat this_aspect_ratio = aspect_ratio;
853 int x_size = 0, y_size = 0;
854 if (_window->has_size()) {
855 x_size = _window->get_sbs_left_x_size();
856 y_size = _window->get_sbs_left_y_size();
859 if (this_aspect_ratio == 0.0f) {
861 this_aspect_ratio = 1.0f;
863 this_aspect_ratio = (float)x_size / (
float)y_size;
868 _aspect_2d.
set_scale(1.0f / this_aspect_ratio, 1.0f, 1.0f);
874 _pixel_2d.set_sx(2.0f / (
float)x_size);
876 _pixel_2d.set_sy(1.0f);
878 _pixel_2d.set_sz(2.0f / (
float)y_size);
882 Cameras::iterator ci;
883 for (ci = _cameras.begin(); ci != _cameras.end(); ++ci) {
884 Lens *lens = (*ci)->get_lens();
885 if (lens != (
Lens *)NULL) {
909 if (split_type == ST_default) {
913 if (_display_region_3d->get_pixel_width() >
914 _display_region_3d->get_pixel_height()) {
915 split_type = ST_horizontal;
917 split_type = ST_vertical;
921 PN_stdfloat left, right, bottom, top;
922 _display_region_3d->get_dimensions(left, right, bottom, top);
925 if (split_type == ST_vertical) {
926 _display_region_3d->
set_dimensions(left, right, bottom, (top + bottom) / 2.0f);
928 _display_region_2d->set_dimensions(left, right, bottom, (top + bottom) / 2.0f);
931 new_region->
set_dimensions(left, right, (top + bottom) / 2.0f, top);
934 _display_region_3d->set_dimensions(left, (left + right) / 2.0f, bottom, top);
936 _display_region_2d->set_dimensions(left, (left + right) / 2.0f, bottom, top);
939 new_region->
set_dimensions((left + right) / 2.0f, right, bottom, top);
943 _panda_framework->_windows.push_back(wf);
956 if (enable == _wireframe_enabled && filled == _wireframe_filled) {
962 if (!_two_sided_enabled) {
969 RenderModeAttrib::M_filled_wireframe,
970 1.4f,
false, LColor(1, 1, 1, .5f)),
974 render.
set_color_scale(LColor(0.7f, 0.7f, 0.7f, 1), override_priority);
982 if (_one_sided_reverse_enabled) {
984 render.node()->set_attrib(attrib);
986 render.clear_color_scale();
989 _wireframe_enabled = enable;
990 _wireframe_filled = filled;
1001 if (enable == _texture_enabled) {
1013 _texture_enabled = enable;
1024 if (enable == _two_sided_enabled) {
1033 if (!_wireframe_enabled) {
1038 _two_sided_enabled = enable;
1039 _one_sided_reverse_enabled =
false;
1051 if (enable == _one_sided_reverse_enabled) {
1057 if (!_wireframe_enabled) {
1060 render.node()->set_attrib(attrib);
1066 _two_sided_enabled =
false;
1067 _one_sided_reverse_enabled = enable;
1077 if (enable == _lighting_enabled) {
1093 _lighting_enabled = enable;
1103 if (enable == _perpixel_enabled) {
1110 render.set_shader_auto();
1112 render.set_shader_off();
1115 _perpixel_enabled = enable;
1128 _background_type = type;
1134 switch (_background_type) {
1139 _display_region_3d->set_clear_color_active(
true);
1140 _display_region_3d->set_clear_depth_active(
true);
1141 _display_region_3d->set_clear_stencil_active(
true);
1142 _display_region_3d->set_clear_color(_window->get_clear_color());
1143 _display_region_3d->set_clear_depth(_window->get_clear_depth());
1144 _display_region_3d->set_clear_stencil(_window->get_clear_stencil());
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(LColor(0.0f, 0.0f, 0.0f, 0.0f));
1152 _display_region_3d->set_clear_depth(1.0f);
1153 _display_region_3d->set_clear_stencil(0);
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.3, 0.3, 0.3, 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(1.0f, 1.0f, 1.0f, 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(
false);
1176 _display_region_3d->set_clear_depth_active(
false);
1177 _display_region_3d->set_clear_stencil_active(
false);
1190 if (_shuttle_controls_font == (
TextFont *)NULL) {
1193 string shuttle_controls_string((const
char *)shuttle_controls, shuttle_controls_len);
1196 if (bam_file.open_read(in, "shuttle_controls font stream")) {
1197 PT(
PandaNode) node = bam_file.read_node();
1204 return _shuttle_controls_font;
1217 _cameras.push_back(camera);
1221 if (aspect_ratio != 0.0) {
1228 if (_window->has_size()) {
1229 int x_size = _window->get_sbs_left_x_size();
1230 int y_size = _window->get_sbs_left_y_size();
1237 camera->set_lens(lens);
1248 void WindowFramework::
1258 alight->
set_color(LColor(0.2, 0.2, 0.2, 1.0f));
1260 dlight->
set_color(LColor(0.8f, 0.8f, 0.8f, 1.0f));
1277 load_image_as_model(const
Filename &filename) {
1278 PT(Texture) tex =
TexturePool::load_texture(filename);
1284 tex->set_minfilter(SamplerState::FT_linear_mipmap_linear);
1285 tex->set_magfilter(SamplerState::FT_linear);
1288 bool has_alpha =
true;
1289 LVecBase2 tex_scale = tex->get_tex_scale();
1293 int x_size = tex->get_orig_file_x_size();
1294 int y_size = tex->get_orig_file_y_size();
1297 PN_stdfloat left,right,top,bottom;
1298 static const PN_stdfloat scale = 10.0;
1299 if (x_size > y_size) {
1302 top = (scale * y_size) / x_size;
1303 bottom = -(scale * y_size) / x_size;
1304 }
else if (y_size != 0) {
1305 left = -(scale * x_size) / y_size;
1306 right = (scale * x_size) / y_size;
1310 framework_cat.warning()
1311 <<
"Texture size is 0 0: " << *tex <<
"\n";
1322 card_node->
set_attrib(TransparencyAttrib::make(TransparencyAttrib::M_alpha));
1326 if (tex->get_texture_type() == Texture::TT_3d_texture ||
1327 tex->get_texture_type() == Texture::TT_cube_map) {
1332 CPT(GeomVertexFormat) vformat;
1335 vformat = GeomVertexFormat::get_v3t2();
1339 vformat = GeomVertexFormat::register_format
1340 (
new GeomVertexArrayFormat
1341 (InternalName::get_vertex(), 3,
1342 GeomEnums::NT_stdfloat, GeomEnums::C_point,
1343 InternalName::get_texcoord(), 3,
1344 GeomEnums::NT_stdfloat, GeomEnums::C_texcoord));
1348 ("card", vformat,
Geom::UH_static);
1354 vertex.
add_data3(LVertex::rfu(left, 0.02, top));
1355 vertex.add_data3(LVertex::rfu(left, 0.02, bottom));
1356 vertex.add_data3(LVertex::rfu(right, 0.02, top));
1357 vertex.add_data3(LVertex::rfu(right, 0.02, bottom));
1359 texcoord.add_data2(0.0f, tex_scale[1]);
1360 texcoord.add_data2(0.0f, 0.0f);
1361 texcoord.add_data2(tex_scale[0], tex_scale[1]);
1362 texcoord.add_data2(tex_scale[0], 0.0f);
1366 vertex.add_data3(-1.0f, -1.0f, 1.0f);
1367 vertex.add_data3(-1.0f, -1.0f, -1.0f);
1368 vertex.add_data3(1.0f, -1.0f, -1.0f);
1369 vertex.add_data3(1.0f, -1.0f, 1.0f);
1370 vertex.add_data3(1.0f, 1.0f, 1.0f);
1371 vertex.add_data3(1.0f, 1.0f, -1.0f);
1372 vertex.add_data3(-1.0f, 1.0f, -1.0f);
1373 vertex.add_data3(-1.0f, 1.0f, 1.0f);
1375 texcoord.add_data3(-1.0f, -1.0f, 1.0f);
1376 texcoord.add_data3(-1.0f, -1.0f, -1.0f);
1377 texcoord.add_data3(1.0f, -1.0f, -1.0f);
1378 texcoord.add_data3(1.0f, -1.0f, 1.0f);
1379 texcoord.add_data3(1.0f, 1.0f, 1.0f);
1380 texcoord.add_data3(1.0f, 1.0f, -1.0f);
1381 texcoord.add_data3(-1.0f, 1.0f, -1.0f);
1382 texcoord.add_data3(-1.0f, 1.0f, 1.0f);
1390 strip->close_primitive();
1394 strip->add_vertex(7);
1395 strip->add_vertex(0);
1396 strip->add_vertex(4);
1397 strip->add_vertex(3);
1398 strip->close_primitive();
1400 strip->add_vertex(1);
1401 strip->add_vertex(6);
1402 strip->add_vertex(2);
1403 strip->add_vertex(5);
1404 strip->close_primitive();
1406 strip->add_vertex(5);
1407 strip->add_vertex(4);
1408 strip->add_vertex(2);
1409 strip->add_vertex(3);
1410 strip->add_vertex(1);
1411 strip->add_vertex(0);
1412 strip->add_vertex(6);
1413 strip->add_vertex(7);
1414 strip->add_vertex(5);
1415 strip->add_vertex(4);
1416 strip->close_primitive();
1420 geom->add_primitive(strip);
1422 card_node->add_geom(geom);
1424 return card_node.p();
1434 create_anim_controls() {
1435 destroy_anim_controls();
1440 style.set_color(0.0f, 0.0f, 0.0f, 0.3);
1441 group->set_frame(-1.0f, 1.0f, 0.0f, 0.2);
1442 group->set_frame_style(0, style);
1444 group->set_active(true);
1446 _anim_controls_group = get_aspect_2d().attach_new_node(group);
1447 _anim_controls_group.set_pos(0.0f, 0.0f, -0.9f);
1449 if (_anim_index >= _anim_controls.get_num_anims()) {
1451 label->set_align(
TextNode::A_center);
1452 label->set_text("No animation.");
1453 NodePath tnp = _anim_controls_group.attach_new_node(label);
1454 tnp.set_pos(0.0f, 0.0f, 0.07f);
1455 tnp.set_scale(0.1f);
1460 AnimControl *control = _anim_controls.get_anim(_anim_index);
1463 if (control->get_num_frames() <= 1) {
1471 label->set_align(
TextNode::A_center);
1472 label->set_text(text.str());
1473 NodePath tnp = _anim_controls_group.attach_new_node(label);
1474 tnp.set_pos(0.0f, 0.0f, 0.07f);
1475 tnp.set_scale(0.1f);
1481 label->set_align(
TextNode::A_left);
1482 label->set_text(_anim_controls.get_anim_name(_anim_index));
1483 NodePath tnp = _anim_controls_group.attach_new_node(label);
1484 tnp.set_pos(-0.95f, 0.0f, 0.15f);
1485 tnp.set_scale(0.05f);
1488 _anim_slider->setup_slider(false, 1.9f, 0.1f, 0.005f);
1490 _anim_slider->get_thumb_button()->set_suppress_flags(
MouseWatcherRegion::SF_mouse_button);
1492 _anim_slider->set_range(0.0f, (PN_stdfloat)(control->get_num_frames() - 1));
1493 _anim_slider->set_scroll_size(0.0f);
1494 _anim_slider->set_page_size(1.0f);
1495 NodePath snp = _anim_controls_group.attach_new_node(_anim_slider);
1496 snp.set_pos(0.0f, 0.0f, 0.06f);
1498 _frame_number = new
TextNode("frame_number");
1499 _frame_number->set_text_color(0.0f, 0.0f, 0.0f, 1.0f);
1500 _frame_number->set_align(
TextNode::A_center);
1501 _frame_number->set_text(format_string(control->get_frame()));
1502 NodePath fnp =
NodePath(_anim_slider->get_thumb_button()).attach_new_node(_frame_number);
1503 fnp.set_scale(0.05f);
1504 fnp.set_pos(0.0f, 0.0f, -0.01f);
1506 _play_rate_slider = new
PGSliderBar("play_rate_slider");
1507 _play_rate_slider->setup_slider(false, 0.4, 0.05f, 0.005f);
1509 _play_rate_slider->get_thumb_button()->set_suppress_flags(
MouseWatcherRegion::SF_mouse_button);
1510 _play_rate_slider->set_value(control->get_play_rate());
1511 NodePath pnp = _anim_controls_group.attach_new_node(_play_rate_slider);
1512 pnp.set_pos(0.75f, 0.0f, 0.15f);
1516 setup_shuttle_button("9", 0, st_back_button);
1517 setup_shuttle_button(";", 1, st_pause_button);
1518 setup_shuttle_button("4", 2, st_play_button);
1519 setup_shuttle_button(":", 3, st_forward_button);
1521 _update_anim_controls_task = new
GenericAsyncTask("controls", st_update_anim_controls, (
void *)this);
1522 _panda_framework->get_task_mgr().add(_update_anim_controls_task);
1531 destroy_anim_controls() {
1532 if (!_anim_controls_group.
is_empty()) {
1536 if (_update_anim_controls_task != NULL) {
1538 _update_anim_controls_task.clear();
1549 void WindowFramework::
1550 update_anim_controls() {
1554 if (_anim_slider != NULL) {
1555 if (_anim_slider->is_button_down()) {
1556 control->
pose((
int)(_anim_slider->get_value() + 0.5));
1558 _anim_slider->set_value((PN_stdfloat)control->
get_frame());
1562 if (_frame_number != NULL) {
1563 _frame_number->set_text(format_string(control->
get_frame()));
1575 void WindowFramework::
1576 setup_shuttle_button(
const string &label,
int index,
1577 EventHandler::EventCallbackFunction *func) {
1579 button->set_frame(-0.05f, 0.05f, 0.0f, 0.07f);
1581 PN_stdfloat bevel = 0.005f;
1584 style.set_color(0.8f, 0.8f, 0.8f, 1.0f);
1585 style.set_width(bevel, bevel);
1588 button->set_frame_style(
PGButton::S_ready, style);
1591 button->set_frame_style(
PGButton::S_depressed, style);
1593 style.set_color(0.9f, 0.9f, 0.9f, 1.0f);
1595 button->set_frame_style(
PGButton::S_rollover, style);
1601 tn->set_text(label);
1602 tn->set_text_color(0.0f, 0.0f, 0.0f, 1.0f);
1604 xform.set_row(3,
LVecBase3(0.0f, 0.0f, 0.016f));
1605 tn->set_transform(xform);
1607 button->get_state_def(
PGButton::S_ready).attach_new_node(tn);
1608 button->get_state_def(
PGButton::S_depressed).attach_new_node(tn);
1609 button->get_state_def(
PGButton::S_rollover).attach_new_node(tn);
1612 NodePath np = _anim_controls_group.attach_new_node(button);
1613 np.set_pos(0.1f * index - 0.15f, 0.0f, 0.12);
1615 _panda_framework->get_event_handler().add_hook(button->get_click_event(
MouseButton::one()), func, (
void *)this);
1635 void WindowFramework::
1647 void WindowFramework::
1651 control->
loop(
false);
1659 void WindowFramework::
1672 AsyncTask::DoneStatus WindowFramework::
1675 self->update_anim_controls();
1676 return AsyncTask::DS_cont;
1685 void WindowFramework::
1686 st_back_button(
const Event *,
void *data) {
1688 self->back_button();
1696 void WindowFramework::
1697 st_pause_button(
const Event *,
void *data) {
1699 self->pause_button();
1707 void WindowFramework::
1708 st_play_button(
const Event *,
void *data) {
1710 self->play_button();
1718 void WindowFramework::
1719 st_forward_button(
const Event *,
void *data) {
1721 self->forward_button();
The principle public interface to reading and writing Bam disk files.
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...
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 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.
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...
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.
Specifies parameters that may be passed to the loader.
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.
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.
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 is_of_type(TypeHandle handle) const
Returns true if the current object is or derives from the indicated type.
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_attrib(const RenderAttrib *attrib, int priority=0)
Adds the indicated render attribute to the scene graph on this node.
virtual int get_num_frames() const
Returns the number of frames in the animation.
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.
PandaNode * node() const
Returns the referenced node of the path.
void set_lighting(bool enable)
Turns lighting on (true) or off (false).
This is a three-component vector distance (as opposed to a three-component point, which represents a ...
void set_pos(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z)
Sets the translation component of the transform, leaving rotation and scale untouched.
Defines a series of triangle strips.
A light source that seems to illuminate all points in space at once.
const LVecBase2 & get_fov() const
Returns the horizontal and vertical film size of the virtual film.
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 ...
bool is_fully_qualified() const
Returns true if the filename is fully qualified, e.g.
void loop_all(bool restart)
Starts all animations looping.
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.
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.
Indicates the set of TextureStages and their associated Textures that should be applied to (or remove...
Indicates which faces should be culled based on their vertex ordering.
int get_frame() const
Returns the current integer frame number.
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...
This is another abstract class, for a general class of bounding volumes that actually enclose points ...
void set_display_region(DisplayRegion *dr)
Constrains the MouseWatcher to watching the mouse within a particular indicated region of the screen...
A container for the various kinds of properties we might ask to have on a graphics window before we o...
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...
void add_consecutive_vertices(int start, int num_vertices)
Adds a consecutive sequence of vertices, beginning at start, to the primitive.
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).
GraphicsOutput * get_window() const
Returns the GraphicsOutput that this DisplayRegion is ultimately associated with, or NULL if no windo...
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...
void center_trackball(const NodePath &object)
Centers the trackball on the indicated object, and scales the trackball motion suitably.
This is the class that defines a rectangular region on the screen for the MouseWatcher.
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.
void add_data3(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z)
Sets the write row to a particular 3-component value, and advances the write row. ...
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.
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.
void set_background_type(WindowFramework::BackgroundType type)
Sets the background type of all windows.
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.
AnimControl * get_anim(int n) const
Returns the nth AnimControl associated with this collection.
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.
Represents a set of settings that indicate how a texture is sampled.
This is the base class for all three-component vectors and points.
string get_basename_wo_extension() const
Returns the basename part of the filename, without the file extension.
bool exists(const Filename &filename) const
Convenience function; returns true if the named file exists.
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...
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...
bool is_empty() const
Returns true if the NodePath contains no nodes.
Defines a series of disconnected triangles.
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.
Indicates what color should be applied to renderable geometry.
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 ...
string get_extension() const
Returns the file extension.
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...
int get_num_anims() const
Returns the number of AnimControls associated with this collection.
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...
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...
void set_mouse_watcher(MouseWatcher *watcher)
Sets the MouseWatcher pointer that the PGTop object registers its PG items with.
string get_anim_name(int n) const
Returns the name of the nth AnimControl associated with this collection.
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).