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

Import Statement: import VPlay 2.0
Since: V-Play 2.5.0



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 Scene3DVPlay::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 Scene3DVPlay 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 Scene3DVPlay::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 transfom 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 V-Play 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 V-Play project:

 import VPlay 2.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

   Scene3DVPlay {
     id: scene3D

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


For a complete game how to use Scene3DVPlay 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 Scene3DVPlay::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 Scene3DVPlay 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.

Voted #1 for:

  • Easiest to learn
  • Most time saving
  • Best support

Develop Cross-Platform Apps and Games 50% Faster!

  • Voted the best supported, most time-saving and easiest to learn cross-platform development tool
  • Based on the Qt framework, with native performance and appearance on all platforms including iOS and Android
  • Offers a variety of plugins to monetize, analyze and engage users
create apps
create games
cross platform
native performance
3rd party services
game network
level editor
easiest to learn
biggest time saving
best support