mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-02 01:44:06 -04:00
egg-optchar -rename
This commit is contained in:
parent
1bef9dd94a
commit
74c56a9487
@ -157,6 +157,11 @@ EggOptchar() {
|
|||||||
"joint will inherit the same net transform as its parent.",
|
"joint will inherit the same net transform as its parent.",
|
||||||
&EggOptchar::dispatch_vector_string_pair, NULL, &_new_joints);
|
&EggOptchar::dispatch_vector_string_pair, NULL, &_new_joints);
|
||||||
|
|
||||||
|
add_option
|
||||||
|
("rename", "joint,newjoint", 0,
|
||||||
|
"Renames the indicated joint, if present, to the given name.",
|
||||||
|
&EggOptchar::dispatch_vector_string_pair, NULL, &_rename_joints);
|
||||||
|
|
||||||
if (FFTCompressor::is_compression_available()) {
|
if (FFTCompressor::is_compression_available()) {
|
||||||
add_option
|
add_option
|
||||||
("optimal", "", 0,
|
("optimal", "", 0,
|
||||||
@ -262,6 +267,8 @@ run() {
|
|||||||
// morph sliders can simply be removed, while static sliders need
|
// morph sliders can simply be removed, while static sliders need
|
||||||
// to be applied to the vertices and then removed.
|
// to be applied to the vertices and then removed.
|
||||||
|
|
||||||
|
rename_joints();
|
||||||
|
|
||||||
// Quantize the vertex memberships. We call this even if
|
// Quantize the vertex memberships. We call this even if
|
||||||
// _vref_quantum is 0, because this also normalizes the vertex
|
// _vref_quantum is 0, because this also normalizes the vertex
|
||||||
// memberships.
|
// memberships.
|
||||||
@ -1357,6 +1364,42 @@ do_flag_groups(EggGroupNode *egg_group) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: EggOptchar::rename_joints
|
||||||
|
// Access: Private
|
||||||
|
// Description: Rename all the joints named with the -rename
|
||||||
|
// command-line option.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void EggOptchar::
|
||||||
|
rename_joints() {
|
||||||
|
for (StringPairs::iterator spi = _rename_joints.begin();
|
||||||
|
spi != _rename_joints.end();
|
||||||
|
++spi) {
|
||||||
|
const StringPair &sp = (*spi);
|
||||||
|
int num_characters = _collection->get_num_characters();
|
||||||
|
int ci;
|
||||||
|
for (ci = 0; ci < num_characters; ++ci) {
|
||||||
|
EggCharacterData *char_data = _collection->get_character(ci);
|
||||||
|
EggJointData *joint = char_data->find_joint(sp._a);
|
||||||
|
if (joint != (EggJointData *)NULL) {
|
||||||
|
nout << "Renaming joint " << sp._a << " to " << sp._b << "\n";
|
||||||
|
joint->set_name(sp._b);
|
||||||
|
|
||||||
|
int num_models = joint->get_num_models();
|
||||||
|
for (int mn = 0; mn < num_models; ++mn) {
|
||||||
|
if (joint->has_model(mn)) {
|
||||||
|
EggBackPointer *model = joint->get_model(mn);
|
||||||
|
model->set_name(sp._b);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
nout << "Couldn't find joint " << sp._a << "\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: EggOptchar::rename_primitives
|
// Function: EggOptchar::rename_primitives
|
||||||
// Access: Private
|
// Access: Private
|
||||||
|
@ -76,6 +76,7 @@ private:
|
|||||||
void quantize_vertex(EggVertex *egg_vertex);
|
void quantize_vertex(EggVertex *egg_vertex);
|
||||||
|
|
||||||
void do_flag_groups(EggGroupNode *egg_group);
|
void do_flag_groups(EggGroupNode *egg_group);
|
||||||
|
void rename_joints();
|
||||||
void rename_primitives(EggGroupNode *egg_group, const string &name);
|
void rename_primitives(EggGroupNode *egg_group, const string &name);
|
||||||
void do_preload();
|
void do_preload();
|
||||||
void do_defpose();
|
void do_defpose();
|
||||||
@ -95,6 +96,7 @@ private:
|
|||||||
StringPairs _new_joints;
|
StringPairs _new_joints;
|
||||||
StringPairs _reparent_joints;
|
StringPairs _reparent_joints;
|
||||||
StringPairs _zero_channels;
|
StringPairs _zero_channels;
|
||||||
|
StringPairs _rename_joints;
|
||||||
|
|
||||||
vector_string _keep_components;
|
vector_string _keep_components;
|
||||||
vector_string _drop_components;
|
vector_string _drop_components;
|
||||||
|
@ -60,3 +60,12 @@ bool EggBackPointer::
|
|||||||
has_vertices() const {
|
has_vertices() const {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: EggBackPointer::set_name
|
||||||
|
// Access: Public, Virtual
|
||||||
|
// Description: Applies the indicated name change to the egg file.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void EggBackPointer::
|
||||||
|
set_name(const string &name) {
|
||||||
|
}
|
||||||
|
@ -41,6 +41,8 @@ public:
|
|||||||
virtual void extend_to(int num_frames);
|
virtual void extend_to(int num_frames);
|
||||||
virtual bool has_vertices() const;
|
virtual bool has_vertices() const;
|
||||||
|
|
||||||
|
virtual void set_name(const string &name);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static TypeHandle get_class_type() {
|
static TypeHandle get_class_type() {
|
||||||
return _type_handle;
|
return _type_handle;
|
||||||
|
@ -229,3 +229,13 @@ make_new_joint(const string &name) {
|
|||||||
_joint->add_child(new_joint);
|
_joint->add_child(new_joint);
|
||||||
return new EggJointNodePointer(new_joint);
|
return new EggJointNodePointer(new_joint);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: EggJointNodePointer::set_name
|
||||||
|
// Access: Public, Virtual
|
||||||
|
// Description: Applies the indicated name change to the egg file.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void EggJointNodePointer::
|
||||||
|
set_name(const string &name) {
|
||||||
|
_joint->set_name(name);
|
||||||
|
}
|
||||||
|
@ -45,6 +45,8 @@ public:
|
|||||||
|
|
||||||
virtual EggJointPointer *make_new_joint(const string &name);
|
virtual EggJointPointer *make_new_joint(const string &name);
|
||||||
|
|
||||||
|
virtual void set_name(const string &name);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PT(EggGroup) _joint;
|
PT(EggGroup) _joint;
|
||||||
|
|
||||||
|
@ -314,3 +314,13 @@ make_new_joint(const string &name) {
|
|||||||
|
|
||||||
return new EggMatrixTablePointer(new_table);
|
return new EggMatrixTablePointer(new_table);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: EggMatrixTablePointer::set_name
|
||||||
|
// Access: Public, Virtual
|
||||||
|
// Description: Applies the indicated name change to the egg file.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void EggMatrixTablePointer::
|
||||||
|
set_name(const string &name) {
|
||||||
|
_table->set_name(name);
|
||||||
|
}
|
||||||
|
@ -51,6 +51,8 @@ public:
|
|||||||
|
|
||||||
virtual EggJointPointer *make_new_joint(const string &name);
|
virtual EggJointPointer *make_new_joint(const string &name);
|
||||||
|
|
||||||
|
virtual void set_name(const string &name);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PT(EggTable) _table;
|
PT(EggTable) _table;
|
||||||
PT(EggXfmSAnim) _xform;
|
PT(EggXfmSAnim) _xform;
|
||||||
|
@ -97,3 +97,16 @@ get_frame(int n) const {
|
|||||||
nassertr(n >= 0 && n < get_num_frames(), 0.0);
|
nassertr(n >= 0 && n < get_num_frames(), 0.0);
|
||||||
return _data->get_value(n);
|
return _data->get_value(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: EggScalarTablePointer::set_name
|
||||||
|
// Access: Public, Virtual
|
||||||
|
// Description: Applies the indicated name change to the egg file.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void EggScalarTablePointer::
|
||||||
|
set_name(const string &name) {
|
||||||
|
// Actually, let's not rename the slider table (yet), because we
|
||||||
|
// haven't written the code to rename all of the morph targets.
|
||||||
|
|
||||||
|
// _data->set_name(name);
|
||||||
|
}
|
||||||
|
@ -38,6 +38,8 @@ public:
|
|||||||
virtual void extend_to(int num_frames);
|
virtual void extend_to(int num_frames);
|
||||||
virtual double get_frame(int n) const;
|
virtual double get_frame(int n) const;
|
||||||
|
|
||||||
|
virtual void set_name(const string &name);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PT(EggSAnimData) _data;
|
PT(EggSAnimData) _data;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user