def rotate_from_max_to_ror(self):
     angle1 = mxs.angleaxis(-90, mxs.point3(0, 1, 0))
     angle2 = mxs.angleaxis(-90, mxs.point3(0, 0, 1))
     for obj in self.mxs_objects:
         self._rotate(obj, angle1)
         self._rotate(obj, angle2)
         self._swap_pivot_x_and_y(obj)
예제 #2
0
	def slateDraw( self ):
		# processing the text
		import re
		scene = self._scene
		text = self._slateText
		matches = re.findall( r'(\[)([F|f][R|r][A|a][M|m][E|e])( +)?(#[0-9]+)?( +)?(\])', text )
		for match in matches:
			padding = match[3]
			if padding:
				padding = int( padding.strip( '#' ) )
			else:
				padding = 1
			text = text.replace( ''.join( match ), str( scene.currentFrame() ).zfill( padding ) )

		# rendering the slate
		text = text + '  '
		viewSize = self.size()
		textSize = mxs.GetTextExtent( text )
		textWidth = int( textSize.x )
		if self.safeFrameIsActive():
			safeFrameSize = self.safeFrameSize()
			safeFrameMargins = self.safeFrameMargins()
			hMargin = safeFrameMargins[0]
			vMargin = safeFrameMargins[1]
		else:
			hMargin = 0
			vMargin = 0

		textPos = mxs.point3( viewSize[0] - textWidth - hMargin, vMargin, 0 )
		color = mxs.color( 255,255,255 )
		mxs.gw.htext( textPos, text, color=color )
		mxs.gw.enlargeUpdateRect( mxs.pyhelper.namify( 'whole' ) )
		mxs.gw.updatescreen() 
예제 #3
0
 def __init__(self, node_pairs, properties):
     BeamThing.BeamThing.__init__(self)
     MaxObjectCustAttribute.MaxObjectCustAttribute.__init__(self)
     
     self.apply_custattributes(properties)
     self.draw_lines_from_node_pairs(node_pairs)
     self.max_object.wirecolor = mxs.point3(200, 200, 200)
 def _rotate(self, object, angle):
     try:
         original_pivot = object.pivot
         object.pivot = mxs.point3(0, 0, 0)
         mxs.rotate(object, angle)
         object.pivot = original_pivot
     except:
         print "failed to rotate " + str(object)
 def _swap_pivot_x_and_y(self, object):
     try:
         original_x = object.pivot.x
         original_y = object.pivot.y
         original_z = object.pivot.z
         object.pivot = mxs.point3(original_y, original_x, original_z)
     except:
         print "failed to move pivot point for " + str(object)
def _import_submesh(index, node_positions, submesh, object_holder):
    if len(submesh.cabs) == 0:
        return
    max_positions = map(lambda node_position: node_position.to_point3(), node_positions)
    max_faces = []
    for cab in submesh.cabs:
        max_faces.append(mxs.point3(cab['node1'] + 1, cab['node2'] + 1, cab['node3'] + 1))
    mesh = mxs.mesh(vertices=max_positions, faces=max_faces)
    mesh.wirecolor = mxs.point3(55, 55, 83)
    mesh.name = "submesh_" + str(index)
    mxs.meshop.deleteisoverts(mesh)
    object_holder.add_object(mesh)
    mxs.custattributes.add(mesh, mxs.rorsubmesh)
    mesh.backmesh = submesh.backmesh
    for cab in submesh.cabs:
        if 'args' in cab:
            mesh.flag = cab['args']
            break
예제 #7
0
 def animateTurntable(self, objects=[], startFrame=0, endFrame=100):
     """
             \remarks	Animates the camera around (and properly framing) the given object(s).
             \return		N/A
     """
     if not objects:
         return
     objects = [o.nativePointer() for o in objects]
     cam = self.nativePointer()
     helper = mxs.cross3dhelper.turntableHelperBuilder(
         self.nativePointer(),
         startFrame,
         endFrame,
     )
     # Create an aggregate bounding box for all of our
     # objects so we know how "big" this stuff is, all
     # inclusive.
     from blur3d.lib import cartesian
     aggBBox = None
     for obj in objects:
         p1, p2 = mxs.nodeLocalBoundingBox(obj)
         oBBox = cartesian.BoundingBox(
             cartesian.Point.newFromMaxPoint(p1),
             cartesian.Point.newFromMaxPoint(p2),
         )
         if not aggBBox:
             aggBBox = oBBox
         else:
             aggBBox = cartesian.BoundingBox.union(
                 aggBBox,
                 oBBox,
             )
     # A bounding sphere conveniently gives us a center point.
     center, radius = aggBBox.boundingSphere()
     helper.pos = center.maxPoint()
     # Stick a target object at the center of the objects and
     # rotate it 360 degrees across our frame range, then link
     # the camera to that via a constraint.
     link = mxs.Link_Constraint()
     link.addTarget(helper, 0)
     cam.controller = link
     self.target().nativePointer().pos = center.maxPoint()
     cam.specify_fov = True
     cam.film_width = 36.0
     cam.fov = 40.0
     aspect = float(mxs.renderers.current.image_aspect)
     fovAngle = cartesian.radians(cam.fov)
     axisLength = aggBBox.length(aggBBox.maximumExtent())
     from math import sin, sqrt
     hypoLength = ((axisLength) / sin(fovAngle / 2.0))
     distance = sqrt(
         (hypoLength * hypoLength) - ((axisLength / 2.0) * (axisLength / 2.0)))
     cam.pos = (cam.pos + mxs.point3(0, -distance, 0))
예제 #8
0
 def animateTurntable(self, objects=[], startFrame=0, endFrame=100):
     """
             \remarks	Animates the camera around (and properly framing) the given object(s).
             \return		N/A
     """
     if not objects:
         return
     objects = [o.nativePointer() for o in objects]
     cam = self.nativePointer()
     helper = mxs.cross3dhelper.turntableHelperBuilder(
         self.nativePointer(),
         startFrame,
         endFrame,
     )
     # Create an aggregate bounding box for all of our
     # objects so we know how "big" this stuff is, all
     # inclusive.
     from blur3d.lib import cartesian
     aggBBox = None
     for obj in objects:
         p1, p2 = mxs.nodeLocalBoundingBox(obj)
         oBBox = cartesian.BoundingBox(
             cartesian.Point.newFromMaxPoint(p1),
             cartesian.Point.newFromMaxPoint(p2),
         )
         if not aggBBox:
             aggBBox = oBBox
         else:
             aggBBox = cartesian.BoundingBox.union(
                 aggBBox,
                 oBBox,
             )
     # A bounding sphere conveniently gives us a center point.
     center, radius = aggBBox.boundingSphere()
     helper.pos = center.maxPoint()
     # Stick a target object at the center of the objects and
     # rotate it 360 degrees across our frame range, then link
     # the camera to that via a constraint.
     link = mxs.Link_Constraint()
     link.addTarget(helper, 0)
     cam.controller = link
     self.target().nativePointer().pos = center.maxPoint()
     cam.specify_fov = True
     cam.film_width = 36.0
     cam.fov = 40.0
     aspect = float(mxs.renderers.current.image_aspect)
     fovAngle = cartesian.radians(cam.fov)
     axisLength = aggBBox.length(aggBBox.maximumExtent())
     from math import sin, sqrt
     hypoLength = ((axisLength) / sin(fovAngle / 2.0))
     distance = sqrt((hypoLength * hypoLength) - ((axisLength / 2.0) *
                                                  (axisLength / 2.0)))
     cam.pos = (cam.pos + mxs.point3(0, -distance, 0))
예제 #9
0
def setAllVerts(obj, newVerts):
    if mxs.classOf(obj) == mxs.XRefObject:
        obj = obj.actualBaseObject
    if mxs.classOf(obj) in [mxs.Editable_Poly, mxs.PolyMeshObject]:
        maxAll = mxs.execute('#all')
        maxPos = [
            mxs.point3(float(i[0]), float(i[1]), float(i[2])) for i in newVerts
        ]
        mxs.polyop.setVert(obj, maxAll, maxPos)
    else:
        for i, v in enumerate(newVerts):
            mxs.setVert(obj, i + 1, *v)
    return True
예제 #10
0
def import_fixes(node_positions, fixes, object_holder):
    for fix in fixes:
        box = Box.Box(node_positions[fix],
                name="fix",
                wirecolor=mxs.point3(62, 55, 83))
        object_holder.add_object(box.max_object)
예제 #11
0
 def to_point3(self):
     return mxs.point3(self.x, self.y, self.z)
def import_contacters(node_positions, contacters, object_holder):
    for contacter in contacters:
        box = Box.Box(node_positions[contacter],
                name="contacter",
                wirecolor=mxs.point3(62, 55, 83))
        object_holder.add_object(box.max_object)
예제 #13
0
 def _generate_node_positions(self):
     the_lambda = lambda node: lambda node: mxs.point3(node.x, node.y, node.z)
     return map(the_lambda, self.nodes)