Open 3DSMax > "MaxScript" > "Run Script." > Select saved *.mcr
"Customize" > "Customize User Interface" > "Toolbars" > Search "Load Mdatr file" in "Action" list > "New..." > Choose name
Drag & Drop "Load Mdatr file" to the new window > Drag & Drop new window to 3DSMax toolbar > Open *.mdatr
or search "MacroScript 3DSMax" for other Tutorial
MacroScript: by ricky92
Code:
MacroScript Load_Mdatr
category: "Mdatr Tool"
buttonText: "Load Mdatr file"
tooltip: "Load Mdatr file"
(
fName = getOpenFileName types:"Mdatr Files (*.mdatr)|*.mdatr"
if fName != undefined do
(
f = fopen fName "rb"
if f != undefined do
(
headerText = ReadString f
if (headerText == "AttributeData") do
(
--messageBox("Header Check OK!")
numOfMeshes = ReadLong f
numOfHeightPlanes = ReadLong f
if (numOfHeightPlanes > 0) do
(
messageBox("Warning: Numer of HeighPlanes is greater than 0. This feature is currently unsupported.")
)
-- Mesh reading and creation
for i = 1 to numOfMeshes do
(
meshType = ReadLong f
meshName = ReadString f
toSeek = 31 - meshName.count
fseek f toSeek #seek_cur
meshX = ReadFloat f
meshY = ReadFloat f
meshZ = ReadFloat f
--messageBox("Mesh type " + (meshType as string) + ", position: " + (meshX as string) + ", " + (meshY as string) + ", " + (meshZ as string))
obj = undefined
case (meshType) of
(
0:
(
-- Plane mesh
scaleX = ReadFloat f
scaleY = ReadFloat f
obj = plane width:scaleX length:scaleY
obj.position = [-meshX, meshY, meshZ]
quatX = readFloat f
quatY = readFloat f
quatZ = readFloat f
quatW= readFloat f
--messageBox("Quaternion: X " + (quatX as string) + " Y " + (quatY as string) + " Z " + (quatZ as string) + " W " + (quatW as string))
rot = quat quatX quatY quatZ quatW
eulerRot = quatToEuler rot order:2
rotate obj eulerRot
)
2:
(
-- Sphere mesh
sRadius = ReadFloat f
obj = sphere radius:sRadius position:[meshX, meshY, meshZ]
quatX = readFloat f
quatY = readFloat f
quatZ = readFloat f
quatW= readFloat f
--messageBox("Quaternion: X " + (quatX as string) + " Y " + (quatY as string) + " Z " + (quatZ as string) + " W " + (quatW as string))
rot = quat quatX quatY quatZ quatW
eulerRot = quatToEuler rot order:2
rotate obj eulerRot
)
3:
(
-- Cylinder mesh
cRadius = ReadFloat f
cLength = ReadFloat f
obj = cylinder radius:cRadius height:cLength position:[meshX, meshY, meshZ]
quatX = readFloat f
quatY = readFloat f
quatZ = readFloat f
quatW= readFloat f
--messageBox("Quaternion: X " + (quatX as string) + " Y " + (quatY as string) + " Z " + (quatZ as string) + " W " + (quatW as string))
rot = quat quatX quatY quatZ quatW
eulerRot = quatToEuler rot order:1
rotate obj eulerRot
)
)
obj.name = meshName
)
)
)
)
)







