PDA

View Full Version : Import PCGAME Objects


johnwhile
11-12-2010, 09:04 PM
Hi all, i have a big problem with importing a game objects data:
this is the Data structure:
2--number of group's faces
"head" --group 1 name
10 --number or faces
1 2 4 -- sequence of index faces
4 5 1
...
10 12 15
"elmet" --group 2 name
5 --number or faces
1 10 16 -- sequence of index faces if there are similar vertex the index are the same (1)
16 17 18
...
20 21 22

22 -- number of all vertex
0.0 1.0 2.0 -- all vertex array
2.4 1.4 2.0
...
0.1 1.1 2.3

22 -- number of all vertex weight of 2 or 1 bone (1.0= 100%)
0.5 0.5 -- all vertex array
1.0 0.0
...
0.3 0.7

22 -- number of normal per vertex & binormal & tangent & vertex color...
....
....

Ok, now i want build a mesh object called "head" and a detached object called "elmet", but the problem is the algorithm to build the Faces array and Vertex array (in parallel with normal, bone assignments etc...)

I write two version:
the first version create all these array but is very very slow because for 10000 verts there are 10000^2 loops...
the second version is very very fast but is impossible assign bone assignment:
BigObj = mesh faces:Faces vertices:VertsData tverts:TVertsData
BigObj.name = "MeshRaggruppata"
buildTVFaces BigObj
for j = 1 to BigObj.numfaces do (setTVFace BigObj j (getFace BigObj j))

setNumCPVVerts BigObj BigObj.numVerts

for j = 1 to BigObj.numVerts do setNormal BigObj j NormalData[j]
update BigObj
ConvertToMax BigObj

for i=1 to BigObj.numfaces do (setFaceSmoothGroup BigObj i 1)
-------------------------------- detachments groups ----------------------------------
for i=1 to FacesIndex.count do
(
detachMesh = meshop.detachFaces BigObj #{1..(FacesIndex[i])} delete:true asMesh:true
obj = Editable_mesh()
obj.mesh = detachMesh
obj.name = FacesName[i][1] + ":" + FacesName[i][2] + ":" + (FacesName[i][3] as string)
obj.pivot = obj.center
)--end obj
delete BigObj

johnwhile
11-12-2010, 09:10 PM
this is the file structure, i have simplified the informations in a text file... did someone know some algorithm or strategy ? if you what i can upload my script with game file to understand well ?

CGTalk Moderation
11-12-2010, 09:10 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.