ClearAtRender

From Director Online Wiki
Jump to: navigation, search
clearAtRender
Type: camera colorbuffer property
Version: 8.5 and up
Language: Lingo, JavaScript
Default value: TRUE
Dependencies: none
Links/Related
addCamera, camera.colorbuffer.clearValue







Syntax

From Director 8.5 Documentation

 member(whichMember).camera(whichCamera).colorBuffer.clearAtRender = TRUE
 sprite(whichSprite).camera{[index]}.colorBuffer.clearAtRender = FALSE

Description

3D property: indicates whether the color buffer is cleared after each frame. For the first camera on a sprite, setting the colorBuffer.clearAtRender to FALSE gives an effect similar to the trails ink effect. Trails example.

For the second and subsequent cameras, setting the value to FALSE means that the scene rendered by the earlier cameras is left intact, rather than overwritten.

Example

Drop the following behavior onto a sprite with an empty 3D member. It will show the views of two spheres superimposed on each other on a grey background. If you comment out the last line, you will see a single wireframe sphere on a blue background.

 on beginSprite(me)
  tSprite = sprite(me.spriteNum)
  tMember = tSprite.member
  tMember.resetWorld()
  tMember.bgColor = rgb(128, 128, 128)
 
  -- Create a model in front of the main camera
  tResource  = tMember.newModelResource("Sphere", #sphere)
  tModel     = tMember.newModel("Sphere", tResource)
 
  -- Copy the camera's settings
  tCamera    = tSprite.camera
  tTransform = tCamera.transform
  tAngle     = tCamera.projectionAngle
 
  -- The camera.rect property is not initialized at this time
  tRect      = tSprite.rect.offset(-tSprite.left, -tSprite.top)
 
  -- Create a similar model with a wireframe 
  tModel     = tMember.newModel("Wireframe", tResource)
  tShader    = tMember.newShader("Wireframe", #standard)
  tShader.renderStyle = #wire
  tModel.shader = tShader
 
  -- Remove this wireframe model from the world, where there is no
  -- light, so all vertex edges will appear black
  tModel.removeFromWorld()
 
  -- Create a camera which can only see the wireframe model
  tCamera = tMember.newCamera("Wire_frame")
  tCamera.colorBuffer.clearValue = rgb("#006699")
  tSprite.addCamera(tCamera, 2)
  tCamera.rect            = tRect
  tCamera.transform       = tTransform
  tCamera.projectionAngle = tAngle
 
  tCamera.rootNode        = tModel
 
  tCamera.colorBuffer.clearAtRender = FALSE
end beginSprite

See also

addCamera, camera.colorbuffer.clearValue

External links

  • []