16 #include "softToEggConverter.h" 17 #include "config_softegg.h" 18 #include "softEggGroupUserData.h" 23 #include "eggVertex.h" 24 #include "eggComment.h" 25 #include "eggVertexPool.h" 26 #include "eggNurbsSurface.h" 27 #include "eggNurbsCurve.h" 28 #include "eggPolygon.h" 29 #include "eggPrimitive.h" 30 #include "eggTexture.h" 31 #include "eggTextureCollection.h" 32 #include "eggXfmSAnim.h" 33 #include "eggSAnimData.h" 34 #include "string_utils.h" 39 const int TEX_PER_MAT = 1;
47 SoftToEggConverter(
const string &program_name) :
48 _program_name(program_name)
50 _from_selection =
false;
51 _polygon_output =
false;
52 _polygon_tolerance = 0.01;
57 _transform_type = TT_model;
93 ignore_tex_offsets = 0;
105 _from_selection(copy._from_selection),
109 _polygon_output(copy._polygon_output),
110 _polygon_tolerance(copy._polygon_tolerance),
115 _transform_type(copy._transform_type)
125 ~SoftToEggConverter() {
140 softegg_cat.info() <<
141 "soft2egg takes a SoftImage scene or model\n" 142 "and outputs its contents as an egg file\n";
157 <<
"soft" <<
" [opts] (must specify -m or -s)\n\n" 161 softegg_cat.info() <<
"\n";
174 softegg_cat.info() <<
175 " -r <path> - Used to provide soft with the resource\n" 176 " Defaults to '/ful/ufs/soft371_mips2/3D/rsrc'.\n" 177 " -d <path> - Database path.\n" 178 " -s <scene> - Indicates that a scene will be converted.\n" 179 " -m <model> - Indicates that a model will be converted.\n" 180 " -t <path> - Specify path to place converted textures.\n" 181 " -T <name> - Specify filename for texture map listing.\n" 182 " -S <step> - Specify step for nurbs surface triangulation.\n" 183 " -M <name> - Specify model output filename. Defaults to scene name.\n" 184 " -A <name> - Specify anim output filename. Defaults to scene name.\n" 185 " -N <name> - Specify egg group name.\n" 186 " -k - Enable soft assignment for geometry.\n" 187 " -n - Specify egg NURBS representation instead of poly's.\n" 188 " -p - Specify egg polygon output for geometry.\n" 189 " -P <frame> - Specify frame number for static pose.\n" 190 " -b <frame> - Specify starting frame for animation (default = first).\n" 191 " -e <frame> - Specify ending frame for animation (default = last).\n" 192 " -f <fps> - Specify frame rate for animation playback.\n" 193 " -a - Compile animation tables if animation present.\n" 194 " -F - Ignore hierarchy and build a completely flat skeleton.\n" 195 " -v <level> - Set debug level.\n" 196 " -x - Shift NURBS parameters to preserve Alias textures.\n" 197 " -i - Ignore Soft texture uv offsets.\n" 198 " -u - Use Soft prefix in model names.\n" 199 " -c - Cancel morph conversion.\n" 200 " -C - Cancel duv conversion.\n" 201 " -D - Don't make the output model a character.\n" 202 " -o <prefix>- Convert only models with given prefix.\n";
220 softegg_cat.info() <<
"argc " << argc <<
"\n";
226 strcat(_commandLine, argv[i]);
227 strcat(_commandLine,
" ");
230 softegg_cat.info() << endl << _commandLine << endl;
233 while ((i < argc) && (argv[i][0] ==
'-') && okflag) {
234 softegg_cat.info() <<
"arg " << i <<
" is " << argv[i] <<
"\n";
252 char flag = argv[idx][1];
257 if ( strcmp( argv[idx+1],
"" ) ) {
259 rsrc_path = argv[idx+1];
260 softegg_cat.info() <<
"using rsrc path " << rsrc_path <<
"\n";
266 if ( strcmp( argv[idx+1],
"" ) ) {
268 database_name = argv[idx+1];
269 softegg_cat.info() <<
"using database " << database_name <<
"\n";
275 if ( strcmp( argv[idx+1],
"" ) ) {
277 scene_name = argv[idx+1];
278 softegg_cat.info() <<
"loading scene " << scene_name <<
"\n";
284 if ( strcmp( argv[idx+1],
"" ) ) {
286 model_name = argv[idx+1];
287 softegg_cat.info() <<
"loading model " << model_name << endl;
293 if ( strcmp( argv[idx+1],
"" ) ) {
295 tex_path = argv[idx+1];
296 softegg_cat.info() <<
"texture path: " << tex_path << endl;
302 if ( strcmp( argv[idx+1],
"") ) {
304 tex_filename = argv[idx+1];
305 softegg_cat.info() <<
"creating texture list file: " << tex_filename << endl;
311 if ( strcmp( argv[idx+1],
"" ) ) {
312 nurbs_step = atoi(argv[idx+1]);
313 softegg_cat.info() <<
"NURBS step: " << nurbs_step << endl;
319 if ( strcmp( argv[idx+1],
"" ) ) {
320 eggFileName = argv[idx+1];
321 softegg_cat.info() <<
"Model output filename: " << eggFileName << endl;
327 if ( strcmp( argv[idx+1],
"" ) ) {
328 animFileName = argv[idx+1];
329 softegg_cat.info() <<
"Anim output filename: " << animFileName << endl;
335 if ( strcmp( argv[idx+1],
"" ) ) {
336 eggGroupName = argv[idx+1];
337 softegg_cat.info() <<
"Egg group name: " << eggGroupName << endl;
343 if ( strcmp( argv[idx+1],
"" ) ) {
344 search_prefix = argv[idx+1];
345 softegg_cat.info() <<
"Only converting models with prefix: " << search_prefix << endl;
357 softegg_cat.info() <<
"canceling morph conversion\n";
362 softegg_cat.info() <<
"canceling uv animation conversion\n";
367 softegg_cat.info() <<
"making a non-character model\n";
373 softegg_cat.info() <<
"-k flag no longer necessary\n";
378 softegg_cat.info() <<
"outputting egg NURBS info\n";
383 softegg_cat.info() <<
"outputting egg polygon info\n";
387 if ( strcmp( argv[idx+1],
"" ) ) {
389 pose_frame = atoi(argv[idx+1]);
390 softegg_cat.info() <<
"generating static pose from frame " << pose_frame << endl;
397 softegg_cat.info() <<
"attempting to compile anim tables\n";
402 softegg_cat.info() <<
"building a flat skeleton!!!\n";
406 shift_textures = TRUE;
407 softegg_cat.info() <<
"shifting NURBS parameters...\n";
411 ignore_tex_offsets = TRUE;
412 softegg_cat.info() <<
"ignoring texture offsets...\n";
417 softegg_cat.info() <<
"using prefix in model names...\n";
422 if ( strcmp( argv[idx+1],
"" ) ) {
423 verbose = atoi(argv[idx+1]);
424 softegg_cat.info() <<
"using debug level " << verbose << endl;
430 anim_start = atoi(argv[idx]+2);
431 softegg_cat.info() <<
"animation starting at frame: " << anim_start << endl;
435 anim_end = atoi(argv[idx]+2);
436 softegg_cat.info() <<
"animation ending at frame: " << anim_end << endl;
440 if ( strcmp( argv[idx+1],
"" ) ) {
441 anim_rate = atoi(argv[idx+1]);
442 softegg_cat.info() <<
"animation frame rate: " << anim_rate << endl;
448 softegg_cat.info() << flag <<
" flag not supported\n";
506 char *fileName =
new char[_MAX_PATH];
507 char tempName[_MAX_PATH];
508 SAA_texture2DGetPicName( scene, texture, _MAX_PATH, tempName );
512 strcpy(fileName, tex_path);
515 char *tmpName = NULL;
516 tmpName = strrchr(tempName,
'/');
523 strcat(fileName,
"/");
524 strcat(fileName, tmpName);
527 strcpy(fileName, tempName);
530 strcat(fileName,
".pic");
551 <<
"Soft is not available.\n";
554 if (_character_name.empty()) {
573 _from_selection = from_selection;
578 softegg_cat.spam() <<
"eggData " <<
get_egg_data() <<
"\n";
581 softegg_cat.info() << _commandLine << endl;
584 if (_egg_data->get_coordinate_system() != CS_default) {
585 softegg_cat.spam() <<
"coordinate system is not default\n";
589 _tree._use_prefix = use_prefix;
590 _tree._search_prefix = search_prefix;
597 char *root_name = _tree.
GetRootName( eggFileName );
599 softegg_cat.debug() <<
"main group name: " << root_name << endl;
601 _character_name = root_name;
603 if (make_poly || make_nurbs) {
606 Filename output_filename(eggFileName);
607 _path_replace->_path_store = PS_relative;
608 _path_replace->_path_directory = output_filename.
get_dirname();
610 if (!convert_char_model()) {
615 if (!make_soft_skin()) {
620 if (!cleanup_soft_skin()) {
625 softegg_cat.info() <<
"Converted Softimage file\n";
628 _egg_data->write_egg(output_filename);
629 softegg_cat.info() <<
"Wrote Egg file " << output_filename << endl;
632 if (!convert_char_chan()) {
637 softegg_cat.info() <<
"Converted Softimage file\n";
640 _egg_data->write_egg(
Filename(animFileName));
641 softegg_cat.info() <<
"Wrote Anim file " << animFileName << endl;
655 if ((scene_name == NULL && model_name == NULL) || database_name == NULL) {
659 if ((result = SAA_Init(rsrc_path, FALSE)) != SI_SUCCESS) {
660 softegg_cat.info() <<
"Error: Couldn't get resource path!\n";
664 if ((result = SAA_databaseLoad(database_name, &database)) != SI_SUCCESS) {
665 softegg_cat.info() <<
"Error: Couldn't load database!\n";
669 if ((result = SAA_sceneGetCurrent(&scene)) != SI_SUCCESS) {
670 softegg_cat.info() <<
"Error: Couldn't get current scene!\n";
674 if ((result = SAA_sceneLoad( &database, scene_name, &scene )) != SI_SUCCESS) {
675 softegg_cat.info() <<
"Error: Couldn't load scene " << scene_name <<
"!\n";
679 if ( SAA_updatelistGet( &scene ) == SI_SUCCESS ) {
682 softegg_cat.info() <<
"setting Scene to frame " << pose_frame <<
"...\n";
684 SAA_frame2Seconds( &scene, pose_frame, &time );
685 SAA_updatelistEvalScene( &scene, time );
687 SAA_sceneFreeze(&scene);
691 if ( eggFileName == NULL ) {
693 string tempName(scene_name);
694 string::size_type end = tempName.find(
".dsc");
695 if (end != string::npos) {
696 madeName.assign(tempName.substr(0,end));
698 madeName.insert(madeName.size(),
"-nurb");
699 madeName.insert(madeName.size(),
".egg" );
701 eggFileName =
new char[madeName.size()+1];
702 strcpy(eggFileName, madeName.c_str());
705 if ( animFileName == NULL ) {
706 madeName.assign(tempName.substr(0,end));
707 madeName.insert(madeName.size(),
"-chan.egg");
708 animFileName =
new char[strlen(scene_name)+ 10];
709 strcpy(animFileName, madeName.c_str());
734 bool SoftToEggConverter::
735 convert_char_model() {
736 softegg_cat.spam() <<
"character name " << _character_name <<
"\n";
739 char_node->set_dart_type(EggGroup::DT_default);
741 return convert_hierarchy(char_node);
754 MorphTable::iterator mt;
755 for (mt = _morph_table.begin(); mt != _morph_table.end(); ++mt) {
757 if (!strcmp(anim->get_name().c_str(), name))
763 anim->set_fps(_tree._fps);
764 _morph_table.push_back(anim);
776 bool SoftToEggConverter::
777 convert_char_chan() {
778 int start_frame = -1;
780 int frame_inc, frame;
781 double output_frame_rate = anim_rate;
788 bundle_node->set_table_type(EggTable::TT_bundle);
797 SAA_sceneGetPlayCtrlStartFrame(&scene, &start_frame);
798 SAA_sceneGetPlayCtrlEndFrame(&scene, &end_frame);
799 SAA_sceneGetPlayCtrlFrameStep( &scene, &frame_inc );
803 softegg_cat.info() <<
"animation start frame: " << start_frame <<
" end frame: " << end_frame << endl;
804 softegg_cat.info() <<
"animation frame inc: " << frame_inc << endl;
806 _tree._fps = output_frame_rate / frame_inc;
825 start_frame = pose_frame;
826 end_frame = pose_frame;
829 start_frame = anim_start;
831 end_frame = anim_end;
832 for ( frame = start_frame; frame <= end_frame; frame += frame_inc) {
833 SAA_frame2Seconds( &scene, frame, &time );
836 SAA_updatelistEvalScene( &scene, time );
838 softegg_cat.spam() <<
"\n> animating frame " << frame << endl;
842 softegg_cat.info() <<
"frame " << time <<
"\n";
850 for (i = 0; i < num_nodes; i++) {
854 softegg_cat.debug() << endl;
861 softegg_cat.spam() <<
"-----joint " << node_desc->get_name() <<
"\n";
877 for (i = 0; i < num_nodes; i++) {
887 softegg_cat.info(
false)
899 bool SoftToEggConverter::
904 softegg_cat.spam() <<
"num_nodes = " << num_nodes << endl;
905 for (
int i = 0; i < num_nodes; i++) {
906 if (!process_model_node(_tree.
get_node(i))) {
909 softegg_cat.debug() << i << endl;
922 bool SoftToEggConverter::
925 const char *name = NULL;
926 char *fullname = NULL;
929 name = node_desc->get_name().c_str();
930 softegg_cat.debug() <<
"element name <" << name <<
">\n";
933 softegg_cat.spam() <<
"no processing, it is junk\n";
939 softegg_cat.debug() << endl;
943 softegg_cat.debug() << endl << name <<
":being processed" << endl;
948 SAA_modelGetType( &scene, node_desc->
get_model(), &type );
950 softegg_cat.debug() <<
"encountered ";
953 softegg_cat.debug() <<
"null\n";
956 softegg_cat.debug() <<
"patch\n";
959 softegg_cat.debug() <<
"face\n";
962 softegg_cat.debug() <<
"mesh\n";
964 make_polyset(node_desc, egg_group, type);
967 softegg_cat.debug() <<
"joint";
968 softegg_cat.debug() <<
" joint type " << node_desc->
is_joint() << endl;
971 softegg_cat.debug() <<
"spline\n";
974 softegg_cat.debug() <<
"meta element\n";
977 softegg_cat.debug() <<
"meta ball\n";
980 softegg_cat.debug() <<
"nurbs curve\n";
983 softegg_cat.debug() <<
"nurbs surf\n";
985 make_nurb_surface(node_desc, egg_group, type);
988 softegg_cat.debug() <<
"unknown type: " << type <<
"\n";
1004 void SoftToEggConverter::
1010 SAA_Boolean visible;
1011 PN_stdfloat *uCoords = NULL;
1012 PN_stdfloat *vCoords = NULL;
1013 string name = node_desc->get_name();
1015 SAA_modelGetNodeVisibility( &scene, node_desc->
get_model(), &visible );
1016 softegg_cat.spam() <<
"model visibility: " << visible << endl;
1024 (type != SAA_MNILL) &&
1025 (type != SAA_MJNT) &&
1027 (make_nurbs && ((type == SAA_MSMSH) || (type == SAA_MFACE )) )) ||
1028 (!make_poly && !make_nurbs && make_duv &&
1029 ((type == SAA_MSMSH) || (type == SAA_MFACE )) ))
1033 SAA_modelGetNbShapes( &scene, node_desc->
get_model(), &numShapes );
1034 softegg_cat.spam() <<
"process_model_node: num shapes: " << numShapes << endl;
1039 string vpool_name = name +
".verts";
1048 _tree.get_egg_root()->insert(_tree.get_egg_root()->begin(), vpool);
1059 for (idx=0; idx<node_desc->numTri; ++idx) {
1063 softegg_cat.spam() <<
"processing polygon " << idx << endl;
1067 if ( modelNoteStr != NULL ) {
1068 if ( strstr( modelNoteStr,
"bface" ) != NULL )
1073 SAA_SubElem cvertices[3];
1074 SAA_triangleGetCtrlVertices( &scene, node_desc->
get_model(), node_desc->gtype, id, 1, node_desc->triangles+idx, cvertices );
1077 SAA_DVector cvertPos[3];
1078 SAA_ctrlVertexGetPositions( &scene, node_desc->
get_model(), 3, cvertices, cvertPos);
1082 indices[0] = indices[1] = indices[2] = 0;
1083 SAA_ctrlVertexGetIndices( &scene, node_desc->
get_model(), 3, cvertices, indices );
1086 SAA_DVector normals[3];
1087 SAA_ctrlVertexGetNormals( &scene, node_desc->
get_model(), 3, cvertices, normals );
1089 softegg_cat.spam() <<
"normals[" << i <<
"] = " << normals[i].x <<
" " << normals[i].y
1090 <<
" " << normals[i].z <<
" " << normals[i].w <<
"\n";
1093 if (node_desc->textures) {
1094 if (node_desc->numTexLoc && node_desc->numTexTri[idx]) {
1097 uCoords =
new PN_stdfloat[3];
1098 vCoords =
new PN_stdfloat[3];
1101 if ( uCoords != NULL && vCoords != NULL) {
1102 for ( i = 0; i < 3; i++ )
1103 uCoords[i] = vCoords[i] = 0.0f;
1106 SAA_ctrlVertexGetUVTxtCoords( &scene, node_desc->
get_model(), 3, cvertices,
1107 3, uCoords, vCoords );
1110 softegg_cat.info() <<
"Not enough Memory for texture coords...\n";
1113 for ( i=0; i<3; i++ )
1114 softegg_cat.spam() <<
"texcoords[" << i <<
"] = ( " << uCoords[i] <<
" , " << vCoords[i] <<
" )\n";
1117 else if (node_desc->numTexGlb) {
1119 uCoords =
new PN_stdfloat[node_desc->numTexGlb*3];
1120 vCoords =
new PN_stdfloat[node_desc->numTexGlb*3];
1122 for ( i = 0; i < node_desc->numTexGlb*3; i++ ) {
1123 uCoords[i] = vCoords[i] = 0.0f;
1127 if ( uCoords != NULL && vCoords != NULL) {
1128 SAA_triCtrlVertexGetGlobalUVTxtCoords( &scene, node_desc->
get_model(), 3, cvertices,
1129 node_desc->numTexGlb, node_desc->textures, uCoords, vCoords );
1132 softegg_cat.info() <<
"Not enough Memory for texture coords...\n";
1136 for ( i=0; i < 3; i++ ) {
1140 SAA_DVector local = cvertPos[i];
1141 SAA_DVector global = {0};
1143 _VCT_X_MAT( global, local, node_desc->matrix );
1145 softegg_cat.spam() <<
"indices[" << i <<
"] = " << indices[i] <<
"\n";
1146 softegg_cat.spam() <<
"cvert[" << i <<
"] = " << cvertPos[i].x <<
" " << cvertPos[i].y
1147 <<
" " << cvertPos[i].z <<
" " << cvertPos[i].w <<
"\n";
1148 softegg_cat.spam() <<
" global cvert[" << i <<
"] = " << global.x <<
" " << global.y
1149 <<
" " << global.z <<
" " << global.w <<
"\n";
1152 LPoint3d p3d(global.x, global.y, global.z);
1153 p3d = p3d * vertex_frame_inv;
1157 _VCT_X_MAT( global, local, node_desc->matrix );
1159 softegg_cat.spam() <<
"normals[" << i <<
"] = " << normals[i].x <<
" " << normals[i].y
1160 <<
" " << normals[i].z <<
" " << normals[i].w <<
"\n";
1161 softegg_cat.spam() <<
" global normals[" << i <<
"] = " << global.x <<
" " << global.y
1162 <<
" " << global.z <<
" " << global.w <<
"\n";
1164 LVector3d n3d(global.x, global.y, global.z);
1165 n3d = n3d * vertex_frame_inv;
1166 vert.set_normal(n3d);
1169 if (node_desc->textures) {
1172 if (uCoords && vCoords) {
1174 v = 1.0f - vCoords[i];
1175 softegg_cat.spam() <<
"texcoords[" << i <<
"] = " << u <<
" " 1186 PN_stdfloat r,g,b,a;
1187 SAA_elementIsValid( &scene, &node_desc->materials[idx], &valid );
1190 SAA_materialGetDiffuse( &scene, &node_desc->materials[idx], &r, &g, &b );
1191 SAA_materialGetTransparency( &scene, &node_desc->materials[idx], &a );
1192 egg_poly->set_color(
LColor(r, g, b, 1.0f - a));
1193 softegg_cat.spam() <<
"color r = " << r <<
" g = " << g <<
" b = " << b <<
" a = " << 1.0f - a <<
"\n";
1196 egg_poly->set_color(
LColor(1.0, 1.0, 1.0, 1.0));
1197 softegg_cat.spam() <<
"default color\n";
1210 softegg_cat.spam() <<
"\n";
1214 if (node_desc->textures != NULL) {
1215 if (node_desc->numTexLoc && node_desc->numTexTri[idx]) {
1216 if (!strstr(node_desc->texNameArray[idx],
"noIcon"))
1217 set_shader_attributes(node_desc, *egg_poly, idx);
1219 softegg_cat.spam() <<
"texname :" << node_desc->texNameArray[idx] << endl;
1222 if (!strstr(node_desc->texNameArray[0],
"noIcon"))
1223 set_shader_attributes(node_desc, *egg_poly, 0);
1225 softegg_cat.spam() <<
"texname :" << node_desc->texNameArray[0] << endl;
1230 if ( numShapes > 0 && make_morph )
1242 void SoftToEggConverter::
1248 SAA_Boolean visible;
1249 PN_stdfloat *uCoords = NULL;
1250 PN_stdfloat *vCoords = NULL;
1251 string name = node_desc->get_name();
1253 SAA_modelGetNodeVisibility( &scene, node_desc->
get_model(), &visible );
1254 softegg_cat.spam() <<
"model visibility: " << visible << endl;
1255 softegg_cat.spam() <<
"nurbs!!!surface!!!" << endl;
1260 if ( (type == SAA_MNSRF) && ( visible ) && (( make_nurbs )
1261 || ( !make_nurbs && !make_poly && make_duv )) )
1264 SAA_modelGetNbShapes( &scene, node_desc->
get_model(), &numShapes );
1265 softegg_cat.spam() <<
"process_model_node: num shapes: " << numShapes << endl;
1270 string vpool_name = name +
".verts";
1280 _tree.get_egg_root()->insert(_tree.get_egg_root()->begin(), vpool);
1293 int uDegree, vDegree;
1294 int uCurves, vCurves;
1296 vector <double> Knots;
1301 SAA_nurbsSurfaceGetDegree( &scene, node_desc->
get_model(), &uDegree, &vDegree );
1302 softegg_cat.spam() <<
"nurbs degree: " << uDegree <<
" u, " << vDegree <<
" v\n";
1304 SAA_nurbsSurfaceGetNbKnots( &scene, node_desc->
get_model(), &uKnots, &vKnots );
1305 softegg_cat.spam() <<
"nurbs knots: " << uKnots <<
" u, " << vKnots <<
" v\n";
1307 SAA_Boolean uClosed = FALSE;
1308 SAA_Boolean vClosed = FALSE;
1310 SAA_nurbsSurfaceGetClosed( &scene, node_desc->
get_model(), &uClosed, &vClosed);
1312 uExtra = vExtra = 2;
1314 softegg_cat.spam() <<
"nurbs is closed in u...\n";
1318 softegg_cat.spam() <<
"nurbs is closed in v...\n";
1321 eggNurbs->
setup(uDegree+1, vDegree+1,
1322 uKnots + uExtra, vKnots + vExtra);
1324 softegg_cat.spam() <<
"from eggNurbs: num u knots " << eggNurbs->
get_num_u_knots() << endl;
1325 softegg_cat.spam() <<
"from eggNurbs: num v knots " << eggNurbs->
get_num_v_knots() << endl;
1326 softegg_cat.spam() <<
"from eggNurbs: num u cvs " << eggNurbs->
get_num_u_cvs() << endl;
1327 softegg_cat.spam() <<
"from eggNurbs: num v cvs " << eggNurbs->
get_num_v_cvs() << endl;
1329 SAA_nurbsSurfaceGetNbVertices( &scene, node_desc->
get_model(), &uRows, &vRows );
1330 softegg_cat.spam() <<
"nurbs vertices: " << uRows <<
" u, " << vRows <<
" v\n";
1332 SAA_nurbsSurfaceGetNbCurves( &scene, node_desc->
get_model(), &uCurves, &vCurves );
1333 softegg_cat.spam() <<
"nurbs curves: " << uCurves <<
" u, " << vCurves <<
" v\n";
1335 if ( shift_textures ) {
1338 SAA_nurbsSurfaceShiftParameterization( &scene, node_desc->
get_model(), -2, 0 );
1342 SAA_nurbsSurfaceShiftParameterization( &scene, node_desc->
get_model(), 0, -2 );
1345 SAA_nurbsSurfaceSetStep( &scene, node_desc->
get_model(), nurbs_step, nurbs_step );
1349 if ( modelNoteStr != NULL ) {
1350 if ( strstr( modelNoteStr,
"bface" ) != NULL ) {
1352 softegg_cat.spam() <<
"Set backface flag\n";
1356 double *uKnotArray =
new double[uKnots];
1357 double *vKnotArray =
new double[vKnots];
1358 result = SAA_nurbsSurfaceGetKnots( &scene, node_desc->
get_model(), node_desc->gtype, 0,
1359 uKnots, vKnots, uKnotArray, vKnotArray );
1361 if (result != SI_SUCCESS) {
1362 softegg_cat.spam() <<
"Couldn't get knots\n";
1367 add_knots( Knots, uKnotArray, uKnots, uClosed, uDegree );
1368 softegg_cat.spam() <<
"u knots: ";
1369 for (i = 0; i < (int)Knots.size(); i++) {
1370 softegg_cat.spam() << Knots[i] <<
" ";
1373 softegg_cat.spam() << endl;
1376 add_knots( Knots, vKnotArray, vKnots, vClosed, vDegree );
1377 softegg_cat.spam() <<
"v knots: ";
1378 for (i = 0; i < (int)Knots.size(); i++) {
1379 softegg_cat.spam() << Knots[i] <<
" ";
1382 softegg_cat.spam() << endl;
1386 SAA_modelGetNbVertices( &scene, node_desc->
get_model(), &numVert );
1388 softegg_cat.spam() << numVert <<
" CV's\n";
1391 SAA_DVector *vertices = NULL;
1392 vertices =
new SAA_DVector[numVert];
1394 SAA_modelGetVertices( &scene, node_desc->
get_model(), node_desc->gtype, 0, numVert, vertices );
1401 softegg_cat.spam() << endl << eggNurbs->
get_num_cvs() << endl << endl;
1404 for ( k = 0; k<numVert; k++ ) {
1421 _VCT_X_MAT( global, vertices[k], node_desc->matrix );
1424 global.w = vertices[k].w;
1427 global.x *= global.w;
1428 global.y *= global.w;
1429 global.z *= global.w;
1437 LPoint4d p4d(global.x, global.y, global.z, global.w);
1438 p4d = p4d * vertex_frame_inv;
1442 if (node_desc->numNurbMats) {
1443 PN_stdfloat r,g,b,a;
1444 SAA_elementIsValid( &scene, &node_desc->materials[0], &valid );
1447 SAA_materialGetDiffuse( &scene, &node_desc->materials[0], &r, &g, &b );
1448 SAA_materialGetTransparency( &scene, &node_desc->materials[0], &a );
1449 verts[k].set_color(
LColor(r, g, b, 1.0f - a));
1453 verts[k].set_color(
LColor(1.0, 1.0, 1.0, 1.0));
1454 softegg_cat.spam() <<
"default color\n";
1462 if ( (k % uRows) == ( uRows - 1) ) {
1463 for ( i = 0; i < uDegree; i++ ) {
1472 if ( vClosed && !uClosed ) {
1474 for (
int i = 0; i < vDegree*uRows; i++ )
1478 else if ( vClosed && uClosed ) {
1481 for ( i = 0; i < vDegree; i++ ) {
1483 for ( j = 0; j < uRows; j++ )
1488 for ( k = 0; k < uDegree; k++ )
1498 if (node_desc->textures != NULL) {
1499 if (!strstr(node_desc->texNameArray[0],
"noIcon"))
1500 set_shader_attributes(node_desc, *eggNurbs, 0);
1502 softegg_cat.spam() <<
"texname :" << node_desc->texNameArray[0] << endl;
1506 if ( numShapes > 0 && make_morph )
1518 void SoftToEggConverter::
1519 add_knots( vector <double> &eggKnots,
double *knots,
int numKnots, SAA_Boolean closed,
int degree ) {
1522 double lastKnot = knots[0];
1528 newKnots =
new double[degree];
1531 for ( k = numKnots - 1; k >= numKnots - degree; k-- ) {
1534 newKnots[i] = lastKnot - (knots[k] - knots[k-1]);
1535 lastKnot = newKnots[i];
1538 for ( k = degree - 1; k >= 0; k-- ) {
1539 eggKnots.push_back( newKnots[k] );
1540 softegg_cat.spam() <<
"knots[" << k <<
"] = " << newKnots[k] << endl;
1544 eggKnots.push_back( knots[k] );
1545 softegg_cat.spam() <<
"knots[" << k <<
"] = " << knots[k] << endl;
1549 for (k = 0; k < numKnots; k++) {
1550 eggKnots.push_back( knots[k] );
1551 softegg_cat.spam() <<
"knots[" << k+1 <<
"] = " << knots[k] << endl;
1554 lastKnot = knots[numKnots-1];
1559 for ( k = 1; k <= degree; k++ ) {
1560 eggKnots.push_back( lastKnot + (knots[k] - knots[k-1]) );
1561 softegg_cat.spam() <<
"knots[" << k <<
"] = " << lastKnot + (knots[k] - knots[k-1]) << endl;
1562 lastKnot = lastKnot + (knots[k] - knots[k-1]);
1566 eggKnots.push_back( knots[k-1] );
1567 softegg_cat.spam() <<
"knots[" << k+1 <<
"] = " << knots[k-1] << endl;
1581 int *vertMap = NULL;
1582 int vpoolSize = (int)vpool->
size();
1583 PN_stdfloat closestDist;
1584 PN_stdfloat thisDist;
1587 vertMap =
new int[vpoolSize];
1590 for (vi = vpool->
begin(); vi != vpool->
end(); ++vi, ++i) {
1592 softegg_cat.spam() <<
"vert external index = " << vert->
get_external_index() << endl;
1598 for ( j = 0; j < numVert; j++ ) {
1601 powf( p3d[0] - vertices[j].x , 2 ) +
1602 powf( p3d[1] - vertices[j].y , 2 ) +
1603 powf( p3d[2] - vertices[j].z , 2 ) );
1606 if ( !j || ( thisDist < closestDist ) ) {
1608 closestDist = thisDist;
1612 vertMap[i] = closest;
1613 softegg_cat.spam() <<
"mapping v " << i <<
" of " << vpoolSize-1 <<
":( " 1618 softegg_cat.spam() <<
" to cv " << closest <<
" of " << numVert-1 <<
":( " 1619 << vertices[closest].x <<
" " 1620 << vertices[closest].y <<
" " 1621 << vertices[closest].z <<
" )\tdelta = " << closestDist << endl;
1632 bool SoftToEggConverter::
1636 SAA_Boolean isSkeleton;
1638 softegg_cat.spam() << endl <<
"----------------------------------------------------------------" << endl;
1640 for (
int i = 0; i < num_nodes; i++) {
1642 SAA_modelIsSkeleton( &scene, node_desc->
get_model(), &isSkeleton );
1644 softegg_cat.spam() <<
"??checking node " << node_desc->get_name() <<
" isSkel " << isSkeleton <<
" isJoint " << node_desc->
is_joint() << endl;
1645 if (isSkeleton && node_desc->
is_joint()) {
1657 SAA_Elem *envelopes;
1658 SAA_Elem *model = node_desc->
get_model();
1662 SAA_skeletonGetNbEnvelopes( &scene, model, &numEnv );
1663 if ( numEnv == 0 ) {
1664 softegg_cat.spam() <<
"no soft skinning for joint " << node_desc->get_name() << endl;
1669 softegg_cat.spam() << endl <<
"found skeleton part( " << node_desc->get_name() <<
")!\n";
1670 softegg_cat.spam() <<
"numEnv = " << numEnv << endl;
1672 envelopes =
new SAA_Elem[numEnv];
1673 if ( envelopes == NULL ) {
1674 softegg_cat.info() <<
"Out Of Memory" << endl;
1678 SAA_EnvType envType;
1679 bool hasEnvVertices = 0;
1681 SAA_skeletonGetEnvelopes( &scene, model, numEnv, envelopes );
1682 for ( thisEnv = 0; thisEnv < numEnv; thisEnv++ ) {
1683 softegg_cat.spam() <<
"env[" << thisEnv <<
"]: ";
1684 SAA_envelopeGetType( &scene, &envelopes[thisEnv], &envType );
1686 if ( envType == SAA_ENVTYPE_NONE ) {
1687 softegg_cat.spam() <<
"envType = none\n";
1689 else if ( envType == SAA_ENVTYPE_FLXLCL ) {
1690 softegg_cat.spam() <<
"envType = flexible, local\n";
1693 else if ( envType == SAA_ENVTYPE_FLXGLB ) {
1694 softegg_cat.spam() <<
"envType = flexible, global\n";
1697 else if ( envType == SAA_ENVTYPE_RGDGLB ) {
1698 softegg_cat.spam() <<
"envType = rigid, global\n";
1702 softegg_cat.spam() <<
"envType = unknown\n";
1706 if ( !hasEnvVertices )
1709 SAA_SubElem *envVertices = NULL;
1710 int *numEnvVertices;
1713 numEnvVertices =
new int[numEnv];
1715 if ( numEnvVertices != NULL ) {
1716 SAA_envelopeGetNbCtrlVertices( &scene, model, numEnv, envelopes, numEnvVertices );
1717 int totalEnvVertices = 0;
1718 for( i = 0; i < numEnv; i++ ) {
1719 totalEnvVertices += numEnvVertices[i];
1720 softegg_cat.spam() <<
"numEnvVertices[" << i <<
"] = " << numEnvVertices[i] << endl;
1722 softegg_cat.spam() <<
"total env verts = " << totalEnvVertices << endl;
1723 if ( totalEnvVertices == 0 )
1726 envVertices =
new SAA_SubElem[totalEnvVertices];
1727 if ( envVertices != NULL ) {
1728 result = SAA_envelopeGetCtrlVertices( &scene, model,
1729 numEnv, envelopes, numEnvVertices, envVertices);
1730 if (result != SI_SUCCESS) {
1731 softegg_cat.spam() <<
"error: GetCtrlVertices\n";
1735 for ( i = 0; i < numEnv; i++ ) {
1736 PN_stdfloat *weights = NULL;
1737 int vertArrayOffset = 0;
1738 softegg_cat.spam() <<
"envelope[" << i <<
"]: ";
1739 weights =
new PN_stdfloat[numEnvVertices[i]];
1742 int *vpoolMap = NULL;
1743 for ( j = 0; j < i; j++ )
1744 vertArrayOffset += numEnvVertices[j];
1745 softegg_cat.spam() <<
"envVertArray offset = " << vertArrayOffset;
1756 result = SAA_ctrlVertexGetEnvelopeWeights( &scene, model, &envelopes[i],
1758 &envVertices[vertArrayOffset], weights );
1763 envName = _tree.
GetFullName( &scene, &envelopes[i] );
1767 envName = _tree.
GetName( &scene, &envelopes[i] );
1770 softegg_cat.spam() <<
" envelop name is [" << envName <<
"]" << endl;
1772 if (result != SI_SUCCESS) {
1773 softegg_cat.spam() <<
"warning: this envelop doesn't have any weights\n";
1777 result = SAA_modelGetType( &scene, &envelopes[i], &type );
1778 if (result != SI_SUCCESS) {
1779 softegg_cat.debug() <<
"choked on get type\n";
1783 softegg_cat.spam() <<
"envelope model type ";
1784 if ( type == SAA_MSMSH )
1785 softegg_cat.spam() <<
"MESH\n";
1786 else if ( type == SAA_MNSRF )
1787 softegg_cat.spam() <<
"NURBS\n";
1789 softegg_cat.spam() <<
"OTHER\n";
1791 int *envVtxIndices = NULL;
1792 envVtxIndices =
new int[numEnvVertices[i]];
1795 result = SAA_ctrlVertexGetIndices( &scene, &envelopes[i], numEnvVertices[i],
1796 &envVertices[vertArrayOffset], envVtxIndices );
1798 if (result != SI_SUCCESS) {
1799 softegg_cat.debug() <<
"error: choked on get indices\n";
1806 SAA_modelGetNbVertices( &scene, &envelopes[i], &modelNumVert );
1808 SAA_DVector *modelVertices = NULL;
1809 modelVertices =
new SAA_DVector[modelNumVert];
1812 SAA_modelGetVertices( &scene, &envelopes[i],
1813 SAA_GEOM_ORIGINAL, 0, modelNumVert,
1817 SAA_DVector *globalModelVertices = NULL;
1818 globalModelVertices =
new SAA_DVector[modelNumVert];
1819 PN_stdfloat matrix[4][4];
1824 SAA_modelGetMatrix( &scene, &envelopes[i], SAA_COORDSYS_GLOBAL, matrix );
1827 for ( j = 0; j < modelNumVert; j++ ) {
1828 _VCT_X_MAT( globalModelVertices[j],
1829 modelVertices[j], matrix );
1833 string s_name = envName;
1836 softegg_cat.debug() <<
"error: node " << s_name <<
" not found in tree\n";
1839 string vpool_name = s_name +
".verts";
1842 DCAST_INTO_R(vpool, t, NULL);
1846 softegg_cat.spam() <<
"found vpool of size " << vpool->
size() << endl;
1847 if ( !make_nurbs || (type == SAA_MSMSH) ) {
1852 softegg_cat.debug() <<
"warning: vpool " << vpool_name <<
" not found\n";
1856 joint = node_desc->get_egg_group();
1858 for (j = 0; j < numEnvVertices[i]; j++) {
1859 double scaledWeight = weights[j]/ 100.0f;
1862 if (( envVtxIndices[j] < modelNumVert )
1863 && ( envVtxIndices[j] >= 0 )) {
1864 if ( (type == SAA_MNSRF) && make_nurbs ) {
1868 softegg_cat.debug() <<
"possible error: index " << envVtxIndices[j] <<
": vert is " << vert << endl;
1872 softegg_cat.spam() << j <<
": adding vref to cv " << envVtxIndices[j]
1873 <<
" with weight " << scaledWeight << endl;
1885 softegg_cat.spam() << j <<
"--trying to find " << envVtxIndices[j] << endl;
1886 for ( k = 0; k < (int)vpool->
size(); k++ ) {
1887 if ( vpoolMap[k] == envVtxIndices[j] ) {
1891 softegg_cat.debug() <<
"possible error: index " << k+1 <<
": vert is " << vert << endl;
1896 softegg_cat.spam() << j <<
": adding vref from cv " << envVtxIndices[j]
1897 <<
" to vert " << k+1 <<
" with weight " << scaledWeight
1925 bool SoftToEggConverter::
1931 softegg_cat.spam() << endl <<
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
1933 for (
int i = 0; i < num_nodes; i++) {
1938 SAA_Elem *model = node_desc->
get_model();
1945 SAA_modelGetType( &scene, model, &type );
1947 softegg_cat.debug() <<
"Cleaning up model------- " << node_desc->get_name() << endl;
1955 string vpool_name = node_desc->get_name() +
".verts";
1958 DCAST_INTO_R(vpool, t, NULL);
1965 int numVerts = (int)vpool->
size();
1966 softegg_cat.spam() <<
"found vpool " << vpool_name <<
" w/ " << numVerts <<
" verts\n";
1971 joint = node_desc->get_egg_group();
1975 while( parentJ && !parentJ->_parentJoint) {
1976 if ( parentJ->_parent) {
1977 SAA_Boolean isSkeleton;
1980 SAA_modelIsSkeleton( &scene, parentJ->_parent->
get_model(), &isSkeleton );
1983 joint = parentJ->_parent->get_egg_group();
1984 softegg_cat.spam() <<
"parent to " << parentJ->_parent->get_name() << endl;
1988 parentJ = parentJ->_parent;
1993 if (!joint && (!parentJ || !parentJ->_parentJoint)) {
1994 softegg_cat.spam() << node_desc->get_name() <<
" has no _parentJoint?!" << endl;
1999 softegg_cat.spam() <<
"parent joint to " << parentJ->_parentJoint->get_name() << endl;
2000 joint = parentJ->_parentJoint->get_egg_group();
2004 double membership = 1.0f;
2005 for ( vi = vpool->
begin(); vi != vpool->
end(); ++vi) {
2027 void SoftToEggConverter::
2029 char *texName = node_desc->texNameArray[idx];
2033 Filename fullpath = _path_replace->match_path(filename, get_model_path());
2034 tex.set_filename(_path_replace->store_path(fullpath));
2037 apply_texture_properties(tex, node_desc->uRepeat[idx], node_desc->vRepeat[idx]);
2050 void SoftToEggConverter::
2051 apply_texture_properties(
EggTexture &tex,
int uRepeat,
int vRepeat) {
2053 tex.set_minfilter(EggTexture::FT_linear_mipmap_linear);
2054 tex.set_magfilter(EggTexture::FT_linear);
2056 EggTexture::WrapMode wrap_u = uRepeat > 0 ? EggTexture::WM_repeat : EggTexture::WM_clamp;
2057 EggTexture::WrapMode wrap_v = vRepeat > 0 ? EggTexture::WM_repeat : EggTexture::WM_clamp;
2059 tex.set_wrap_u(wrap_u);
2060 tex.set_wrap_v(wrap_v);
2078 bool SoftToEggConverter::
2080 const SoftShaderColorDef &color_def) {
2083 EggTexture::WrapMode wrap_u = color_def._wrap_u ? EggTexture::WM_repeat : EggTexture::WM_clamp;
2084 EggTexture::WrapMode wrap_v = color_def._wrap_v ? EggTexture::WM_repeat : EggTexture::WM_clamp;
2088 if (wrap_u == EggTexture::WM_repeat) {
2089 tex.set_wrap_u(wrap_u);
2094 if (wrap_v == EggTexture::WM_repeat) {
2095 tex.set_wrap_v(wrap_v);
2100 LMatrix3d mat = color_def.compute_texture_matrix();
2118 bool SoftToEggConverter::
2127 EggGroupNode::iterator ci;
2128 for (ci = egg_parent->begin(); ci != egg_parent->end(); ++ci) {
2130 if (child->
is_of_type(EggGroup::get_class_type())) {
2133 if (decal_base != (
EggNode *)NULL) {
2135 <<
"Two children of " << egg_parent->get_name()
2136 <<
" both have decalbase set: " << decal_base->get_name()
2137 <<
" and " << child_group->get_name() <<
"\n";
2141 decal_base = child_group;
2145 decal_children.push_back(child_group);
2150 if (decal_base == (
EggGroup *)NULL) {
2151 if (!decal_children.empty()) {
2152 softegg_cat.warning()
2153 << decal_children.front()->get_name()
2154 <<
" has decal, but no sibling node has decalbase.\n";
2158 if (decal_children.empty()) {
2159 softegg_cat.warning()
2160 << decal_base->get_name()
2161 <<
" has decalbase, but no sibling nodes have decal.\n";
2169 for (di = decal_children.begin(); di != decal_children.end(); ++di) {
2175 decal_base->set_decal_flag(
true);
2180 for (ci = egg_parent->begin(); ci != egg_parent->end(); ++ci) {
2182 if (child->
is_of_type(EggGroupNode::get_class_type())) {
2184 if (!reparent_decals(child_group)) {
2201 if (cmp_nocase(arg,
"all") == 0) {
2203 }
else if (cmp_nocase(arg,
"model") == 0) {
2205 }
else if (cmp_nocase(arg,
"dcs") == 0) {
2207 }
else if (cmp_nocase(arg,
"none") == 0) {
2219 extern "C" int init_soft2egg (
int argc,
char **argv)
2221 stec._commandName = argv[0];
2222 stec.rsrc_path =
"c:\\Softimage\\SOFT3D_3.9.2\\3D\\rsrc";
void set_fullpath(const Filename &fullpath)
Records the full pathname to the file, for the benefit of get_fullpath().
A base class for any of a number of kinds of geometry primitives: polygons, point lights...
string get_dirname() const
Returns the directory part of the filename.
virtual string get_extension() const
Returns the common extension of the file type this converter supports.
GroupRef::size_type gref_size() const
Returns the number of elements between gref_begin() and gref_end().
This is an iterator adaptor that converts any iterator that returns a pair (e.g.
bool open_api()
Attempts to open the Soft API if it was not already open, and returns true if successful, or false if there is an error.
void set_highest_index(int highest_index)
Artificially changes the "highest index number", so that a newly created vertex will begin at this nu...
EggTexture * create_unique_texture(const EggTexture ©, int eq)
Creates a new texture if there is not already one equivalent (according to eq, see EggTexture::is_equ...
This is a 4-by-4 transform matrix.
bool has_model() const
Returns true if a Soft dag path has been associated with this node, false otherwise.
void get_joint_transform(SAA_Scene *scene, EggGroup *egg_group, EggXfmSAnim *anim, bool global)
Extracts the transform on the indicated Soft node, as appropriate for a joint in an animated characte...
virtual bool convert_file(const Filename &filename)
Handles the reading of the input file and converting it to egg.
int get_num_v_knots() const
Returns the number of knots in the V direction.
void close_api()
Closes the Soft API, if it was previously opened.
EggVertex * add_vertex(EggVertex *vertex, int index=-1)
Adds the indicated vertex to the pool.
void set_pos(double pos)
Sets the vertex position.
int get_num_u_cvs() const
Returns the number of control vertices that should be present in the U direction. ...
bool has_object_type(const string &object_type) const
Returns true if the indicated object type has been added to the group, or false otherwise.
A base class for nodes in the hierarchy that are not leaf nodes.
This is a four-component point in space.
Defines a texture map that may be applied to geometry.
EggVertex * get_vertex(int index) const
Returns the vertex in the pool with the indicated index number, or NULL if no vertices have that inde...
void set_u_knot(int k, double value)
Resets the value of the indicated knot as indicated.
char * GetModelNoteInfo(SAA_Scene *, SAA_Elem *)
Given an element, return a string containing the contents of its MODEL NOTE entry.
char * GetName(SAA_Scene *scene, SAA_Elem *element)
Given an element, return a copy of the element's name WITHOUT prefix.
SoftNodeDesc * get_node(int n) const
Returns the nth node in the hierarchy, in an arbitrary ordering.
void clear()
Removes all textures from the collection.
void set_texture(EggTexture *texture)
Replaces the current list of textures with the indicated texture.
EggData * get_egg_data()
Returns the EggData structure.
Corresponding to an <S$Anim> entry, this stores a single column of numbers, for instance for a morph ...
void setup(int u_order, int v_order, int num_u_knots, int num_v_knots)
Prepares a new surface definition with the indicated order and number of knots in each dimension...
This is a two-component point in space.
void Help()
Displays the "what is this program" message, along with the usage message.
SAA_Elem * get_model() const
Returns the SAA_Elem * associated with this node.
LVertexd get_pos3() const
Valid if get_num_dimensions() returns 3 or 4.
void set_external_index(int external_index)
Sets a special index number that is associated with the EggVertex (but is not written to the egg file...
This is the primary interface into all the egg data, and the root of the egg file structure...
bool HandleGetopts(int &idx, int argc, char **argv)
increment idx based on what kind of option parsed Supported options are as follows: r:d:s:m:t:P:b:e:f...
size_type size() const
Returns the number of vertices in the pool.
iterator end() const
Returns an iterator that can be used to traverse through all the vertices in the pool.
int get_num_nodes() const
Returns the total number of nodes in the hierarchy, not counting the root node.
int get_num_v_cvs() const
Returns the number of control vertices that should be present in the V direction. ...
bool remove_object_type(const string &object_type)
Removes the first instance of the indicated object type from the group if it is present.
char * GetFullName(SAA_Scene *scene, SAA_Elem *element)
Given an element, return a copy of the element's name complete with prefix.
bool almost_equal(const LMatrix3d &other, double threshold) const
Returns true if two matrices are memberwise equal within a specified tolerance.
This is our own Panda specialization on the default STL vector.
iterator begin() const
Returns an iterator that can be used to traverse through all the vertices in the pool.
char * GetTextureName(SAA_Scene *scene, SAA_Elem *texture)
Given a texture element, return texture name with given tex_path.
void clear_egg(EggData *egg_data, EggGroupNode *egg_root, EggGroupNode *skeleton_node)
Removes all of the references to generated egg structures from the tree, and prepares the tree for ge...
EggSAnimData * find_morph_table(char *name)
Given a tablename, it either creates a new eggSAnimData structure (if doesn't exist) or locates it...
void set_bface_flag(bool flag)
Sets the backfacing flag of the polygon.
The main glue of the egg hierarchy, this corresponds to the <Group>, <Instance>, and <Joint> type nod...
void set_v_knot(int k, double value)
Resets the value of the indicated knot as indicated.
void ShowOpts()
Displays the valid options.
WrapMode determine_wrap_v() const
Determines the appropriate wrap in the V direction.
This is a 3-by-3 transform matrix.
int get_num_cvs() const
Returns the total number of control vertices that should* be defined for the surface.
char * GetRootName(const char *)
Given a string, return a copy of the string up to the first occurence of '-'.
EggGroup * get_egg_group(SoftNodeDesc *node_desc)
Returns the EggGroupNode corresponding to the group or joint for the indicated node.
The name of a file, such as a texture file or an Egg file.
bool is_partial(char *search_prefix)
check to see if this is a selected branch we want to descend - this will prevent creating geometry fo...
Any one-, two-, three-, or four-component vertex, possibly with attributes such as a normal...
int * FindClosestTriVert(EggVertexPool *vpool, SAA_DVector *vertices, int numVert)
Given an egg vertex pool, map each vertex therein to a vertex within an array of SAA model vertices o...
bool build_complete_hierarchy(SAA_Scene &scene, SAA_Database &database)
Walks through the complete Soft hierarchy and builds up the corresponding tree.
This corresponds to an <Xfm$Anim_S$> entry, which is a collection of up to nine <S$Anim> entries that...
void make_vertex_offsets(int numShapes)
Given a scene, a model , the vertices of its original shape and its name find the difference between ...
Describes a single instance of a node aka element in the Soft scene graph, relating it to the corresp...
void set_egg_data(EggData *egg_data)
Sets the egg data that will be filled in when convert_file() is called.
void optimize()
Optimizes the table by collapsing redundant sub-tables.
string get_basename_wo_extension() const
Returns the basename part of the filename, without the file extension.
This is the base class for all three-component vectors and points.
void load_nurbs_model(SAA_Scene *scene, SAA_ModelType type)
Converts the indicated Soft polyset to a bunch of EggPolygons and parents them to the indicated egg g...
This class supervises the construction of an EggData structure from a single Softimage file...
virtual SomethingToEggConverter * make_copy()
Allocates and returns a new copy of the converter.
This is a three-component vector distance (as opposed to a three-component point, which represents a ...
This is a three-component point in space (as opposed to a three-component vector, which represents a ...
EggNode * add_child(EggNode *node)
Adds the indicated child to the group and returns it.
WrapMode determine_wrap_u() const
Determines the appropriate wrap in the U direction.
A base class for things that may be directly added into the egg hierarchy.
void Usage()
Displays the usage message.
A parametric NURBS surface.
void ref_vertex(EggVertex *vert, double membership=1.0)
Adds the vertex to the set of those referenced by the group, at the indicated membership level...
void get_transform(SAA_Scene *scene, EggGroup *egg_group, bool global)
Extracts the transform on the indicated Soft node, and applies it to the corresponding Egg node...
int get_external_index() const
Returns the number set by set_external_index().
bool is_of_type(TypeHandle handle) const
Returns true if the current object is or derives from the indicated type.
EggNode * find_child(const string &name) const
Returns the child of this node whose name is the indicated string, or NULL if there is no child of th...
bool DoGetopts(int &argc, char **&argv)
Calls getopt() to parse the command-line switches.
SoftNodeDesc * find_node(string name)
Returns the English name of the file type this converter supports.
EggXfmSAnim * get_egg_anim(SoftNodeDesc *node_desc)
Returns the anim table corresponding to the joint for the indicated node.
bool is_joint() const
Returns true if the node should be treated as a joint by the converter.
virtual string get_name() const
Returns the English name of the file type this converter supports.
int get_num_u_knots() const
Returns the number of knots in the U direction.
bool convert_soft(bool from_selection)
Fills up the egg_data structure according to the global soft model data.
void set_uv(const LTexCoordd &texCoord)
Replaces the unnamed UV coordinate pair on the vertex with the indicated value.
This is a base class for a family of converter classes that manage a conversion from some file type t...
EggVertex * create_unique_vertex(const EggVertex ©)
Creates a new vertex in the pool that is a copy of the indicated one and returns it.
A collection of vertices.
EggVertex * add_vertex(EggVertex *vertex)
Adds the indicated vertex to the end of the primitive's list of vertices, and returns it...
void load_poly_model(SAA_Scene *scene, SAA_ModelType type)
Converts the indicated Soft polyset to a bunch of EggPolygons and parents them to the indicated egg g...
static TransformType string_transform_type(const string &arg)
Returns the TransformType value corresponding to the indicated string, or TT_invalid.
void make_morph_table(PN_stdfloat time)
Given a scene, a model, a name and a frame time, determine what type of shape interpolation is used a...
bool is_junk() const
Returns true if the node should be treated as a junk by the converter.
const LMatrix4d & get_vertex_frame_inv() const
Returns the inverse of the matrix returned by get_vertex_frame().
static Filename from_os_specific(const string &os_specific, Type type=T_general)
This named constructor returns a Panda-style filename (that is, using forward slashes, and no drive letter) based on the supplied filename string that describes a filename in the local system conventions (for instance, on Windows, it may use backslashes or begin with a drive letter and a colon).