예제 #1
0
    def createScene(self):
        # root
        rootEntity = QSkyboxEntity()
        material = QPhongMaterial(rootEntity)
        #skybox = QSkyboxEntity(rootEntity)

        # torus
        cubeEntity = QEntity(rootEntity)
        cubeMesh = QCuboidMesh()
        cubeTransform = QTransform()
        #cubeMaterial = getRgbCubeMaterial(cubeEntity)
        cubeMaterial = QPhongMaterial(cubeEntity)
        cubeTransform.setTranslation(QVector3D(5.0, -4.0, 0.0))
        cubeTransform.setScale(4.0)
        cubeTransform.setRotation(QQuaternion.fromAxisAndAngle(QVector3D(1, 0, 0), 45))

        cubeEntity.addComponent(cubeMesh)
        cubeEntity.addComponent(cubeTransform)
        cubeEntity.addComponent(cubeMaterial)

        return rootEntity
예제 #2
0
    def __init__(self, rootEntity):
        super(SceneModifier, self).__init__()

        self.m_rootEntity = rootEntity

        # Torus shape data.
        self.m_torus = QTorusMesh()
        self.m_torus.setRadius(1.0)
        self.m_torus.setMinorRadius(0.4)
        self.m_torus.setRings(100)
        self.m_torus.setSlices(20)

        # TorusMesh transform.
        torusTransform = QTransform()
        torusTransform.setScale(2.0)
        torusTransform.setRotation(
            QQuaternion.fromAxisAndAngle(QVector3D(0.0, 1.0, 0.0), 25.0))
        torusTransform.setTranslation(QVector3D(5.0, 4.0, 0.0))

        torusMaterial = QPhongMaterial()
        torusMaterial.setDiffuse(QColor(0xbeb32b))

        # Torus.
        self.m_torusEntity = QEntity(self.m_rootEntity)
        self.m_torusEntity.addComponent(self.m_torus)
        self.m_torusEntity.addComponent(torusMaterial)
        self.m_torusEntity.addComponent(torusTransform)

        # Cone shape data.
        cone = QConeMesh()
        cone.setTopRadius(0.5)
        cone.setBottomRadius(1)
        cone.setLength(3)
        cone.setRings(50)
        cone.setSlices(20)

        # ConeMesh transform.
        coneTransform = QTransform()
        coneTransform.setScale(1.5)
        coneTransform.setRotation(
            QQuaternion.fromAxisAndAngle(QVector3D(1.0, 0.0, 0.0), 45.0))
        coneTransform.setTranslation(QVector3D(0.0, 4.0, -1.5))

        coneMaterial = QPhongMaterial()
        coneMaterial.setDiffuse(QColor(0x928327))

        # Cone.
        self.m_coneEntity = QEntity(self.m_rootEntity)
        self.m_coneEntity.addComponent(cone)
        self.m_coneEntity.addComponent(coneMaterial)
        self.m_coneEntity.addComponent(coneTransform)

        # Cylinder shape data.
        cylinder = QCylinderMesh()
        cylinder.setRadius(1)
        cylinder.setLength(3)
        cylinder.setRings(100)
        cylinder.setSlices(20)

        # CylinderMesh transform.
        cylinderTransform = QTransform()
        cylinderTransform.setScale(1.5)
        cylinderTransform.setRotation(
            QQuaternion.fromAxisAndAngle(QVector3D(1.0, 0.0, 0.0), 45.0))
        cylinderTransform.setTranslation(QVector3D(-5.0, 4.0, -1.5))

        cylinderMaterial = QPhongMaterial()
        cylinderMaterial.setDiffuse(QColor(0x928327))

        # Cylinder.
        self.m_cylinderEntity = QEntity(self.m_rootEntity)
        self.m_cylinderEntity.addComponent(cylinder)
        self.m_cylinderEntity.addComponent(cylinderMaterial)
        self.m_cylinderEntity.addComponent(cylinderTransform)

        # Cuboid shape data.
        cuboid = QCuboidMesh()

        # CuboidMesh transform.
        cuboidTransform = QTransform()
        cuboidTransform.setScale(4.0)
        cuboidTransform.setTranslation(QVector3D(5.0, -4.0, 0.0))

        cuboidMaterial = QPhongMaterial()
        cuboidMaterial.setDiffuse(QColor(0x665423))

        # Cuboid.
        self.m_cuboidEntity = QEntity(self.m_rootEntity)
        self.m_cuboidEntity.addComponent(cuboid)
        self.m_cuboidEntity.addComponent(cuboidMaterial)
        self.m_cuboidEntity.addComponent(cuboidTransform)

        # Plane shape data.
        planeMesh = QPlaneMesh()
        planeMesh.setWidth(2)
        planeMesh.setHeight(2)

        # Plane mesh transform.
        planeTransform = QTransform()
        planeTransform.setScale(1.3)
        planeTransform.setRotation(
            QQuaternion.fromAxisAndAngle(QVector3D(1.0, 0.0, 0.0), 45.0))
        planeTransform.setTranslation(QVector3D(0.0, -4.0, 0.0))

        planeMaterial = QPhongMaterial()
        planeMaterial.setDiffuse(QColor(0xa69929))

        # Plane.
        self.m_planeEntity = QEntity(self.m_rootEntity)
        self.m_planeEntity.addComponent(planeMesh)
        self.m_planeEntity.addComponent(planeMaterial)
        self.m_planeEntity.addComponent(planeTransform)

        # Sphere shape data.
        sphereMesh = QSphereMesh()
        sphereMesh.setRings(20)
        sphereMesh.setSlices(20)
        sphereMesh.setRadius(2)

        # Sphere mesh transform.
        sphereTransform = QTransform()
        sphereTransform.setScale(1.3)
        sphereTransform.setTranslation(QVector3D(-5.0, -4.0, 0.0))

        sphereMaterial = QPhongMaterial()
        sphereMaterial.setDiffuse(QColor(0xa69929))

        # Sphere.
        self.m_sphereEntity = QEntity(self.m_rootEntity)
        self.m_sphereEntity.addComponent(sphereMesh)
        self.m_sphereEntity.addComponent(sphereMaterial)
        self.m_sphereEntity.addComponent(sphereTransform)