コード例 #1
0
ファイル: geometry.py プロジェクト: Derfies/p3d
def Line(start, end, thickness=1.0):
    """Return a geom node representing a simple line."""
    # Create line segments
    ls = pm.LineSegs()
    ls.setThickness(thickness)
    ls.drawTo(pm.Point3(start))
    ls.drawTo(pm.Point3(end))

    # Return the geom node
    return ls.create()
コード例 #2
0
ファイル: geometry.py プロジェクト: Derfies/p3d
def Circle(radius=1.0,
           numSegs=16,
           axis=pm.Vec3(1, 0, 0),
           thickness=1.0,
           origin=pm.Point3(0, 0, 0)):

    # Create line segments
    ls = pm.LineSegs()
    ls.setThickness(thickness)

    # Get the points for an arc
    for p in GetPointsForArc(360, numSegs):

        # Draw the point rotated around the desired axis
        p = pm.Point3(p[0], p[1], 0) - origin
        p = RotatePoint3(p, pm.Vec3(0, 0, 1), pm.Vec3(axis))
        ls.drawTo(p * radius)

    return ls.create()
コード例 #3
0
ファイル: geometry.py プロジェクト: Derfies/p3d
def Axes(thickness=1, length=25):
    """Class representing the viewport camera axes."""
    # Build line segments
    ls = pm.LineSegs()
    ls.setThickness(thickness)

    # X Axis - Red
    ls.setColor(1.0, 0.0, 0.0, 1.0)
    ls.moveTo(0.0, 0.0, 0.0)
    ls.drawTo(length, 0.0, 0.0)

    # Y Axis - Green
    ls.setColor(0.0, 1.0, 0.0, 1.0)
    ls.moveTo(0.0, 0.0, 0.0)
    ls.drawTo(0.0, length, 0.0)

    # Z Axis - Blue
    ls.setColor(0.0, 0.0, 1.0, 1.0)
    ls.moveTo(0.0, 0.0, 0.0)
    ls.drawTo(0.0, 0.0, length)

    return ls.create()
コード例 #4
0
ファイル: geometry.py プロジェクト: Derfies/p3d
def Square(width=1,
           height=1,
           axis=pm.Vec3(1, 0, 0),
           thickness=1.0,
           origin=pm.Point3(0, 0, 0)):
    """Return a geom node representing a wire square."""
    # Create line segments
    ls = pm.LineSegs()
    ls.setThickness(thickness)

    # Get the points for a square
    points = GetPointsForSquare(width, height)
    points.append(points[0])
    for p in points:

        # Draw the point rotated around the desired axis
        p = pm.Point3(p[0], p[1], 0) - origin
        p = RotatePoint3(p, pm.Vec3(0, 0, 1), axis)
        ls.drawTo(p)

    # Return the geom node
    return ls.create()
コード例 #5
0
ファイル: geometry.py プロジェクト: Derfies/p3d
    def __init__(self,
                 radius=1.0,
                 numSegs=16,
                 degrees=360,
                 axis=pm.Vec3(1, 0, 0),
                 thickness=1.0,
                 origin=pm.Point3(0, 0, 0)):

        # Create line segments
        self.ls = pm.LineSegs()
        self.ls.setThickness(thickness)

        # Get the points for an arc
        for p in GetPointsForArc(degrees, numSegs):

            # Draw the point rotated around the desired axis
            p = pm.Point3(p[0], p[1], 0) - origin
            p = RotatePoint3(p, pm.Vec3(0, 0, 1), pm.Vec3(axis))
            self.ls.drawTo(p * radius)

        # Init the node path, wrapping the lines
        node = self.ls.create()
        pm.NodePath.__init__(self, node)