Python hou.Vector2() Examples
The following are 30
code examples of hou.Vector2().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
hou
, or try the search function
.
Example #1
Source File: createCtrlReadFile4Cache.py From Nagamochi with GNU General Public License v3.0 | 6 votes |
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() )
Example #2
Source File: BossCoreComponent.py From gamestuff with GNU Lesser General Public License v3.0 | 6 votes |
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
Example #3
Source File: AssfireComponent.py From gamestuff with GNU Lesser General Public License v3.0 | 6 votes |
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))
Example #4
Source File: BigExplosionComponent.py From gamestuff with GNU Lesser General Public License v3.0 | 6 votes |
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
Example #5
Source File: PlaneGameDirector.py From gamestuff with GNU Lesser General Public License v3.0 | 6 votes |
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
Example #6
Source File: PlaneGameDirector.py From gamestuff with GNU Lesser General Public License v3.0 | 6 votes |
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
Example #7
Source File: BaseColliderComponent.py From gamestuff with GNU Lesser General Public License v3.0 | 6 votes |
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)
Example #8
Source File: createNetworkBoxSet.py From Nagamochi with GNU General Public License v3.0 | 6 votes |
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])
Example #9
Source File: BoundingBoxComponent.py From gamestuff with GNU Lesser General Public License v3.0 | 6 votes |
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)
Example #10
Source File: BigExplosionComponent.py From gamestuff with GNU Lesser General Public License v3.0 | 5 votes |
def __init__(self,gobj): super(BigExplosionComponent,self).__init__(gobj) self.__timer=0 self.__delayTimer=0 self.__delayTime=0.02 self.__radius=1 #actually, not radius, but half square side for now self.__offset=Vector2() self.__shape=None
Example #11
Source File: ScoreComponent.py From gamestuff with GNU Lesser General Public License v3.0 | 5 votes |
def update(self): gobj=self.gameObject() if(self.__rewriteNeeded): spareshapes=[x for x in self.__shapes] self.__shapes=[] stext=str(self.__score) for x in stext: node=None if(len(spareshapes)>0): node=spareshapes.pop(0) else: node=hou.node(self.__nodelevel).createNode("null","score") node.setUserData("nodeshape","numbers"+x) self.__shapes.append(node) for shape in spareshapes: shape.destroy() self.__rewriteNeeded=False #position shapes pos=gobj.position for shape in self.__shapes: shape.setPosition(pos) pos+=hou.Vector2(0.75,0)
Example #12
Source File: StackShapesComponent.py From gamestuff with GNU Lesser General Public License v3.0 | 5 votes |
def __init__(self,gobj): super(StackShapesComponent,self).__init__(gobj) self.__shapeObjs=[] self.__offset=Vector2((0.2,0)) self.__shapeBaseName="" self.__count=0
Example #13
Source File: ExplosionComponent.py From gamestuff with GNU Lesser General Public License v3.0 | 5 votes |
def __init__(self,gobj): super(ExplosionComponent,self).__init__(gobj) self.__shape=None self.__frame=0 self.__timer=0.00 self.__vel=Vector2()
Example #14
Source File: AssfireComponent.py From gamestuff with GNU Lesser General Public License v3.0 | 5 votes |
def setFlameMode(self,mode): if(self.__gomeds is None or type(mode) is not int or mode==self.__mode or mode<0 or mode>3):return if(mode==0): self.__gomeds.gameObject().transform.localPosition=Vector2((0,-50)) self.__gohigs.gameObject().transform.localPosition=Vector2((0,-50)) elif(mode==1): self.__gomeds.gameObject().transform.localPosition=Vector2((0,0)) self.__gohigs.gameObject().transform.localPosition=Vector2((0,-50)) elif(mode==2): self.__gomeds.gameObject().transform.localPosition=Vector2((0,0)) self.__gohigs.gameObject().transform.localPosition=Vector2((0,0)) self.__mode=mode
Example #15
Source File: AssfireComponent.py From gamestuff with GNU Lesser General Public License v3.0 | 5 votes |
def onStart(self): gobj=self.gameObject() self.__shape=gobj.getComponent("ShapeComponent") if(self.__shape is None): self.__shape=gobj.addComponent("ShapeComponent") self.__shape.setBaseShape("big_boss_assfirelow") self.__shape.setAnimated(True) gm=GameObject("killzone_enemy_m") gm.transform.setParent(gobj.transform,False) gm.transform.localPosition=Vector2((0,-50)) self.__gomeds=gm.addComponent("ShapeComponent") self.__gomeds.setBaseShape("big_boss_assfiremed") self.__gomeds.setAnimated(True) gm.addComponent("BoundingBoxComponent").readjust("0","0") gh=GameObject("killzone_enemy_h") gh.transform.setParent(gobj.transform,False) gh.transform.localPosition=Vector2((0,-50)) self.__gohigs=gh.addComponent("ShapeComponent") self.__gohigs.setBaseShape("big_boss_assfirehig") self.__gohigs.setAnimated(True) gh.addComponent("BoundingBoxComponent").readjust("0","0") #self.__shapem=self.gameObject().addComponent("ShapeComponent") #self.__shapem.setBaseShape("big_boss_assfirelow") #self.__shapem.setAnimated(True) #self.__shapeh=self.gameObject().addComponent("ShapeComponent") #self.__shapeh.setBaseShape("big_boss_assfirelow") #self.__shapeh.setAnimated(True) bbx=self.gameObject().getComponent("BoundingBoxComponent") if(bbx is None): bbx=self.gameObject().addComponent("BoundingBoxComponent") bbx.readjust("0","0") (self.__bbmin,self.__bbmax)=bbx.getInitBBox()
Example #16
Source File: AssfireComponent.py From gamestuff with GNU Lesser General Public License v3.0 | 5 votes |
def __init__(self,gobj): super(AssfireComponent,self).__init__(gobj) self.__timer=0 self.__shape=None self.__gomeds=None self.__gohigs=None self.__bbmin=Vector2() self.__bbmax=Vector2() self.__mode=0 self.__ot1=0.0 self.__ot2=0.0
Example #17
Source File: PlaneBullet.py From gamestuff with GNU Lesser General Public License v3.0 | 5 votes |
def setActive(self,active): self.__active=active if(not self.__active): self.gameObject().position=Vector2(-15,0)
Example #18
Source File: BoundingBoxComponent.py From gamestuff with GNU Lesser General Public License v3.0 | 5 votes |
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
Example #19
Source File: BigExplosionComponent.py From gamestuff with GNU Lesser General Public License v3.0 | 5 votes |
def setExplosionParams(self,radius=None,offset=None): if(radius is not None): self.__radius=radius if(offset is not None): self.__offset=offset*1 #to ensure no refs. fuck this Vector2, fuck people who designed it to be mutable
Example #20
Source File: BaseColliderComponent.py From gamestuff with GNU Lesser General Public License v3.0 | 5 votes |
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()
Example #21
Source File: FirePuffComponent.py From gamestuff with GNU Lesser General Public License v3.0 | 5 votes |
def setActive(self,active): self.__active=active if(self.__active): self.__shape.setColor(self.clrs[0]) self.__frame=0 self.__timer=0.04 self.__shape.setAnimationFrame(self.__frame) else: self.gameObject().position=Vector2(-16,0)
Example #22
Source File: BossPartComponent.py From gamestuff with GNU Lesser General Public License v3.0 | 5 votes |
def __init__(self,gobj): super(BossPartComponent,self).__init__(gobj) self.__active=False self.__lives=1 self.__oldClr=None self.__shape=None self.__exradius=1 self.__excenter=Vector2()
Example #23
Source File: PlaneGameDirector.py From gamestuff with GNU Lesser General Public License v3.0 | 5 votes |
def explosion(self,pos,vel=None,**kwargs): if(vel is None):vel=Vector2() go=GameObject("explosion") go.position=pos shp=go.addComponent("ShapeComponent") shp.setBaseShape("plane_boomMain") shp.setAnimated(True) shp.setColor((0,0,0)) go.addComponent("ExplosionComponent").setVel(vel*1) return go
Example #24
Source File: PlaneGameDirector.py From gamestuff with GNU Lesser General Public License v3.0 | 5 votes |
def createBoss(self,pos): go=GameObject("enemy_BOSS") go.position=pos+Vector2(0,20) go.addComponent("BossCoreComponent") return go
Example #25
Source File: BoundingBoxComponent.py From gamestuff with GNU Lesser General Public License v3.0 | 5 votes |
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
Example #26
Source File: MoveSpinComponent.py From gamestuff with GNU Lesser General Public License v3.0 | 5 votes |
def __init__(self,gobj): super(MoveSpinComponent,self).__init__(gobj) self.__lvel=Vector2() self.__avel=0
Example #27
Source File: SnekGameDirector.py From gamestuff with GNU Lesser General Public License v3.0 | 5 votes |
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()
Example #28
Source File: SnekGameDirector.py From gamestuff with GNU Lesser General Public License v3.0 | 5 votes |
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)
Example #29
Source File: PlaneEvilSimple.py From gamestuff with GNU Lesser General Public License v3.0 | 4 votes |
def update(self): gobj=self.gameObject() if(self.__oldClr is not None): self.__shape.setColor(self.__oldClr) self.__oldClr=None if(PlaneGameDirector.instance().isOutOfGameArea(gobj.position)): gobj.destroy() return dt=self.time.deltaTime() self.__timer+=dt if(self.__shooting): if(self.__reloadTimer>0):self.__reloadTimer-=dt else: baseangle=self.__shootAngle if(baseangle==-1): pass #means we are targeting player #TODO: do if(self.__shootProjectilesCount==1): PlaneGameDirector.instance().fireBullet(gobj.position,baseangle,10,"enemy",(1,0.35,0.35)) else: angstep=2*self.__shootSpreadHalfangle/(self.__shootProjectilesCount-1) for i in range(self.__shootProjectilesCount): PlaneGameDirector.instance().fireBullet(gobj.position,baseangle-self.__shootSpreadHalfangle+i*angstep,10,"enemy",(1,0.35,0.35)) #do shoot here self.__rowCounter+=1 if(self.__rowCounter>=self.__shootRowCount): self.__reloadTimer=self.__shootReloadTime self.__rowCounter=0 else: self.__reloadTimer+=self.__shootRowDelay sid=self.__sinFreq*cos(self.__sinFreq*self.__timer + self.__sinOffset) self.__actualVel=(Vector2(self.__sinAmp*sid,0)+self.__linearVel) gobj.position+=self.__actualVel*dt self.__plane.setForce(sid)
Example #30
Source File: PlaneGameDirector.py From gamestuff with GNU Lesser General Public License v3.0 | 4 votes |
def update(self): dt=self.time.deltaTime() self.__timer+=dt if(self.__gameover): self.__score.position=Vector2(7*math.sin(self.__timer*2),0) else: if(len(self.__level)==0 and len(self.__levelinstances)==0): print("--------------------") print("--CONGRATULATIONS!--") print("--------------------") print("YOU ARE THE WINRAR!!") print("--------------------") self.__score.sendMessage("addScore",self.getPlayer().getComponent("PlanePlayerControl").lives()*500) self.__gameover=True if(self.__level is not None): while(len(self.__level)>0 and self.__level[0][0][1]<self.__timer*10): entry=self.__level.pop(0) pos=entry[0] node=entry[1] #print(node.name()) go=None if(node.name().find("plane_small")==0): go=self.createEnemySimple("plane_evil01","s",Vector2(pos[0],9.9),Vector2(node.evalParm("velx"),node.evalParm("vely")),node.evalParm("sinAmp"),node.evalParm("sinFreq"),node.evalParm("sinOffset"),destroyCallback=self.explosion) elif(node.name().find("plane_big")==0): go=self.createEnemySimple("plane_evil02","m",Vector2(pos[0],9.9),Vector2(node.evalParm("velx"),node.evalParm("vely")),node.evalParm("sinAmp"),node.evalParm("sinFreq"),node.evalParm("sinOffset"),node.evalParm("lives"),node.evalParm("shooting"),node.evalParm("shootRowCount"),node.evalParm("projectilesCount"),node.evalParm("spreadHalfangle"),node.evalParm("shootRowDelay"),node.evalParm("shootReloadTime"),node.evalParm("shootAngle"),self.bigExplosion) elif(node.name().find("plane_boss_type1")==0): go=self.createBoss(Vector2(pos[0],9.9)) if(go is not None): self.__levelinstances.append(go) if(len(self.__neds)>0): needsort=False if(random.random()<0.7*dt): self.__clouds.append(self.__genCloud(1,20,1,20,1,10)) needsort=True if(random.random()<0.35*dt): self.__clouds.append(self.__genCloud(2,4,2,4.5,1,1.25)) needsort=True if(needsort): self.__clouds.sort(key=lambda x:x[4],reverse=True) shapelist=[] removelist=[] for cloud in self.__clouds: cloud[0]+=self.__globalVel[0]*dt/cloud[4] cloud[1]+=self.__globalVel[1]*dt/cloud[4] if(cloud[1]+cloud[3]*0.5 < -10): removelist.append(cloud) else: clr=cloud[5] shapelist.append(hou.NetworkShapeBox(hou.BoundingRect(cloud[0]-cloud[2]*0.5,cloud[1]-cloud[3]*0.5,cloud[0]+cloud[2]*0.5,cloud[1]+cloud[3]*0.5),color=hou.Color((clr,clr,clr)),alpha=0.9,screen_space=False)) for item in removelist: self.__clouds.remove(item) for ne in self.__neds: ne.setShapes(shapelist) self.__playerCached=None #to update in case player was killed or shit #helper functions