mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 10:22:45 -04:00
Added pview option -i (ignore group/channel names)
This commit is contained in:
parent
95f9d58591
commit
c8e4f430aa
@ -22,6 +22,7 @@
|
||||
#include "partBundleNode.h"
|
||||
#include "config_chan.h"
|
||||
#include "string_utils.h"
|
||||
#include "partGroup.h"
|
||||
|
||||
typedef pset<AnimBundleNode *> AnimNodes;
|
||||
typedef pmap<string, AnimNodes> Anims;
|
||||
@ -96,23 +97,29 @@ bind_anims(const PartNodes &parts, const AnimNodes &anims,
|
||||
// Function: r_find_bundles
|
||||
// Description: A support function for auto_bind(), below. Walks
|
||||
// through the hierarchy and finds all of the
|
||||
// PartBundles and AnimBundles.
|
||||
// PartBundles and AnimBundles. The flag 'classify'
|
||||
// controls whether or not the bundles are separated
|
||||
// into groups according to their root name. If not,
|
||||
// they are all filed under the same name.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
static void
|
||||
r_find_bundles(PandaNode *node, Anims &anims, Parts &parts) {
|
||||
r_find_bundles(PandaNode *node, Anims &anims, Parts &parts, bool classify) {
|
||||
if (node->is_of_type(AnimBundleNode::get_class_type())) {
|
||||
AnimBundleNode *bn = DCAST(AnimBundleNode, node);
|
||||
anims[bn->get_bundle()->get_name()].insert(bn);
|
||||
|
||||
if (classify)
|
||||
anims[bn->get_bundle()->get_name()].insert(bn);
|
||||
else anims[""].insert(bn);
|
||||
} else if (node->is_of_type(PartBundleNode::get_class_type())) {
|
||||
PartBundleNode *bn = DCAST(PartBundleNode, node);
|
||||
parts[bn->get_bundle()->get_name()].insert(bn);
|
||||
if (classify)
|
||||
parts[bn->get_bundle()->get_name()].insert(bn);
|
||||
else parts[""].insert(bn);
|
||||
}
|
||||
|
||||
PandaNode::Children cr = node->get_children();
|
||||
int num_children = cr.get_num_children();
|
||||
for (int i = 0; i < num_children; i++) {
|
||||
r_find_bundles(cr.get_child(i), anims, parts);
|
||||
r_find_bundles(cr.get_child(i), anims, parts, classify);
|
||||
}
|
||||
}
|
||||
|
||||
@ -132,8 +139,11 @@ auto_bind(PandaNode *root_node, AnimControlCollection &controls,
|
||||
// First, locate all the bundles in the subgraph.
|
||||
Anims anims;
|
||||
Parts parts;
|
||||
r_find_bundles(root_node, anims, parts);
|
||||
|
||||
bool classify = true;
|
||||
if (hierarchy_match_flags & PartGroup::HMF_ok_wrong_root_name)
|
||||
classify = false;
|
||||
r_find_bundles(root_node, anims, parts, classify);
|
||||
|
||||
if (chan_cat.is_debug()) {
|
||||
int anim_count = 0;
|
||||
Anims::const_iterator ai;
|
||||
|
@ -661,11 +661,11 @@ load_default_model(const NodePath &parent) {
|
||||
// matching animations found.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void WindowFramework::
|
||||
loop_animations() {
|
||||
loop_animations(int hierarchy_match_flags) {
|
||||
// If we happened to load up both a character file and its matching
|
||||
// animation file, attempt to bind them together now and start the
|
||||
// animations looping.
|
||||
auto_bind(get_render().node(), _anim_controls, ~0);
|
||||
auto_bind(get_render().node(), _anim_controls, hierarchy_match_flags);
|
||||
_anim_controls.loop_all(true);
|
||||
}
|
||||
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include "filename.h"
|
||||
#include "frameRateMeter.h"
|
||||
#include "pointerTo.h"
|
||||
#include "partGroup.h"
|
||||
#include "pvector.h"
|
||||
#include "typedWritableReferenceCount.h"
|
||||
#include "graphicsWindow.h"
|
||||
@ -87,7 +88,9 @@ public:
|
||||
const pvector<Filename> &files);
|
||||
NodePath load_model(const NodePath &parent, Filename filename);
|
||||
NodePath load_default_model(const NodePath &parent);
|
||||
void loop_animations();
|
||||
void loop_animations(int hierarchy_match_flags =
|
||||
PartGroup::HMF_ok_part_extra |
|
||||
PartGroup::HMF_ok_anim_extra);
|
||||
|
||||
enum BackgroundType {
|
||||
BT_other = 0,
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "texturePool.h"
|
||||
#include "multitexReducer.h"
|
||||
#include "sceneGraphReducer.h"
|
||||
#include "partGroup.h"
|
||||
|
||||
// By including checkPandaVersion.h, we guarantee that runtime
|
||||
// attempts to run pview will fail if it inadvertently links with the
|
||||
@ -219,6 +220,10 @@ help() {
|
||||
" displayed in the window. The default is not to open the window\n"
|
||||
" until all models are loaded.\n\n"
|
||||
|
||||
" -i\n"
|
||||
" Ignore bundle/group names. Normally, the <group> name must match\n"
|
||||
" the <bundle> name, or the animation will not be used.\n\n"
|
||||
|
||||
" -s filename\n"
|
||||
" After displaying the models, immediately take a screenshot and\n"
|
||||
" exit.\n\n"
|
||||
@ -246,11 +251,13 @@ main(int argc, char *argv[]) {
|
||||
bool auto_center = false;
|
||||
bool show_loading = false;
|
||||
bool auto_screenshot = false;
|
||||
int hierarchy_match_flags = PartGroup::HMF_ok_part_extra |
|
||||
PartGroup::HMF_ok_anim_extra;
|
||||
Filename screenshotfn;
|
||||
|
||||
extern char *optarg;
|
||||
extern int optind;
|
||||
static const char *optflags = "cls:Vh";
|
||||
static const char *optflags = "cls:Vhi";
|
||||
int flag = getopt(argc, argv, optflags);
|
||||
|
||||
while (flag != EOF) {
|
||||
@ -263,6 +270,10 @@ main(int argc, char *argv[]) {
|
||||
show_loading = true;
|
||||
break;
|
||||
|
||||
case 'i':
|
||||
hierarchy_match_flags |= PartGroup::HMF_ok_wrong_root_name;
|
||||
break;
|
||||
|
||||
case 's':
|
||||
auto_screenshot = true;
|
||||
screenshotfn = optarg;
|
||||
@ -322,7 +333,8 @@ main(int argc, char *argv[]) {
|
||||
} else {
|
||||
window->load_models(framework.get_models(), argc, argv);
|
||||
}
|
||||
window->loop_animations();
|
||||
window->loop_animations(hierarchy_match_flags);
|
||||
|
||||
loading_np.remove_node();
|
||||
|
||||
if (auto_center) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user