Re: Follow Path Python constraint

投稿ツリー


このトピックの投稿一覧へ

通常 Re: Follow Path Python constraint

msg# 1.1.1.1.1.1.1
depth:
6
前の投稿 - 次の投稿 | 親投稿 - 子投稿.1 | 投稿日時 2008/1/1 2:42
tsurubaso  新米   投稿数: 17
yahooo
akeomeeeeeeeeeeeeeeeeeee
Bonne annee,
happy new year!!
akemashiteomedetogozaimasuuuu
Every things looks find but it's not working.
引用:
import Blender
from Blender import *
from Blender import Camera,Object, Scene, Ipo,Window, Curve, BezTriple, Mathutils, BezTriple, Mathutils

# script author 80% enhzflep 20% tsurubaso

#isolate the selected object
cur = Scene.getCurrent()
object = cur.objects.active

#change the position of the moved object to (0,0,0)in order to be in the center of the circle
#this is not working!
object.setLocation (0.0,0.0,0.0)


#create a new camera and set it active

c = Camera.New('ortho','Camera-Vue01')
ob = Object.New('Camera','Vue01')
ob.link(c)
cur.link(ob)
cur.setCurrentCamera(ob)
c.setLens(35.00)
c.setClipStart(0.10)
c.setClipEnd(200.00)
ob.Layer = 2

#put the active object in an empty layer
StartLayer = 1
EndLayer = 2

ObList = Blender.Object.GetSelected()

for Object in ObList:
if Object.Layer == StartLayer:
Object.Layer = EndLayer



#add a circle
cu = Curve.New() # create new curve data
scn = Scene.GetCurrent() # get current scene
obcurve = scn.objects.new(cu) # make a new curve from the curve data
obcurve.link(cu) # link curve data with this object
obcurve.Layer = 2 # put curve in layer2

center = (0,0,0)



#Here you change the radius to change the distance of the camera
radius = 4

AUTO = BezTriple.HandleTypes.AUTO
# Build four points at radius distance in the four cardnal directions
p1 = (0, -radius, 0)
p2 = (radius, 0, 0)
p3 = (0, radius, 0)
p4 = (-radius, 0, 0)

p1 = BezTriple.New(p1)
p2 = BezTriple.New(p2)
p3 = BezTriple.New(p3)
p4 = BezTriple.New(p4)

# Can't have a curve without points...
curve = cu.appendNurb(p1)
curve.append(p2)
curve.append(p3)
curve.append(p4)

# Set both handles to auto for each point
for point in curve:
point.handleTypes = [AUTO, AUTO]
curve.flagU = 1 # Set curve cyclic
cu.update()
obcurve.loc = center # Put it where it goes


#set a Track to constraint
ob.constraints.append(2)
const = ob.constraints[len(ob.constraints)-1] #last constraint in the list
const[Constraint.Settings.TARGET] = object
const.__setitem__(Constraint.Settings.TRACK, Constraint.Settings.TRACKNEGZ)
const.__setitem__(Constraint.Settings.UP, Constraint.Settings.UPY)
#add a followpath constraint
const2 = ob.constraints.append(Constraint.Type.FOLLOWPATH)
const2[Constraint.Settings.TARGET] = obcurve



Window.RedrawAll()


投票数:6 平均点:0.00

  条件検索へ


ログイン

ユーザ名:

パスワード:



パスワード紛失

クイックリンク

2021/07/01版
●Blender.org
BlenderFoundation
- Blenderのダウンロード
- 公式チュート等
- 公式マニュアル(和訳)

●ニュース(英文)
BlenderNation

●Blenderコミュニティ
blenderartists.org

●Blender Q&A
- Blender Stack Exchange

●テストビルド
Buildbot(自動生成)


●開発関連
公式開発サイト
Blender開発blog
Blender Wiki