コード例 #1
0
ファイル: prims.py プロジェクト: b2rex/b2rex
    def create(self, objId, pars):
        editor = self._parent
        if 'Name' in pars:
            name = pars['Name']
        else:
            name = 'prim'
        mesh = bpy.data.meshes.new(name)
        sides = 5
        hollowSides = 5

        profileCurve = pars['ProfileCurve']
        profileShape = profileCurve & 0x0f
        hollowShape = profileCurve & 0xf0

        if profileShape == ProfileShape.Circle:
            sides = 10
        elif profileShape == ProfileShape.Square:
            sides = 4
        elif profileShape == ProfileShape.IsometricTriangle:
            sides = 3
        elif profileShape == ProfileShape.EquilateralTriangle:
            sides = 3
        elif profileShape == ProfileShape.RightTriangle:
            sides = 3
        elif profileShape == ProfileShape.HalfCircle:
            sides = 10

        if hollowShape == HollowShape.Same:
            hollowSides = sides
        elif hollowShape == HollowShape.Circle:
            hollowSides = 10
        elif hollowShape == HollowShape.Square:
            hollowSides = 4
        elif hollowShape == HollowShape.Triangle:
            hollowSides = 3


        profileStart = pars['ProfileBegin']
        profileEnd = pars['ProfileEnd']
        hollow = pars['ProfileHollow']

        p = PrimMesh(sides, profileStart, profileEnd, hollow, hollowSides)
        if profileShape in [ProfileShape.RightTriangle, ProfileShape.HalfCircle]:
            p._pathCutBegin = 0.0
            p._pathCutEnd = 0.5
        else:
            p._pathCutBegin = pars['PathBegin']
            p._pathCutEnd = pars['PathEnd']
        p._twistBegin = pars['PathTwistBegin']
        p._twistEnd = pars['PathTwist']
        p._topShearX = pars['PathShearX']
        p._topShearY = pars['PathShearY']
        p._holeSizeX = pars['PathScaleX']
        p._holeSizeY = pars['PathScaleY']
        p._radius = pars['PathRadiusOffset']
        p._taperX = pars['PathTaperX']
        p._taperY = pars['PathTaperY']
        p._revolutions = pars['PathRevolutions']
        p._skew = pars['PathSkew']
        p._viewerMode = True

        if pars['PathCurve'] == Extrusion.Straight:
            p.Extrude(PathType.Linear)
        elif pars['PathCurve'] in [Extrusion.Curve1, Extrusion.Curve2]:
            p.Extrude(PathType.Circular)
        elif pars['PathCurve'] == Extrusion.Flexible:
            p.Extrude(PathType.Flexible)
        else:
            print("Unknown Path Type!!", pars['PathCurve'])
            return

        mesh = self.apply_prim(p)

        obj = editor.Object.createObjectWithMesh(mesh, objId, objId)

        return obj
コード例 #2
0
    def create(self, objId, pars):
        editor = self._parent
        if 'Name' in pars:
            name = pars['Name']
        else:
            name = 'prim'
        mesh = bpy.data.meshes.new(name)
        sides = 5
        hollowSides = 5

        profileCurve = pars['ProfileCurve']
        profileShape = profileCurve & 0x0f
        hollowShape = profileCurve & 0xf0

        if profileShape == ProfileShape.Circle:
            sides = 10
        elif profileShape == ProfileShape.Square:
            sides = 4
        elif profileShape == ProfileShape.IsometricTriangle:
            sides = 3
        elif profileShape == ProfileShape.EquilateralTriangle:
            sides = 3
        elif profileShape == ProfileShape.RightTriangle:
            sides = 3
        elif profileShape == ProfileShape.HalfCircle:
            sides = 10

        if hollowShape == HollowShape.Same:
            hollowSides = sides
        elif hollowShape == HollowShape.Circle:
            hollowSides = 10
        elif hollowShape == HollowShape.Square:
            hollowSides = 4
        elif hollowShape == HollowShape.Triangle:
            hollowSides = 3

        profileStart = pars['ProfileBegin']
        profileEnd = pars['ProfileEnd']
        hollow = pars['ProfileHollow']

        p = PrimMesh(sides, profileStart, profileEnd, hollow, hollowSides)
        if profileShape in [
                ProfileShape.RightTriangle, ProfileShape.HalfCircle
        ]:
            p._pathCutBegin = 0.0
            p._pathCutEnd = 0.5
        else:
            p._pathCutBegin = pars['PathBegin']
            p._pathCutEnd = pars['PathEnd']
        p._twistBegin = pars['PathTwistBegin']
        p._twistEnd = pars['PathTwist']
        p._topShearX = pars['PathShearX']
        p._topShearY = pars['PathShearY']
        p._holeSizeX = pars['PathScaleX']
        p._holeSizeY = pars['PathScaleY']
        p._radius = pars['PathRadiusOffset']
        p._taperX = pars['PathTaperX']
        p._taperY = pars['PathTaperY']
        p._revolutions = pars['PathRevolutions']
        p._skew = pars['PathSkew']
        p._viewerMode = True

        if pars['PathCurve'] == Extrusion.Straight:
            p.Extrude(PathType.Linear)
        elif pars['PathCurve'] in [Extrusion.Curve1, Extrusion.Curve2]:
            p.Extrude(PathType.Circular)
        elif pars['PathCurve'] == Extrusion.Flexible:
            p.Extrude(PathType.Flexible)
        else:
            print("Unknown Path Type!!", pars['PathCurve'])
            return

        mesh = self.apply_prim(p)

        obj = editor.Object.createObjectWithMesh(mesh, objId, objId)

        return obj