Learn what Felgo offers to help your business succeed. Start your free evaluation today! Felgo for Your Business

Render3D

A 3D model with a texture and material to be rendered in a Scene3D. More...

Import Statement: import Felgo 3.0
Since: Felgo 2.5.0
Inherits:

Item

Properties

Detailed Description

The Render3D component is the visual component of a 3D model with a texture and a material. It is added as a child of Scene3D::rootEntity and then rendered with OpenGL.

Usually you will use Render3D to load a Mesh with the source property and set a texture. However, you can customize to display custom Qt3D Entity instances like a PlaneMesh.

The Render3D and Scene3D concept has the advantage that you can add the Render3D component as a child of your EntityBase. It will then register automatically itself with the Scene3D::rootEntity and gets the position and rotation of the parent entity applied.

The Render3D component also makes working with often-needed functionality easier like changing the material settings like shininess, ambient or specular colors.

It is flexible enough to use custom materials or Qt3D Entity instances as its children - do so by changing the components property. By default, it uses a DiffuseMapMaterial, a Mesh and a Transform component internally.

The specialty of the Render3D component is that its transform gets set to the parent position automatically. This means if you change in the example below the position of the EntityBase, the position of the Qt3D Entity will also change. Specifically, the x, y, z, rotation and scale properties of the parent are forwarded to the Entity.

Note: Qt3D and also the Felgo 3D Components are in a Tech Preview state and may change its API in future versions.

Example Usage

Here is an example how to use Scene3D and Render3D in a Felgo project:

 import Felgo 3.0
 import QtQuick 2.0

 GameWindow {

   // is needed by the Render3D component - to this entity the Entity objects are added to
   property alias rootEntity: scene3D.rootEntity

   Scene {
     id: gameScene

     Level {

       EntityBase {
         entityType: "car"

         // this Box2D physics component modifies the entity position by applying forces
         // when the entity position changes, the Render and Image components change too
         BoxCollider {}

         // allows loading a Mesh and a texture
         // registers itself at the rootEntity
         Render3D {
           source: "assets/3d/car_model.obj"
           texture: "assets/3d/car_texture.png"
         }

         // you could mix 2D images with the 3D renderer like this
         Image {
           source: "assets/2d/car.png"
         }
       }// EntityBase
     }// Level

   }// GameScene

   Scene3D {
     id: scene3D
   }

   Scene {
     id: hudScene
     // put user elements like buttons here
   }

 }

For a complete game how to use Scene3D together with the Render3D component, see the CarChallenge 3D Demo.

Property Documentation

ambient : alias

Ambient color of the diffuse material. The default value is Qt.rgba(0.5, 0.5, 0.5, 1).


components : alias

List of Qt3D Component objects of the Entity. By default the components are the Mesh, DiffuseMapMaterial and the renderTransform.


material : alias

The default DiffuseMapMaterial of the Entity. You can either change the material property or change the components property.


renderTransform : alias

Allows to set the transform of the Entity.

Alternatively, you can set a different transform with the components property.


rotationAxis : alias

The rotationAxis that gets applied with the rotation property.


rotationAxisOffset : alias

The rotationAxisOffset of the model which is applied before the normal rotation value.


rotationOffset : alias

The rotationOffset of the model which is applied before the normal rotation value.


scaleOffset : alias

The scaleOffset of the model which is applied before the normal scale value.


sceneRootEntity : Entity

Set this property to the Scene3D::rootEntity. It is the root Entity where the Qt3D children of this component are added to.

By default, it is set to the id rootEntity. Thus a property with this name is required as child of your GameWindow to be usable by default.

See the Example Usage how the Scene3D and Render3D components are connected with the rootEntity id.


shininess : alias

Specular value color of the diffuse material. The default value is 150.0.


source : alias

Url of the Mesh .obj file.


specular : alias

Specular color of the diffuse material. The default value is Qt.rgba( 0.95, 0.95, 0.95, 1.0 ).


texture : alias

Url of the UV-mapped texture of the .obj file.


textureScale : alias

Uniform texture scale in x and y direction. Increase this value to wrap a texture next to each other more often. The default value is 1.


xOffset : alias

The xOffset of the model which is applied before the normal x value.


yOffset : alias

The yOffset of the model which is applied before the normal y value.


zOffset : alias

The zOffset of the model which is applied before the normal z value.


Qt_Technology_Partner_RGB_475 Qt_Service_Partner_RGB_475_padded