mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 18:31:55 -04:00
add unit scaling to maya2egg
This commit is contained in:
parent
ddf51444e7
commit
309840d086
@ -30,6 +30,8 @@
|
||||
#include "eggPolygon.h"
|
||||
|
||||
#include "pre_maya_include.h"
|
||||
#include <maya/MGlobal.h>
|
||||
#include <maya/MDistance.h>
|
||||
#include <maya/MArgList.h>
|
||||
#include <maya/MColor.h>
|
||||
#include <maya/MDagPath.h>
|
||||
@ -62,7 +64,6 @@
|
||||
MayaFile::
|
||||
MayaFile() {
|
||||
verbose = 0;
|
||||
_scale_units = 1.0;
|
||||
}
|
||||
|
||||
MayaFile::
|
||||
@ -102,6 +103,50 @@ make_egg(EggData &data) {
|
||||
traverse(data);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: MayaFile::get_units
|
||||
// Access: Public, Static
|
||||
// Description: Returns Maya's internal units in effect.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
DistanceUnit MayaFile::
|
||||
get_units() {
|
||||
switch (MDistance::internalUnit()) {
|
||||
case MDistance::kInches:
|
||||
return DU_inches;
|
||||
case MDistance::kFeet:
|
||||
return DU_feet;
|
||||
case MDistance::kYards:
|
||||
return DU_yards;
|
||||
case MDistance::kMiles:
|
||||
return DU_statute_miles;
|
||||
case MDistance::kMillimeters:
|
||||
return DU_millimeters;
|
||||
case MDistance::kCentimeters:
|
||||
return DU_centimeters;
|
||||
case MDistance::kKilometers:
|
||||
return DU_kilometers;
|
||||
case MDistance::kMeters:
|
||||
return DU_meters;
|
||||
|
||||
default:
|
||||
return DU_invalid;
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: MayaFile::get_coordinate_system
|
||||
// Access: Public, Static
|
||||
// Description: Returns Maya's internal coordinate system in effect.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
CoordinateSystem MayaFile::
|
||||
get_coordinate_system() {
|
||||
if (MGlobal::isYAxisUp()) {
|
||||
return CS_yup_right;
|
||||
} else {
|
||||
return CS_zup_right;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool MayaFile::
|
||||
traverse(EggData &data) {
|
||||
|
@ -22,6 +22,8 @@
|
||||
#include "pandatoolbase.h"
|
||||
#include "mayaShaders.h"
|
||||
#include "eggTextureCollection.h"
|
||||
#include "distanceUnit.h"
|
||||
#include "coordinateSystem.h"
|
||||
|
||||
class EggData;
|
||||
class EggGroup;
|
||||
@ -43,6 +45,9 @@ public:
|
||||
bool read(const string &filename);
|
||||
void make_egg(EggData &data);
|
||||
|
||||
static DistanceUnit get_units();
|
||||
static CoordinateSystem get_coordinate_system();
|
||||
|
||||
private:
|
||||
bool traverse(EggData &data);
|
||||
bool process_node(const MDagPath &dag_path, EggData &data);
|
||||
@ -65,7 +70,6 @@ private:
|
||||
Groups _groups;
|
||||
|
||||
public:
|
||||
double _scale_units;
|
||||
MayaShaders _shaders;
|
||||
EggTextureCollection _textures;
|
||||
};
|
||||
|
@ -19,10 +19,6 @@
|
||||
#include "mayaToEgg.h"
|
||||
#include "global_parameters.h"
|
||||
|
||||
#include "pre_maya_include.h"
|
||||
#include <maya/MGlobal.h>
|
||||
#include "post_maya_include.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: MayaToEgg::Constructor
|
||||
// Access: Public
|
||||
@ -32,7 +28,12 @@ MayaToEgg::
|
||||
MayaToEgg() :
|
||||
SomethingToEgg("Maya", ".mb")
|
||||
{
|
||||
add_units_options();
|
||||
add_normals_options();
|
||||
add_transform_options();
|
||||
// add_texture_path_options();
|
||||
// add_rel_dir_options();
|
||||
// add_search_path_options(false);
|
||||
|
||||
set_program_description
|
||||
("This program converts Maya model files to egg. Nothing fancy yet.");
|
||||
@ -85,16 +86,17 @@ run() {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// Set the coordinate system to match Maya's.
|
||||
if (!_got_coordinate_system) {
|
||||
// Choose a suitable coordinate system matching Maya.
|
||||
if (MGlobal::isYAxisUp()) {
|
||||
_coordinate_system = CS_yup_right;
|
||||
} else {
|
||||
_coordinate_system = CS_zup_right;
|
||||
}
|
||||
_coordinate_system = MayaFile::get_coordinate_system();
|
||||
}
|
||||
_data.set_coordinate_system(_coordinate_system);
|
||||
|
||||
// Get the units from the Maya file, if the user didn't override.
|
||||
if (_input_units == DU_invalid) {
|
||||
_input_units = MayaFile::get_units();
|
||||
}
|
||||
|
||||
_maya.make_egg(_data);
|
||||
|
||||
write_egg_file();
|
||||
|
Loading…
x
Reference in New Issue
Block a user