Beispiel #1
0
    def __initialize(self):
        # Load data from json file
        with open(self.filePath) as f:
            data = json.load(f)

        # Create background object
        self.position = data['position']
        self.scale = data['scale']
        self.background = pyxie.figure(data['background']['path'])
        self.background.position = vmath.vec3(self.position)
        self.background.scale = vmath.vec3(self.scale)
        self.showcase.add(self.background)

        # Spawn all objects inside this cell
        if len(data['objects']) > 0:
            for obj in data['objects']:
                actual_obj = self.__spawnDependOnObjectType(obj)
                if actual_obj is not None:
                    self.objects.append(actual_obj)

        # Create col box for background for check, will delete this part later
        col_scale = [self.scale[0] / 2, self.scale[1] / 2, self.scale[2] / 2]
        colId = p.createCollisionShape(p.GEOM_BOX, halfExtents=col_scale)
        p.createMultiBody(baseMass=0,
                          baseCollisionShapeIndex=colId,
                          basePosition=self.position)
Beispiel #2
0
	def __init__(self, pos, scale, base_rotate, modelPath, cam, col_scale, col_local_pos = [0,0,0], camfollow = False):
		# Create model to display on pyxie
		self.model = pyxie.figure(modelPath)
		self.model.position = pos
		self.model.scale = scale
		self.base_rotate = base_rotate
		self.model.rotation = vmath.quat(self.base_rotate)
		self.currentState = STATUS_STAY
		self.model.connectAnimator(pyxie.ANIMETION_SLOT_A0, STATE_MOTION[self.currentState])
		# Create collider box to simulate physics on bullet physics
		self.colId = 0
		self.col_scale = col_scale
		self.col_local_pos = col_local_pos
		self.lastContactId = -1

		# Create box collider		
		self.camFollow = camfollow

		self.__createColBox(10)
		self.tapped = False

		# Should this player have camera follow behind?
		if self.camFollow:
			self.cam = cam
			self.camDis = [0.0, -3.0, 1]
Beispiel #3
0
    def __init__(self,
                 pos,
                 scale,
                 modelPath,
                 col_radius,
                 col_height,
                 col_local_pos=[0, 0, 0],
                 base_quaternion=[0, 0, 0, 1],
                 isStatic=False,
                 isIteractable=False):
        # Create model to display on pyxie
        self.model = pyxie.figure(modelPath)
        self.model.position = pos
        self.model.scale = scale
        self.base_rotate = base_quaternion
        self.model.rotation = vmath.quat(self.base_rotate)

        # Create collider to simulate physics on bullet physics
        self.colId = 0
        self.col_radius = col_radius
        self.col_height = col_height
        self.col_local_pos = col_local_pos

        # Create box collider
        self.isIteractable = isIteractable
        self.isStatic = isStatic
        if self.isStatic:
            self.__createCollider(0)
        else:
            self.__createCollider(1)

        # Depend on cube type should be iteractable or not
        if self.isIteractable:
            self.tapped = False
Beispiel #4
0
 def __init__(self, pos, scale, rotation, modelPath, showcase):
     self.model = pyxie.figure(modelPath)
     self.model.position = pos
     self.model.scale = scale
     self.model.rotation = rotation
     self.showcase = showcase
     self.showcase.add(self.model)
Beispiel #5
0
 def replaceMesh(self, meshData):
     self.meshName = meshData
     self.mesh = pyxie.figure(meshData)
     self.mesh.position = vmath.vec3(self.gameObject.transform.position)
     self.mesh.rotation = vmath.quat(
         helperFunction.fromEulerToQuaternion(
             self.gameObject.transform.rotation))
     self.mesh.scale = vmath.vec3(self.gameObject.transform.scale)
Beispiel #6
0
    def __init__(self, gameObject, meshData):
        super().__init__(gameObject)
        self.meshName = meshData
        self.showOnInspector("meshName")

        self.mesh = pyxie.figure(meshData)
        self.mesh.position = vmath.vec3(self.gameObject.transform.position)
        self.mesh.rotation = vmath.quat(
            helperFunction.fromEulerToQuaternion(
                self.gameObject.transform.rotation))
        self.mesh.scale = vmath.vec3(self.gameObject.transform.scale)
Beispiel #7
0
    def __init__(self, skyboxPath, gameCamera, skyboxCamera, skyboxShowcase):
        self.skyboxPath = skyboxPath
        self.skybox = pyxie.figure(self.skyboxPath)
        self.skybox.scale = vmath.vec3([600.0, 600.0, 600.0])
        self.skybox.position = vmath.vec3([0.0, -300, 100.0])
        # self.skybox.rotation = vmath.quat([ 0.7071068, 0, 0, 0.7071068 ])
        self.skyboxShowcase = skyboxShowcase
        self.skyboxShowcase.add(self.skybox)

        self.gameCamera = gameCamera
        self.skyboxCamera = skyboxCamera
Beispiel #8
0
    def __init__(self, gameObject, colliderPath, showcase):
        super().__init__(gameObject)
        self.colType = "BOX COLLIDER"
        self.showOnInspector("colType")

        self.scale = self.gameObject.transform.scale
        self.showOnInspector("scale")
        self.isDisplay = True
        self.showOnInspector("isDisplay")
        self.showcase = showcase

        self.mesh = pyxie.figure(colliderPath)
        self.mesh.position = vmath.vec3(self.gameObject.transform.position)
        self.mesh.rotation = vmath.quat(
            helperFunction.fromEulerToQuaternion(
                self.gameObject.transform.rotation))
        self.mesh.scale = vmath.vec3(self.gameObject.transform.scale)
        self.showcase.add(self.mesh)
Beispiel #9
0
    def __init__(self,
                 pos,
                 scale,
                 base_rotate,
                 modelPath,
                 cam,
                 col_scale,
                 col_local_pos=[0, 0, 0],
                 camfollow=False):
        # Create model to display on pyxie
        self.model = pyxie.figure(modelPath)
        self.model.position = pos
        self.model.scale = scale
        self.base_rotate = base_rotate
        self.model.rotation = vmath.quat(self.base_rotate)
        self.currentState = STATUS_STAY
        self.nextState = STATUS_STAY
        # self.model.connectAnimator(pyxie.ANIMETION_SLOT_A0, STATE_MOTION[self.currentState])
        # Create collider box to simulate physics on bullet physics
        self.colId = 0
        self.col_scale = col_scale
        self.col_local_pos = col_local_pos
        self.lastContactId = -1
        self.firstClick = False
        self.transitTime = 0.0

        # Create box collider
        self.camFollow = camfollow

        self.__createColBox(10)
        self.tapped = False
        self.dragged = False
        self.abortCheckContact = False
        self.kEpsilon = 1.0
        self.isDeath = False

        # Should this player have camera follow behind?
        if self.camFollow:
            self.cam = cam
            self.camDis = [0.0, -3.0, 2.0]

        # Previous touch
        self.previousTouchX = 0
Beispiel #10
0
    def __init__(self,
                 pos,
                 scale,
                 modelPath,
                 col_scale,
                 col_local_pos=[0, 0, 0],
                 base_quaternion=[0, 0, 0, 1],
                 isPlane=False,
                 camfollow=False,
                 isIteractable=False):
        # Create model to display on pyxie
        self.model = pyxie.figure(modelPath)
        # self.model.setMaterialRenderState()
        self.model.position = pos
        self.model.scale = scale
        self.base_rotate = base_quaternion
        self.model.rotation = vmath.quat(self.base_rotate)

        # Create collider to simulate physics on bullet physics
        self.colId = 0
        self.col_scale = col_scale
        self.col_local_pos = col_local_pos

        # Create box collider
        self.isPlane = isPlane
        self.isIteractable = isIteractable

        if not self.isPlane:
            self.__createColBox(1)
        else:
            self.__createColBox(0)

        # Depend on cube type should be iteractable or not
        if self.isIteractable:
            self.tapped = False

        self.isDestroy = False
Beispiel #11
0
        mass=1,
        linearDamping=0.4,
        angularDamping=1,
        restitution=0.8,
    )
    bodies.append(body)


# bodies = []
# for data in boxinfo:
#     body = p.createMultiBody(
#         baseMass=1, baseCollisionShapeIndex=shape, basePosition=data[0]
#     )
#     bodies.append(body)

figure = pyxie.figure("Castle_standard")
cam = pyxie.camera()
cam.position = (0, -2, 1)
cam.target = vmath.vec3(0, 0, 0)

showcase = pyxie.showcase("case")
showcase.add(figure)

FPS = 240
p.setPhysicsEngineParameter(
    fixedTimeStep=1.0 / FPS,
    numSolverIterations=12,
    numSubSteps=3,  # 8 is smooth but not sure abt performance. Lowered substeps actually raise fps
    contactBreakingThreshold=0.00000002,
    useSplitImpulse=0,
    splitImpulsePenetrationThreshold=9999999,
Beispiel #12
0
 def PyxieDisplayProcess(self):
     self.model = pyxie.figure("TestVoxel/Lion_Enemy")
     # self.model.scale = vmath.vec3(self.sizeMulti, self.sizeMulti, self.sizeMulti)
     self.showcase.add(self.model)