コード例 #1
0
ファイル: prims.py プロジェクト: b2rex/b2rex
    def generate(self, context):
        obj = self._parent.getSelected()[0]
        props = obj.data.opensim.prim
        sides = props.sides
        profileStart = props.profile[0]
        profileEnd = props.profile[1]
        hollow = props.hollow
        hollowSides = props.hollowSides

        p = PrimMesh(sides, profileStart, profileEnd, hollow, hollowSides)
        for prop in [ 'topShear',
                      'holeSize',
                     'taper']:
            setattr(p, "_"+prop+"X", getattr(props, prop)[0])
            setattr(p, "_"+prop+"Y", getattr(props, prop)[1])

        for prop in [ 'pathCut',
                     'twist']:
            setattr(p, "_"+prop+"Begin", getattr(props, prop)[0])
            setattr(p, "_"+prop+"End", getattr(props, prop)[1])

        for prop in ['skew',
                     # 'dimpleBegin',
                     # 'dimpleEnd',
                        'revolutions',
                        'stepsPerRevolution']:
            setattr(p, "_"+prop, getattr(props, prop))


        p._viewerMode = True
        p._radius = props.radius

        if props.extrapolationType == 'LINEAR':
            p.Extrude(PathType.Linear)
        elif props.extrapolationType == 'FLEXIBLE':
            p.Extrude(PathType.Flexible)
        else:
            p.Extrude(PathType.Circular)
        print(p.ParamsToDisplayString())

        for obj in self._parent.getSelected():
            obj.data.name = "tobdeleted"
            obj.data = self.apply_prim(p, obj.data)
コード例 #2
0
    def generate(self, context):
        obj = self._parent.getSelected()[0]
        props = obj.data.opensim.prim
        sides = props.sides
        profileStart = props.profile[0]
        profileEnd = props.profile[1]
        hollow = props.hollow
        hollowSides = props.hollowSides

        p = PrimMesh(sides, profileStart, profileEnd, hollow, hollowSides)
        for prop in ['topShear', 'holeSize', 'taper']:
            setattr(p, "_" + prop + "X", getattr(props, prop)[0])
            setattr(p, "_" + prop + "Y", getattr(props, prop)[1])

        for prop in ['pathCut', 'twist']:
            setattr(p, "_" + prop + "Begin", getattr(props, prop)[0])
            setattr(p, "_" + prop + "End", getattr(props, prop)[1])

        for prop in [
                'skew',
                # 'dimpleBegin',
                # 'dimpleEnd',
                'revolutions',
                'stepsPerRevolution'
        ]:
            setattr(p, "_" + prop, getattr(props, prop))

        p._viewerMode = True
        p._radius = props.radius

        if props.extrapolationType == 'LINEAR':
            p.Extrude(PathType.Linear)
        elif props.extrapolationType == 'FLEXIBLE':
            p.Extrude(PathType.Flexible)
        else:
            p.Extrude(PathType.Circular)
        print(p.ParamsToDisplayString())

        for obj in self._parent.getSelected():
            obj.data.name = "tobdeleted"
            obj.data = self.apply_prim(p, obj.data)
コード例 #3
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
コード例 #4
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