User Tools

Site Tools


Canvas Render World

Render world canvas renders a 3D world resource. The world covers the entire area of the canvas. To render a world you have to assign a camera resource to the canvas. If the camera resource is part of a world the world is rendered using the camera with the active camera properties. If no camera is set or the camera is not part of a world black is rendered. Multiple canvas render world can render the same world using the same camera or different cameras. The graphic module takes care of organizing rendering to be efficient and correct.

Dynamic Skin Renderable Usage

Dynamic skin renderables support rendering the world using a camera to textures of scene elements. Renderables can also use a [gamedev:canvassystem:view|view canvas]] with a canvas render world inside. Both situations have their own uses and properties.

The direct rendering using camera on dynamic skin renderables is free of size restrictions. The graphic module typically renders the world directly into the parent scene as if the affected texture is just a window to look through into a different world. While it is possible for a graphic module to choose to pre-render this situation into a texture and using it the main idea is to allow full resolution if possible. This is the best choice for scene elements and should be chosen whenever possible.

Using canvas render world on the other hand forces the graphic module to pre-render the world into a texture of the size of the canvas render window and then using the texture for rendering. This locks the resolution of the rendered world to the canvas size. The advantage of this solution is that you are able to use all the power of the canvas system to manipulate the rendered world before the result is used for texturing. This is the best solution if you need fancy modifications to be applied to the rendered world or if you plan to not cover the entire scene element texture with the rendered world. An example for this can be a remove camera with multiple rendered worlds. In general the performance and resolution is worse than using direct world rendering.

Usage example DragonScript

// during initialization time
var World world =        // create a new world

/** add components, lights and other scene elements to the world */

var Camera camera =     // create camera
world.addCamera( camera )            // add camera to world

var Canvas canvas = Canvas.RENDERWORLD )
canvas.setSize( 800, 600 ) )      // set size to render world with
canvas.setPosition( 10, 20 ) )    // set position relative to parent canvas
canvas.setCamera( camera )                   // assign camera
parentCanvas.addCanvas( canvas )             // add canvas to parent making it visible

// during frame update for example in response to Game.onFrameUpdate()
// these changes will be used the next time the graphic module renders the screen
camera.setPosition( 10.0, 1.8, -5.0 ) )       // set camera position
camera.setOrientation( Quaternion.newFromEulerY( 30.0 ) )  // set rotatom from actor along up axis
You could leave a comment if you were logged in.
gamedev/canvassystem/renderworld.txt · Last modified: 2015/06/17 23:47 by dragonlord