Commit 360e6ff4 authored by cmaffeo2's avatar cmaffeo2
Browse files

Added some temporary files for parsing maya

parent 1b27f431
# set ID [mol new]
graphics $ID delete all
class MayaObj():
def __init__(self, maya_lines):
self.name, self.parent_name = MayaObj._parse_first_maya_line( maya_lines[0] )
def _parse_first_maya_line(l):
## createNode vHelix -n "helix_1";
name = parent = None
vals = l.split()
for i in range(len(vals)):
if vals[i] == "-n": name = vals[i+1]
if vals[i] == "-p": parent = vals[i+1]
return name,parent
b = MayaObj( lines )
class MayaHelix(MayaObj):
def __init__(self, maya_lines):
MayaObj.__init__(self, maya_lines)
self.bases = []
helices = []
bases = []
# set ch [open /home/cmaffeo2/Downloads/ball.ma]
# proc getNextVector {ch} {
# gets $ch line
# set line [split $line]
# lrange $line 5 7
# }
# proc eulerToRot {euler} {
# lassign $euler x y z
# transmult [transaxis z $z] [transaxis y $y] [transaxis x $x]
# }
with open("/home/cmaffeo2/Downloads/bunny.ma") as fh:
linesBuffer = []
for line in fh:
if line[0] == "createNode":
## Create a new object
if len(linesBuffer) > 0:
objType = linesBuffer[0].split()[1]
if objType == "vHelix":
helices.append( MayaHelix( linesBuffer ) )
elif objType == "HelixBase":
bases.append = MayaBase( linesBuffer )
elif objType == "aimConstraint":
bases.append = MayaBase( linesBuffer )
linesBuffer = []
linesBuffer.append(line)
if line[1] == "vHelix"
while {[gets $ch line] >= 0} {
set args [lassign [split $line] cmd obj]
if {$cmd == "createNode"} {
if {$obj == "HelixBase" && $drawBase} {
set drawBase 1
# set v [vecscale 10 [getNextVector $ch]]
set v [coordtrans $R [vecscale 10 [getNextVector $ch]]]
# set v [coordtrans [transmult [trans_from_offset [vecscale 10 [getNextVector $ch]] $R ] {0 0 0}]]
graphics $ID sphere $v radius 2
} elseif {$obj == "vHelix"} {
set drawBase 1
# createNode vHelix -n "helix_1";
# setAttr ".t" -type "double3" -16.9433 11.8494 25.2659 ;
# setAttr ".r" -type "double3" 42.338094401101131 222.16004220698011 5.8192508587610412 ;
# setAttr ".dh" yes;
set v [vecscale 10 [getNextVector $ch]]
# set r [vecscale [expr {90.0/acos(0)}] [getNextVector $ch]]
set r [getNextVector $ch]
set R [eulerToRot $r]
set R [transmult [trans_from_offset $v] $R ]
# if {$helixCount == 2} {
# break
# } else {
# incr helixCount
# }
}
}
}
# set ID [mol new]
graphics $ID delete all
# set ch [open /home/cmaffeo2/Downloads/bunny.ma]
set ch [open /home/cmaffeo2/Downloads/ball.ma]
set helixCount 0
proc getNextVector {ch} {
gets $ch line
set line [split $line]
lrange $line 5 7
}
proc eulerToRot {euler} {
lassign $euler x y z
transmult [transaxis z $z] [transaxis y $y] [transaxis x $x]
}
while {[gets $ch line] >= 0} {
set args [lassign [split $line] cmd obj]
if {$cmd == "createNode"} {
if {$obj == "HelixBase" && $drawBase} {
set drawBase 1
# set v [vecscale 10 [getNextVector $ch]]
set v [coordtrans $R [vecscale 10 [getNextVector $ch]]]
# set v [coordtrans [transmult [trans_from_offset [vecscale 10 [getNextVector $ch]] $R ] {0 0 0}]]
graphics $ID sphere $v radius 2
} elseif {$obj == "vHelix"} {
set drawBase 1
# createNode vHelix -n "helix_1";
# setAttr ".t" -type "double3" -16.9433 11.8494 25.2659 ;
# setAttr ".r" -type "double3" 42.338094401101131 222.16004220698011 5.8192508587610412 ;
# setAttr ".dh" yes;
set v [vecscale 10 [getNextVector $ch]]
set r [getNextVector $ch]
set R [eulerToRot $r]
set R [transmult [trans_from_offset $v] $R ]
}
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment