Adverti horiz upsell

Rubik's cube 0.0.2 for 3dsmax (3dsmax script)

Play Rubik's cube in 3D Max viewport

License
Button download
758 Downloads

Compatibility

  • 8.x

History

Created:03/17/2010
Last Modified:04/24/2011
File Size: 7.7 KB

04/24/2011 

I've noticed that there's something wrong in the SCENE I downloaded, I got a crash when I tried to open it.

so I wrote a MS script to help you guys to create the scene.

You can just copy the code followed and save it as a ".ms" format file.

Run it in a new scene in 3ds Max.

Enjoy!

-- code start

struct IDLINK (xs, xa, ys, ya, zs, za)

fn getTag num=(
    tag = ""
    if num>0 then tag="a" else if num<0 then tag="s"
    return tag
)

fn cubeInit=(
    txsAttr = attributes txsData(
        parameters main rollout:params(
            nowPos type:#string ui:txt default:""
            colorNum type:#integer ui:colorNum default:0
            colorIndex type:#string ui:colorIndex default:""
            direct1 type:#string ui:direct1 default:"0_0_0"
            direct2 type:#string ui:direct2 default:"0_0_0"
            direct3 type:#string ui:direct3 default:"0_0_0"
        )
        rollout params "txs Cube Attr"(
            editText txt "nowPos" type:#string
            spinner colorNum "colorNum" type:#integer
            editText colorIndex "colorIndex" type:#string
            editText direct1 "direct1" type:#string
            editText direct2 "direct2" type:#string
            editText direct3 "direct3" type:#string
        )
    )
    colors = #((color 0 0 0), --black
                (color 35 102 255), --blue
                (color 35 99 0), --green
                (color 192 0 0), --red
                (color 255 234 0), --yellow
                (color 240 147 0), --orange
                (color 255 255 255)) --white
    meditMaterials[1] = Multimaterial ()
    for i=1 to colors.count do meditMaterials[1].materialList[i].Diffuse = colors[i]
    
    
    
    ids = IDLINK #(6,4) #(4,2) #(3,3) #(5,6) #(1,7) #(2,5)
    
    for i=0 to 2 do(
        for j=0 to 2 do(
            for l=0 to 2 do(
                b=Box lengthsegs:1 widthsegs:1 heightsegs:1 length:10 width:10 height:10 pos:[(i-1)*10,(j-1)*10,(l-1)*10-5] name:("mf_"+((i-1) as string)+"_"+((j-1) as string)+"_"+((l-1) as string)) isSelected:on                ConvertToPoly(b)
                b.pivot = [(i-1)*10,(j-1)*10,(l-1)*10]
                b.wirecolor =color 0 0 0

                max modify mode
                subobjectLevel = 2
                polyOp.setEdgeSelection b #{1..12}
                b.edgeChamfer = 0.5
                b.EditablePoly.buttonOp #chamfer
                subobjectLevel = 4
                polyOp.SetFaceSelection b #{1..26}
                b.EditablePoly.setMaterialIndex 1 1

                colorNum = 0
                direct = #()
                colorIndex = #()
                if i-1!=0 then(
                    colorNum += 1
                    tag="x"+(getTag (i-1))
                    face = getProperty ids tag
                    polyOp.SetFaceSelection b #{face[1]}
                    b.EditablePoly.setMaterialIndex face[2] 1
                    append colorIndex face[2]
                    if i-1>0 then (append direct "1_0_0") else if i-1<0 then (append direct "-1_0_0")
                )
                if j-1!=0 then(
                    colorNum += 1
                    tag="y"+(getTag (j-1))
                    face = getProperty ids tag
                    polyOp.SetFaceSelection b #{face[1]}
                    b.EditablePoly.setMaterialIndex face[2] 1
                    append colorIndex face[2]
                    if j-1>0 then (append direct "0_1_0") else if j-1<0 then (append direct "0_-1_0")
                )
                if l-1!=0 then(
                    colorNum += 1
                    tag="z"+(getTag (l-1))
                    face = getProperty ids tag
                    polyOp.SetFaceSelection b #{face[1]}
                    b.EditablePoly.setMaterialIndex face[2] 1
                    append colorIndex face[2]
                    if l-1>0 then (append direct "0_0_1") else if l-1<0 then (append direct "0_0_-1")
                )
                subobjectLevel = 0
                b.material = meditMaterials[1]
                custAttributes.add b txsAttr
                b.nowPos = (((i-1)) as string)+"_"+(((j-1)) as string)+"_"+(((l-1)) as string)
                b.colorNum = colorNum
                colorIndexStr = ""
                if colorIndex.count >0 then(
                    for n=1 to colorIndex.count-1 do colorIndexStr += (((colorIndex[n]-1) as string)+"_")
                    colorIndexStr += ((colorIndex[colorIndex.count]-1) as string)
                    b.colorIndex = colorIndexStr
                )
                for n=1 to colorNum do execute("$'"+b.name+"'.direct"+(n as string)+"=\""+direct[n]+"\"")
            )
        )
    )
)

fn controllerInit=(
    meditMaterials[2].opacity = 20
    preSet1 = #(#("d",[1,0,0],180),#("w",[1,0,0],90),#("s",[1,0,0],-90),#("q",[0,1,0],90),#("e", [0,1,0],-90))
    preSet2 = #(#("g",[1,0,0],180),#("f",[1,0,0],90),#("o",[1,0,0],-90),#("u",[0,1,0],90),#("h", [0,1,0],-90))
    preSet3 = #(#("t",[1,0,0],180),#("r",[1,0,0],90),#("l",[1,0,0],-90),#("j",[0,1,0],90),#("y", [0,1,0],-90))

    c=Cylinder heightsegs:5 capsegs:1 sides:6 height:10 radius:2 pos:[0,0,0] isSelected:on
    ConvertToPoly(c)
    
    v=polyOp.getVert c 31
    v1 = [0,0, v.z]
    for i=31 to 36 do(v=polyOp.getVert c i;polyOp.setVert c i ((v-v1)/2+v1);polyOp.moveVert c i [0,0,-1])
    
    v=polyOp.getVert c 19
    v1 = [0,0, v.z]
    for i=19 to 24 do(v=polyOp.getVert c i;polyOp.setVert c i ((v-v1)*1.1+v1);polyOp.moveVert c i [0,0,1])
    
    for i=13 to 18 do(polyOp.moveVert c i [0,0,2])
    
    v=polyOp.getVert c 7
    v1 = [0,0, v.z]
    for i=7 to 12 do(v=polyOp.getVert c i;polyOp.setVert c i ((v-v1)/3*2+v1);polyOp.moveVert c i [0,0,2.95])
    
    v=polyOp.getVert c 1
    v1 = [0,0, v.z]
    for i=1 to 6 do(v=polyOp.getVert c i;polyOp.setVert c i ((v-v1)/2+v1))
    
    t=Torus smooth:2 segs:48 sides:6 radius1:8 radius2:0.8 pos:[0,0,0] isSelected:on
    convertToPoly(t)
    max modify mode
    polyop.setFaceSelection t #{145..288}
    t.EditablePoly.delete #Face
    
    wv = t.weldThreshold
    t.weldThreshold = 100
    polyop.setVertSelection t #{1..6}
    t.EditablePoly.weldFlaggedVertices ()
    polyop.setVertSelection t #{140..145}
    t.EditablePoly.weldFlaggedVertices ()
    t.weldThreshold = wv
    
    v=polyop.getvert t 1
    polyop.setvert t 1 (v*(quat 5 [0,0,1]))
    
    vt=[0,0,0]
    vp=[0,0,0]
    for i=8 to 13 do (vt += (polyop.getvert t i))
    vp = vt/6
    for i=8 to 13 do (polyop.setvert t i (((polyop.getvert t i)-vp)*2+vp))
    
    v=polyop.getvert t 140
    polyop.setvert t 140 (v*(quat -5 [0,0,1]))
    
    maxOps.cloneNodes t cloneType:#copy newNodes:&tt
    rotate tt 180 [0,1,0]
    t.name = "i"
    tt.name = "k"
    t.position = [0,0,30]
    tt.position = [0,0,30]
    t.pivot = [0,0,0]
    tt.pivot = [0,0,0]
    t.material = meditMaterials[2]
    tt.material = meditMaterials[2]

    c.position = [0,0,30]
    c.pivot = [0,0,0]
    c.name = "a"
    c.material = meditMaterials[2]
    for i in preSet1 do(
        maxOps.cloneNodes c cloneType:#copy newNodes:&tmp
        tmp.name=i[1]
        rotate tmp i[3] i[2]
    )
    for i in preSet2 do(
        maxOps.cloneNodes t cloneType:#copy newNodes:&tmp
        tmp.name=i[1]
        rotate tmp i[3] i[2]
    )
    for i in preSet3 do(
        maxOps.cloneNodes tt cloneType:#copy newNodes:&tmp
        tmp.name=i[1]
        rotate tmp i[3] i[2]
    )
)

fn main=(
    cubeInit()
    controllerInit()
    messageBox "The scene has been ready.\nPlease run the \"mofang.ms\" script to play."
)
main()

-- code end

 

#######################################################################################

/some day once upon/

Open the scene and make sure do not change any thing in the scene.
Then, run the script named 'mofang.ms'.
Now, you can try to select the handle in the scene to rot the cube.

Additional, you can type the command 'txsAutoComp()' in the command line to complete the cube automatically.

And moreover, there's another version in Maya python(.py).



Please use the Bug System to report any bugs.
Please use the Feature Requests to give me ideas.
Please use the Support Forum if you have any questions or problems.
Please rate and review in the Review section.

People who favorited this item:

  • eric dima-ala
    eric dima-ala
  • monci monci
    monci monci
  • introspecs33
    introspecs33