Added aqua_speed for rite geo 50 tryker
[ryzomcore.git] / nel / tools / 3d / file_info / main.cpp
blobe8c6e072b033548fadafb5d152280909c756467c
1 // NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
2 // Copyright (C) 2010 Winch Gate Property Limited
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
18 #include "nel/misc/file.h"
19 #include "nel/misc/path.h"
20 #include "nel/misc/common.h"
21 #include "nel/3d/scene_group.h"
22 #include "nel/3d/zone.h"
23 #include "nel/3d/skeleton_shape.h"
24 #include "nel/3d/register_3d.h"
25 #include "nel/3d/mesh.h"
26 #include "nel/3d/mesh_mrm.h"
27 #include "nel/3d/mesh_mrm_skinned.h"
28 #include "nel/3d/mesh_multi_lod.h"
30 #ifdef NL_OS_WINDOWS
31 #include <conio.h>
32 #endif // NL_OS_WINDOWS
34 #ifdef NL_OS_UNIX
35 #include <stdio.h>
36 #include <termios.h>
37 #include <unistd.h>
39 int _getch( ) {
40 struct termios oldt,
41 newt;
42 int ch;
43 tcgetattr( STDIN_FILENO, &oldt );
44 newt = oldt;
45 newt.c_lflag &= ~( ICANON | ECHO );
46 tcsetattr( STDIN_FILENO, TCSANOW, &newt );
47 ch = getchar();
48 tcsetattr( STDIN_FILENO, TCSANOW, &oldt );
49 return ch;
51 #endif // NL_OS_UNIX
54 using namespace std;
55 using namespace NLMISC;
56 using namespace NL3D;
59 // ***************************************************************************
60 void displayGeom(FILE *logStream, const CMeshGeom &geom)
62 uint i,j;
63 uint numFaces=0;
64 for(i=0;i<geom.getNbMatrixBlock();i++)
66 for(j=0;j<geom.getNbRdrPass(i);j++)
68 numFaces+= geom.getRdrPassPrimitiveBlock(i,j).getNumIndexes()/3;
71 fprintf(logStream, "Standard Mesh %s\n", geom.isSkinned()?"Skinned":"" );
72 fprintf(logStream, " NumFaces: %d\n", numFaces );
73 fprintf(logStream, " NumVertices: %d\n", geom.getVertexBuffer().getNumVertices() );
74 uint nbBS= geom.getNbBlendShapes();
75 if(nbBS)
76 fprintf(logStream, " NumBlendShapes: %d\n", nbBS );
77 IMeshVertexProgram *mvp= geom.getMeshVertexProgram();
78 if(mvp)
79 fprintf(logStream, " MeshVertexProgram: %s\n", typeid(*mvp).name() );
83 void displayMRMGeom(FILE *logStream, const CMeshMRMGeom &geom)
85 uint i,j;
86 uint numFaces=0;
87 uint numFacesLodMax=0;
88 for(i=0;i<geom.getNbLod();i++)
90 for(j=0;j<geom.getNbRdrPass(i);j++)
92 uint nPassFaces= geom.getRdrPassPrimitiveBlock(i,j).getNumIndexes()/3;
93 numFaces+= nPassFaces;
94 if(i==geom.getNbLod()-1)
95 numFacesLodMax+= nPassFaces;
98 fprintf(logStream, "MRM Mesh %s\n", geom.isSkinned()?"Skinned":"" );
99 fprintf(logStream, " NumFaces(Max Lod): %d\n", numFacesLodMax );
100 fprintf(logStream, " NumFaces(Sum all Lods): %d\n", numFaces );
101 fprintf(logStream, " NumVertices(Sum all Lods): %d\n", geom.getVertexBuffer().getNumVertices() );
102 fprintf(logStream, " NumShadowSkinVertices: %d\n", geom.getNumShadowSkinVertices() );
103 fprintf(logStream, " Skinned: %s\n", geom.isSkinned()?"true":"false" );
104 uint nbBS= geom.getNbBlendShapes();
105 if(nbBS)
106 fprintf(logStream, " NumBlendShapes: %d\n", nbBS );
110 void displayMRMSkinnedGeom(FILE *logStream, const CMeshMRMSkinnedGeom &geom)
112 uint i,j;
113 uint numFaces=0;
114 uint numFacesLodMax=0;
115 for(i=0;i<geom.getNbLod();i++)
117 for(j=0;j<geom.getNbRdrPass(i);j++)
119 CIndexBuffer block;
120 geom.getRdrPassPrimitiveBlock(i,j,block);
121 uint nPassFaces= block.getNumIndexes()/3;
122 numFaces+= nPassFaces;
123 if(i==geom.getNbLod()-1)
124 numFacesLodMax+= nPassFaces;
127 fprintf(logStream, "MRM Skinned Mesh\n");
128 fprintf(logStream, " NumFaces(Max Lod): %d\n", numFacesLodMax );
129 fprintf(logStream, " NumFaces(Sum all Lods): %d\n", numFaces );
130 CVertexBuffer VB;
131 geom.getVertexBuffer(VB);
132 fprintf(logStream, " NumVertices(Sum all Lods): %d\n", VB.getNumVertices() );
133 fprintf(logStream, " NumShadowSkinVertices: %d\n", geom.getNumShadowSkinVertices() );
137 uint MaxNumLightMap= 0;
138 void displayMeshBase(FILE *logStream, CMeshBase *meshBase)
140 uint nMat= meshBase->getNbMaterial();
141 uint nLms= (uint)meshBase->_LightInfos.size();
142 MaxNumLightMap= max(MaxNumLightMap, nLms);
143 if(nLms)
145 fprintf(logStream, "The Mesh has %d lightmaps for %d Materials\n", nLms, nMat );
146 for(uint i=0;i<nLms;i++)
148 uint32 lg= meshBase->_LightInfos[i].LightGroup;
149 string al= meshBase->_LightInfos[i].AnimatedLight;
150 fprintf(logStream, " LightGroup=%d; AnimatedLight='%s'; mat/stage: ", lg, al.c_str());
151 std::list<CMeshBase::CLightMapInfoList::CMatStage>::iterator it= meshBase->_LightInfos[i].StageList.begin();
152 while(it!=meshBase->_LightInfos[i].StageList.end())
154 fprintf(logStream, "%d/%d, ", it->MatId, it->StageId);
155 it++;
157 fprintf(logStream, "\n");
160 else
162 fprintf(logStream, "The Mesh has %d Materials\n", nMat );
165 fprintf(logStream, "The mesh has a LodCharacterTexture: %s\n", meshBase->getLodCharacterTexture()?"true":"false");
169 // ***************************************************************************
170 /// Dispaly info for file in stdout
171 void displayInfoFileInStream(FILE *logStream, const char *fileName, const set<string> &options, bool displayShortFileName)
173 if(fileName==NULL)
174 return;
176 bool ms = options.find ("-ms") != options.end();
177 bool vi = options.find ("-vi") != options.end();
178 bool vl = options.find ("-vl") != options.end();
179 bool vp = options.find ("-vp") != options.end();
180 bool veil = options.find ("-veil") != options.end();
182 // Special option.
183 if( ms )
185 if(strstr(fileName, ".shape"))
187 // read the skeleton.
188 CIFile file(fileName);
189 CShapeStream shapeStream;
190 file.serial(shapeStream);
192 // Test Type
193 CMesh *mesh= dynamic_cast<CMesh*>(shapeStream.getShapePointer());
195 // Mesh ??
196 if( mesh )
198 if( mesh->getMeshGeom().isSkinned() )
200 fprintf(logStream, "%s is Skinned, but without MRM!!!\n", fileName);
204 // release
205 delete shapeStream.getShapePointer();
206 shapeStream.setShapePointer(NULL);
209 // Std Way.
210 else
212 // some general info.
213 if(displayShortFileName)
215 string sfn= CFile::getFilename(fileName);
216 fprintf(logStream, "File: %s\n", sfn.c_str());
218 else
220 fprintf(logStream, "File: %s\n", fileName);
222 fprintf(logStream, "***********\n\n");
224 if(strstr(fileName, ".zone"))
226 // read the zone.
227 CIFile file(fileName);
228 CZone zone;
229 file.serial(zone);
231 // retreive info on Zone
232 CZoneInfo zoneInfo;
233 zone.retrieve(zoneInfo);
235 // display Info on the zone:
236 fprintf(logStream, " Num Patchs: %d\n", zone.getNumPatchs() );
237 fprintf(logStream, " Num PointLights: %u\n", (uint)zoneInfo.PointLights.size() );
238 if (vl)
240 fprintf(logStream, " Lights\n");
241 uint k;
242 for(k = 0; k < zoneInfo.PointLights.size(); ++k)
244 const CPointLightNamed &pl = zoneInfo.PointLights[k];
245 CRGBA diffuse = pl.getDiffuse();
246 CRGBA defaultDiffuse = pl.getDefaultDiffuse ();
247 fprintf(logStream, " light group = %d, anim = \"%s\" x=%.1f, y=%.1f, z=%.1f, r=%d, g=%d, b=%d, dr=%d, dg=%d, db=%d\n", pl.LightGroup,
248 pl.AnimatedLight.c_str(), pl.getPosition().x, pl.getPosition().y, pl.getPosition().z,
249 diffuse.R, diffuse.G, diffuse.B, defaultDiffuse.R, defaultDiffuse.G, defaultDiffuse.B);
252 if (vp)
254 CZoneInfo zoneInfo;
255 zone.retrieve (zoneInfo);
257 // Patch information
258 uint k;
259 for(k = 0; k < zoneInfo.Patchs.size(); ++k)
261 fprintf(logStream, " Patch %d, S %d, T %d, smooth flags %d %d %d %d, corner flags %d %d %d %d\n",
263 zoneInfo.Patchs[k].OrderS,
264 zoneInfo.Patchs[k].OrderT,
265 zoneInfo.Patchs[k].getSmoothFlag (0),
266 zoneInfo.Patchs[k].getSmoothFlag (1),
267 zoneInfo.Patchs[k].getSmoothFlag (2),
268 zoneInfo.Patchs[k].getSmoothFlag (3),
269 zoneInfo.Patchs[k].getCornerSmoothFlag(0),
270 zoneInfo.Patchs[k].getCornerSmoothFlag(1),
271 zoneInfo.Patchs[k].getCornerSmoothFlag(2),
272 zoneInfo.Patchs[k].getCornerSmoothFlag(3));
273 uint l;
274 for (l=0; l<4; l++)
276 fprintf(logStream, " Bind edge %d, NPatchs %d, ZoneId %d, Next %d %d %d %d, Edge %d %d %d %d\n",
278 zoneInfo.Patchs[k].BindEdges[l].NPatchs,
279 zoneInfo.Patchs[k].BindEdges[l].ZoneId,
280 zoneInfo.Patchs[k].BindEdges[l].Next[0],
281 zoneInfo.Patchs[k].BindEdges[l].Next[1],
282 zoneInfo.Patchs[k].BindEdges[l].Next[2],
283 zoneInfo.Patchs[k].BindEdges[l].Next[3],
284 zoneInfo.Patchs[k].BindEdges[l].Edge[0],
285 zoneInfo.Patchs[k].BindEdges[l].Edge[1],
286 zoneInfo.Patchs[k].BindEdges[l].Edge[2],
287 zoneInfo.Patchs[k].BindEdges[l].Edge[3]);
292 else if(strstr(fileName, ".ig"))
294 // read the ig.
295 CIFile file(fileName);
296 CInstanceGroup ig;
297 file.serial(ig);
299 // display Info on the ig:
300 CVector gpos = ig.getGlobalPos();
301 fprintf(logStream, " Global pos : x = %.1f, y = %.1f, z =%.1f\n", gpos.x, gpos.y, gpos.z);
302 fprintf(logStream, " Num Instances: %d\n", ig.getNumInstance() );
303 fprintf(logStream, " Num PointLights: %u\n", (uint)ig.getPointLightList().size() );
304 fprintf(logStream, " Realtime sun contribution = %s\n", ig.getRealTimeSunContribution() ? "on" : "off");
305 if (vi)
307 fprintf(logStream, " Instances:\n");
308 uint k;
309 for(k = 0; k < ig._InstancesInfos.size(); ++k)
311 fprintf(logStream, " Instance %3d: shape = %s, name = %s, x = %.1f, y = %.1f, z = %.1f, sx = %.1f, sy = %.1f, sz = %.1f\n", k, ig._InstancesInfos[k].Name.c_str(), ig._InstancesInfos[k].InstanceName.c_str(), ig._InstancesInfos[k].Pos.x + gpos.x, ig._InstancesInfos[k].Pos.y + gpos.y, ig._InstancesInfos[k].Pos.z + gpos.z, ig._InstancesInfos[k].Scale.x, ig._InstancesInfos[k].Scale.y, ig._InstancesInfos[k].Scale.z);
314 if (vl)
316 fprintf(logStream, " Lights:\n");
317 uint k;
318 for(k = 0; k < ig.getNumPointLights(); ++k)
320 const CPointLightNamed &pl = ig.getPointLightNamed(k);
321 CRGBA diffuse = pl.getDiffuse();
322 CRGBA defaultDiffuse = pl.getDefaultDiffuse ();
323 fprintf(logStream, " Light %3d: Light group = %d, anim = \"%s\" x=%.1f, y=%.1f, z=%.1f, r=%d, g=%d, b=%d, dr=%d, dg=%d, db=%d\n", k, pl.LightGroup,
324 pl.AnimatedLight.c_str(), pl.getPosition().x + gpos.x, pl.getPosition().y + gpos.y, pl.getPosition().z + gpos.z,
325 diffuse.R, diffuse.G, diffuse.B, defaultDiffuse.R, defaultDiffuse.G, defaultDiffuse.B);
328 if (veil)
330 fprintf(logStream, " Instances Bound To Lights:\n");
331 fprintf(logStream, " WordList:\n");
332 fprintf(logStream, " 'StaticLight Not Computed' means the instance has a ASP flag or the ig is not yet lighted\n");
333 fprintf(logStream, " If lighted, for each instance, the format is 'SunContribution(8Bit) - idLight0;idLight1 (or NOLIGHT) - LocalAmbientId (or GLOBAL_AMBIENT)' \n");
334 fprintf(logStream, " DCS means the instance don't cast shadow (used in the lighter)\n");
335 fprintf(logStream, " DCSINT Same but very special for ig_lighter only\n");
336 fprintf(logStream, " DCSEXT Same but very special for zone_lighter and zone_ig_lighter only\n");
337 fprintf(logStream, " ASP means the instance AvoidStaticLightPreCompute (used in the lighter)\n");
338 fprintf(logStream, " -------------------------------------------------------------\n");
339 uint k;
340 for(k = 0; k < ig._InstancesInfos.size(); ++k)
342 CInstanceGroup::CInstance &instance= ig._InstancesInfos[k];
343 fprintf(logStream, " Instance %3d: ", k);
344 if(!instance.StaticLightEnabled)
345 fprintf(logStream, " StaticLight Not Computed.");
346 else
348 fprintf(logStream, " %3d - ", instance.SunContribution);
349 if(instance.Light[0]==0xFF)
350 fprintf(logStream, "NOLIGHT - ");
351 else
353 fprintf(logStream, "%3d;", instance.Light[0]);
354 if(instance.Light[1]!=0xFF)
355 fprintf(logStream, "%3d", instance.Light[1]);
356 else
357 fprintf(logStream, " "); //, instance.Light[1]);
358 fprintf(logStream, " - ");
360 if(instance.LocalAmbientId==0xFF)
361 fprintf(logStream, "GLOBAL_AMBIENT. ");
362 else
363 fprintf(logStream, "%d. ", instance.LocalAmbientId);
365 if(instance.DontCastShadow)
366 fprintf(logStream, "DCS,");
367 if(instance.DontCastShadowForInterior)
368 fprintf(logStream, "DCSINT,");
369 if(instance.DontCastShadowForExterior)
370 fprintf(logStream, "DCSEXT,");
371 if(instance.AvoidStaticLightPreCompute)
372 fprintf(logStream, "ASP,");
374 fprintf(logStream, "\n");
378 else if(strstr(fileName, ".skel"))
380 // read the skeleton.
381 CIFile file(fileName);
382 CShapeStream shapeStream;
383 file.serial(shapeStream);
384 CSkeletonShape *skel= dynamic_cast<CSkeletonShape*>(shapeStream.getShapePointer());
386 if(skel)
388 vector<CBoneBase> bones;
389 skel->retrieve(bones);
390 // Display Bone Infos.
391 fprintf(logStream, "Num Bones: %u\n", (uint)bones.size());
392 for(uint i=0; i<bones.size(); i++)
395 // get parent
396 sint32 parent = bones[i].FatherId;
398 // get parent
399 bool inheritScale = bones[i].UnheritScale;
401 // get default pos.
402 CVector pos = bones[i].DefaultPos.getDefaultValue();
404 // get default rotquat.
405 CQuat rotQuat = bones[i].DefaultRotQuat.getDefaultValue();
407 // get default scale.
408 CVector scale = bones[i].DefaultScale.getDefaultValue();
410 // get inv bind pos.
411 CMatrix invBindPos = bones[i].InvBindPos;
412 CVector invBindPosI = invBindPos.getI();
413 CVector invBindPosJ = invBindPos.getJ();
414 CVector invBindPosK = invBindPos.getK();
415 CVector invBindPosT = invBindPos.getPos();
417 // print info
418 fprintf(logStream, "Bone %2d. %s.\n", i, bones[i].Name.c_str());
419 fprintf(logStream, " Parent: %d\n", parent );
420 fprintf(logStream, " InheritScale: %d\n", inheritScale );
421 fprintf(logStream, " Position: (%2.3f, %2.3f, %2.3f)\n",
422 pos.x, pos.y, pos.z);
423 fprintf(logStream, " RotQuat: (%2.3f, %2.3f, %2.3f, %2.3f)\n",
424 rotQuat.x, rotQuat.y, rotQuat.z, rotQuat.w);
425 fprintf(logStream, " Scale: (%2.3f, %2.3f, %2.3f)\n",
426 scale.x, scale.y, scale.z);
427 fprintf(logStream, " InvBindPos: I: (%2.3f, %2.3f, %2.3f)\n",
428 invBindPosI.x, invBindPosI.y, invBindPosI.z);
429 fprintf(logStream, " InvBindPos: J: (%2.3f, %2.3f, %2.3f)\n",
430 invBindPosJ.x, invBindPosJ.y, invBindPosJ.z);
431 fprintf(logStream, " InvBindPos: K: (%2.3f, %2.3f, %2.3f)\n",
432 invBindPosK.x, invBindPosK.y, invBindPosK.z);
433 fprintf(logStream, " InvBindPos: Pos: (%2.3f, %2.3f, %2.3f)\n",
434 invBindPosT.x, invBindPosT.y, invBindPosT.z);
438 else
440 fprintf(logStream, "Bad Skel file\n");
443 // release
444 delete shapeStream.getShapePointer();
445 shapeStream.setShapePointer(NULL);
447 else if(strstr(fileName, ".shape"))
449 // read the shape.
450 CIFile file(fileName);
451 CShapeStream shapeStream;
452 file.serial(shapeStream);
454 // Test Type
455 CMesh *mesh= dynamic_cast<CMesh*>(shapeStream.getShapePointer());
456 CMeshMRM *meshMRM= dynamic_cast<CMeshMRM*>(shapeStream.getShapePointer());
457 CMeshMRMSkinned *meshMRMSkinned= dynamic_cast<CMeshMRMSkinned*>(shapeStream.getShapePointer());
458 CMeshMultiLod *meshMulti= dynamic_cast<CMeshMultiLod*>(shapeStream.getShapePointer());
460 // Material infos
461 CMeshBase *meshBase= dynamic_cast<CMeshBase*>(shapeStream.getShapePointer());
462 if(meshBase)
464 displayMeshBase(logStream, meshBase);
467 // Mesh ??
468 if( mesh )
470 displayGeom(logStream, mesh->getMeshGeom());
472 // MRM ??
473 else if( meshMRM )
475 displayMRMGeom(logStream, meshMRM->getMeshGeom());
477 else if( meshMRMSkinned )
479 displayMRMSkinnedGeom(logStream, meshMRMSkinned->getMeshGeom());
481 // MultiLod??
482 else if( meshMulti )
484 uint numSlots= meshMulti->getNumSlotMesh ();
485 fprintf(logStream, " Num Lods: %d\n", numSlots );
486 if(numSlots)
488 const CMeshGeom *meshGeom= dynamic_cast<const CMeshGeom*>(&(meshMulti->getMeshGeom(0)));
489 const CMeshMRMGeom *meshMRMGeom= dynamic_cast<const CMeshMRMGeom*>(&(meshMulti->getMeshGeom(0)));
490 if( meshGeom )
491 displayGeom(logStream, *meshGeom);
492 else if( meshMRMGeom )
493 displayMRMGeom(logStream, *meshMRMGeom);
496 else
498 fprintf(logStream, "Unsupported .shape type for display info\n");
501 // release
502 delete shapeStream.getShapePointer();
503 shapeStream.setShapePointer(NULL);
505 else if(strstr(fileName, ".anim"))
507 // read the shape.
508 CIFile file(fileName);
509 CAnimation anim;
510 file.serial(anim);
512 // Enum the tracks
513 std::set<std::string> tracks;
514 anim.getTrackNames (tracks);
515 std::set<std::string>::iterator ite = tracks.begin();
516 while (ite != tracks.end())
518 // Track name
519 fprintf(logStream, "Track name=%s", ite->c_str());
521 uint trackId = anim.getIdTrackByName (*ite);
522 ITrack *track = anim.getTrack (trackId);
523 if (track)
525 fprintf(logStream, " type=%s", typeid(*track).name());
527 UTrackKeyframer *keyFramer = dynamic_cast<UTrackKeyframer*> (track);
528 if (keyFramer)
530 TAnimationTime begin = track->getBeginTime ();
531 TAnimationTime end = track->getEndTime ();
532 std::vector<TAnimationTime> keys;
533 keyFramer->getKeysInRange(begin, end, keys);
534 if (!keys.empty())
536 float fvalue;
537 sint32 ivalue;
538 CRGBA cvalue;
539 CVector vvalue;
540 CQuat qvalue;
541 string svalue;
542 bool bvalue;
543 uint i;
544 if (track->interpolate (begin, fvalue))
546 fprintf(logStream, " floats\n");
547 for (i=0; i<keys.size(); i++)
549 if (track->interpolate (keys[i], fvalue))
550 fprintf(logStream, "\tKey %d : time=%f, value=%f\n", i, keys[i], fvalue);
553 else if (track->interpolate (begin, ivalue))
555 fprintf(logStream, " integers\n");
556 for (i=0; i<keys.size(); i++)
558 if (track->interpolate (keys[i], ivalue))
559 fprintf(logStream, "\tKey %d : time=%f, value=%d\n", i, keys[i], ivalue);
562 else if (track->interpolate (begin, cvalue))
564 fprintf(logStream, " color\n");
565 for (i=0; i<keys.size(); i++)
567 if (track->interpolate (keys[i], cvalue))
568 fprintf(logStream, "\tKey %d : time=%f, r=%d, g=%d, b=%d, a=%d\n", i, keys[i], cvalue.R, cvalue.G, cvalue.B, cvalue.A);
571 else if (track->interpolate (begin, vvalue))
573 fprintf(logStream, " vector\n");
574 for (i=0; i<keys.size(); i++)
576 if (track->interpolate (keys[i], vvalue))
577 fprintf(logStream, "\tKey %d : time=%f, x=%f, y=%f, z=%f\n", i, keys[i], vvalue.x, vvalue.y, vvalue.z);
580 else if (track->interpolate (begin, qvalue))
582 fprintf(logStream, " quaternion\n");
583 for (i=0; i<keys.size(); i++)
585 if (track->interpolate (keys[i], qvalue))
586 fprintf(logStream, "\tKey %d : time=%f, x=%f, y=%f, z=%f, w=%f\n", i, keys[i], qvalue.x, qvalue.y, qvalue.z, qvalue.w);
589 else if (track->interpolate (begin, svalue))
591 fprintf(logStream, " string\n");
592 for (i=0; i<keys.size(); i++)
594 if (track->interpolate (keys[i], svalue))
595 fprintf(logStream, "\tKey %d : time=%f, value=%s\n", i, keys[i], svalue.c_str());
598 else if (track->interpolate (begin, bvalue))
600 fprintf(logStream, " bool\n");
601 for (i=0; i<keys.size(); i++)
603 if (track->interpolate (keys[i], bvalue))
604 fprintf(logStream, "\tKey %d : time=%f, value=%s\n", i, keys[i], bvalue?"true":"false");
611 ite++;
614 else
616 fprintf(logStream, "unsupported format\n");
622 // ***************************************************************************
623 // dispaly info for a file.
624 void displayInfoFile(FILE *logStream, const char *fileName, const set<string> &options, bool displayShortFileName)
626 // Display on screen.
627 displayInfoFileInStream(stdout, fileName,options, displayShortFileName);
628 // Display in log
629 if(logStream)
630 displayInfoFileInStream(logStream, fileName,options, displayShortFileName);
634 // ***************************************************************************
635 /// Dispaly info cmd line
636 int main(int argc, const char *argv[])
638 registerSerial3d();
640 if(argc<2)
642 puts("Usage: ig_info file.??? [opt]");
643 puts("Usage: ig_info directory [opt]");
644 puts(" For now, only .ig, .zone, .skel, .shape are supported");
645 puts(" Results are displayed too in \"c:/temp/file_info.log\" ");
646 puts(" [opt] can get: ");
647 puts(" -ms display only a Warning if file is a .shape and is a Mesh, skinned, but without MRM");
648 puts(" -vi verbose instance information");
649 puts(" -vl verbose light information");
650 puts(" -vp verbose patche information");
651 puts(" -veil verbose instances bound to light extra information");
652 puts("Press any key");
653 _getch();
654 return -1;
657 // Parse options.
658 set<string> options;
659 int i;
660 for (i=2; i<argc; i++)
661 options.insert (argv[i]);
663 // Open log
664 FILE *logStream = nlfopen(getLogDirectory() + "file_info.log", "wt");
666 // parse dir or file ??
667 const char *fileName= argv[1];
668 if(CFile::isDirectory(fileName))
670 // dir all files.
671 std::vector<std::string> listFile;
672 CPath::getPathContent (fileName, false, false, true, listFile);
674 fprintf(stdout, "Scanning Directory '%s' .........\n\n\n", fileName);
675 if(logStream)
676 fprintf(logStream, "Scanning Directory '%s' .........\n\n\n", fileName);
678 // For all files.
679 for(uint i=0;i<listFile.size();i++)
681 displayInfoFile(logStream, listFile[i].c_str(), options, true);
684 // display info for lightmaps
685 fprintf(stdout, "\n\n ************** \n I HAVE FOUND AT MAX %d LIGHTMAPS IN A SHAPE\n", MaxNumLightMap);
686 if(logStream)
687 fprintf(logStream, "\n\n ************** \n I HAVE FOUND AT MAX %d LIGHTMAPS IN A SHAPE\n", MaxNumLightMap);
689 else
691 displayInfoFile(logStream, fileName, options, false);
695 // close log
696 if(logStream)
697 fclose(logStream);
700 puts("Press any key");
701 _getch();