本文整理汇总了Python中hou.Vector2方法的典型用法代码示例。如果您正苦于以下问题:Python hou.Vector2方法的具体用法?Python hou.Vector2怎么用?Python hou.Vector2使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类hou
的用法示例。
在下文中一共展示了hou.Vector2方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
# 需要导入模块: import hou [as 别名]
# 或者: from hou import Vector2 [as 别名]
def run():
netBoxLists = {
#-name-:[ ---Position---- , -----Size------ , -----------Color------------,]
'Camera':[hou.Vector2(5,-0), hou.Vector2(20,2),hou.Color((0.10, 0.10, 0.10)),],
'Light':[hou.Vector2(5,-3), hou.Vector2(20,2),hou.Color((1.00, 0.98, 0.67)),],
'Import-Stage':[hou.Vector2(5,-7), hou.Vector2(20,3),hou.Color((0.62, 0.87, 0.77)),],
'Import-Chr':[hou.Vector2(5,-12),hou.Vector2(20,4),hou.Color((0.62, 0.77, 0.87)),],
'Import-Prop':[hou.Vector2(5,-16),hou.Vector2(20,3),hou.Color((0.77, 0.77, 0.87)),],
'Work':[hou.Vector2(5,-21),hou.Vector2(20,4),hou.Color((0.56, 0.10, 0.10)),],
'Shader':[hou.Vector2(5,-24),hou.Vector2(20,2),hou.Color((0.99, 0.65, 0.65)),],
'Render':[hou.Vector2(5,-31),hou.Vector2(20,6),hou.Color((0.57, 0.49, 0.86)),],
}
obj = hou.node('/obj')
for nName,nAttr in netBoxLists.items():
box = obj.createNetworkBox()
box.setComment(nName)
box.setName('nm_{}'.format(nName))
box.setPosition(nAttr[0])
box.setColor(nAttr[2])
box.setSize(nAttr[1])
示例2: run
# 需要导入模块: import hou [as 别名]
# 或者: from hou import Vector2 [as 别名]
def run(n,choice):
n_pos = n.position()
n_outs = n.outputs()
pos = n_pos - hou.Vector2(0,1)
if choice==0:
nn = createTimeBlend(n)
else:
nn = createSwitchOff(n)
nn.setPosition( pos )
nn.setInput( 0,n )
if len(n_outs)>0:
for n_out in n_outs:
from_n = n_out.inputs().index(n)
n_out.setInput( from_n,nn )
print "[Nagamochi][Python][createCtrlReadFile4Cache] Create '%s' under '%s'." % ( nn.name(),n.name() )
示例3: offsetBbox
# 需要导入模块: import hou [as 别名]
# 或者: from hou import Vector2 [as 别名]
def offsetBbox(self,offsetmin,offsetmax=None):
if(isinstance(offsetmin,int) or isinstance(offsetmin,float)):offsetmin=hou.Vector2((offsetmin,offsetmin))
if(offsetmax is None):offsetmax=offsetmin
else:
if(isinstance(offsetmax,int) or isinstance(offsetmax,float)):offsetmax=hou.Vector2((offsetmax,offsetmax))
size=self.__bbmax-self.__bbmin
#the following restrictions are not covering cases of offset shifting beyond center! (legacy code)
offsetmin[0]=min(size[0]*0.5 -0.000001,offsetmin[0]) #arbitrary tolerance
offsetmin[1]=min(size[1]*0.5 -0.000001,offsetmin[1]) #arbitrary tolerance
offsetmax[0]=min(size[0]*0.5 -0.000001,offsetmax[0]) #arbitrary tolerance
offsetmax[1]=min(size[1]*0.5 -0.000001,offsetmax[1]) #arbitrary tolerance
#offset=min(size[0]*0.5 -0.000001,size[1]*0.5 -0.000001,offset)
self.__bbmin+=offsetmin
self.__bbmax-=offsetmax
self._radius2=max(self.__bbmin.lengthSquared(),self.__bbmax.lengthSquared())
self._radius=sqrt(self._radius2)
示例4: __crosscheck
# 需要导入模块: import hou [as 别名]
# 或者: from hou import Vector2 [as 别名]
def __crosscheck(self,pts,opts):
'''
helper function
returns (isNonintersecting? , axis of separation)
'''
pp=pts[-1]
good=False
axis=hou.Vector2()
for p in pts:
v=p-pp
good=True
for op in opts:
if(self.cross2d(v,op-pp)>0):
good=False
break
if(good):
axis=v
break
pp=p
return (good,axis)
示例5: __init__
# 需要导入模块: import hou [as 别名]
# 或者: from hou import Vector2 [as 别名]
def __init__(self,gobj):
super(PlaneGameDirector,self).__init__(gobj)
self.__globalVel=Vector2()
self.__level=None
self.__timer=0
self._bulletcache=[]
self._firepuffcache=[]
if(PlaneGameDirector.__instance is not None):raise Exception("TOO MANY DIRECTORS!!")
PlaneGameDirector.__instance=self
self.__clouds=[] #(px,py,sx,sy,depth)
self.__neds=[]
self.__playerCached=None
self.__score=None
self.__playerlives=None
self.__levelinstances=[]
self.__gameover=False
示例6: firePuff
# 需要导入模块: import hou [as 别名]
# 或者: from hou import Vector2 [as 别名]
def firePuff(self,pos,angle,vel=None,fwdShift=0,animSpeed=1):
if(vel is None):vel=Vector2()
if(len(self._firepuffcache)==0):
go=GameObject("puff")
go.angle=angle
go.position=pos+go.fwd()*fwdShift
shp=go.addComponent("ShapeComponent")
shp.setBaseShape("plane_boomWhisp")
shp.setAnimated(True)
fpf=go.addComponent("FirePuffComponent")
fpf.setVel(vel*1)
fpf.setAnimSpeed(animSpeed)
return go
else:
cp=self._firepuffcache.pop(0)
cpgo=cp.gameObject()
cpgo.angle=angle
cpgo.position=pos+cpgo.fwd()*fwdShift
cp.setActive(True)
if(random.random()<0.1):
cp.shapeShortcut().recreateHouNode()
cp.setVel(vel)
cp.setAnimSpeed(animSpeed)
return cpgo
示例7: update
# 需要导入模块: import hou [as 别名]
# 或者: from hou import Vector2 [as 别名]
def update(self):
if(self.__timer<=0):
self.gameObject().destroy()
return
if(self.__shape is not None):
self.__flipclr=not self.__flipclr
if(self.__flipclr):
self.gameObject().position+=Vector2(0.05,0)
self.__shape.setColor((1,1,1))
else:
self.gameObject().position-=Vector2(0.05,0)
self.__shape.setColor((0,0,0))
dt=self.time.deltaTime()
self.__timer-=dt
if(self.__delayTimer<=0):
gobj=self.gameObject()
for i in range(2):
pos=gobj.position+self.__offset+Vector2(random.uniform(-self.__radius,self.__radius),random.uniform(-self.__radius,self.__radius))
PlaneGameDirector.instance().explosion(pos)
self.__delayTimer=self.__delayTime
else:
self.__delayTimer-=dt
示例8: update
# 需要导入模块: import hou [as 别名]
# 或者: from hou import Vector2 [as 别名]
def update(self):
gobj=self.gameObject()
dt=self.time.deltaTime()
self.__timer+=dt
af=round(self.__timer/0.04)%6
self.__shape.setAnimationFrame(af)
self.__gomeds.setAnimationFrame(af)
self.__gohigs.setAnimationFrame(af)
t=self.time.time()*2
self.__shape.setColor(self.__getColor(t))
self.__gomeds.setColor(self.__getColor(self.__ot1,-0.2))
self.__gohigs.setColor(self.__getColor(self.__ot2,-0.4))
self.__ot2=self.__ot1
self.__ot1=t
for i in range(2):
pos=Vector2((random.uniform(self.__bbmin[0],self.__bbmax[0]),random.uniform(self.__bbmin[1],self.__bbmax[1]))) + gobj.position
PlaneGameDirector.instance().firePuff(pos,random.uniform(0,360))
示例9: __init__
# 需要导入模块: import hou [as 别名]
# 或者: from hou import Vector2 [as 别名]
def __init__(self,gobj):
super(BossCoreComponent,self).__init__(gobj)
self.__parts={}
self.__state="goto"
self.__nextState="stage1"
self.__targetpos=Vector2((0,15))
self.__assfire=None
self.__stage1_timer=0
self.__stage1_c=0
self.__stage2_timer=0
self.__stage2_spawntimer=0
self.__stage2_c=0
self.__stage3_timer=0
self.__stage3_c=0
self.__stage3_speed=0
self.__stage3_timer=0
示例10: __init__
# 需要导入模块: import hou [as 别名]
# 或者: from hou import Vector2 [as 别名]
def __init__(self,gobj):
super(BoundingBoxComponent,self).__init__(gobj)
self.__bbmin=hou.Vector2()
self.__bbmax=hou.Vector2()
self.__chc_pos=hou.Vector2()
self.__chc_ang=0
self.__chc_chg=True
try:
self.readjust() #Shape component must be added before this
except Exception:
pass
示例11: getConvexHull
# 需要导入模块: import hou [as 别名]
# 或者: from hou import Vector2 [as 别名]
def getConvexHull(self):
'''
calculates and returns convex hull points for boxes
it also tries to cache this shit
returns mutable lists - plz dont fuck with them
'''
gobj=self.gameObject()
if(not self.__chc_chg and self.__chc_pos==gobj.position and self.__chc_ang==gobj.angle):
return self.__chc_pts
pts=[hou.Vector2(self.__bbmin[0],self.__bbmin[1]),hou.Vector2(self.__bbmax[0],self.__bbmin[1]),hou.Vector2(self.__bbmax[0],self.__bbmax[1]),hou.Vector2(self.__bbmin[0],self.__bbmax[1])]
rad=radians(gobj.angle)
co=cos(rad)
si=sin(rad)
for pt in pts:
x=pt[0]*co-pt[1]*si
y=pt[0]*si+pt[1]*co
pt[0]=x+gobj.position[0]+self._pivot[0] #TODO: if object is parented - figure out shit
pt[1]=y+gobj.position[1]+self._pivot[1] #Looks like if shape was rotated not around 0,0 it's not valid for parenting at all !
self.__chc_ang=gobj.angle
self.__chc_pos=gobj.position
self.__chc_chg=False
self.__chc_pts=pts
#print(self.__chc_pts)
return self.__chc_pts
示例12: __init__
# 需要导入模块: import hou [as 别名]
# 或者: from hou import Vector2 [as 别名]
def __init__(self,gobj):
super(BaseColliderComponent,self).__init__(gobj)
#warning: these radiuses are super important and it's your responsibility to set them in children classes
self._radius=99999
self._radius2=99999
self._pivot=hou.Vector2()
示例13: spawnFood
# 需要导入模块: import hou [as 别名]
# 或者: from hou import Vector2 [as 别名]
def spawnFood(self,pos):
food=gameobject.GameObject("food")
food.position=pos
food.addComponent("ShapeComponent").setBaseShape("snek_food")
food.addComponent("SnekFoodComponent")
food.addComponent("BoundingBoxComponent")
food.addComponent("MoveSpinComponent").setVel(Vector2(),450)
示例14: update
# 需要导入模块: import hou [as 别名]
# 或者: from hou import Vector2 [as 别名]
def update(self):
if(self.__gameover):
self.__deathtimer+=self.time.deltaTime()
self.__scoreobject.position=Vector2(7*math.sin(self.__deathtimer*2),0)
return
timepassed=self.time.time()-self.__lastfoodspawntime
if(SnekFoodComponent.totalFoodCount()==0 or random.random()<timepassed*0.001):
self.spawnFood(Vector2(9.0*2*(random.random()-0.5),9.0*2*(random.random()-0.5)))
self.__lastfoodspawntime=self.time.time()
示例15: __init__
# 需要导入模块: import hou [as 别名]
# 或者: from hou import Vector2 [as 别名]
def __init__(self,gobj):
super(MoveSpinComponent,self).__init__(gobj)
self.__lvel=Vector2()
self.__avel=0