Director Tutorials

 

Creating a Backdrop (background image) for a Shockwave 3D sprite

Download my demo DIR movie - backgroundForSW3D.zip

If you select sprite 1, and click on the Behavior tab in the Property Inspector, you’ll see 2 behaviors. The first is a Reset World one from the Chrome Library. The second is one I created. It is a relatively simple script.

property p3Dmember -- reference to the 3D member

on beginSprite me
  -- define the 3D cast member
  p3Dmember = sprite(me.spriteNum).member

  -- create the backdrop for the 3D scene
  p3Dmember.newTexture("backdrop", #fromCastmember, member("scribble"))
  p3Dmember
.camera(1).insertBackdrop(1, p3Dmember.texture("backdrop"), point(0,0), 0)
end


It creates a new texture through:
p3Dmember.newTexture("backdrop", #fromCastmember, member("scribble"))
This creates a texture called ‘backdrop’ using the internal image cast member ‘scribble’.

I then apply that texture to the camera (camera number 1 in this case), with
p3Dmember.camera(1).insertBackdrop(1, p3Dmember.texture("backdrop"), point(0,0), 0)
This aligns the image to the top left corner of the 3D sprite. If the image pixel size is the same as the sprite size, the image will fill the sprite. It will not stretch to fit if the image is bigger or smaller than the sprite.

All you need to do is replace the ‘scribble’ with the name of the image you want to use for the background and make sure it’s sized correctly.

Note:
If you click on the 3D cast member, then open the Property Inspector to the 3D Model tab, you'll see a DTS property. This is Direct To Stage Property. It means the sprite will be the top most layer (nothing will show above it regardless of if they are above it in the Score), and the sprite won't allow transparencies. If you uncheck this property, you will be able to use Background Transparent for the sprite and put a background image in a lower sprite channel to appear behind the 3D sprite. Generally, it is better to use a backdrop, particularly for more complex 3D models.