Jump to content

Recommended Posts

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Scrypt 3DS Max by Ricky92

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
                )
            )
        )
    )
)
Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

Announcements



  • Similar Content

  • Activity

    1. 8

      ZycloniusMT2 Server from Australia still around

    2. 60

      Inbuild GR2 Animation

    3. 2

      wait() function bug

    4. 0

      Remove Party Role Bonuses

    5. 1

      Fix CBar3D

    6. 2

      set_quest_state not working

  • Recently Browsing

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.