mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-02 01:44:06 -04:00
pgraph pgui
This commit is contained in:
parent
daf2cf5934
commit
ac8ab3b258
@ -104,7 +104,6 @@ pgraphClassRenameDictionary = {
|
||||
'DataNode' : 'SpDataNode',
|
||||
'DialNode' : 'SpDialNode',
|
||||
'DriveInterface' : 'SpDriveInterface',
|
||||
'DriverInterface' : 'SpDriveInterface',
|
||||
'GeomNode' : 'SpGeomNode',
|
||||
'LODNode' : 'SpLODNode',
|
||||
'LensNode' : 'SpLensNode',
|
||||
@ -113,6 +112,11 @@ pgraphClassRenameDictionary = {
|
||||
'MouseWatcher' : 'SpMouseWatcher',
|
||||
'NodePath' : 'SpNodePath',
|
||||
'NodePathCollection' : 'SpNodePathCollection',
|
||||
'PGTop' : 'SpPGTop',
|
||||
'PGItem' : 'SpPGItem',
|
||||
'PGButton' : 'SpPGButton',
|
||||
'PGEntry' : 'SpPGEntry',
|
||||
'PGWaitBar' : 'SpPGWaitBar',
|
||||
'PartBundleNode' : 'SpPartBundleNode',
|
||||
'SequenceNode' : 'SpSequenceNode',
|
||||
'TextNode' : 'SpTextNode',
|
||||
@ -132,7 +136,6 @@ pgraphClassRenameDictionary = {
|
||||
'QpDataNode' : 'DataNode',
|
||||
'QpDialNode' : 'DialNode',
|
||||
'QpDriveInterface' : 'DriveInterface',
|
||||
'QpDriverInterface' : 'DriveInterface',
|
||||
'QpGeomNode' : 'GeomNode',
|
||||
'QpLODNode' : 'LODNode',
|
||||
'QpLensNode' : 'LensNode',
|
||||
@ -141,6 +144,11 @@ pgraphClassRenameDictionary = {
|
||||
'QpMouseWatcher' : 'MouseWatcher',
|
||||
'QpNodePath' : 'NodePath',
|
||||
'QpNodePathCollection' : 'NodePathCollection',
|
||||
'QpPGTop' : 'PGTop',
|
||||
'QpPGItem' : 'PGItem',
|
||||
'QpPGButton' : 'PGButton',
|
||||
'QpPGEntry' : 'PGEntry',
|
||||
'QpPGWaitBar' : 'PGWaitBar',
|
||||
'QpPartBundleNode' : 'PartBundleNode',
|
||||
'QpSequenceNode' : 'SequenceNode',
|
||||
'QpTextNode' : 'TextNode',
|
||||
|
@ -255,8 +255,7 @@ class ShowBase:
|
||||
# matching that of a traditional PC screen (w / h) = (4 / 3)
|
||||
self.aspectRatio = self.config.GetFloat('aspect-ratio', (4.0 / 3.0))
|
||||
|
||||
#self.aspect2d = self.render2d.attachNewNode(PGTop("aspect2d"))
|
||||
self.aspect2d = self.render2d.attachNewNode("aspect2d")
|
||||
self.aspect2d = self.render2d.attachNewNode(PGTop("aspect2d"))
|
||||
self.aspect2d.setScale(1.0 / self.aspectRatio, 1.0, 1.0)
|
||||
|
||||
# It's important to know the bounds of the aspect2d screen.
|
||||
@ -359,8 +358,8 @@ class ShowBase:
|
||||
self.buttonThrower.node().setModifierButtons(mods)
|
||||
|
||||
# Tell the gui system about our new mouse watcher.
|
||||
#self.aspect2d.node().setMouseWatcher(self.mouseWatcherNode)
|
||||
#self.mouseWatcherNode.addRegion(PGMouseWatcherBackground())
|
||||
self.aspect2d.node().setMouseWatcher(self.mouseWatcherNode)
|
||||
self.mouseWatcherNode.addRegion(PGMouseWatcherBackground())
|
||||
|
||||
def enableSoftwareMousePointer(self):
|
||||
"""enableSoftwareMousePointer(self)
|
||||
|
@ -142,7 +142,7 @@ has_cull_callback() const {
|
||||
// visible, or false if it should be culled.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool qpCharacter::
|
||||
cull_callback(CullTraverserData &) {
|
||||
cull_callback(qpCullTraverser *, CullTraverserData &) {
|
||||
// For now, we update the character during the cull traversal; this
|
||||
// prevents us from needlessly updating characters that aren't in
|
||||
// the view frustum. We may need a better way to do this
|
||||
|
@ -49,7 +49,7 @@ public:
|
||||
|
||||
virtual bool safe_to_transform() const;
|
||||
virtual bool has_cull_callback() const;
|
||||
virtual bool cull_callback(CullTraverserData &data);
|
||||
virtual bool cull_callback(qpCullTraverser *trav, CullTraverserData &data);
|
||||
|
||||
PUBLISHED:
|
||||
INLINE CharacterJointBundle *get_bundle() const;
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "cullBinAttrib.h"
|
||||
#include "cullBinBackToFront.h"
|
||||
#include "cullBinUnsorted.h"
|
||||
#include "qpcullTraverser.h"
|
||||
#include "cullableObject.h"
|
||||
#include "decalAttrib.h"
|
||||
#include "depthTestAttrib.h"
|
||||
@ -87,6 +88,7 @@ init_libpgraph() {
|
||||
CullBinAttrib::init_type();
|
||||
CullBinBackToFront::init_type();
|
||||
CullBinUnsorted::init_type();
|
||||
qpCullTraverser::init_type();
|
||||
CullableObject::init_type();
|
||||
DecalAttrib::init_type();
|
||||
DepthTestAttrib::init_type();
|
||||
|
@ -27,14 +27,12 @@ CullTraverserData(const TransformState *render_transform,
|
||||
const TransformState *net_transform,
|
||||
const RenderState *state,
|
||||
GeometricBoundingVolume *view_frustum,
|
||||
GeometricBoundingVolume *guard_band,
|
||||
const TransformState *camera_transform) :
|
||||
GeometricBoundingVolume *guard_band) :
|
||||
_render_transform(render_transform),
|
||||
_net_transform(net_transform),
|
||||
_state(state),
|
||||
_view_frustum(view_frustum),
|
||||
_guard_band(guard_band),
|
||||
_camera_transform(camera_transform)
|
||||
_guard_band(guard_band)
|
||||
{
|
||||
}
|
||||
|
||||
@ -49,8 +47,7 @@ CullTraverserData(const CullTraverserData ©) :
|
||||
_net_transform(copy._net_transform),
|
||||
_state(copy._state),
|
||||
_view_frustum(copy._view_frustum),
|
||||
_guard_band(copy._guard_band),
|
||||
_camera_transform(copy._camera_transform)
|
||||
_guard_band(copy._guard_band)
|
||||
{
|
||||
}
|
||||
|
||||
@ -66,7 +63,6 @@ operator = (const CullTraverserData ©) {
|
||||
_state = copy._state;
|
||||
_view_frustum = copy._view_frustum;
|
||||
_guard_band = copy._guard_band;
|
||||
_camera_transform = copy._camera_transform;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
@ -17,6 +17,7 @@
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "cullTraverserData.h"
|
||||
#include "qpcullTraverser.h"
|
||||
#include "config_pgraph.h"
|
||||
#include "pandaNode.h"
|
||||
#include "colorAttrib.h"
|
||||
@ -30,7 +31,7 @@
|
||||
// billboards, etc.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void CullTraverserData::
|
||||
apply_transform_and_state(PandaNode *node) {
|
||||
apply_transform_and_state(qpCullTraverser *trav, PandaNode *node) {
|
||||
const TransformState *node_transform = node->get_transform();
|
||||
if (!node_transform->is_identity()) {
|
||||
_render_transform = _render_transform->compose(node_transform);
|
||||
@ -73,7 +74,7 @@ apply_transform_and_state(PandaNode *node) {
|
||||
if (billboard != (const BillboardAttrib *)NULL) {
|
||||
// Got to apply a billboard transform here.
|
||||
CPT(TransformState) billboard_transform =
|
||||
billboard->do_billboard(_net_transform, _camera_transform);
|
||||
billboard->do_billboard(_net_transform, trav->get_camera_transform());
|
||||
_render_transform = _render_transform->compose(billboard_transform);
|
||||
_net_transform = _net_transform->compose(billboard_transform);
|
||||
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include "drawMask.h"
|
||||
|
||||
class PandaNode;
|
||||
class qpCullTraverser;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Class : CullTraverserData
|
||||
@ -49,14 +50,13 @@ public:
|
||||
const TransformState *net_transform,
|
||||
const RenderState *state,
|
||||
GeometricBoundingVolume *view_frustum,
|
||||
GeometricBoundingVolume *guard_band,
|
||||
const TransformState *camera_transform);
|
||||
GeometricBoundingVolume *guard_band);
|
||||
INLINE CullTraverserData(const CullTraverserData ©);
|
||||
INLINE void operator = (const CullTraverserData ©);
|
||||
INLINE ~CullTraverserData();
|
||||
|
||||
INLINE bool is_in_view(PandaNode *node, const DrawMask &camera_mask);
|
||||
void apply_transform_and_state(PandaNode *node);
|
||||
void apply_transform_and_state(qpCullTraverser *trav, PandaNode *node);
|
||||
|
||||
CPT(TransformState) _render_transform;
|
||||
CPT(TransformState) _net_transform;
|
||||
@ -64,12 +64,6 @@ public:
|
||||
PT(GeometricBoundingVolume) _view_frustum;
|
||||
PT(GeometricBoundingVolume) _guard_band;
|
||||
|
||||
// This one is not modified during traversal, so it doesn't need to
|
||||
// be reference counted (we trust the original owner of this pointer
|
||||
// to reference count it and hold it during the lifetime of the
|
||||
// traversal).
|
||||
const TransformState *_camera_transform;
|
||||
|
||||
private:
|
||||
bool is_in_view_impl(PandaNode *node);
|
||||
static CPT(RenderState) get_fake_view_frustum_cull_effect();
|
||||
|
@ -470,7 +470,7 @@ has_cull_callback() const {
|
||||
// visible, or false if it should be culled.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool PandaNode::
|
||||
cull_callback(CullTraverserData &) {
|
||||
cull_callback(qpCullTraverser *, CullTraverserData &) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -38,6 +38,7 @@
|
||||
#include "notify.h"
|
||||
|
||||
class qpNodePathComponent;
|
||||
class qpCullTraverser;
|
||||
class CullTraverserData;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@ -69,7 +70,7 @@ public:
|
||||
virtual PandaNode *combine_with(PandaNode *other);
|
||||
|
||||
virtual bool has_cull_callback() const;
|
||||
virtual bool cull_callback(CullTraverserData &data);
|
||||
virtual bool cull_callback(qpCullTraverser *trav, CullTraverserData &data);
|
||||
virtual bool has_selective_visibility() const;
|
||||
virtual int get_first_visible_child() const;
|
||||
virtual int get_next_visible_child(int n) const;
|
||||
|
@ -29,6 +29,18 @@ set_initial_state(const RenderState *initial_state) {
|
||||
_initial_state = initial_state;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: qpCullTraverser::get_initial_state
|
||||
// Access: Public
|
||||
// Description: Returns the initial RenderState at the top of the
|
||||
// scene graph we are traversing, or the empty state if
|
||||
// the initial state was never set.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE const RenderState *qpCullTraverser::
|
||||
get_initial_state() const {
|
||||
return _initial_state;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: qpCullTraverser::set_camera_mask
|
||||
// Access: Public
|
||||
@ -41,6 +53,17 @@ set_camera_mask(const DrawMask &camera_mask) {
|
||||
_camera_mask = camera_mask;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: qpCullTraverser::get_camera_mask
|
||||
// Access: Public
|
||||
// Description: Returns the visibility mask from the camera viewing
|
||||
// the scene.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE const DrawMask &qpCullTraverser::
|
||||
get_camera_mask() const {
|
||||
return _camera_mask;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: qpCullTraverser::set_camera_transform
|
||||
// Access: Public
|
||||
@ -54,6 +77,19 @@ set_camera_transform(const TransformState *camera_transform) {
|
||||
_camera_transform = camera_transform;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: qpCullTraverser::get_camera_transform
|
||||
// Access: Public
|
||||
// Description: Returns the position of the camera relative to the
|
||||
// starting node, without any compensating
|
||||
// coordinate-system transforms that might have been
|
||||
// introduced for the purposes of rendering.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE const TransformState *qpCullTraverser::
|
||||
get_camera_transform() const {
|
||||
return _camera_transform;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: qpCullTraverser::set_render_transform
|
||||
// Access: Public
|
||||
@ -66,11 +102,29 @@ set_render_transform(const TransformState *render_transform) {
|
||||
_render_transform = render_transform;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: qpCullTraverser::get_render_transform
|
||||
// Access: Public
|
||||
// Description: Returns the position of the starting node relative
|
||||
// to the camera, pretransformed as appropriate for
|
||||
// rendering.
|
||||
//
|
||||
// Note that this value is always the position of the
|
||||
// starting node, not the current node, even if it is
|
||||
// sampled during a traversal. To get the render
|
||||
// transform of the current node check in the current
|
||||
// CullTraverserData.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE const TransformState *qpCullTraverser::
|
||||
get_render_transform() const {
|
||||
return _render_transform;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: qpCullTraverser::set_view_frustum
|
||||
// Access: Public
|
||||
// Description: Specifies the bounding volume that corresponds to the
|
||||
// viewing frustum. Any primitives that fall entirely
|
||||
// view frustum. Any primitives that fall entirely
|
||||
// outside of this volume are not drawn.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void qpCullTraverser::
|
||||
@ -78,6 +132,25 @@ set_view_frustum(GeometricBoundingVolume *view_frustum) {
|
||||
_view_frustum = view_frustum;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: qpCullTraverser::get_view_frustum
|
||||
// Access: Public
|
||||
// Description: Returns the bounding volume that corresponds to the
|
||||
// view frustum, or NULL if the view frustum is not in
|
||||
// use or has not been set.
|
||||
//
|
||||
// Note that the view frustum returned here is always in
|
||||
// the coordinate space of the starting node, not the
|
||||
// current node, even if it is sampled during a
|
||||
// traversal. To get the view frustum in the current
|
||||
// node's coordinate space, check in the current
|
||||
// CullTraverserData.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE GeometricBoundingVolume *qpCullTraverser::
|
||||
get_view_frustum() const {
|
||||
return _view_frustum;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: qpCullTraverser::set_guard_band
|
||||
// Access: Public
|
||||
@ -99,6 +172,25 @@ set_guard_band(GeometricBoundingVolume *guard_band) {
|
||||
_guard_band = guard_band;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: qpCullTraverser::get_guard_band
|
||||
// Access: Public
|
||||
// Description: Returns the bounding volume that corresponds to the
|
||||
// guard band, or NULL if the guard band is not in
|
||||
// use or has not been set.
|
||||
//
|
||||
// Note that the guard band returned here is always in
|
||||
// the coordinate space of the starting node, not the
|
||||
// current node, even if it is sampled during a
|
||||
// traversal. To get the guard band in the current
|
||||
// node's coordinate space, check in the current
|
||||
// CullTraverserData.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE GeometricBoundingVolume *qpCullTraverser::
|
||||
get_guard_band() const {
|
||||
return _guard_band;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: qpCullTraverser::set_cull_handler
|
||||
// Access: Public
|
||||
@ -109,3 +201,14 @@ INLINE void qpCullTraverser::
|
||||
set_cull_handler(CullHandler *cull_handler) {
|
||||
_cull_handler = cull_handler;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: qpCullTraverser::get_cull_handler
|
||||
// Access: Public
|
||||
// Description: Returns the object that will receive the culled
|
||||
// Geoms.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE CullHandler *qpCullTraverser::
|
||||
get_cull_handler() const {
|
||||
return _cull_handler;
|
||||
}
|
||||
|
@ -26,6 +26,9 @@
|
||||
#include "qpgeomNode.h"
|
||||
#include "config_pgraph.h"
|
||||
|
||||
|
||||
TypeHandle qpCullTraverser::_type_handle;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: qpCullTraverser::Constructor
|
||||
// Access: Public
|
||||
@ -40,6 +43,23 @@ qpCullTraverser() {
|
||||
_cull_handler = (CullHandler *)NULL;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: qpCullTraverser::Copy Constructor
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
qpCullTraverser::
|
||||
qpCullTraverser(const qpCullTraverser ©) :
|
||||
_initial_state(copy._initial_state),
|
||||
_camera_mask(copy._camera_mask),
|
||||
_camera_transform(copy._camera_transform),
|
||||
_render_transform(copy._render_transform),
|
||||
_view_frustum(copy._view_frustum),
|
||||
_guard_band(copy._guard_band),
|
||||
_cull_handler(copy._cull_handler)
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: qpCullTraverser::traverse
|
||||
// Access: Public
|
||||
@ -50,20 +70,19 @@ traverse(PandaNode *root) {
|
||||
nassertv(_cull_handler != (CullHandler *)NULL);
|
||||
|
||||
CullTraverserData data(_render_transform, TransformState::make_identity(),
|
||||
_initial_state, _view_frustum, _guard_band,
|
||||
_camera_transform);
|
||||
r_traverse(root, data);
|
||||
_initial_state, _view_frustum, _guard_band);
|
||||
traverse(root, data);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: qpCullTraverser::r_traverse
|
||||
// Access: Private
|
||||
// Description: The recursive traversal implementation.
|
||||
// Function: qpCullTraverser::traverse
|
||||
// Access: Public
|
||||
// Description: Traverses from the indicated node with the given
|
||||
// data, which has not yet been converted into the
|
||||
// node's space.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void qpCullTraverser::
|
||||
r_traverse(PandaNode *node, const CullTraverserData &data) {
|
||||
CullTraverserData next_data(data);
|
||||
|
||||
traverse(PandaNode *node, const CullTraverserData &data) {
|
||||
// Most nodes will have no transform or state, and will not
|
||||
// contain decals or require a special cull callback. As an
|
||||
// optimization, we should tag nodes with these properties as
|
||||
@ -74,45 +93,58 @@ r_traverse(PandaNode *node, const CullTraverserData &data) {
|
||||
return;
|
||||
}
|
||||
|
||||
CullTraverserData next_data(data);
|
||||
if (next_data.is_in_view(node, _camera_mask)) {
|
||||
next_data.apply_transform_and_state(node);
|
||||
next_data.apply_transform_and_state(this, node);
|
||||
|
||||
if (node->has_cull_callback()) {
|
||||
if (!node->cull_callback(next_data)) {
|
||||
if (!node->cull_callback(this, next_data)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
const RenderState *node_state = node->get_state();
|
||||
if (node_state->has_decal()) {
|
||||
start_decal(node, next_data);
|
||||
traverse_below(node, next_data);
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: qpCullTraverser::traverse_below
|
||||
// Access: Public
|
||||
// Description: Traverses all the children of the indicated node,
|
||||
// with the given data, which been converted into the
|
||||
// node's space.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void qpCullTraverser::
|
||||
traverse_below(PandaNode *node, const CullTraverserData &data) {
|
||||
const RenderState *node_state = node->get_state();
|
||||
if (node_state->has_decal()) {
|
||||
start_decal(node, data);
|
||||
|
||||
} else {
|
||||
if (node->is_geom_node()) {
|
||||
qpGeomNode *geom_node = DCAST(qpGeomNode, node);
|
||||
|
||||
// Get all the Geoms, with no decalling.
|
||||
int num_geoms = geom_node->get_num_geoms();
|
||||
for (int i = 0; i < num_geoms; i++) {
|
||||
CullableObject *object = new CullableObject(data, geom_node, i);
|
||||
_cull_handler->record_object(object);
|
||||
}
|
||||
}
|
||||
|
||||
// Now visit all the node's children.
|
||||
PandaNode::Children cr = node->get_children();
|
||||
int num_children = cr.get_num_children();
|
||||
if (node->has_selective_visibility()) {
|
||||
int i = node->get_first_visible_child();
|
||||
while (i < num_children) {
|
||||
traverse(cr.get_child(i), data);
|
||||
i = node->get_next_visible_child(i);
|
||||
}
|
||||
|
||||
} else {
|
||||
if (node->is_geom_node()) {
|
||||
qpGeomNode *geom_node = DCAST(qpGeomNode, node);
|
||||
|
||||
// Get all the Geoms, with no decalling.
|
||||
int num_geoms = geom_node->get_num_geoms();
|
||||
for (int i = 0; i < num_geoms; i++) {
|
||||
CullableObject *object = new CullableObject(next_data, geom_node, i);
|
||||
_cull_handler->record_object(object);
|
||||
}
|
||||
}
|
||||
|
||||
// Now visit all the node's children.
|
||||
PandaNode::Children cr = node->get_children();
|
||||
int num_children = cr.get_num_children();
|
||||
if (node->has_selective_visibility()) {
|
||||
int i = node->get_first_visible_child();
|
||||
while (i < num_children) {
|
||||
r_traverse(cr.get_child(i), next_data);
|
||||
i = node->get_next_visible_child(i);
|
||||
}
|
||||
|
||||
} else {
|
||||
for (int i = 0; i < num_children; i++) {
|
||||
r_traverse(cr.get_child(i), next_data);
|
||||
}
|
||||
for (int i = 0; i < num_children; i++) {
|
||||
traverse(cr.get_child(i), data);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -188,15 +220,14 @@ start_decal(PandaNode *node, const CullTraverserData &data) {
|
||||
CullableObject *qpCullTraverser::
|
||||
r_get_decals(PandaNode *node, const CullTraverserData &data,
|
||||
CullableObject *decals) {
|
||||
CullTraverserData next_data(data);
|
||||
|
||||
if (node->get_transform()->is_invalid()) {
|
||||
// If the transform is invalid, forget it.
|
||||
return decals;
|
||||
}
|
||||
|
||||
CullTraverserData next_data(data);
|
||||
if (next_data.is_in_view(node, _camera_mask)) {
|
||||
next_data.apply_transform_and_state(node);
|
||||
next_data.apply_transform_and_state(this, node);
|
||||
|
||||
// First, visit all of the node's children.
|
||||
PandaNode::Children cr = node->get_children();
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "geometricBoundingVolume.h"
|
||||
#include "pointerTo.h"
|
||||
#include "drawMask.h"
|
||||
#include "typedObject.h"
|
||||
|
||||
class PandaNode;
|
||||
class CullHandler;
|
||||
@ -40,22 +41,37 @@ class CullableObject;
|
||||
// Each renderable Geom encountered is passed along with
|
||||
// its associated RenderState to the CullHandler object.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
class EXPCL_PANDA qpCullTraverser {
|
||||
class EXPCL_PANDA qpCullTraverser : public TypedObject {
|
||||
public:
|
||||
qpCullTraverser();
|
||||
qpCullTraverser(const qpCullTraverser ©);
|
||||
|
||||
INLINE void set_initial_state(const RenderState *initial_state);
|
||||
INLINE const RenderState *get_initial_state() const;
|
||||
|
||||
INLINE void set_camera_mask(const DrawMask &draw_mask);
|
||||
INLINE const DrawMask &get_camera_mask() const;
|
||||
|
||||
INLINE void set_camera_transform(const TransformState *camera_transform);
|
||||
INLINE const TransformState *get_camera_transform() const;
|
||||
|
||||
INLINE void set_render_transform(const TransformState *render_transform);
|
||||
INLINE const TransformState *get_render_transform() const;
|
||||
|
||||
INLINE void set_view_frustum(GeometricBoundingVolume *view_frustum);
|
||||
INLINE GeometricBoundingVolume *get_view_frustum() const;
|
||||
|
||||
INLINE void set_guard_band(GeometricBoundingVolume *guard_band);
|
||||
INLINE GeometricBoundingVolume *get_guard_band() const;
|
||||
|
||||
INLINE void set_cull_handler(CullHandler *cull_handler);
|
||||
INLINE CullHandler *get_cull_handler() const;
|
||||
|
||||
void traverse(PandaNode *root);
|
||||
void traverse(PandaNode *node, const CullTraverserData &data);
|
||||
void traverse_below(PandaNode *node, const CullTraverserData &data);
|
||||
|
||||
private:
|
||||
void r_traverse(PandaNode *node, const CullTraverserData &data);
|
||||
void start_decal(PandaNode *node, const CullTraverserData &data);
|
||||
CullableObject *r_get_decals(PandaNode *node,
|
||||
const CullTraverserData &data,
|
||||
@ -68,6 +84,23 @@ private:
|
||||
PT(GeometricBoundingVolume) _view_frustum;
|
||||
PT(GeometricBoundingVolume) _guard_band;
|
||||
CullHandler *_cull_handler;
|
||||
|
||||
public:
|
||||
static TypeHandle get_class_type() {
|
||||
return _type_handle;
|
||||
}
|
||||
static void init_type() {
|
||||
TypedObject::init_type();
|
||||
register_type(_type_handle, "qpCullTraverser",
|
||||
TypedObject::get_class_type());
|
||||
}
|
||||
virtual TypeHandle get_type() const {
|
||||
return get_class_type();
|
||||
}
|
||||
virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
|
||||
|
||||
private:
|
||||
static TypeHandle _type_handle;
|
||||
};
|
||||
|
||||
#include "qpcullTraverser.I"
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
#include "qplodNode.h"
|
||||
#include "cullTraverserData.h"
|
||||
#include "qpcullTraverser.h"
|
||||
|
||||
TypeHandle qpLODNode::_type_handle;
|
||||
|
||||
@ -114,7 +115,7 @@ has_cull_callback() const {
|
||||
// visible, or false if it should be culled.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool qpLODNode::
|
||||
cull_callback(CullTraverserData &data) {
|
||||
cull_callback(qpCullTraverser *trav, CullTraverserData &data) {
|
||||
if (data._net_transform->is_singular()) {
|
||||
// If we're under a singular transform, we can't compute the LOD;
|
||||
// select none of them instead.
|
||||
@ -126,7 +127,7 @@ cull_callback(CullTraverserData &data) {
|
||||
|
||||
// Get the LOD center in camera space
|
||||
CPT(TransformState) rel_transform =
|
||||
data._net_transform->invert_compose(data._camera_transform);
|
||||
data._net_transform->invert_compose(trav->get_camera_transform());
|
||||
LPoint3f center = cdata->_lod._center * rel_transform->get_mat();
|
||||
|
||||
// Determine which child to traverse
|
||||
|
@ -42,7 +42,7 @@ public:
|
||||
virtual PandaNode *make_copy() const;
|
||||
virtual void xform(const LMatrix4f &mat);
|
||||
virtual bool has_cull_callback() const;
|
||||
virtual bool cull_callback(CullTraverserData &data);
|
||||
virtual bool cull_callback(qpCullTraverser *trav, CullTraverserData &data);
|
||||
|
||||
virtual void output(ostream &out) const;
|
||||
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
#include "pandabase.h"
|
||||
#include "qpsequenceNode.h"
|
||||
#include "qpcullTraverser.h"
|
||||
|
||||
TypeHandle qpSequenceNode::_type_handle;
|
||||
|
||||
@ -121,7 +122,7 @@ has_cull_callback() const {
|
||||
// visible, or false if it should be culled.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool qpSequenceNode::
|
||||
cull_callback(CullTraverserData &) {
|
||||
cull_callback(qpCullTraverser *, CullTraverserData &) {
|
||||
select_child(get_visible_child());
|
||||
return true;
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ public:
|
||||
virtual PandaNode *make_copy() const;
|
||||
|
||||
virtual bool has_cull_callback() const;
|
||||
virtual bool cull_callback(CullTraverserData &data);
|
||||
virtual bool cull_callback(qpCullTraverser *trav, CullTraverserData &data);
|
||||
|
||||
PUBLISHED:
|
||||
INLINE void set_cycle_rate(float cycle_rate);
|
||||
|
@ -12,40 +12,58 @@
|
||||
#define SOURCES \
|
||||
config_pgui.h \
|
||||
pgButton.I pgButton.h \
|
||||
qppgButton.I qppgButton.h \
|
||||
pgCullTraverser.I pgCullTraverser.h \
|
||||
pgEntry.I pgEntry.h \
|
||||
qppgEntry.I qppgEntry.h \
|
||||
pgMouseWatcherGroup.I pgMouseWatcherGroup.h \
|
||||
pgMouseWatcherParameter.I pgMouseWatcherParameter.h \
|
||||
pgFrameStyle.I pgFrameStyle.h \
|
||||
pgItem.I pgItem.h \
|
||||
qppgItem.I qppgItem.h \
|
||||
pgMouseWatcherBackground.h \
|
||||
pgMouseWatcherRegion.I pgMouseWatcherRegion.h \
|
||||
pgTop.I pgTop.h \
|
||||
pgWaitBar.I pgWaitBar.h
|
||||
qppgTop.I qppgTop.h \
|
||||
pgWaitBar.I pgWaitBar.h \
|
||||
qppgWaitBar.I qppgWaitBar.h
|
||||
|
||||
#define INCLUDED_SOURCES \
|
||||
config_pgui.cxx \
|
||||
pgButton.cxx \
|
||||
qppgButton.cxx \
|
||||
pgCullTraverser.cxx \
|
||||
pgEntry.cxx \
|
||||
qppgEntry.cxx \
|
||||
pgMouseWatcherGroup.cxx \
|
||||
pgMouseWatcherParameter.cxx \
|
||||
pgFrameStyle.cxx \
|
||||
pgItem.cxx \
|
||||
qppgItem.cxx \
|
||||
pgMouseWatcherBackground.cxx \
|
||||
pgMouseWatcherRegion.cxx \
|
||||
pgTop.cxx \
|
||||
pgWaitBar.cxx
|
||||
qppgTop.cxx \
|
||||
pgWaitBar.cxx \
|
||||
qppgWaitBar.cxx
|
||||
|
||||
#define INSTALL_HEADERS \
|
||||
pgButton.I pgButton.h \
|
||||
qppgButton.I qppgButton.h \
|
||||
pgCullTraverser.I pgCullTraverser.h \
|
||||
pgEntry.I pgEntry.h \
|
||||
qppgEntry.I qppgEntry.h \
|
||||
pgMouseWatcherGroup.I pgMouseWatcherGroup.h \
|
||||
pgMouseWatcherParameter.I pgMouseWatcherParameter.h \
|
||||
pgFrameStyle.I pgFrameStyle.h \
|
||||
pgItem.I pgItem.h \
|
||||
qppgItem.I qppgItem.h \
|
||||
pgMouseWatcherBackground.h \
|
||||
pgMouseWatcherRegion.I pgMouseWatcherRegion.h \
|
||||
pgTop.I pgTop.h \
|
||||
pgWaitBar.I pgWaitBar.h
|
||||
qppgTop.I qppgTop.h \
|
||||
pgWaitBar.I pgWaitBar.h \
|
||||
qppgWaitBar.I qppgWaitBar.h
|
||||
|
||||
|
||||
#define IGATESCAN all
|
||||
|
@ -18,14 +18,20 @@
|
||||
|
||||
#include "config_pgui.h"
|
||||
#include "pgButton.h"
|
||||
#include "qppgButton.h"
|
||||
#include "pgCullTraverser.h"
|
||||
#include "pgEntry.h"
|
||||
#include "qppgEntry.h"
|
||||
#include "pgMouseWatcherParameter.h"
|
||||
#include "pgMouseWatcherGroup.h"
|
||||
#include "pgItem.h"
|
||||
#include "qppgItem.h"
|
||||
#include "pgMouseWatcherBackground.h"
|
||||
#include "pgMouseWatcherRegion.h"
|
||||
#include "pgTop.h"
|
||||
#include "qppgTop.h"
|
||||
#include "pgWaitBar.h"
|
||||
#include "qppgWaitBar.h"
|
||||
|
||||
#include "dconfig.h"
|
||||
|
||||
@ -63,12 +69,18 @@ init_libpgui() {
|
||||
initialized = true;
|
||||
|
||||
PGButton::init_type();
|
||||
qpPGButton::init_type();
|
||||
PGCullTraverser::init_type();
|
||||
PGEntry::init_type();
|
||||
qpPGEntry::init_type();
|
||||
PGMouseWatcherParameter::init_type();
|
||||
PGMouseWatcherGroup::init_type();
|
||||
PGItem::init_type();
|
||||
qpPGItem::init_type();
|
||||
PGMouseWatcherBackground::init_type();
|
||||
PGMouseWatcherRegion::init_type();
|
||||
PGTop::init_type();
|
||||
qpPGTop::init_type();
|
||||
PGWaitBar::init_type();
|
||||
qpPGWaitBar::init_type();
|
||||
}
|
||||
|
@ -19,11 +19,15 @@
|
||||
#include "pgFrameStyle.h"
|
||||
#include "geomTristrip.h"
|
||||
#include "geomTrifan.h"
|
||||
#include "qpgeomNode.h"
|
||||
#include "pandaNode.h"
|
||||
#include "transparencyAttrib.h"
|
||||
#include "pointerTo.h"
|
||||
|
||||
#include "geomNode.h"
|
||||
#include "transparencyProperty.h"
|
||||
#include "transparencyTransition.h"
|
||||
#include "renderRelation.h"
|
||||
#include "pointerTo.h"
|
||||
|
||||
ostream &
|
||||
operator << (ostream &out, PGFrameStyle::Type type) {
|
||||
@ -157,6 +161,58 @@ generate_into(Node *node, const LVecBase4f &frame) {
|
||||
return arc;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PGFrameStyle::generate_into
|
||||
// Access: Public
|
||||
// Description: Generates geometry representing a frame of the
|
||||
// indicated size, and parents it to the indicated node,
|
||||
// with a scene graph sort order of -1.
|
||||
//
|
||||
// The return value is the generated node, if any, or
|
||||
// NULL if nothing is generated.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
PandaNode *PGFrameStyle::
|
||||
generate_into(PandaNode *node, const LVecBase4f &frame) {
|
||||
PT(PandaNode) new_node;
|
||||
|
||||
switch (_type) {
|
||||
case T_none:
|
||||
return (PandaNode *)NULL;
|
||||
|
||||
case T_flat:
|
||||
new_node = qpgenerate_flat_geom(frame);
|
||||
break;
|
||||
|
||||
case T_bevel_out:
|
||||
new_node = qpgenerate_bevel_geom(frame, false);
|
||||
break;
|
||||
|
||||
case T_bevel_in:
|
||||
new_node = qpgenerate_bevel_geom(frame, true);
|
||||
break;
|
||||
|
||||
case T_groove:
|
||||
new_node = qpgenerate_groove_geom(frame, true);
|
||||
break;
|
||||
|
||||
case T_ridge:
|
||||
new_node = qpgenerate_groove_geom(frame, false);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (new_node != (PandaNode *)NULL && _color[3] != 1.0f) {
|
||||
// We've got some alpha on the color; we need transparency.
|
||||
new_node->set_attrib(TransparencyAttrib::make(TransparencyAttrib::M_alpha));
|
||||
}
|
||||
|
||||
// Adding the node to the parent keeps the reference count.
|
||||
node->add_child(new_node);
|
||||
return new_node;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PGFrameStyle::generate_flat_geom
|
||||
// Access: Private
|
||||
@ -583,3 +639,430 @@ generate_groove_geom(const LVecBase4f &frame, bool in) {
|
||||
|
||||
return gnode.p();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PGFrameStyle::qpgenerate_flat_geom
|
||||
// Access: Private
|
||||
// Description: Generates the qpGeomNode appropriate to a T_flat
|
||||
// frame.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
PT(PandaNode) PGFrameStyle::
|
||||
qpgenerate_flat_geom(const LVecBase4f &frame) {
|
||||
PT(qpGeomNode) gnode = new qpGeomNode("flat");
|
||||
Geom *geom = new GeomTristrip;
|
||||
gnode->add_geom(geom);
|
||||
|
||||
float left = frame[0];
|
||||
float right = frame[1];
|
||||
float bottom = frame[2];
|
||||
float top = frame[3];
|
||||
|
||||
PTA_int lengths=PTA_int::empty_array(0);
|
||||
lengths.push_back(4);
|
||||
|
||||
PTA_Vertexf verts;
|
||||
verts.push_back(Vertexf(left, 0.0f, top));
|
||||
verts.push_back(Vertexf(left, 0.0f, bottom));
|
||||
verts.push_back(Vertexf(right, 0.0f, top));
|
||||
verts.push_back(Vertexf(right, 0.0f, bottom));
|
||||
|
||||
geom->set_num_prims(1);
|
||||
geom->set_lengths(lengths);
|
||||
|
||||
geom->set_coords(verts);
|
||||
|
||||
PTA_Colorf colors;
|
||||
colors.push_back(_color);
|
||||
geom->set_colors(colors, G_OVERALL);
|
||||
|
||||
return gnode.p();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PGFrameStyle::qpgenerate_bevel_geom
|
||||
// Access: Private
|
||||
// Description: Generates the qpGeomNode appropriate to a T_bevel_in or
|
||||
// T_bevel_out frame.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
PT(PandaNode) PGFrameStyle::
|
||||
qpgenerate_bevel_geom(const LVecBase4f &frame, bool in) {
|
||||
//
|
||||
// Colors:
|
||||
//
|
||||
//
|
||||
// * * * * * * * * * * * * * * * * * * * * * * *
|
||||
// * * * *
|
||||
// * * ctop * *
|
||||
// * * * *
|
||||
// * * * * * * * * * * * * * * * * *
|
||||
// * * * *
|
||||
// * * * *
|
||||
// * cleft * _color * cright*
|
||||
// * * * *
|
||||
// * * * *
|
||||
// * * * * * * * * * * * * * * * * *
|
||||
// * * * *
|
||||
// * * cbottom * *
|
||||
// * * * *
|
||||
// * * * * * * * * * * * * * * * * * * * * * * *
|
||||
//
|
||||
//
|
||||
// Vertices:
|
||||
//
|
||||
// tristrip 1:
|
||||
// 4 * * * * * * * * * * * * * * * * * * * * * 6
|
||||
// * * *
|
||||
// * * *
|
||||
// * * *
|
||||
// * 5 * * * * * * * * * * * * * 7
|
||||
// * *
|
||||
// * *
|
||||
// * *
|
||||
// * *
|
||||
// * *
|
||||
// * 3 * * * * * * * * * * * * * 1
|
||||
// * * *
|
||||
// * * *
|
||||
// * * *
|
||||
// 2 * * * * * * * * * * * * * * * * * * * * * 0
|
||||
//
|
||||
// tristrip 2:
|
||||
// 1
|
||||
// * *
|
||||
// * *
|
||||
// * *
|
||||
// 5 * * * * * * * * * * * * * 3 *
|
||||
// * * *
|
||||
// * * *
|
||||
// * * *
|
||||
// * * *
|
||||
// * * *
|
||||
// 4 * * * * * * * * * * * * * 2 *
|
||||
// * *
|
||||
// * *
|
||||
// * *
|
||||
// 0
|
||||
|
||||
PT(qpGeomNode) gnode = new qpGeomNode("bevel");
|
||||
|
||||
float left = frame[0];
|
||||
float right = frame[1];
|
||||
float bottom = frame[2];
|
||||
float top = frame[3];
|
||||
|
||||
float inner_left = left + _width[0];
|
||||
float inner_right = right - _width[0];
|
||||
float inner_bottom = bottom + _width[1];
|
||||
float inner_top = top - _width[1];
|
||||
|
||||
float left_color_scale = 1.2;
|
||||
float right_color_scale = 0.8;
|
||||
float bottom_color_scale = 0.7;
|
||||
float top_color_scale = 1.3;
|
||||
|
||||
if (in) {
|
||||
right_color_scale = 1.2;
|
||||
left_color_scale = 0.8;
|
||||
top_color_scale = 0.7;
|
||||
bottom_color_scale = 1.3;
|
||||
}
|
||||
|
||||
// Clamp all colors at white, and don't scale the alpha.
|
||||
Colorf cleft(min(_color[0] * left_color_scale, 1.0f),
|
||||
min(_color[1] * left_color_scale, 1.0f),
|
||||
min(_color[2] * left_color_scale, 1.0f),
|
||||
_color[3]);
|
||||
|
||||
Colorf cright(min(_color[0] * right_color_scale, 1.0f),
|
||||
min(_color[1] * right_color_scale, 1.0f),
|
||||
min(_color[2] * right_color_scale, 1.0f),
|
||||
_color[3]);
|
||||
|
||||
Colorf cbottom(min(_color[0] * bottom_color_scale, 1.0f),
|
||||
min(_color[1] * bottom_color_scale, 1.0f),
|
||||
min(_color[2] * bottom_color_scale, 1.0f),
|
||||
_color[3]);
|
||||
|
||||
Colorf ctop(min(_color[0] * top_color_scale, 1.0f),
|
||||
min(_color[1] * top_color_scale, 1.0f),
|
||||
min(_color[2] * top_color_scale, 1.0f),
|
||||
_color[3]);
|
||||
|
||||
// Now make the tristrips.
|
||||
Geom *geom = new GeomTristrip;
|
||||
gnode->add_geom(geom);
|
||||
|
||||
PTA_int lengths;
|
||||
PTA_Vertexf verts;
|
||||
PTA_Colorf colors;
|
||||
|
||||
// Tristrip 1.
|
||||
lengths.push_back(8);
|
||||
|
||||
verts.push_back(Vertexf(right, 0.0f, bottom));
|
||||
verts.push_back(Vertexf(inner_right, 0.0f, inner_bottom));
|
||||
verts.push_back(Vertexf(left, 0.0f, bottom));
|
||||
verts.push_back(Vertexf(inner_left, 0.0f, inner_bottom));
|
||||
verts.push_back(Vertexf(left, 0.0f, top));
|
||||
verts.push_back(Vertexf(inner_left, 0.0f, inner_top));
|
||||
verts.push_back(Vertexf(right, 0.0f, top));
|
||||
verts.push_back(Vertexf(inner_right, 0.0f, inner_top));
|
||||
|
||||
colors.push_back(cbottom);
|
||||
colors.push_back(cbottom);
|
||||
colors.push_back(cleft);
|
||||
colors.push_back(cleft);
|
||||
colors.push_back(ctop);
|
||||
colors.push_back(ctop);
|
||||
|
||||
// Tristrip 2.
|
||||
lengths.push_back(6);
|
||||
|
||||
verts.push_back(Vertexf(right, 0.0f, bottom));
|
||||
verts.push_back(Vertexf(right, 0.0f, top));
|
||||
verts.push_back(Vertexf(inner_right, 0.0f, inner_bottom));
|
||||
verts.push_back(Vertexf(inner_right, 0.0f, inner_top));
|
||||
verts.push_back(Vertexf(inner_left, 0.0f, inner_bottom));
|
||||
verts.push_back(Vertexf(inner_left, 0.0f, inner_top));
|
||||
|
||||
colors.push_back(cright);
|
||||
colors.push_back(cright);
|
||||
colors.push_back(_color);
|
||||
colors.push_back(_color);
|
||||
|
||||
geom->set_num_prims(2);
|
||||
geom->set_lengths(lengths);
|
||||
geom->set_coords(verts);
|
||||
geom->set_colors(colors, G_PER_COMPONENT);
|
||||
|
||||
return gnode.p();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PGFrameStyle::qpgenerate_groove_geom
|
||||
// Access: Private
|
||||
// Description: Generates the qpGeomNode appropriate to a T_groove or
|
||||
// T_ridge frame.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
PT(PandaNode) PGFrameStyle::
|
||||
qpgenerate_groove_geom(const LVecBase4f &frame, bool in) {
|
||||
//
|
||||
// Colors:
|
||||
//
|
||||
//
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
// * * * *
|
||||
// * * ctop * *
|
||||
// * * * *
|
||||
// * * * * * * * * * * * * * * * * * * * * *
|
||||
// * * * * * *
|
||||
// * * * cbottom * * *
|
||||
// * * * * * *
|
||||
// * * * * * * * * * * * * * * *
|
||||
// * * * * * *
|
||||
// * * * * * *
|
||||
// * cleft * cright* _color * cleft * cright*
|
||||
// * * * * * *
|
||||
// * * * * * *
|
||||
// * * * * * * * * * * * * * * *
|
||||
// * * * * * *
|
||||
// * * * ctop * * *
|
||||
// * * * * * *
|
||||
// * * * * * * * * * * * * * * * * * * * * *
|
||||
// * * * *
|
||||
// * * cbottom * *
|
||||
// * * * *
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
//
|
||||
//
|
||||
// Vertices:
|
||||
//
|
||||
// tristrip 1:
|
||||
// 4 * * * * * * * * * * * * * * * * * * * * * * * * * 6
|
||||
// * * *
|
||||
// * * *
|
||||
// * * *
|
||||
// * 5 * * * * * * * * * * * * * * * * * 7
|
||||
// * *
|
||||
// * *
|
||||
// * *
|
||||
// * *
|
||||
// * *
|
||||
// * *
|
||||
// * *
|
||||
// * *
|
||||
// * *
|
||||
// * *
|
||||
// * *
|
||||
// * *
|
||||
// * *
|
||||
// * 3 * * * * * * * * * * * * * * * * * 1
|
||||
// * * *
|
||||
// * * *
|
||||
// * * *
|
||||
// 2 * * * * * * * * * * * * * * * * * * * * * * * * * 0
|
||||
//
|
||||
// tristrip 2:
|
||||
// 4 * * * * * * * * * * * * * * * * * 6
|
||||
// * * *
|
||||
// * * *
|
||||
// * * *
|
||||
// * 5 * * * * * * * * * 7
|
||||
// * *
|
||||
// * *
|
||||
// * *
|
||||
// * *
|
||||
// * *
|
||||
// * 3 * * * * * * * * * 1
|
||||
// * * *
|
||||
// * * *
|
||||
// * * *
|
||||
// 2 * * * * * * * * * * * * * * * * * 0
|
||||
//
|
||||
// tristrip 3:
|
||||
// 1
|
||||
// * *
|
||||
// * *
|
||||
// * *
|
||||
// 3 *
|
||||
// * * *
|
||||
// * * *
|
||||
// * * *
|
||||
// 7 * * * * * * * * * 5 * *
|
||||
// * * * *
|
||||
// * * * *
|
||||
// * * * *
|
||||
// * * * *
|
||||
// * * * *
|
||||
// 6 * * * * * * * * * 4 * *
|
||||
// * * *
|
||||
// * * *
|
||||
// * * *
|
||||
// 2 *
|
||||
// * *
|
||||
// * *
|
||||
// * *
|
||||
// 0
|
||||
|
||||
PT(qpGeomNode) gnode = new qpGeomNode("groove");
|
||||
|
||||
float left = frame[0];
|
||||
float right = frame[1];
|
||||
float bottom = frame[2];
|
||||
float top = frame[3];
|
||||
|
||||
float mid_left = left + 0.5f * _width[0];
|
||||
float mid_right = right - 0.5f * _width[0];
|
||||
float mid_bottom = bottom + 0.5f * _width[1];
|
||||
float mid_top = top - 0.5f * _width[1];
|
||||
|
||||
float inner_left = left + _width[0];
|
||||
float inner_right = right - _width[0];
|
||||
float inner_bottom = bottom + _width[1];
|
||||
float inner_top = top - _width[1];
|
||||
|
||||
float left_color_scale = 1.2f;
|
||||
float right_color_scale = 0.8f;
|
||||
float bottom_color_scale = 0.7f;
|
||||
float top_color_scale = 1.3f;
|
||||
|
||||
if (in) {
|
||||
right_color_scale = 1.2f;
|
||||
left_color_scale = 0.8f;
|
||||
top_color_scale = 0.7f;
|
||||
bottom_color_scale = 1.3f;
|
||||
}
|
||||
|
||||
// Clamp all colors at white, and don't scale the alpha.
|
||||
Colorf cleft(min(_color[0] * left_color_scale, 1.0f),
|
||||
min(_color[1] * left_color_scale, 1.0f),
|
||||
min(_color[2] * left_color_scale, 1.0f),
|
||||
_color[3]);
|
||||
|
||||
Colorf cright(min(_color[0] * right_color_scale, 1.0f),
|
||||
min(_color[1] * right_color_scale, 1.0f),
|
||||
min(_color[2] * right_color_scale, 1.0f),
|
||||
_color[3]);
|
||||
|
||||
Colorf cbottom(min(_color[0] * bottom_color_scale, 1.0f),
|
||||
min(_color[1] * bottom_color_scale, 1.0f),
|
||||
min(_color[2] * bottom_color_scale, 1.0f),
|
||||
_color[3]);
|
||||
|
||||
Colorf ctop(min(_color[0] * top_color_scale, 1.0f),
|
||||
min(_color[1] * top_color_scale, 1.0f),
|
||||
min(_color[2] * top_color_scale, 1.0f),
|
||||
_color[3]);
|
||||
|
||||
// Now make the tristrips.
|
||||
Geom *geom = new GeomTristrip;
|
||||
gnode->add_geom(geom);
|
||||
|
||||
PTA_int lengths;
|
||||
PTA_Vertexf verts;
|
||||
PTA_Colorf colors;
|
||||
|
||||
// Tristrip 1.
|
||||
lengths.push_back(8);
|
||||
|
||||
verts.push_back(Vertexf(right, 0.0f, bottom));
|
||||
verts.push_back(Vertexf(mid_right, 0.0f, mid_bottom));
|
||||
verts.push_back(Vertexf(left, 0.0f, bottom));
|
||||
verts.push_back(Vertexf(mid_left, 0.0f, mid_bottom));
|
||||
verts.push_back(Vertexf(left, 0.0f, top));
|
||||
verts.push_back(Vertexf(mid_left, 0.0f, mid_top));
|
||||
verts.push_back(Vertexf(right, 0.0f, top));
|
||||
verts.push_back(Vertexf(mid_right, 0.0f, mid_top));
|
||||
|
||||
colors.push_back(cbottom);
|
||||
colors.push_back(cbottom);
|
||||
colors.push_back(cleft);
|
||||
colors.push_back(cleft);
|
||||
colors.push_back(ctop);
|
||||
colors.push_back(ctop);
|
||||
|
||||
// Tristrip 2.
|
||||
lengths.push_back(8);
|
||||
|
||||
verts.push_back(Vertexf(mid_right, 0.0f, mid_bottom));
|
||||
verts.push_back(Vertexf(inner_right, 0.0f, inner_bottom));
|
||||
verts.push_back(Vertexf(mid_left, 0.0f, mid_bottom));
|
||||
verts.push_back(Vertexf(inner_left, 0.0f, inner_bottom));
|
||||
verts.push_back(Vertexf(mid_left, 0.0f, mid_top));
|
||||
verts.push_back(Vertexf(inner_left, 0.0f, inner_top));
|
||||
verts.push_back(Vertexf(mid_right, 0.0f, mid_top));
|
||||
verts.push_back(Vertexf(inner_right, 0.0f, inner_top));
|
||||
|
||||
colors.push_back(ctop);
|
||||
colors.push_back(ctop);
|
||||
colors.push_back(cright);
|
||||
colors.push_back(cright);
|
||||
colors.push_back(cbottom);
|
||||
colors.push_back(cbottom);
|
||||
|
||||
// Tristrip 3.
|
||||
lengths.push_back(8);
|
||||
|
||||
verts.push_back(Vertexf(right, 0.0f, bottom));
|
||||
verts.push_back(Vertexf(right, 0.0f, top));
|
||||
verts.push_back(Vertexf(mid_right, 0.0f, mid_bottom));
|
||||
verts.push_back(Vertexf(mid_right, 0.0f, mid_top));
|
||||
verts.push_back(Vertexf(inner_right, 0.0f, inner_bottom));
|
||||
verts.push_back(Vertexf(inner_right, 0.0f, inner_top));
|
||||
verts.push_back(Vertexf(inner_left, 0.0f, inner_bottom));
|
||||
verts.push_back(Vertexf(inner_left, 0.0f, inner_top));
|
||||
|
||||
colors.push_back(cright);
|
||||
colors.push_back(cright);
|
||||
colors.push_back(cleft);
|
||||
colors.push_back(cleft);
|
||||
colors.push_back(_color);
|
||||
colors.push_back(_color);
|
||||
|
||||
geom->set_num_prims(3);
|
||||
geom->set_lengths(lengths);
|
||||
geom->set_coords(verts);
|
||||
geom->set_colors(colors, G_PER_COMPONENT);
|
||||
|
||||
return gnode.p();
|
||||
}
|
||||
|
@ -26,6 +26,7 @@
|
||||
|
||||
class NodeRelation;
|
||||
class Node;
|
||||
class PandaNode;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Class : PGFrameStyle
|
||||
@ -64,11 +65,15 @@ PUBLISHED:
|
||||
public:
|
||||
bool xform(const LMatrix4f &mat);
|
||||
NodeRelation *generate_into(Node *node, const LVecBase4f &frame);
|
||||
PandaNode *generate_into(PandaNode *node, const LVecBase4f &frame);
|
||||
|
||||
private:
|
||||
PT_Node generate_flat_geom(const LVecBase4f &frame);
|
||||
PT_Node generate_bevel_geom(const LVecBase4f &frame, bool in);
|
||||
PT_Node generate_groove_geom(const LVecBase4f &frame, bool in);
|
||||
PT(PandaNode) qpgenerate_flat_geom(const LVecBase4f &frame);
|
||||
PT(PandaNode) qpgenerate_bevel_geom(const LVecBase4f &frame, bool in);
|
||||
PT(PandaNode) qpgenerate_groove_geom(const LVecBase4f &frame, bool in);
|
||||
|
||||
private:
|
||||
Type _type;
|
||||
|
@ -24,6 +24,17 @@
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE PGMouseWatcherGroup::
|
||||
PGMouseWatcherGroup(PGTop *top) : _top(top) {
|
||||
_qptop = (qpPGTop *)NULL;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PGMouseWatcherGroup::Constructor
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE PGMouseWatcherGroup::
|
||||
PGMouseWatcherGroup(qpPGTop *top) : _qptop(top) {
|
||||
_top = (PGTop *)NULL;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@ -38,3 +49,16 @@ clear_top(PGTop *top) {
|
||||
nassertv(_top == top);
|
||||
_top = (PGTop *)NULL;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PGMouseWatcherGroup::clear_top
|
||||
// Access: Public
|
||||
// Description: Called by the PGTop object to indicate that it is no
|
||||
// longer keeping the pointer to the PGMouseWatcherGroup
|
||||
// object.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void PGMouseWatcherGroup::
|
||||
clear_top(qpPGTop *top) {
|
||||
nassertv(_qptop == top);
|
||||
_qptop = (qpPGTop *)NULL;
|
||||
}
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "pointerTo.h"
|
||||
|
||||
class PGTop;
|
||||
class qpPGTop;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Class : PGMouseWatcherGroup
|
||||
@ -37,12 +38,15 @@ class PGTop;
|
||||
class EXPCL_PANDA PGMouseWatcherGroup : public MouseWatcherGroup {
|
||||
public:
|
||||
INLINE PGMouseWatcherGroup(PGTop *top);
|
||||
INLINE PGMouseWatcherGroup(qpPGTop *top);
|
||||
virtual ~PGMouseWatcherGroup();
|
||||
|
||||
INLINE void clear_top(PGTop *top);
|
||||
INLINE void clear_top(qpPGTop *top);
|
||||
|
||||
private:
|
||||
PGTop *_top;
|
||||
qpPGTop *_qptop;
|
||||
|
||||
public:
|
||||
static TypeHandle get_class_type() {
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
#include "pgMouseWatcherRegion.h"
|
||||
#include "pgItem.h"
|
||||
#include "qppgItem.h"
|
||||
|
||||
#include "string_utils.h"
|
||||
|
||||
@ -36,6 +37,22 @@ PGMouseWatcherRegion(PGItem *item) :
|
||||
#endif
|
||||
_item(item)
|
||||
{
|
||||
_qpitem = (qpPGItem *)NULL;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PGMouseWatcherRegion::Constructor
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
PGMouseWatcherRegion::
|
||||
PGMouseWatcherRegion(qpPGItem *item) :
|
||||
#ifndef CPPPARSER
|
||||
MouseWatcherRegion("pg" + format_string(_next_index++), 0, 0, 0, 0),
|
||||
#endif
|
||||
_qpitem(item)
|
||||
{
|
||||
_item = (PGItem *)NULL;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@ -62,6 +79,9 @@ enter(const MouseWatcherParameter ¶m) {
|
||||
if (_item != (PGItem *)NULL) {
|
||||
_item->enter(param);
|
||||
}
|
||||
if (_qpitem != (qpPGItem *)NULL) {
|
||||
_qpitem->enter(param);
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@ -78,6 +98,9 @@ exit(const MouseWatcherParameter ¶m) {
|
||||
if (_item != (PGItem *)NULL) {
|
||||
_item->exit(param);
|
||||
}
|
||||
if (_qpitem != (qpPGItem *)NULL) {
|
||||
_qpitem->exit(param);
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@ -95,6 +118,9 @@ within(const MouseWatcherParameter ¶m) {
|
||||
if (_item != (PGItem *)NULL) {
|
||||
_item->within(param);
|
||||
}
|
||||
if (_qpitem != (qpPGItem *)NULL) {
|
||||
_qpitem->within(param);
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@ -109,6 +135,9 @@ without(const MouseWatcherParameter ¶m) {
|
||||
if (_item != (PGItem *)NULL) {
|
||||
_item->without(param);
|
||||
}
|
||||
if (_qpitem != (qpPGItem *)NULL) {
|
||||
_qpitem->without(param);
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@ -123,6 +152,9 @@ press(const MouseWatcherParameter ¶m) {
|
||||
if (_item != (PGItem *)NULL) {
|
||||
_item->press(param, false);
|
||||
}
|
||||
if (_qpitem != (qpPGItem *)NULL) {
|
||||
_qpitem->press(param, false);
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@ -137,6 +169,9 @@ release(const MouseWatcherParameter ¶m) {
|
||||
if (_item != (PGItem *)NULL) {
|
||||
_item->release(param, false);
|
||||
}
|
||||
if (_qpitem != (qpPGItem *)NULL) {
|
||||
_qpitem->release(param, false);
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@ -150,4 +185,7 @@ keystroke(const MouseWatcherParameter ¶m) {
|
||||
if (_item != (PGItem *)NULL) {
|
||||
_item->keystroke(param, false);
|
||||
}
|
||||
if (_qpitem != (qpPGItem *)NULL) {
|
||||
_qpitem->keystroke(param, false);
|
||||
}
|
||||
}
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "mouseWatcherRegion.h"
|
||||
|
||||
class PGItem;
|
||||
class qpPGItem;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Class : PGMouseWatcherRegion
|
||||
@ -35,6 +36,7 @@ class PGItem;
|
||||
class EXPCL_PANDA PGMouseWatcherRegion : public MouseWatcherRegion {
|
||||
public:
|
||||
PGMouseWatcherRegion(PGItem *item);
|
||||
PGMouseWatcherRegion(qpPGItem *item);
|
||||
virtual ~PGMouseWatcherRegion();
|
||||
|
||||
virtual void enter(const MouseWatcherParameter ¶m);
|
||||
@ -47,6 +49,7 @@ public:
|
||||
|
||||
private:
|
||||
PGItem *_item;
|
||||
qpPGItem *_qpitem;
|
||||
static int _next_index;
|
||||
|
||||
public:
|
||||
@ -67,6 +70,7 @@ private:
|
||||
static TypeHandle _type_handle;
|
||||
|
||||
friend class PGItem;
|
||||
friend class qpPGItem;
|
||||
};
|
||||
|
||||
#include "pgMouseWatcherRegion.I"
|
||||
|
@ -1,7 +1,10 @@
|
||||
|
||||
#include "config_pgui.cxx"
|
||||
#include "pgButton.cxx"
|
||||
#include "qppgButton.cxx"
|
||||
#include "pgCullTraverser.cxx"
|
||||
#include "pgEntry.cxx"
|
||||
#include "qppgEntry.cxx"
|
||||
#include "pgMouseWatcherGroup.cxx"
|
||||
#include "pgMouseWatcherParameter.cxx"
|
||||
|
||||
|
@ -1,8 +1,11 @@
|
||||
|
||||
#include "pgFrameStyle.cxx"
|
||||
#include "pgItem.cxx"
|
||||
#include "qppgItem.cxx"
|
||||
#include "pgMouseWatcherBackground.cxx"
|
||||
#include "pgMouseWatcherRegion.cxx"
|
||||
#include "pgTop.cxx"
|
||||
#include "qppgTop.cxx"
|
||||
#include "pgWaitBar.cxx"
|
||||
#include "qppgWaitBar.cxx"
|
||||
|
||||
|
@ -845,7 +845,7 @@ exit_region(MouseWatcherRegion *region, const MouseWatcherParameter ¶m) {
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void qpMouseWatcher::
|
||||
do_transmit_data(const DataNodeTransmit &input, DataNodeTransmit &output) {
|
||||
if (!input.has_data(_pixel_xy_input)) {
|
||||
if (!input.has_data(_xy_input)) {
|
||||
// No mouse in the window.
|
||||
|
||||
if (_has_mouse) {
|
||||
@ -863,9 +863,9 @@ do_transmit_data(const DataNodeTransmit &input, DataNodeTransmit &output) {
|
||||
}
|
||||
|
||||
// The mouse is within the window. Get the current mouse position.
|
||||
const EventStoreVec2 *pixel_xy;
|
||||
DCAST_INTO_V(pixel_xy, input.get_data(_pixel_xy_input).get_ptr());
|
||||
const LVecBase2f &p = pixel_xy->get_value();
|
||||
const EventStoreVec2 *xy;
|
||||
DCAST_INTO_V(xy, input.get_data(_xy_input).get_ptr());
|
||||
const LVecBase2f &p = xy->get_value();
|
||||
_mouse.set(p[0], p[1]);
|
||||
|
||||
if (!_geometry.is_null()) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user