当前位置: 首页>>代码示例>>Python>>正文


Python Vector.resize_3d方法代码示例

本文整理汇总了Python中mathutils.Vector.resize_3d方法的典型用法代码示例。如果您正苦于以下问题:Python Vector.resize_3d方法的具体用法?Python Vector.resize_3d怎么用?Python Vector.resize_3d使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mathutils.Vector的用法示例。


在下文中一共展示了Vector.resize_3d方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Ant

# 需要导入模块: from mathutils import Vector [as 别名]
# 或者: from mathutils.Vector import resize_3d [as 别名]

#.........这里部分代码省略.........
                self.return_home_timer -= 1
            
            #have we arrived (away from home)?
            if (Vector((0,-3,0)) - self.target).length > 1.5:
                if (self.worldPosition - self.target).length < 1.5:

                    if self.return_home_timer is not None and self.return_home_timer < 1:
                        self.go_back()
                    elif self.return_home_timer is None:
                        self.return_home_timer = 60 * 10
                    
        
        elif self.mode == "GOGET":
            # is there still something to collect?
            if self.collect is not None:
                # go get resource
                if (self.worldPosition - self.collect.worldPosition).length < 1.5:
                        
                    if self.collect["points"] > 0:
                        self.collect["points"] -= 1
                        
                        self.carry_type = self.collect["type"]
                        self.carry_category = self.collect["category"]
                        self.carrying = scene.addObject(self.carry_type + "fragment", self)
#                        if self.collect_type == "honey":
#                            print("replacing mesh")
#                            self.replaceMesh("Cube.001")
                    
                    # if we grabbed the last one, make resource vanish
                    if self.collect["points"] <= 0:
                
                        self.collect.parent.endObject()
                        self.collect.endObject()  
                        
                    self.go_drop()
                        
            else:
                #send him back
                #self.update_workercount(recount=True)
                self.go_get(None)
                self.go_back()
                
            
        elif self.mode == "DROP":
            # return with resource
            if (self.worldPosition - self.destination.worldPosition).length < 1.5:
                
                if self.carry_category == "food":
                    if "stored" in self.destination:
                        self.destination['stored'] += 1
                    else:
                        increase_resource(self, "food")
                else:
                    increase_resource(self, self.carry_category)
                
                if self.carrying:
                    self.carrying.endObject()
                    self.carrying = None
                
                # go back for more
                self.go_get(self.collect)
                
            
        elif self.mode == "GOBACK":
            # if resource is gone but we still are carrying some around
            if self.carrying is not None:
                self.mode = "DROP"
            
        if self.carrying is not None and not self.carrying.invalid:
            self.carrying.worldPosition = self.worldPosition                

        
        
        # other stuff        
        
        # insist upon being at ground level at all times
        obj, hitpoint, normal = self.rayCast(self.worldPosition + Vector((0,0,-1)), self.worldPosition + Vector((0,0,1)), 10, "Ground", 0, 1)
        self.worldPosition.z = hitpoint.z + self.zoffset
        self.alignAxisToVect(normal, 2)
        
        #self.accelerate()
        
        #bge.render.drawLine(self.worldPosition, self.target.to_3d(), (1, 1, 1))
        
        o = self.around_obstacles()
        t = self.towards_target()
        s = self.separate()
        w = self.wander()
        
        self.target_direction = o.to_2d() + t.to_2d() + s.to_2d()
        self.target_direction = self.target_direction + (w.to_2d() * self.target_direction.length)
        self.target_direction.resize_3d()
        self.target_direction.normalize()
        
        #bge.render.drawLine(self.worldPosition, self.worldPosition + self.target_direction*10, (1, 0, 0))
        
        self.direction = self.direction.lerp(self.target_direction, .05)
        
        self.move()
        self.eat()
开发者ID:gandalf3,项目名称:The-Queen-s-Workers,代码行数:104,代码来源:ant.py


注:本文中的mathutils.Vector.resize_3d方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。