Beispiel #1
0
def createScene():
    # Root entity.
    rootEntity = QEntity()

    # Material.
    material = QPhongMaterial(rootEntity)

    # Torus.
    torusEntity = QEntity(rootEntity)
    torusMesh = QTorusMesh()
    torusMesh.setRadius(5)
    torusMesh.setMinorRadius(1)
    torusMesh.setRings(100)
    torusMesh.setSlices(20)

    torusTransform = QTransform()
    torusTransform.setScale3D(QVector3D(1.5, 1.0, 0.5))
    torusTransform.setRotation(
        QQuaternion.fromAxisAndAngle(QVector3D(1.0, 0.0, 0.0), 45.0))

    torusEntity.addComponent(torusMesh)
    torusEntity.addComponent(torusTransform)
    torusEntity.addComponent(material)

    # Sphere.
    sphereEntity = QEntity(rootEntity)
    sphereMesh = QSphereMesh()
    sphereMesh.setRadius(3)

    sphereEntity.addComponent(sphereMesh)
    sphereEntity.addComponent(material)

    return rootEntity
Beispiel #2
0
    def createScene():
        # Root entity
        rootEntity = QEntity()

        # Material
        material = QPhongMaterial(rootEntity)

        # Torus
        torusEntity = QEntity(rootEntity)
        # Qt3DExtras.QTorusMesh *
        torusMesh = QTorusMesh()
        torusMesh.setRadius(5)
        torusMesh.setMinorRadius(1)
        torusMesh.setRings(100)
        torusMesh.setSlices(20)

        # Qt3DCore.QTransform *
        torusTransform = QTransform()
        torusTransform.setScale3D(QVector3D(1.5, 1, 0.5))
        torusTransform.setRotation(
            QQuaternion.fromAxisAndAngle(QVector3D(1, 0, 0), 45.0))

        torusEntity.addComponent(torusMesh)
        torusEntity.addComponent(torusTransform)
        torusEntity.addComponent(material)

        # Sphere
        sphereEntity = QEntity(rootEntity)
        sphereMesh = QSphereMesh()
        sphereMesh.setRadius(3)

        # Qt3DCore.QTransform *
        sphereTransform = QTransform()
        # OrbitTransformController *
        controller = OrbitTransformController(sphereTransform)
        controller.setTarget(sphereTransform)
        controller.setRadius(20.0)
        # QPropertyAnimation *
        sphereRotateTransformAnimation = QPropertyAnimation(sphereTransform)
        sphereRotateTransformAnimation.setTargetObject(controller)
        sphereRotateTransformAnimation.setPropertyName(b"angle")
        sphereRotateTransformAnimation.setStartValue(0)
        sphereRotateTransformAnimation.setEndValue(360)
        sphereRotateTransformAnimation.setDuration(10000)
        sphereRotateTransformAnimation.setLoopCount(-1)
        sphereRotateTransformAnimation.start()

        sphereEntity.addComponent(sphereMesh)
        sphereEntity.addComponent(sphereTransform)
        sphereEntity.addComponent(material)

        return rootEntity
Beispiel #3
0
    def createScene(self):
        root = QEntity()
        # Material
        material = QPhongMaterial(root)
        material.setAmbient(QColor(100, 100, 0))
        material.setDiffuse(QColor(100, 0, 100))

        cube_E = QEntity(root)
        cube_mesh = QCuboidMesh()
        cube_mesh.setXExtent(2)
        cube_mesh.setYExtent(2)
        cube_mesh.setZExtent(2)

        cube_tr = QTransform()
        cube_tr.setScale3D(QVector3D(2, 2, 2))

        cube_E.addComponent(cube_mesh)
        cube_E.addComponent(cube_tr)
        cube_E.addComponent(material)

        return root