Update of /cvsroot/ogre/ogrenew/Tools/3dsmaxExport/scripts/ogre/lib
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18141/Tools/3dsmaxExport/scripts/ogre/lib
Modified Files:
OgreBipedLib.ms OgreSkeletonLib_meshfns.ms
OgreSkeletonLib_usefulfns.ms
Log Message:
Speed up the mesh export process. No very easy to notice for small objects but great speed improvements for very big objects.
Any kind of objects can now be part of the hierarchy if they are part of the Skin/Physique modifier.
Index: OgreBipedLib.ms
===================================================================
RCS file: /cvsroot/ogre/ogrenew/Tools/3dsmaxExport/scripts/ogre/lib/OgreBipedLib.ms,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** OgreBipedLib.ms 29 Nov 2004 13:30:00 -0000 1.4
--- OgreBipedLib.ms 30 Nov 2004 11:29:15 -0000 1.5
***************
*** 2,25 ****
-----------------------------------------------------------------------------
- -- check if the bone is the root object of the biped
- -----------------------------------------------------------------------------
- function isPelvis bipObj =
- (
- if (bipObj == undefined) then return false ;
- if (classof bipObj != Biped_Object) then return false;
- return ((biped.getNode bipObj 13) == bipObj) ;
- )
-
- -----------------------------------------------------------------------------
- -- check if the bone is the footstep object of the biped
- -----------------------------------------------------------------------------
- function isFootStep bipObj =
- (
- if (bipObj == undefined) then return false ;
- if (classof bipObj != Biped_Object) then return false;
- return ((biped.getNode bipObj 16) == bipObj) ;
- )
-
- -----------------------------------------------------------------------------
-- gets keyframes from the controllers animation
-----------------------------------------------------------------------------
--- 2,5 ----
***************
*** 151,155 ****
at time 0f (
initTform = d.transform ;
! if (not isRootUniversal d) then (
mparent = d.parent.transform ;
initTform = initTform*inverse(mparent) ;
--- 131,135 ----
at time 0f (
initTform = d.transform ;
! if (not isRootUniversal2 d) then (
mparent = d.parent.transform ;
initTform = initTform*inverse(mparent) ;
***************
*** 174,178 ****
Tform = d.transform ;
-- if this is the pelvis
! if (isRootUniversal d) then (
mparent = matrix3 1 ;
-- if flipYZ == true
--- 154,158 ----
Tform = d.transform ;
-- if this is the pelvis
! if (isRootUniversal2 d) then (
mparent = matrix3 1 ;
-- if flipYZ == true
***************
*** 197,201 ****
-- if this is the root bone and flipYZ == true
! if (isRootUniversal d and flipYZ) then (
Tform = flipYZTransform Tform ;
)
--- 177,181 ----
-- if this is the root bone and flipYZ == true
! if (isRootUniversal2 d and flipYZ) then (
Tform = flipYZTransform Tform ;
)
***************
*** 237,240 ****
--- 217,221 ----
-------------------------------------
global BonesList=#()
+ global RootsList=#()
-------------------------------------
***************
*** 245,260 ****
-- recursive function to build the list of bones for the skeleton
-----------------------------------------------------------------
! function computeBList b =
(
bname = b ;
bone = execute ("$" + bname) ;
if (findItem BonesList bname == 0) then
! if (isKindOf bone BoneGeometry or iskindOf bone Biped_Object) then
append BonesList bname ;
childrenArray = bone.children ;
for i=1 to childrenArray.count do
(
! if (isKindOf bone BoneGeometry or iskindOf bone Biped_Object) then
! computeBList (replaceSpaces childrenArray[i].name);
)
)
--- 226,241 ----
-- recursive function to build the list of bones for the skeleton
-----------------------------------------------------------------
! function computeBList b sk phy exportHelpers =
(
bname = b ;
bone = execute ("$" + bname) ;
if (findItem BonesList bname == 0) then
! if (isKindOf bone BoneGeometry or iskindOf bone Biped_Object or (exportHelpers and (isPartOfModifier bone sk phy)) ) then
append BonesList bname ;
childrenArray = bone.children ;
for i=1 to childrenArray.count do
(
! if (isKindOf bone BoneGeometry or iskindOf bone Biped_Object or (exportHelpers and (isPartOfModifier bone sk phy))) then
! computeBList (replaceSpaces childrenArray[i].name) sk phy exportHelpers;
)
)
***************
*** 291,295 ****
-- find the root(s) of the rhierarchy
-----------------------------------------------------------------
! function getHierarchyRoots phy sk =
(
local rootstab=#();
--- 272,276 ----
-- find the root(s) of the rhierarchy
-----------------------------------------------------------------
! function getHierarchyRoots phy sk exportHelpers =
(
local rootstab=#();
***************
*** 303,307 ****
d = execute ("$" + bname) ;
! while (d.parent!=undefined and (iskindof d.parent BoneGeometry or iskindOf d.parent Biped_Object)) do
(
d = d.parent
--- 284,288 ----
d = execute ("$" + bname) ;
! while (d.parent!=undefined and (iskindof d.parent BoneGeometry or iskindOf d.parent Biped_Object or (exportHelpers and (isPartOfModifier d.parent sk phy)) )) do
(
d = d.parent
***************
*** 319,323 ****
if trouve==0 then
(
! if (iskindof d BoneGeometry or iskindOf d Biped_Object) then
(
if (not g_MAX) then
--- 300,304 ----
if trouve==0 then
(
! if (iskindof d BoneGeometry or iskindOf d Biped_Object or (exportHelpers and (isPartOfModifier d sk phy)) ) then
(
if (not g_MAX) then
***************
*** 336,340 ****
d = execute ("$" + bname) ;
! while (d.parent!=undefined and (iskindof d.parent BoneGeometry or iskindOf d.parent Biped_Object)) do
(
d = d.parent
--- 317,321 ----
d = execute ("$" + bname) ;
! while (d.parent!=undefined and (iskindof d.parent BoneGeometry or iskindOf d.parent Biped_Object or (exportHelpers and (isPartOfModifier d.parent sk phy)) )) do
(
d = d.parent
***************
*** 352,356 ****
if trouve==0 then
(
! if (iskindof d BoneGeometry or iskindOf d Biped_Object) then
(
if (not g_MAX) then
--- 333,337 ----
if trouve==0 then
(
! if (iskindof d BoneGeometry or iskindOf d Biped_Object or (exportHelpers and (isPartOfModifier d sk phy))) then
(
if (not g_MAX) then
***************
*** 368,383 ****
-- function to build the list of bones for the skeleton
-----------------------------------------------------------------
! function computeBonesList phy sk =
(
! rootnodes = getHierarchyRoots phy sk ; -- find the roots of the current hierarchy
! print rootsnode
! for b in rootnodes do
(
! computeBList b;
)
-- add the nodes that are parts of the skin (or physique) modifier but are neither biped_object nor standard bones
-- only helpers (Point, Dummy) at the moment...
! addHelpersToHierarchy phy sk ;
)
--- 349,364 ----
-- function to build the list of bones for the skeleton
-----------------------------------------------------------------
! function computeBonesList phy sk exportHelpers =
(
! RootsList = getHierarchyRoots phy sk exportHelpers; -- find the roots of the current hierarchy
! print RootsList;
! for b in RootsList do
(
! computeBList b sk phy exportHelpers;
)
-- add the nodes that are parts of the skin (or physique) modifier but are neither biped_object nor standard bones
-- only helpers (Point, Dummy) at the moment...
! -- addHelpersToHierarchy phy sk ;
)
***************
*** 397,401 ****
slidertime = 0f ;
Tform = d.transform ;
! if (not isRootUniversal d) then (
mparent = d.parent.transform ;
Tform = Tform*inverse(mparent) ;
--- 378,382 ----
slidertime = 0f ;
Tform = d.transform ;
! if (not isRootUniversal2 d) then (
mparent = d.parent.transform ;
Tform = Tform*inverse(mparent) ;
***************
*** 404,408 ****
Tform.pos = Tform.pos * scale ;
! if ((isRootUniversal d) and flipYZ) then (
if (not g_MAX) then
format "- Flipping root... \n" ;
--- 385,389 ----
Tform.pos = Tform.pos * scale ;
! if ((isRootUniversal2 d) and flipYZ) then (
if (not g_MAX) then
format "- Flipping root... \n" ;
***************
*** 430,439 ****
-- write Bones (using writeB)
-----------------------------
! function writeBones phy sk scale flipYZ outFile =
(
local i ;
if (BonesList.count == 0) then
! computeBonesList phy sk ;
format("\t<bones>\n") to:outFile;
--- 411,422 ----
-- write Bones (using writeB)
-----------------------------
! function writeBones phy sk scale flipYZ exportHelpers outFile =
(
local i ;
+ OgreExportObject.exportProgress.value = 0;
+
if (BonesList.count == 0) then
! computeBonesList phy sk exportHelpers;
format("\t<bones>\n") to:outFile;
***************
*** 443,450 ****
--- 426,437 ----
for i=1 to BonesList.count do
(
+ OgreExportObject.exportProgress.value = (100.0*i/BonesList.count);
+
writeB BonesList[i] i scale flipYZ outFile ;
)
format("\t</bones>\n") to:outFile;
+
+ OgreExportObject.exportProgress.value = 100;
)
***************
*** 454,458 ****
function writeH b outFile =
(
! if (not isRootUniversal b) then
(
p = b.parent ;
--- 441,445 ----
function writeH b outFile =
(
! if (not isRootUniversal2 b) then
(
p = b.parent ;
***************
*** 463,466 ****
--- 450,455 ----
function writeHierarchy outFile =
(
+ OgreExportObject.exportProgress.value = 0;
+
local bname,pelvis
format("\t<bonehierarchy>\n") to:outFile ;
***************
*** 468,471 ****
--- 457,462 ----
for i=1 to BonesList.count do
(
+ OgreExportObject.exportProgress.value = (100.0*i/BonesList.count);
+
b = execute ("$" + (replaceSpaces BonesList[i])) ;
writeH b outFile ;
***************
*** 473,476 ****
--- 464,469 ----
format("\t</bonehierarchy>\n") to:outFile ;
+
+ OgreExportObject.exportProgress.value = 100;
)
***************
*** 482,485 ****
--- 475,480 ----
local i,n ;
+ OgreExportObject.exportProgress.value = 0;
+
format("\t<animations>\n") to: outFile ;
***************
*** 491,495 ****
--- 486,494 ----
n = BonesList.count ;
for i = 1 to n do
+ (
+ OgreExportObject.exportProgress.value = (100.0*i/BonesList.count)/Anims.names.count;
+
writeTrack BonesList[i] i Anims.startframes[anm] Anims.endframes[anm] samplerate IKsamplerate Anims.lengths[anm] scale flipYZ outFile ;
+ )
format("\t\t\t</tracks>\n") to:outFile
***************
*** 498,501 ****
--- 497,502 ----
format("\t</animations>\n") to: outFile ;
+
+ OgreExportObject.exportProgress.value = 100;
)
***************
*** 552,556 ****
if (not g_MAX) then
format "Writing bones :\n" ;
! writeBones phy sk exportOptions.scale exportOptions.flipYZ outFile ;
if (not g_MAX) then
--- 553,557 ----
if (not g_MAX) then
format "Writing bones :\n" ;
! writeBones phy sk exportOptions.scale exportOptions.flipYZ exportOptions.exportHelpers outFile ;
if (not g_MAX) then
Index: OgreSkeletonLib_meshfns.ms
===================================================================
RCS file: /cvsroot/ogre/ogrenew/Tools/3dsmaxExport/scripts/ogre/lib/OgreSkeletonLib_meshfns.ms,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** OgreSkeletonLib_meshfns.ms 29 Nov 2004 18:15:34 -0000 1.13
--- OgreSkeletonLib_meshfns.ms 30 Nov 2004 11:29:16 -0000 1.14
***************
*** 109,122 ****
(
local start_uvs;
- local index = 0;
vertex = #();
--format "vertex a tester % % \n" vertexIndex vertexNormal;
! for vertex in searchTable do
(
- --format "vertex % % \n" vertex[1] vertex[2];
- index = index + 1;
- if (vertex[1]!=vertexIndex) then
- continue;
-
if (vertex[2]!=vertexNormal) then
continue;
--- 109,120 ----
(
local start_uvs;
vertex = #();
--format "vertex a tester % % \n" vertexIndex vertexNormal;
!
! if (searchTable[vertexIndex]==undefined) then
! return 0;
!
! for vertex in searchTable[vertexIndex] do
(
if (vertex[2]!=vertexNormal) then
continue;
***************
*** 149,153 ****
)
! return index ;
)
return 0;
--- 147,151 ----
)
! return vertex[1] ;
)
return 0;
***************
*** 167,171 ****
-- stores datas in verticesArrays and facesArrays.
----------------------------------------------------------------------------
! function getDatas tmesh flipyz scale flipNormal exportUV numUVsets exportColours sk phy =
(
local face; --index of the current face
--- 165,169 ----
-- stores datas in verticesArrays and facesArrays.
----------------------------------------------------------------------------
! function getDatas tmesh flipyz scale flipNormal exportUV numUVsets exportColours exportHelpers sk phy =
(
local face; --index of the current face
***************
*** 211,215 ****
-- compute bones list for the model.
BonesList=#()
! computeBonesList phy sk;
numFaces = (getNumFaces tmesh);
--- 209,213 ----
-- compute bones list for the model.
BonesList=#()
! computeBonesList phy sk exportHelpers ;
numFaces = (getNumFaces tmesh);
***************
*** 218,222 ****
for face = 1 to numFaces do -- LOOP on FACES --
(
! --progressUpdate (100.0*face/numFaces) ;
faceVerticesIndices = getFace tmesh face ;
--- 216,220 ----
for face = 1 to numFaces do -- LOOP on FACES --
(
! OgreExportObject.exportProgress.value = (100.0*face/numFaces);
faceVerticesIndices = getFace tmesh face ;
***************
*** 283,298 ****
if (newVertex == 1) then -- That is to say it has not been found.
(
-- the vertex number for the current submesh must be updated
! -- vertex number is increased.
! ogreVertNum = searchTable.count + 1 ;
! -- it is added to the search table.
! searchTable[ogreVertNum] = #() ;
! append searchTable[ogreVertNum] vertexIndex ;
! n = copy vertexNormal;
! append searchTable[ogreVertNum] n ;
if (exportColours) then
(
! append searchTable[ogreVertNum] VertexColorIndex ;
)
if (exportUV) then
--- 281,309 ----
if (newVertex == 1) then -- That is to say it has not been found.
(
+ -- Maybe the material found defines a new submesh...
+ if (verticesArrays[matId] == undefined) then
+ (
+ format "- Submesh detected: material ID = %\n" matId
+ verticesArrays[matId] = #() ;
+ boneAssignments[matId] = #() ;
+ append submeshesId matId ;
+ )
+
-- the vertex number for the current submesh must be updated
! -- vertex number is increased
! ogreVertNum = verticesArrays[matId].count + 1;
! -- it is added to the searchTable
! if (searchTable[vertexIndex]==undefined) then
! (
! searchTable[vertexIndex] = #() ;
! )
! local data = #();
! append data ogreVertNum ;
! n = copy vertexNormal ;
! append data n ;
if (exportColours) then
(
! append data VertexColorIndex ;
)
if (exportUV) then
***************
*** 301,308 ****
(
for uv=1 to UVcoords.count do
! append searchTable[ogreVertNum] UVcoords[uv];
)
)
! --print searchTable[ogreVertNum];
-- we retrieve data
--- 312,319 ----
(
for uv=1 to UVcoords.count do
! append data UVcoords[uv];
)
)
! append searchTable[vertexIndex] data ;
-- we retrieve data
***************
*** 328,339 ****
)
! -- Maybe the material found defines a new submesh...
! if (verticesArrays[matId] == undefined) then
! (
! format "- Submesh detected: material ID = %\n" matId
! verticesArrays[matId] = #() ;
! boneAssignments[matId] = #() ;
! append submeshesId matId ;
! )
vertexData = #(vertexPosition[1],vertexPosition[2],vertexPosition[3],vertexNormal[1],vertexNormal[2],vertexNormal[3],vertexColor.r,vertexColor.g,vertexColor.b,vertexColor.a) ;
if (exportUV) then
--- 339,343 ----
)
! -- store the vertex in verticesArrays
vertexData = #(vertexPosition[1],vertexPosition[2],vertexPosition[3],vertexNormal[1],vertexNormal[2],vertexNormal[3],vertexColor.r,vertexColor.g,vertexColor.b,vertexColor.a) ;
if (exportUV) then
***************
*** 396,400 ****
(
-- gets the root Id:
! append boneAssignments[matId] #(ogreVertNum,0,1) ;
)
)
--- 400,404 ----
(
-- gets the root Id:
! append boneAssignments[matId] #(ogreVertNum-1,0,1) ;
)
)
***************
*** 611,615 ****
sk = getSkin pmesh;
-
if (sk != undefined) then
format "Skin modifier detected.\n"
--- 615,618 ----
***************
*** 632,639 ****
max modify mode ;
modPanel.setCurrentObject pmesh.modifiers[#Physique] ;
- --setBonesNumber phy ;
--physiqueOps.setInitialPose pmesh true ;
)
!
-- retieving material
if (pmesh.material != undefined) then (
--- 635,643 ----
max modify mode ;
modPanel.setCurrentObject pmesh.modifiers[#Physique] ;
--physiqueOps.setInitialPose pmesh true ;
)
!
! OgreExportObject.exportProgress.value = 0;
!
-- retieving material
if (pmesh.material != undefined) then (
***************
*** 648,652 ****
format "Retrieving vertices and faces data : \n" ;
! getDatas m exportOptions.flipyz exportOptions.scale exportOptions.flipNormal exportOptions.exportUV exportOptions.UVchannels exportOptions.exportColours sk phy;
-- writing in the file
--- 652,656 ----
format "Retrieving vertices and faces data : \n" ;
! getDatas m exportOptions.flipyz exportOptions.scale exportOptions.flipNormal exportOptions.exportUV exportOptions.UVchannels exportOptions.exportColours exportOptions.exportHelpers sk phy;
-- writing in the file
***************
*** 668,671 ****
--- 672,676 ----
MessageBox ("Exporting mesh successful !") ;
+ OgreExportObject.exportProgress.value = 100;
)
return true ;
Index: OgreSkeletonLib_usefulfns.ms
===================================================================
RCS file: /cvsroot/ogre/ogrenew/Tools/3dsmaxExport/scripts/ogre/lib/OgreSkeletonLib_usefulfns.ms,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** OgreSkeletonLib_usefulfns.ms 28 Nov 2004 22:06:05 -0000 1.7
--- OgreSkeletonLib_usefulfns.ms 30 Nov 2004 11:29:16 -0000 1.8
***************
*** 8,12 ****
-- global structures
! struct exportOptions (sampleRate, ikSampleRate, scale, flipyz, flipNormal, exportColours, exportUV, UVchannels);
struct exportAnims (names, startframes, endframes, lengths) ;
--- 8,12 ----
-- global structures
! struct exportOptions (sampleRate, ikSampleRate, scale, flipyz, flipNormal, exportColours, exportUV, UVchannels, exportHelpers);
struct exportAnims (names, startframes, endframes, lengths) ;
***************
*** 14,17 ****
--- 14,20 ----
global Options;
+ global OgreExportFloater;
+ global OgreExportOptions, OgreExportObject, OgreExportMesh, OgreExportAnimation, OgreExportMaterial, OgreExportAbout;
+
--------------------------------------------------------------------
-- compute the transform, if you want to flip Y and Z axis,
***************
*** 35,38 ****
--- 38,62 ----
)
+ -----------------------------------------------------------------------------
+ -- check if the bone is the root object of the biped
+ -----------------------------------------------------------------------------
+ function isPelvis bipObj =
+ (
+ if (bipObj == undefined) then return false ;
+ if (classof bipObj != Biped_Object) then return false;
+ return ((biped.getNode bipObj 13) == bipObj) ;
+ )
+
+
+ -----------------------------------------------------------------------------
+ -- check if the bone is the footstep object of the biped
+ -----------------------------------------------------------------------------
+ function isFootStep bipObj =
+ (
+ if (bipObj == undefined) then return false ;
+ if (classof bipObj != Biped_Object) then return false;
+ return ((biped.getNode bipObj 16) == bipObj) ;
+ )
+
--------------------------------------------------------------------
***************
*** 62,65 ****
--- 86,130 ----
--------------------------------------------------------------------
+ -- returns if the object is a root or not,
+ -- handles any kind oj object
+ --------------------------------------------------------------------
+ function isRootUniversal2 b = (
+ bname = replaceSpaces b.name;
+ ind = (findItem RootsList bname);
+ if (ind == 0) then
+ return false;
+ else
+ return true;
+ )
+
+ --------------------------------------------------------------------
+ -- returns if the object is part of the skin (or physique modifier)
+ --------------------------------------------------------------------
+ function isPartOfModifier b sk phy = (
+ name = replaceSpaces b.name ;
+ if (sk!=undefined) then
+ (
+ for i=1 to (skinOps.GetNumberBones sk) do
+ (
+ bname = skinOps.GetBoneName sk i 1 ;
+ replaceSpaces bname ;
+ if (name == bname) then
+ return true;
+ )
+ )
+ else if (phy!=undefined) then
+ (
+ for i=1 to (physiqueOps.GetBoneCount $) do
+ (
+ bname = (physiqueOps.GetBones $)[i].name;
+ replaceSpaces bname ;
+ if (name == bname) then
+ return true;
+ )
+ )
+ return false;
+ )
+
+ --------------------------------------------------------------------
-- creates a new array (which must be set up as an array before
-- calling this function) in which there isn't the same element.
|