meshes in xml form
Moderators: Pandora Moderators, Slitherine Core
meshes in xml form
What I'm ultimately trying to do is port meshes and textures from another game into Pandora, but first, I need to know how to work with the .xml files in Video/Meshes/x. How would one go about using a 3d mesh editor such as Blender to import and export such files? I've tried converting the xml's to obj's but that didn't work.
Re: meshes in xml form
I can just hear the wind carrying the tumbleweeds down the scorching, lifeless desert that is this forum.
Re: meshes in xml form
As for getting xml meshes to blender you would need to use xmlconverter, its somewhere on blender forumSephiRok wrote:Meshes were made in 3ds Max, but we have a custom format.
But it wont help since the custom format, you cant even preview them with.
Re: meshes in xml form
Hi guys,
We indeed use a simple custom XML format for meshes and animations. Our artist works with 3D Studio Max, and runs those two Max scripts to export the data:
Mesh Exporter:
Animation Exporter:
Note that the exported mesh file is outdated/verbose, the game will automatically convert it into a format that is faster to parse on load.
We indeed use a simple custom XML format for meshes and animations. Our artist works with 3D Studio Max, and runs those two Max scripts to export the data:
Mesh Exporter:
Code: Select all
--
-- Mesh Exporter 2.0
-- Copyright (C) 2013 by Proxy Studios.
-- All rights reserved.
--
selectedObjects = selection as array
exportedObjectsCount = 0
for obj in selectedObjects do (
-- Only export non-hiden meshes for non-bone geometry objects.
if not obj.isHidden and superClassOf obj == GeometryClass and not isKindOf obj BoneGeometry do (
msh = snapshotAsMesh obj
-- Collect influencing bones.
bones = #()
for skn in obj.modifiers do (
if iskindof skn Skin do (
SetCommandPanelTaskMode mode:#modify
ModPanel.SetCurrentObject skn
for v = 1 to msh.numVerts do (
numBones = skinOps.getVertexWeightCount skn v
for b = 1 to numBones do (
boneID = skinOps.getVertexWeightBoneId skn v b
boneName = skinOps.GetBoneName skn boneID 0
if (findItem bones boneName) == 0 do (
append bones boneName
)
)
)
)
)
sort bones
outputPath = obj.name + ".xml"
outputFile = createfile outputPath
format "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" to:outputFile
format "<mesh>\n" to:outputFile
-- Export vertices.
for v = 1 to msh.numVerts do (
vert = getVert msh v
format "\t<vertex id=\"%\" x=\"%\" y=\"%\" z=\"%\"/>\n" (v - 1) vert.x vert.y vert.z to:outputFile
)
-- Export texture coordinates.
for vt = 1 to msh.numTVerts do (
tVert = getTVert msh vt
format "\t<textureCoordinate id=\"%\" x=\"%\" y=\"%\"/>\n" (vt - 1) tVert.x tVert.y to:outputFile
)
-- Export normals.
for f = 1 to msh.numFaces do (
normals = meshop.getFaceRNormals msh f
format "\t<normal id=\"%\" x=\"%\" y=\"%\" z=\"%\"/>\n" ((f - 1) * 3 + 0) normals[1].x normals[1].y normals[1].z to:outputFile
format "\t<normal id=\"%\" x=\"%\" y=\"%\" z=\"%\"/>\n" ((f - 1) * 3 + 1) normals[2].x normals[2].y normals[2].z to:outputFile
format "\t<normal id=\"%\" x=\"%\" y=\"%\" z=\"%\"/>\n" ((f - 1) * 3 + 2) normals[3].x normals[3].y normals[3].z to:outputFile
)
-- Export bone weights and bones.
for skn in obj.modifiers do (
if iskindof skn Skin do (
SetCommandPanelTaskMode mode:#modify
ModPanel.SetCurrentObject skn
-- Export bone weights.
for v = 1 to msh.numVerts do (
numBones = skinOps.getVertexWeightCount skn v
format "\t<boneWeights id=\"%\">\n" (v - 1) to:outputFile
for b = 1 to numBones do (
boneID = skinOps.getVertexWeightBoneId skn v b
boneName = skinOps.GetBoneName skn boneID 0
boneWeight = skinOps.getVertexWeight skn v b
if boneWeight > 0.0 do (
index = (findItem bones boneName) - 1
format "\t\t<bone id=\"%\" weight=\"%\"/>\n" index boneWeight to:outputFile
)
)
format "\t</boneWeights>\n" to:outputFile
)
-- Export bones.
for b = 1 to bones.count do (
boneName = bones[b]
format "\t<bone id=\"%\" name=\"%\">\n" (b - 1) boneName to:outputFile
boneObject = getNodeByName boneName
p = in coordsys world boneObject.pivot
format "\t\t<position x=\"%\" y=\"%\" z=\"%\"/>\n" p.x p.y p.z to:outputFile
r = in coordsys world boneObject.rotation
format "\t\t<rotation x=\"%\" y=\"%\" z=\"%\" w=\"%\"/>\n" r.x r.y r.z r.w to:outputFile
s = boneObject.scale
format "\t\t<scale x=\"%\" y=\"%\" z=\"%\"/>\n" s.x s.y s.z to:outputFile
format "\t</bone>\n" (b - 1) to:outputFile
)
)
)
-- Export faces.
for f = 1 to msh.numFaces do (
face = getFace msh f
tvFace = getTVFace msh f
faceX = int(face.x) - 1
faceY = int(face.y) - 1
faceZ = int(face.z) - 1
tvFaceX = int(tvFace.x) - 1
tvFaceY = int(tvFace.y) - 1
tvFaceZ = int(tvFace.z) - 1
format "\t<face id=\"%\">\n" (f - 1) to:outputFile
format "\t\t<vertex id=\"%\"/>\n" faceX to:outputFile
format "\t\t<vertex id=\"%\"/>\n" faceY to:outputFile
format "\t\t<vertex id=\"%\"/>\n" faceZ to:outputFile
format "\t\t<textureCoordinate id=\"%\"/>\n" tvFaceX to:outputFile
format "\t\t<textureCoordinate id=\"%\"/>\n" tvFaceY to:outputFile
format "\t\t<textureCoordinate id=\"%\"/>\n" tvFaceZ to:outputFile
format "\t\t<normal id=\"%\"/>\n" ((f - 1) * 3 + 0) to:outputFile
format "\t\t<normal id=\"%\"/>\n" ((f - 1) * 3 + 1) to:outputFile
format "\t\t<normal id=\"%\"/>\n" ((f - 1) * 3 + 2) to:outputFile
format "\t</face>\n" to:outputFile
)
format "</mesh>\n" to:outputFile
delete msh
close outputFile
exportedObjectsCount = exportedObjectsCount + 1
)
)
message = "Exported " + exportedObjectsCount as string + " mesh(es)."
messageBox message title:"Mesh Exporter"
Code: Select all
--
-- Animation Exporter 2.0
-- Copyright (C) 2013 by Proxy Studios.
-- All rights reserved.
--
selectedObjects = selection as array
exportedObjectsCount = 0
for obj in selectedObjects do (
-- Only export animations for non-bone geometry objects.
if superClassOf obj == GeometryClass and not isKindOf obj BoneGeometry do (
msh = snapshotAsMesh obj
-- Collect influencing bones.
bones = #()
for skn in obj.modifiers do (
if iskindof skn Skin do (
SetCommandPanelTaskMode mode:#modify
ModPanel.SetCurrentObject skn
for v = 1 to msh.numVerts do (
numBones = skinOps.getVertexWeightCount skn v
for b = 1 to numBones do (
boneID = skinOps.getVertexWeightBoneId skn v b
boneName = skinOps.GetBoneName skn boneID 0
boneWeight = skinOps.getVertexWeight skn v b
if (findItem bones boneName) == 0 do (
append bones boneName
)
)
)
)
)
sort bones
-- Only export animations for objects influenced by bones.
if (bones.count > 0) do (
outputPath = obj.name + ".xml"
outputFile = createfile outputPath
format "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" to:outputFile
frames = int(animationRange.end - animationRange.start + 1)
format "<animation frames=\"%\" frameRate=\"%\">\n" frames frameRate to:outputFile
-- Export bones.
for b = 1 to bones.count do (
format "\t<bone id=\"%\" name=\"%\">\n" (b - 1) bones[b] to:outputFile
boneObject = getNodeByName bones[b]
-- Export frames.
for f = animationRange.start to animationRange.end do (
at time f (
fCurrent = int(f)
format "\t\t<frame id=\"%\">\n" fCurrent to:outputFile
p = in coordsys world boneObject.pivot
format "\t\t\t<position x=\"%\" y=\"%\" z=\"%\"/>\n" p.x p.y p.z to:outputFile
r = in coordsys world boneObject.rotation
format "\t\t\t<rotation x=\"%\" y=\"%\" z=\"%\" w=\"%\"/>\n" r.x r.y r.z r.w to:outputFile
s = boneObject.scale
format "\t\t\t<scale x=\"%\" y=\"%\" z=\"%\"/>\n" s.x s.y s.z to:outputFile
format "\t\t</frame>\n" to:outputFile
)
)
format "\t</bone>\n" (b - 1) to:outputFile
)
format "</animation>\n" to:outputFile
close outputFile
exportedObjectsCount = exportedObjectsCount + 1
)
delete msh
)
)
message = "Exported " + exportedObjectsCount as string + " animation(s)."
messageBox message title:"Animation Exporter"
Lorenz Ruhmann
Proxy Studios
Proxy Studios
Re: meshes in xml form
Thanks void, its time to learn modeling
Re: meshes in xml form
A bold endeavour, mrowka, but I have faith in you!
Lorenz Ruhmann
Proxy Studios
Proxy Studios
Re: meshes in xml form
Only question is that i need to use 3dmax or i can use that scripts somewhere in blender ?
Re: meshes in xml form
Is there any way to import the meshes and animations? Being able to export things is pretty useless if I can't import things to make sure it's going to work as intended.
Re: meshes in xml form
I'm afraid not at the moment, but our artist said he'll write a short tutorial / offer a sample 3D studio file over the next days to illustrate how it's done. With a bit of programming knowledge one can see fairly easily how the format works by examining the script files or the mesh/animation files (especially the simpler ones like Meshes/WorkshopGround.xml for the plane below units in the workshop view). Coordinate system wise we use X front, Y left, and Z up, just like the Source engine. Units are centered on X and Y, the ground they stand on being Z = 0. Weapons are attached to all bones named "Weapon0", "Weapon1", etc.
Lorenz Ruhmann
Proxy Studios
Proxy Studios
Re: meshes in xml form
Right, a tutorial is needed. I hate to sound like an idiot, but those 3dxml files are all Greek to me.
Re: meshes in xml form
Anyone have an update on that tutorial?
Re: meshes in xml form
stiefelss wrote:Anyone have an update on that tutorial?