def __init__(self, window): # メンバ変数の初期化 --------------------------------------------------- super(PrototypeScene, self).__init__(window) self.__sceneID = IScene.SceneID.PROTOTYPE_SCENE self.__sceneInfo = SceneInfo() self.__bestEmotion = BestEmotion() self.__window = window # シーンを扱うウィンドウを取得する self.__initFlags() # シーン終了フラグをOFFにする self.__sceneEventId = SceneEventID.SceneEventID() # シーンイベントを初期化する self.__videoCapture = VideoCapture.VideoCapture( window, self.__sceneInfo.videoType) # フレーム等の表示/非表示フラグの初期設定を行う self.__initDrawFlags() self.__faces = faces.Faces( self.__videoCapture.getCaptureImage()) # 顔リストクラスの初期化を行う self.__emotionImages = EmotionImages.EmotionImages( self.__window.getWidth(), self.__window.getHeight()) # 装飾クラスの初期化 self.__decorator = Decoration.Decoration(self.__window.getWidth(), self.__window.getHeight())
import Decoration from Map import Map import Blocks import VoxelGraphics as vg import sys file_name = sys.argv[0][::-1][3:][::-1] variables = [] materials = [] def init(): pass # ----------------------- def decorate_foundation(obj, options=Map()): # TODO: FINISH return obj # ----------------------- init() Decoration.Decoration(kind="foundation", callback=decorate_foundation, namespace=file_name, variables=variables, materials=materials)
for vec in spaced_points + spaced_points2: obj.features.append(Feature("spacing", vec)) else: spaced_points = vg.points_spaced(obj.bottom(), Map(every=3)) spaced_points = vg.extrude( spaced_points, Map(spacing=V3(0, math.ceil(obj.height / 2), 0))) for vec in spaced_points: obj.features.append(Feature("window", vec, options=options.options)) mid_points = vg.middle_of_line(obj.bottom(), Map(center=True, max_width=2, point_per=10)) for vec in mid_points: obj.features.append( Feature( "door", vec, Map(cardinality=obj.cardinality, door_inside=options.options.door_inside))) return obj # ----------------------- init() Decoration.Decoration(kind="wall", callback=decorate_wall, namespace=file_name, variables=variables, materials=materials)
def __init__(self, name, weight) : Decoration.__init__(self) self.Name = name self.Weight = weight
def __init__(self, val1, val2) : Decoration.__init__(self) self.Value1 = val1 self.Value2 = val2
import mcpi.block as block import VoxelGraphics as vg from V3 import V3 from Feature import Feature import sys file_name = sys.argv[0][::-1][3:][::-1] variables = [] materials = [] # ----------------------- def decorate_castle_wall_tower(obj, options): height = options.options.roof_battlement_height or 1 spacing = options.options.roof_battlement_space or 2 # TODO: Add in battlements, wood roof, stairway, torches points = vg.cylinder(options.center, radius=3, height=obj.height or 10) obj.points.extend(points) return obj # ----------------------- Decoration.Decoration(kind="castle_wall_tower", callback=decorate_castle_wall_tower, namespace=file_name, variables=variables, materials=materials)
if settings.roof_shape_object == "cylinder": func = vg.cylinder height = min_radius * (settings.roof_shape_height_multiplier or 1) elif settings.roof_shape_object == "cone": func = vg.cone height = min_radius * (settings.roof_shape_height_multiplier or 1) elif settings.roof_shape_object == "box": func = vg.box height = min_radius * (settings.roof_shape_height_multiplier or 1) else: # sphere func = vg.oblate_sphere height = None if settings.roof_shape_floating: pos = vg.up(boundaries.center, min_radius) sides = func(pos, min_radius, tight=settings.roof_shape_tight, height=height, options=Map(min_y_pct=.5, x_radius=boundaries.x_radius, z_radius=boundaries.z_radius)) roof_lists = list() roof_lists.append(Map(blocks=sides, material=material)) obj.features.append(Feature("roof", boundaries.center, Map(block_lists=roof_lists))) obj.points_edges = [] return obj # ----------------------- init() Decoration.Decoration(kind="roof_floating_shape", callback=decorate_roof_shape, namespace=file_name, variables=variables, materials=materials)
def __init__(self) : ShowBase.__init__(self) #--------------------- MUSIC mySound = base.loader.loadSfx(musicPath + "mus_reunited.ogg") mySound.play() #--------------------- WORLD self.world = BulletWorld() self.world.setGravity(Vec3(0, 0, -9.81)) ## --------------------- DEBUG # debugNode = BulletDebugNode('Debug') # debugNode.showWireframe(True) # debugNode.showConstraints(True) # debugNode.showBoundingBoxes(False) # debugNode.showNormals(False) # debugNP = render.attachNewNode(debugNode) # debugNP.show() # # debugNode.showWireframe(True) # self.world.setDebugNode(debugNP.node()) #--------------------- GRASS shape = BulletPlaneShape(Vec3(0, 0, 1), 0) # creo la forma geometrica (normale, distanza) node = BulletRigidBodyNode('Ground') # creo il rigidbody per il terreno node.addShape(shape) # link tra il rigidbody e la forma geometrica np = render.attachNewNode(node) np.setPos(0, 0, -0.5) #-1.5 cm = CardMaker('card') # crea una carta bianca a cui appiccicare la texture cm.setFrame(-20, 20, -20, 20) grass = self.render.attachNewNode(cm.generate()) # attacca il nodo FLOOR pattern = self.loader.loadTexture(imagePath + 'grass3.jpg') # handler per la texture ts = TextureStage('ts') grass.setP(270) grass.setTexScale(ts, 3, 3) grass.setTexture(ts, pattern) # appiccica la texture al modello grass.reparentTo(np) # collega la texture dell'erba al nodo fisico self.world.attachRigidBody(node) # solo i nodi attaccati al world vengono considerati nella simulazione #--------------------- CRASH (MY MODEL) self.actor = Actor("models/MyCrash1/MyCrash1.egg", {"walk":"./models/MyCrash1/CrashWalk.egg","launch":"./models/MyCrash1/CrashLaunch.egg"}) self.actor.reparentTo(np) # reparent the model to render self.actor.setScale(1, 1, 1) # apply scale to model self.actor.setPos(3, -10, 0) # apply position to model #--------------------- CAMERA base.cam.setPos(self.actor.getX(), self.actor.getY() - 18, self.actor.getZ() + 4) base.cam.lookAt(self.actor.getX(), self.actor.getY(), self.actor.getZ() + 2) #--------------------- TABLE shape = BulletBoxShape(Vec3(4.8, 1.45, 0.15)) node = BulletRigidBodyNode('Box') node.addShape(shape) np = render.attachNewNode(node) np.setPos(5, 3, 0.8 - 0.5) self.table = Object(self, "CafeTableLong/CafeTableLong", 0.01, 0.01, 0.01, 0, 0, 0, 0, 0, -0.15, np) self.world.attachRigidBody(node) #--------------------- ARMCHAIR shape = BulletBoxShape(Vec3(1.35, 1.5, 2)) #2 node = BulletRigidBodyNode('Box') node.addShape(shape) node.setMass(5) np = render.attachNewNode(node) np.setPos(12, 3, 1.5) self.chair = Object(self, "ArmChair/ArmChair", 0.0013, 0.0013, 0.0013, 100, 0, 0, 0, 0, -1.5, np) self.world.attachRigidBody(node) #--------------------- OBJECTS TO HIT # cake shape = BulletCylinderShape(0.56, 0.5, 2) node = BulletRigidBodyNode('Cylinder') node.setMass(2) node.addShape(shape) np = render.attachNewNode(node) np.setPos(5, 3, 0.62) self.cake = Object(self, "Cake/Cake", 0.008, 0.008, 0.009, 0, 0, 0, 0, 0, -0.25, np) self.world.attachRigidBody(node) #teapot shape = BulletBoxShape(Vec3(0.65, 0.3, 0.8)) # creo la forma geometrica (normale, distanza) node = BulletRigidBodyNode('Box') # creo il rigidbody per il terreno node.setMass(2) node.addShape(shape) # link tra il rigidbody e la forma geometrica np = render.attachNewNode(node) np.setPos(3, 3, 1.2) self.tea = Object(self, "Teapot/Teapot", 1, 1, 1, 90, 0, 0, 0, 0, -0.83, np) self.world.attachRigidBody(node) #mug shape = BulletCylinderShape(0.2, 0.5, 2) node = BulletRigidBodyNode('Cylinder') node.setMass(2) node.addShape(shape) np = render.attachNewNode(node) np.setPos(6, 3, 1.2 - 0.54) self.mug = Object(self, "cup/cup", 0.02, 0.02, 0.02, 0, 0, 0, 0, 0.2, -0.1, np) self.world.attachRigidBody(node) #creamer shape = BulletBoxShape(Vec3(0.5, 0.3, 0.5)) node = BulletRigidBodyNode('Box') node.setMass(2) node.addShape(shape) np = render.attachNewNode(node) np.setPos(8, 3.2, 1.1 - 0.2) self.creamer = Object(self, "creamer/creamer", 1, 1, 1, -90, 0, 0, 0.1, 0, -0.5, np) self.world.attachRigidBody(node) #mint shape = BulletCylinderShape(0.25, 0.2, 2) node = BulletRigidBodyNode('Cylinder') node.setMass(1) node.addShape(shape) np = render.attachNewNode(node) np.setPos(1.8, 3.2, 1.2 - 0.65) self.mint = Object(self, "Mint/Mint", 3, 3, 3, 0, 0, 0, 0, 0, 0, np) self.world.attachRigidBody(node) #--------------------- TASK and FUNCTIONS Decoration(self) self.lightUp() HandleArrows(self, 8, 12, -8, -31) Shoot(self) HandleCharacter(self, 8, 12, -8, -31) taskMgr.add(self.update, 'update')
# ----------------------- def decorate_moat(obj, options=Map()): # TODO: FINISH moat_type = options.options.moat or "clear" radius = options.moat_width or 2 height = -1 * abs(options.moat_depth or (radius + 2)) obj.material_clear = Blocks.GRASS points = [] for i, vec in enumerate(obj.vertices): next_vec = obj.vertices[(i + 1) % len(obj.vertices)] p1, p2 = vg.move_points_together(vec, next_vec, -radius) points.extend(vg.triangular_prism(p1, p2, height=height, radius=radius, sloped=True)) obj.points = points obj.points_edges = [] obj.material = Blocks.STILLWATER # if moat_type=="ice": return obj # ----------------------- init() Decoration.Decoration(kind="moat", callback=decorate_moat, namespace=file_name, variables=variables, materials=materials)
def build_basic_shape(obj, options): vertices = options.vertices if type(vertices) is not list: raise ValueError( "Expected list of points passed in, even though only 1st will be used" ) # TODO: These are being built at center obj.center = options.center = p1 = vertices[0] obj.height = h = options.height or 8 obj.points = [] obj.points_edges = [] # TODO: Use bottom and top circles for edges? obj.vertices = [p1, p1, vg.up(p1, h), vg.up(p1, h)] # points straight up obj.inside_vector = vg.inside_vector(p1=p1, center=options.center) obj.outside_vector = obj.inside_vector * -1 return obj # ----------------------- init() Decoration.Decoration(kind="standing line", callback=build_basic_shape, namespace=file_name, variables=variables, materials=materials)
radius=radius, chop_pct=chop_pct, sloped=settings.roof_triangular_sloped, material=obj.material, endpoint_out=settings.roof_triangular_end_cap_out) obj.features.append(Feature("roof", p1, Map(block_lists=roof_lists))) else: # Nothing fancy, color each block all the same type roof = vg.triangular_prism(p1, p2, height=height, radius=radius, chop_pct=chop_pct, sloped=settings.roof_triangular_sloped) obj.points.update(roof) obj.points_edges = [] return obj # ----------------------- init() Decoration.Decoration(kind="roof_triangular", callback=decorate_roof_triangular, namespace=file_name, variables=variables, materials=materials)
def colorize(obj, options): # TODO: Move to a materials manager for overall color schemes r = options.options.color_scheme if not options.options.material: if r == "gold_white": obj.material = Blocks.WHITEWOOL obj.material_edges = Blocks.GOLDBLOCK elif r == "grey_iron": obj.material = Blocks.STONEBRICK obj.material_edges = Blocks.IRONBLOCK elif r == "grey_stone": obj.material = Blocks.DOUBLESTONESLAB obj.material_edges = Blocks.IRONBLOCK elif r == "blue_white": obj.material = Blocks.WHITEWOOL obj.material_edges = Blocks.LAPISLAZULIBLOCK elif r == "brown": obj.material = Blocks.SAND obj.material_edges = Blocks.SANDSTONE return obj init() Decoration.Decoration(kind="colorize", callback=colorize, namespace=file_name, variables=variables, materials=materials)
# ----------------------- def init(): pass def build_basic_shape(obj, options): vertices = options.vertices # It's a non-y-rectangular-shaped polygon, so use a different getFace builder function obj.height = options.height or (vg.highest(vertices) - vg.lowest(vertices) + 1) obj.cardinality = options.cardinality obj.points = vg.unique_points(vg.getFace(obj.vertices)) null, obj.top_line, obj.bottom_line, obj.left_line, obj.right_line = vg.poly_point_edges(obj.points) obj.points_edges = obj.top_line + obj.bottom_line + obj.left_line + obj.right_line if options.vertices[0].y > options.center.y: obj.material_clear = Blocks.AIR else: obj.material_clear = Blocks.GRASS return obj # ----------------------- init() Decoration.Decoration(kind="flat rectangle", callback=build_basic_shape, namespace=file_name, variables=variables, materials=materials)
trees.append(b) colors = Blocks.kind("Sapling") np.random.shuffle(colors) obj.features.append(Feature("flowers", trees, Map(material=colors[0]))) elif options.options.outside == "grass": trees = [] for i, b in enumerate(border): if (i % 3) == 0: trees.append(b) obj.features.append( Feature("flowers", trees, Map(material=Blocks.DOUBLETALLGRASS))) elif options.options.outside == "fence": fence_type = np.random.random_integers(188, 192) obj.features.append(Feature("fence", border, Map(material=fence_type))) return obj # ----------------------- init() Decoration.Decoration(kind="garden", callback=decorate_outside, namespace=file_name, variables=variables, materials=materials)