Panda3D
|
This encapsulates the data that is normally associated with a single window, or with a single display region within a window. More...
#include "windowFramework.h"
Public Types | |
enum | BackgroundType { BT_other = 0, BT_default, BT_black, BT_gray, BT_white, BT_none } |
enum | SplitType { ST_default, ST_horizontal, ST_vertical } |
Public Member Functions | |
void | adjust_aspect_ratio () |
Reevaluates the aspect ratio of the window, presumably after the window has been resized by the user or some other force. | |
void | center_trackball (const NodePath &object) |
Centers the trackball on the indicated object, and scales the trackball motion suitably. | |
void | enable_keyboard () |
Creates a ButtonThrower to listen to button presses and throw them as events. | |
virtual TypeHandle | force_init_type () |
bool | get_anim_controls () const |
Returns the current state of the anim_controls flag. | |
NodePath | get_aspect_2d () |
Returns the node under the 2-d scene graph that is scaled to suit the window's aspect ratio. | |
BackgroundType | get_background_type () const |
Returns the current background type setting. | |
NodePath | get_button_thrower () |
Returns the node in the data graph corresponding to the ButtonThrower object associated with this window. | |
Camera * | get_camera (int n) const |
Returns the nth camera associated with the window. | |
NodePath | get_camera_group () |
Returns the node above the collection of 3-d cameras in the scene graph. | |
DisplayRegion * | get_display_region_2d () const |
Returns the default DisplayRegion created for the 2-d scene (render2d). | |
DisplayRegion * | get_display_region_3d () const |
Returns the default DisplayRegion created for the 3-d scene (render). | |
GraphicsOutput * | get_graphics_output () const |
Returns a pointer to the underlying GraphicsOutput object. | |
GraphicsWindow * | get_graphics_window () const |
Returns a pointer to the underlying GraphicsWindow object, if it is in fact a window; or NULL if it is not. | |
bool | get_lighting () const |
Returns the current state of the lighting flag. | |
NodePath | get_mouse () |
Returns the node in the data graph corresponding to the mouse associated with this window. | |
int | get_num_cameras () const |
Returns the number of 3-d cameras associated with the window. | |
bool | get_one_sided_reverse () const |
Returns the current state of the one_sided_reverse flag. | |
PandaFramework * | get_panda_framework () const |
Returns a pointer to the associated PandaFramework object. | |
bool | get_perpixel () const |
Returns the current state of the perpixel flag. | |
NodePath | get_render () |
Returns the root of the 3-d scene graph. | |
NodePath | get_render_2d () |
Returns the root of the 2-d scene graph. | |
bool | get_texture () const |
Returns the current state of the texture flag. | |
bool | get_two_sided () const |
Returns the current state of the two_sided flag. | |
virtual TypeHandle | get_type () const |
bool | get_wireframe () const |
Returns the current state of the wireframe flag. | |
NodePath | load_default_model (const NodePath &parent) |
Loads our favorite blue triangle. | |
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 not be loaded. | |
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. | |
bool | load_models (const NodePath &parent, const pvector< Filename > &files) |
Loads up all the model files listed in the indicated argument list. | |
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 matching animations found. | |
NodePath | make_camera () |
Makes a new 3-d camera for the window. | |
void | next_anim_control () |
Rotates the animation controls through all of the available animations. | |
void | set_anim_controls (bool enable) |
Creates an onscreen animation slider for frame-stepping through the animations. | |
void | set_background_type (BackgroundType type) |
Sets the background of the window to one of the pre-canned background types (or to BT_other, which indicates the user intends to set up his own special background mode). | |
void | set_lighting (bool enable) |
Turns lighting on (true) or off (false). | |
void | set_one_sided_reverse (bool enable) |
Toggles one-sided reverse mode. | |
void | set_perpixel (bool enable) |
Turns per-pixel lighting on (true) or off (false). | |
void | set_texture (bool enable) |
Forces textures off (false) or restores default rendering (true). | |
void | set_two_sided (bool enable) |
Forces two-sided rendering (true) or restores default rendering (false). | |
void | set_wireframe (bool enable) |
Forces wireframe state (true) or restores default rendering (false). | |
void | setup_trackball () |
Sets up the mouse to trackball around the camera. | |
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. | |
void | stagger_animations () |
Walks through all the animations that were bound by loop_animations() and staggers their play rate slightly so that they will not remain perfectly in sync. | |
Static Public Member Functions | |
static TypeHandle | get_class_type () |
static TextFont * | get_shuttle_controls_font () |
Returns a font that contains the shuttle controls icons. | |
static void | init_type () |
Protected Member Functions | |
WindowFramework (PandaFramework *panda_framework) | |
WindowFramework (const WindowFramework ©, DisplayRegion *display_region) | |
void | close_window () |
Closes the window or buffer. | |
GraphicsOutput * | open_window (const WindowProperties &props, int flags, GraphicsEngine *engine, GraphicsPipe *pipe, GraphicsStateGuardian *gsg=NULL) |
Opens the actual window or buffer. | |
void | setup_lights () |
Makes light nodes and attaches them to the camera for viewing the scene. | |
Friends | |
class | PandaFramework |
This encapsulates the data that is normally associated with a single window, or with a single display region within a window.
(In the case where a window has been subdivided with split_window(), there may be multiple WindowFrameworks objects that share the same GraphicsOutput pointer, but reference different display regions within that window).
Definition at line 55 of file windowFramework.h.
void WindowFramework::adjust_aspect_ratio | ( | ) |
Reevaluates the aspect ratio of the window, presumably after the window has been resized by the user or some other force.
Adjusts the render film size and aspect2d scale as necessary according to the new window shape, or new config setting.
Definition at line 801 of file windowFramework.cxx.
References NodePath::is_empty(), Lens::set_aspect_ratio(), Lens::set_film_size(), and NodePath::set_scale().
void WindowFramework::center_trackball | ( | const NodePath & | object | ) |
Centers the trackball on the indicated object, and scales the trackball motion suitably.
Definition at line 457 of file windowFramework.cxx.
References LVector3f::forward(), Lens::get_default_far(), Lens::get_default_near(), Lens::get_fov(), Lens::set_far(), and Lens::set_near().
Referenced by PandaFramework::event_c().
void WindowFramework::close_window | ( | ) | [protected] |
Closes the window or buffer.
This is normally called from PandaFramework::close_window().
Definition at line 203 of file windowFramework.cxx.
References NodePath::remove_node().
Referenced by PandaFramework::close_all_windows().
void WindowFramework::enable_keyboard | ( | ) |
Creates a ButtonThrower to listen to button presses and throw them as events.
Definition at line 397 of file windowFramework.cxx.
References ModifierButtons::add_button(), NodePath::attach_new_node(), and get_mouse().
bool WindowFramework::get_anim_controls | ( | ) | const [inline] |
Returns the current state of the anim_controls flag.
Definition at line 106 of file windowFramework.I.
NodePath WindowFramework::get_aspect_2d | ( | ) |
Returns the node under the 2-d scene graph that is scaled to suit the window's aspect ratio.
Definition at line 321 of file windowFramework.cxx.
References NodePath::attach_new_node(), get_mouse(), get_render_2d(), NodePath::is_empty(), TypedObject::is_of_type(), NodePath::node(), PGTop::set_mouse_watcher(), and NodePath::set_scale().
Referenced by PandaFramework::event_f9(), and PandaFramework::event_question().
WindowFramework::BackgroundType WindowFramework::get_background_type | ( | ) | const [inline] |
Returns the current background type setting.
Definition at line 176 of file windowFramework.I.
Referenced by PandaFramework::event_comma().
NodePath WindowFramework::get_button_thrower | ( | ) |
Returns the node in the data graph corresponding to the ButtonThrower object associated with this window.
Definition at line 386 of file windowFramework.cxx.
Camera * WindowFramework::get_camera | ( | int | n | ) | const [inline] |
Returns the nth camera associated with the window.
Definition at line 73 of file windowFramework.I.
NodePath WindowFramework::get_camera_group | ( | ) |
Returns the node above the collection of 3-d cameras in the scene graph.
This node may be moved around to represent the viewpoint.
Definition at line 241 of file windowFramework.cxx.
References NodePath::attach_new_node(), get_render(), and NodePath::is_empty().
Referenced by make_camera(), setup_lights(), and setup_trackball().
DisplayRegion * WindowFramework::get_display_region_2d | ( | ) | const [inline] |
Returns the default DisplayRegion created for the 2-d scene (render2d).
Definition at line 85 of file windowFramework.I.
DisplayRegion * WindowFramework::get_display_region_3d | ( | ) | const [inline] |
Returns the default DisplayRegion created for the 3-d scene (render).
Definition at line 96 of file windowFramework.I.
GraphicsOutput * WindowFramework::get_graphics_output | ( | ) | const [inline] |
Returns a pointer to the underlying GraphicsOutput object.
Definition at line 50 of file windowFramework.I.
Referenced by PandaFramework::all_windows_closed(), PandaFramework::close_all_windows(), PandaFramework::event_esc(), and PandaFramework::event_f9().
GraphicsWindow * WindowFramework::get_graphics_window | ( | ) | const [inline] |
Returns a pointer to the underlying GraphicsWindow object, if it is in fact a window; or NULL if it is not.
Definition at line 35 of file windowFramework.I.
bool WindowFramework::get_lighting | ( | ) | const [inline] |
Returns the current state of the lighting flag.
Definition at line 156 of file windowFramework.I.
Referenced by PandaFramework::event_l().
NodePath WindowFramework::get_mouse | ( | ) |
Returns the node in the data graph corresponding to the mouse associated with this window.
Definition at line 360 of file windowFramework.cxx.
References NodePath::attach_new_node(), PandaFramework::get_mouse(), and NodePath::is_empty().
Referenced by enable_keyboard(), get_aspect_2d(), and setup_trackball().
int WindowFramework::get_num_cameras | ( | ) | const [inline] |
Returns the number of 3-d cameras associated with the window.
A window usually has only one camera, but it may have multiple cameras if there are multiple display regions within the window.
Definition at line 63 of file windowFramework.I.
bool WindowFramework::get_one_sided_reverse | ( | ) | const [inline] |
Returns the current state of the one_sided_reverse flag.
Definition at line 146 of file windowFramework.I.
Referenced by PandaFramework::event_i().
PandaFramework * WindowFramework::get_panda_framework | ( | ) | const [inline] |
Returns a pointer to the associated PandaFramework object.
Definition at line 23 of file windowFramework.I.
bool WindowFramework::get_perpixel | ( | ) | const [inline] |
Returns the current state of the perpixel flag.
Definition at line 166 of file windowFramework.I.
Referenced by PandaFramework::event_p().
NodePath WindowFramework::get_render | ( | ) |
Returns the root of the 3-d scene graph.
Definition at line 254 of file windowFramework.cxx.
References NodePath::is_empty(), NodePath::node(), PandaNode::set_attrib(), and NodePath::set_two_sided().
Referenced by get_camera_group(), loop_animations(), open_window(), set_lighting(), set_one_sided_reverse(), set_perpixel(), set_texture(), set_two_sided(), and set_wireframe().
NodePath WindowFramework::get_render_2d | ( | ) |
Returns the root of the 2-d scene graph.
Definition at line 273 of file windowFramework.cxx.
References NodePath::attach_new_node(), NodePath::is_empty(), NodePath::set_depth_test(), NodePath::set_depth_write(), Lens::set_film_size(), NodePath::set_material_off(), and NodePath::set_two_sided().
Referenced by get_aspect_2d().
TextFont * WindowFramework::get_shuttle_controls_font | ( | ) | [static] |
Returns a font that contains the shuttle controls icons.
Definition at line 1114 of file windowFramework.cxx.
References BamFile::open_read().
bool WindowFramework::get_texture | ( | ) | const [inline] |
Returns the current state of the texture flag.
Definition at line 126 of file windowFramework.I.
Referenced by PandaFramework::event_t().
bool WindowFramework::get_two_sided | ( | ) | const [inline] |
Returns the current state of the two_sided flag.
Definition at line 136 of file windowFramework.I.
Referenced by PandaFramework::event_b().
bool WindowFramework::get_wireframe | ( | ) | const [inline] |
Returns the current state of the wireframe flag.
Definition at line 116 of file windowFramework.I.
Referenced by PandaFramework::event_w().
Loads our favorite blue triangle.
This is intended to provide some default geometry to have *something* to look at for testing, when no other models are provided.
Definition at line 661 of file windowFramework.cxx.
References GeomVertexWriter::add_data2f(), GeomVertexWriter::add_data3f(), GeomNode::add_geom(), NodePath::attach_new_node(), LVector3f::back(), GeomVertexFormat::get_v3n3cpt2(), PNMImage::read(), and LPoint3f::rfu().
Loads up the indicated model and returns the new NodePath, or the empty NodePath if the model could not be loaded.
Definition at line 590 of file windowFramework.cxx.
References NodePath::attach_new_node(), VirtualFileSystem::exists(), TexturePool::get_global_ptr(), LoaderFileTypeRegistry::get_global_ptr(), VirtualFileSystem::get_global_ptr(), TexturePool::get_texture_type(), LoaderFileTypeRegistry::get_type_from_extension(), and NodePath::not_found().
Referenced by load_models().
bool WindowFramework::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.
If first_arg is supplied, it is the first argument in the list to consider.
Returns true if all models loaded successfully, or false if at least one of them had an error.
Definition at line 547 of file windowFramework.cxx.
References Filename::from_os_specific().
Loads up all the model files listed in the indicated argument list.
Returns true if all models loaded successfully, or false if at least one of them had an error.
Definition at line 567 of file windowFramework.cxx.
References NodePath::is_empty(), and load_model().
void WindowFramework::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 matching animations found.
Definition at line 721 of file windowFramework.cxx.
References get_render(), and AnimControlCollection::loop_all().
NodePath WindowFramework::make_camera | ( | ) |
Makes a new 3-d camera for the window.
Definition at line 1138 of file windowFramework.cxx.
References NodePath::attach_new_node(), get_camera_group(), and Lens::set_aspect_ratio().
Referenced by open_window().
void WindowFramework::next_anim_control | ( | ) |
Rotates the animation controls through all of the available animations.
If the animation controls are not already enabled, enables them at sets to the first animation; if they are already enabled, steps to the next animation; if that is the last animation, disables the animation controls.
Definition at line 758 of file windowFramework.cxx.
References AnimControlCollection::get_num_anims(), and set_anim_controls().
Referenced by PandaFramework::event_a().
GraphicsOutput * WindowFramework::open_window | ( | const WindowProperties & | props, |
int | flags, | ||
GraphicsEngine * | engine, | ||
GraphicsPipe * | pipe, | ||
GraphicsStateGuardian * | gsg = NULL |
||
) | [protected] |
Opens the actual window or buffer.
This is normally called only from PandaFramework::open_window().
Definition at line 149 of file windowFramework.cxx.
References FrameBufferProperties::get_default(), get_render(), make_camera(), GraphicsOutput::make_display_region(), GraphicsEngine::make_output(), set_background_type(), and DrawableRegion::set_clear_color_active().
void WindowFramework::set_anim_controls | ( | bool | enable | ) |
Creates an onscreen animation slider for frame-stepping through the animations.
Definition at line 781 of file windowFramework.cxx.
Referenced by next_anim_control().
void WindowFramework::set_background_type | ( | WindowFramework::BackgroundType | type | ) |
Sets the background of the window to one of the pre-canned background types (or to BT_other, which indicates the user intends to set up his own special background mode).
Definition at line 1052 of file windowFramework.cxx.
Referenced by PandaFramework::event_comma(), open_window(), and PandaFramework::set_background_type().
void WindowFramework::set_lighting | ( | bool | enable | ) |
Turns lighting on (true) or off (false).
Definition at line 1001 of file windowFramework.cxx.
References NodePath::clear_light(), get_render(), NodePath::set_light(), and setup_lights().
Referenced by PandaFramework::event_l(), and PandaFramework::set_lighting().
void WindowFramework::set_one_sided_reverse | ( | bool | enable | ) |
Toggles one-sided reverse mode.
In this mode, the front sides of one-sided polygons are culled instead of the back side.
Definition at line 975 of file windowFramework.cxx.
References NodePath::clear_two_sided(), get_render(), NodePath::node(), and PandaNode::set_attrib().
Referenced by PandaFramework::event_i().
void WindowFramework::set_perpixel | ( | bool | enable | ) |
Turns per-pixel lighting on (true) or off (false).
Definition at line 1027 of file windowFramework.cxx.
References get_render().
Referenced by PandaFramework::event_p(), and PandaFramework::set_perpixel().
void WindowFramework::set_texture | ( | bool | enable | ) |
Forces textures off (false) or restores default rendering (true).
Definition at line 925 of file windowFramework.cxx.
References NodePath::clear_texture(), get_render(), and NodePath::set_texture_off().
Referenced by PandaFramework::event_t(), and PandaFramework::set_texture().
void WindowFramework::set_two_sided | ( | bool | enable | ) |
Forces two-sided rendering (true) or restores default rendering (false).
Definition at line 948 of file windowFramework.cxx.
References NodePath::clear_two_sided(), get_render(), and NodePath::set_two_sided().
Referenced by PandaFramework::event_b(), and PandaFramework::set_two_sided().
void WindowFramework::set_wireframe | ( | bool | enable | ) |
Forces wireframe state (true) or restores default rendering (false).
Definition at line 894 of file windowFramework.cxx.
References NodePath::clear_render_mode(), NodePath::clear_two_sided(), get_render(), NodePath::node(), PandaNode::set_attrib(), NodePath::set_render_mode_wireframe(), and NodePath::set_two_sided().
Referenced by PandaFramework::event_w(), and PandaFramework::set_wireframe().
void WindowFramework::setup_lights | ( | ) | [protected] |
Makes light nodes and attaches them to the camera for viewing the scene.
Definition at line 1174 of file windowFramework.cxx.
References NodePath::attach_new_node(), get_camera_group(), Light::set_color(), and NodePath::set_hpr().
Referenced by set_lighting().
void WindowFramework::setup_trackball | ( | ) |
Sets up the mouse to trackball around the camera.
Definition at line 428 of file windowFramework.cxx.
References NodePath::attach_new_node(), LVector3f::forward(), get_camera_group(), get_mouse(), and NodePath::node().
WindowFramework * 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.
The new window pointer is returned.
There is not an interface for recombining divided windows.
Definition at line 845 of file windowFramework.cxx.
References DisplayRegion::get_window(), GraphicsOutput::make_display_region(), and DisplayRegion::set_dimensions().
void WindowFramework::stagger_animations | ( | ) |
Walks through all the animations that were bound by loop_animations() and staggers their play rate slightly so that they will not remain perfectly in sync.
Definition at line 738 of file windowFramework.cxx.
References AnimControlCollection::get_anim(), AnimControlCollection::get_num_anims(), and AnimInterface::set_play_rate().