mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 02:42:49 -04:00
512 lines
22 KiB
Plaintext
512 lines
22 KiB
Plaintext
// Filename: somethingToEggConverter.I
|
|
// Created by: drose (26Apr01)
|
|
//
|
|
////////////////////////////////////////////////////////////////////
|
|
//
|
|
// PANDA 3D SOFTWARE
|
|
// Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved
|
|
//
|
|
// All use of this software is subject to the terms of the Panda 3d
|
|
// Software license. You should have received a copy of this license
|
|
// along with this source code; you will also find a current copy of
|
|
// the license at http://www.panda3d.org/license.txt .
|
|
//
|
|
// To contact the maintainers of this program write to
|
|
// panda3d@yahoogroups.com .
|
|
//
|
|
////////////////////////////////////////////////////////////////////
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
// Function: SomethingToEggConverter::set_texture_path_convert
|
|
// Access: Public
|
|
// Description: Sets the mode for converting texture paths extracted
|
|
// from the source file. The following options are
|
|
// defined:
|
|
//
|
|
// PC_relative - texture pathnames are made relative
|
|
// to the indicated tpc_directory.
|
|
//
|
|
// PC_absolute - textures are looked up along the
|
|
// search path and then converted to absolute
|
|
// filenames. tpc_directory is ignored.
|
|
//
|
|
// PC_rel_abs - as above, but the resulting filename
|
|
// is guaranteed to be relative to tpc_directory, and
|
|
// may include a number of ../ paths to guarantee
|
|
// this, if necessary.
|
|
//
|
|
// PC_strip - pathname components are stripped from
|
|
// the texture names, and only the base filename is
|
|
// retained.
|
|
//
|
|
// PC_unchanged - texture pathnames are left exactly
|
|
// as they appear in the source file.
|
|
////////////////////////////////////////////////////////////////////
|
|
INLINE void SomethingToEggConverter::
|
|
set_texture_path_convert(PathConvert tpc,
|
|
const Filename &tpc_directory) {
|
|
_tpc = tpc;
|
|
_tpc_directory = tpc_directory;
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
// Function: SomethingToEggConverter::set_model_path_convert
|
|
// Access: Public
|
|
// Description: Sets the mode for converting model paths extracted
|
|
// from the source file. These are typically for
|
|
// external references. See set_texture_path_convert
|
|
// for a complete list of PathConvert values and their
|
|
// interpretations.
|
|
////////////////////////////////////////////////////////////////////
|
|
INLINE void SomethingToEggConverter::
|
|
set_model_path_convert(PathConvert mpc,
|
|
const Filename &mpc_directory) {
|
|
_mpc = mpc;
|
|
_mpc_directory = mpc_directory;
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
// Function: SomethingToEggConverter::set_animation_convert
|
|
// Access: Public
|
|
// Description: Specifies how source animation will be converted into
|
|
// egg structures. The default is AC_none, which means
|
|
// animation tables will be ignored. This is only
|
|
// meaningful for converters that understand animation.
|
|
////////////////////////////////////////////////////////////////////
|
|
INLINE void SomethingToEggConverter::
|
|
set_animation_convert(AnimationConvert animation_convert) {
|
|
_animation_convert = animation_convert;
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
// Function: SomethingToEggConverter::get_animation_convert
|
|
// Access: Public
|
|
// Description: Returns how source animation will be converted into
|
|
// egg structures.
|
|
////////////////////////////////////////////////////////////////////
|
|
INLINE AnimationConvert SomethingToEggConverter::
|
|
get_animation_convert() const {
|
|
return _animation_convert;
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
// Function: SomethingToEggConverter::set_character_name
|
|
// Access: Public
|
|
// Description: Specifies the name of the character generated. This
|
|
// name should match between all the model and channel
|
|
// egg files for a particular character and its
|
|
// associated animations.
|
|
////////////////////////////////////////////////////////////////////
|
|
INLINE void SomethingToEggConverter::
|
|
set_character_name(const string &character_name) {
|
|
_character_name = character_name;
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
// Function: SomethingToEggConverter::get_character_name
|
|
// Access: Public
|
|
// Description: Returns the name of the character generated. See
|
|
// set_character_name().
|
|
////////////////////////////////////////////////////////////////////
|
|
INLINE const string &SomethingToEggConverter::
|
|
get_character_name() const {
|
|
return _character_name;
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
// Function: SomethingToEggConverter::set_start_frame
|
|
// Access: Public
|
|
// Description: Specifies the starting frame of the animation to
|
|
// convert, in the units specified by
|
|
// set_input_frame_rate(). If this is unspecified, the
|
|
// starting frame is taken from the source, for instance
|
|
// from the first frame of the animation slider.
|
|
////////////////////////////////////////////////////////////////////
|
|
INLINE void SomethingToEggConverter::
|
|
set_start_frame(double start_frame) {
|
|
_start_frame = start_frame;
|
|
_control_flags |= CF_start_frame;
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
// Function: SomethingToEggConverter::has_start_frame
|
|
// Access: Public
|
|
// Description: Returns true if the starting frame has been
|
|
// explicitly specified via set_start_frame(), or false
|
|
// if the starting frame should be implicit based on the
|
|
// source.
|
|
////////////////////////////////////////////////////////////////////
|
|
INLINE bool SomethingToEggConverter::
|
|
has_start_frame() const {
|
|
return (_control_flags & CF_start_frame) != 0;
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
// Function: SomethingToEggConverter::get_start_frame
|
|
// Access: Public
|
|
// Description: Returns the value set by a previous call to
|
|
// set_start_frame(). It is an error to call this if
|
|
// has_start_frame() returns false.
|
|
////////////////////////////////////////////////////////////////////
|
|
INLINE double SomethingToEggConverter::
|
|
get_start_frame() const {
|
|
nassertr(has_start_frame(), 0.0);
|
|
return _start_frame;
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
// Function: SomethingToEggConverter::clear_start_frame
|
|
// Access: Public
|
|
// Description: Removes the value previously set by
|
|
// set_start_frame().
|
|
////////////////////////////////////////////////////////////////////
|
|
INLINE void SomethingToEggConverter::
|
|
clear_start_frame() {
|
|
_start_frame = 0.0;
|
|
_control_flags &= ~CF_start_frame;
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
// Function: SomethingToEggConverter::set_end_frame
|
|
// Access: Public
|
|
// Description: Specifies the ending frame of the animation to
|
|
// convert, in the units specified by
|
|
// set_input_frame_rate(). If this is unspecified, the
|
|
// ending frame is taken from the source, for instance
|
|
// from the last frame of the animation slider.
|
|
////////////////////////////////////////////////////////////////////
|
|
INLINE void SomethingToEggConverter::
|
|
set_end_frame(double end_frame) {
|
|
_end_frame = end_frame;
|
|
_control_flags |= CF_end_frame;
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
// Function: SomethingToEggConverter::has_end_frame
|
|
// Access: Public
|
|
// Description: Returns true if the ending frame has been
|
|
// explicitly specified via set_end_frame(), or false
|
|
// if the ending frame should be implicit based on the
|
|
// source.
|
|
////////////////////////////////////////////////////////////////////
|
|
INLINE bool SomethingToEggConverter::
|
|
has_end_frame() const {
|
|
return (_control_flags & CF_end_frame) != 0;
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
// Function: SomethingToEggConverter::get_end_frame
|
|
// Access: Public
|
|
// Description: Returns the value set by a previous call to
|
|
// set_end_frame(). It is an error to call this if
|
|
// has_end_frame() returns false.
|
|
////////////////////////////////////////////////////////////////////
|
|
INLINE double SomethingToEggConverter::
|
|
get_end_frame() const {
|
|
nassertr(has_end_frame(), 0.0);
|
|
return _end_frame;
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
// Function: SomethingToEggConverter::clear_end_frame
|
|
// Access: Public
|
|
// Description: Removes the value previously set by
|
|
// set_end_frame().
|
|
////////////////////////////////////////////////////////////////////
|
|
INLINE void SomethingToEggConverter::
|
|
clear_end_frame() {
|
|
_end_frame = 0.0;
|
|
_control_flags &= ~CF_end_frame;
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
// Function: SomethingToEggConverter::set_frame_inc
|
|
// Access: Public
|
|
// Description: Specifies the increment between frames to extract.
|
|
// This is the amount to increment the time slider (in
|
|
// units of internal_frame_rate) between extracting each
|
|
// frame. If this is not specified, the default is
|
|
// taken from the animation package, or 1.0 if the
|
|
// animation package does not specified a frame
|
|
// increment.
|
|
////////////////////////////////////////////////////////////////////
|
|
INLINE void SomethingToEggConverter::
|
|
set_frame_inc(double frame_inc) {
|
|
_frame_inc = frame_inc;
|
|
_control_flags |= CF_frame_inc;
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
// Function: SomethingToEggConverter::has_frame_inc
|
|
// Access: Public
|
|
// Description: Returns true if the frame increment has been
|
|
// explicitly specified via set_frame_inc(), or false
|
|
// if the ending frame should be implicit based on the
|
|
// source.
|
|
////////////////////////////////////////////////////////////////////
|
|
INLINE bool SomethingToEggConverter::
|
|
has_frame_inc() const {
|
|
return (_control_flags & CF_frame_inc) != 0;
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
// Function: SomethingToEggConverter::get_frame_inc
|
|
// Access: Public
|
|
// Description: Returns the value set by a previous call to
|
|
// set_frame_inc(). It is an error to call this if
|
|
// has_frame_inc() returns false.
|
|
////////////////////////////////////////////////////////////////////
|
|
INLINE double SomethingToEggConverter::
|
|
get_frame_inc() const {
|
|
nassertr(has_frame_inc(), 0.0);
|
|
return _frame_inc;
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
// Function: SomethingToEggConverter::clear_frame_inc
|
|
// Access: Public
|
|
// Description: Removes the value previously set by
|
|
// set_frame_inc().
|
|
////////////////////////////////////////////////////////////////////
|
|
INLINE void SomethingToEggConverter::
|
|
clear_frame_inc() {
|
|
_frame_inc = 0.0;
|
|
_control_flags &= ~CF_frame_inc;
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
// Function: SomethingToEggConverter::set_input_frame_rate
|
|
// Access: Public
|
|
// Description: Specifies the number of frames per second that is
|
|
// represented by the "frame" unit in the animation
|
|
// package. If this is omitted, it is taken from
|
|
// whatever the file header indicates. Some animation
|
|
// packages do not encode a frame rate, in which case
|
|
// the default if this is omitted is the same as the
|
|
// output frame rate.
|
|
////////////////////////////////////////////////////////////////////
|
|
INLINE void SomethingToEggConverter::
|
|
set_input_frame_rate(double input_frame_rate) {
|
|
_input_frame_rate = input_frame_rate;
|
|
_control_flags |= CF_input_frame_rate;
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
// Function: SomethingToEggConverter::has_input_frame_rate
|
|
// Access: Public
|
|
// Description: Returns true if the frame rate has been
|
|
// explicitly specified via set_input_frame_rate(), or
|
|
// false otherwise.
|
|
////////////////////////////////////////////////////////////////////
|
|
INLINE bool SomethingToEggConverter::
|
|
has_input_frame_rate() const {
|
|
return (_control_flags & CF_input_frame_rate) != 0;
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
// Function: SomethingToEggConverter::get_input_frame_rate
|
|
// Access: Public
|
|
// Description: Returns the value set by a previous call to
|
|
// set_input_frame_rate(). It is an error to call this
|
|
// if has_input_frame_rate() returns false.
|
|
////////////////////////////////////////////////////////////////////
|
|
INLINE double SomethingToEggConverter::
|
|
get_input_frame_rate() const {
|
|
nassertr(has_input_frame_rate(), 0.0);
|
|
return _input_frame_rate;
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
// Function: SomethingToEggConverter::clear_input_frame_rate
|
|
// Access: Public
|
|
// Description: Removes the value previously set by
|
|
// set_input_frame_rate().
|
|
////////////////////////////////////////////////////////////////////
|
|
INLINE void SomethingToEggConverter::
|
|
clear_input_frame_rate() {
|
|
_input_frame_rate = 0.0;
|
|
_control_flags &= ~CF_input_frame_rate;
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
// Function: SomethingToEggConverter::set_output_frame_rate
|
|
// Access: Public
|
|
// Description: Specifies the number of frames per second that the
|
|
// resulting animation should be played at. If this is
|
|
// omitted, it is taken to be the same as the input
|
|
// frame rate.
|
|
////////////////////////////////////////////////////////////////////
|
|
INLINE void SomethingToEggConverter::
|
|
set_output_frame_rate(double output_frame_rate) {
|
|
_output_frame_rate = output_frame_rate;
|
|
_control_flags |= CF_output_frame_rate;
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
// Function: SomethingToEggConverter::has_output_frame_rate
|
|
// Access: Public
|
|
// Description: Returns true if the frame rate has been
|
|
// explicitly specified via set_output_frame_rate(), or
|
|
// false otherwise.
|
|
////////////////////////////////////////////////////////////////////
|
|
INLINE bool SomethingToEggConverter::
|
|
has_output_frame_rate() const {
|
|
return (_control_flags & CF_output_frame_rate) != 0;
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
// Function: SomethingToEggConverter::get_output_frame_rate
|
|
// Access: Public
|
|
// Description: Returns the value set by a previous call to
|
|
// set_output_frame_rate(). It is an error to call this
|
|
// if has_output_frame_rate() returns false.
|
|
////////////////////////////////////////////////////////////////////
|
|
INLINE double SomethingToEggConverter::
|
|
get_output_frame_rate() const {
|
|
nassertr(has_output_frame_rate(), 0.0);
|
|
return _output_frame_rate;
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
// Function: SomethingToEggConverter::clear_output_frame_rate
|
|
// Access: Public
|
|
// Description: Removes the value previously set by
|
|
// set_output_frame_rate().
|
|
////////////////////////////////////////////////////////////////////
|
|
INLINE void SomethingToEggConverter::
|
|
clear_output_frame_rate() {
|
|
_output_frame_rate = 0.0;
|
|
_control_flags &= ~CF_output_frame_rate;
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
// Function: SomethingToEggConverter::get_default_frame_rate
|
|
// Access: Public, Static
|
|
// Description: Returns the default frame rate if nothing is
|
|
// specified for input_frame_rate or output_frame_rate,
|
|
// and the animation package does not have an implicit
|
|
// frame rate.
|
|
////////////////////////////////////////////////////////////////////
|
|
INLINE double SomethingToEggConverter::
|
|
get_default_frame_rate() {
|
|
return 24.0;
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
// Function: SomethingToEggConverter::set_merge_externals
|
|
// Access: Public
|
|
// Description: Sets the merge_externals flag. When this is true,
|
|
// external references within the source file are read
|
|
// in and merged directly; otherwise, only a reference
|
|
// to a similarly-named egg file is inserted.
|
|
////////////////////////////////////////////////////////////////////
|
|
INLINE void SomethingToEggConverter::
|
|
set_merge_externals(bool merge_externals) {
|
|
_merge_externals = merge_externals;
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
// Function: SomethingToEggConverter::get_merge_externals
|
|
// Access: Public
|
|
// Description: Returns the current state of the merge_externals
|
|
// flag. See set_merge_externals().
|
|
////////////////////////////////////////////////////////////////////
|
|
INLINE bool SomethingToEggConverter::
|
|
get_merge_externals() const {
|
|
return _merge_externals;
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
// Function: SomethingToEggConverter::clear_egg_data
|
|
// Access: Public
|
|
// Description: Sets the EggData to NULL and makes the converter
|
|
// invalid.
|
|
////////////////////////////////////////////////////////////////////
|
|
INLINE void SomethingToEggConverter::
|
|
clear_egg_data() {
|
|
set_egg_data((EggData *)NULL, false);
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
// Function: SomethingToEggConverter::get_egg_data
|
|
// Access: Public
|
|
// Description: Returns the EggData structure.
|
|
////////////////////////////////////////////////////////////////////
|
|
INLINE EggData &SomethingToEggConverter::
|
|
get_egg_data() {
|
|
return *_egg_data;
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
// Function: SomethingToEggConverter::handle_external_reference
|
|
// Access: Public
|
|
// Description: Handles an external reference in the source file. If
|
|
// the merge_externals flag is true (see
|
|
// set_merge_externals()), this causes the named file to
|
|
// be read in and converted, and the converted egg
|
|
// geometry is parented to egg_parent. Otherwise, only
|
|
// a reference to a similarly named egg file is parented
|
|
// to egg_parent.
|
|
//
|
|
// The parameters orig_filename and searchpath are as
|
|
// those passed to convert_model_path().
|
|
//
|
|
// Returns true on success, false on failure.
|
|
////////////////////////////////////////////////////////////////////
|
|
bool SomethingToEggConverter::
|
|
handle_external_reference(EggGroupNode *egg_parent,
|
|
const Filename &orig_filename) {
|
|
return handle_external_reference(egg_parent, orig_filename, get_model_path());
|
|
}
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
// Function: SomethingToEggConverter::convert_texture_path
|
|
// Access: Public
|
|
// Description: Converts the indicated texture filename to a relative
|
|
// or absolute or whatever filename, according to _tpc
|
|
// and _tpc_directory. See convert_path().
|
|
////////////////////////////////////////////////////////////////////
|
|
INLINE Filename SomethingToEggConverter::
|
|
convert_texture_path(const Filename &orig_filename) {
|
|
return convert_path(orig_filename, get_texture_path(), _tpc_directory, _tpc);
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
// Function: SomethingToEggConverter::convert_texture_path
|
|
// Access: Public
|
|
// Description: Converts the indicated texture filename to a relative
|
|
// or absolute or whatever filename, according to _tpc
|
|
// and _tpc_directory. See convert_path().
|
|
////////////////////////////////////////////////////////////////////
|
|
INLINE Filename SomethingToEggConverter::
|
|
convert_texture_path(const Filename &orig_filename,
|
|
const DSearchPath &searchpath) {
|
|
return convert_path(orig_filename, searchpath, _tpc_directory, _tpc);
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
// Function: SomethingToEggConverter::convert_model_path
|
|
// Access: Public
|
|
// Description: Converts the indicated model filename to a relative
|
|
// or absolute or whatever filename, according to _mpc
|
|
// and _mpc_directory. See convert_path().
|
|
////////////////////////////////////////////////////////////////////
|
|
INLINE Filename SomethingToEggConverter::
|
|
convert_model_path(const Filename &orig_filename) {
|
|
return convert_path(orig_filename, get_model_path(), _mpc_directory, _mpc);
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
// Function: SomethingToEggConverter::convert_model_path
|
|
// Access: Public
|
|
// Description: Converts the indicated model filename to a relative
|
|
// or absolute or whatever filename, according to _mpc
|
|
// and _mpc_directory. See convert_path().
|
|
////////////////////////////////////////////////////////////////////
|
|
INLINE Filename SomethingToEggConverter::
|
|
convert_model_path(const Filename &orig_filename,
|
|
const DSearchPath &searchpath) {
|
|
return convert_path(orig_filename, searchpath, _mpc_directory, _mpc);
|
|
}
|