Go to file
Benoit Bolsee 149d231d69 VideoTexture: new ImageMirror class for easy mirror (and portal) creation
The new class VideoTexture.ImageMirror() is available to perform
automatic mirror rendering.

Constructor:

  VideoTexture.ImageMirror(scene,observer,mirror,material)
    scene:    reference to the scene that will be rendered.
              Both observer and mirror must be part of that scene.
    observer: reference to a game object used as view point for
              mirror rendering: the scene will be rendered through
              the mirror as if the active camera was at the observer 
              location. Usually the observer is the active camera
              but you can use any game obejct.
    mirror:   reference to the mesh object holding the mirror.
    material: material ID of the mirror texture as returned by 
              VideoTexture.materialID(). The mirror is formed by 
              the polygons mapped to that material.

There are no specific methods or attributes. ImageMirror inherits 
all methods and attributes from ImageRender. You must refresh the
parent VideoTexture.Texture object regularly to update the mirror 
rendering.

Guidelines on how to create a working mirror:
- Use a texture that is specific to the mirror so that the mirror 
  rendering only appears on the mirror.
- The mirror must be planar; the algorithm works well only for planar
  or quasi planar mirror. For spherical mirror, you will get better
  results with ImageRender and a camera at the center of the mirror. 
  ImageMirror automatically computes the mirror orientation and 
  position. The mirror doesn't need to be rectangular, it can be 
  circular or take any form provided it is planar.
- The mirror up direction must be along the Z axis in local mesh
  coordinates. If the mirror is not vertical, ImageMirror will 
  compute the up direction as being the projection of the Z axis
  on the mirror plane.
- UV mapping must be set right to get correct mirror rendering:
  - make a planar projection of the mirror polygons (Unwrap or projection from view)
  - eventually rotate the projection so that UV up direction corresponds to the mesh Z axis
  - scale the projection so that the extreme points touch the border of the texture
  - flip the UV projection horizontally (scale -1 on X axis). This is needed
    because the mirror texture is rendered from the back of the mirror and
    thus is reversed from the view point of the observer. Horizontal flip 
    in the UV map restores the correct orientation.

Besides these simple rules, the mirror rendering is completely automatic. 
In particular, you don't need to allocate a camera for the rendering, 
ImageMirror creates dynamically a camera for that. The reflection is correct
even on large angles. The mirror can be a dynamic and moving object, the 
algorithm always computes the correct camera position based on observer 
relative position. You don't have to worry about mirror position in the scene: 
the algorithm automatically computes the camera frustum so that any object 
behind the mirror is not rendered.

Warnings:
- observer and mirror are references to game objects. ImageMirror keeps
  a pointer to them but does not increment the reference count. You must ensure 
  that these game objects are not deleted as long as you refresh() the ImageMirror
  object. You must release the ImageMirror object before you delete the game
  objects. To release the ImageMirror object (normally stored in GameLogic),
  just assign it to None.
- Mirror rendering is automatically skipped when the observer is behind the mirror
  but it is not disabled when the mirror is out of sight of the observer.
  You should only refresh the mirror when you know that the observer is likely to see it.
  For example, no need to refresh a car inner mirror when the player is not in the car.

Example:

  contr = GameLogic.getCurrentController()
  # object holding the mirror
  mirror = contr.getOwner()
  scene = GameLogic.getCurrentScene()
  # observer will be the active camere
  camera = scene.getObjectList()['OBCamera']
  matID = VideoTexture.materialID(mirror, 'IMmirror.png')
  GameLogic.mirror = VideoTexture.Texture(mirror, matID)
  GameLogic.mirror.source = VideoTexture.ImageMirror(scene,camera,mirror,matID)
  # to render the mirror, just call GameLogic.mirror.refresh(True) on each frame.

You can download a demo game (with a video file) here:

  http://home.scarlet.be/~tsi46445/blender/VideoTextureDemo.zip

For those who have already downloaded the demo, you can just update the blend file:

  http://home.scarlet.be/~tsi46445/blender/MirrorTextureDemo.blend
2008-12-04 16:07:46 +00:00
bin/.blender Move Korean file from kr to ko also updated it to newer file. 2008-09-29 15:02:20 +00:00
blenderplayer Fixes blenderplayer for dds stuff 2008-10-28 19:53:54 +00:00
CMake Fix: compiling with cmake 2.4 didn't work anymore due to a 2008-09-05 21:57:34 +00:00
config This is patch [#17896] Irix Build Files 2008-11-21 17:22:17 +00:00
doc * add Brecht's small patch to make values to BF_QUICK and BF_QUICKDEBUG function as partial search entries. 2008-11-09 21:00:49 +00:00
extern patch #8583: Add support for gcc on irix 2008-11-24 14:15:05 +00:00
intern patch #8583: Add support for gcc on irix 2008-11-24 14:15:05 +00:00
po Move Korean file from kr to ko also updated it to newer file. 2008-09-29 15:02:20 +00:00
projectfiles == Sequencer == 2007-10-02 12:36:53 +00:00
projectfiles_vc7 VideoTexture: forgot to commit MSVC project file, strange that nobody noticed... 2008-11-07 20:13:07 +00:00
projectfiles_vc9 MSVC9 project file update for TEX nodes 2008-11-26 17:34:10 +00:00
release missed saving a small change 2008-12-03 07:51:12 +00:00
source VideoTexture: new ImageMirror class for easy mirror (and portal) creation 2008-12-04 16:07:46 +00:00
tools some scons command line args were not working since recent changes- 2008-11-18 05:47:19 +00:00
CMakeLists.txt Disable completely OpenAL if WITH_OPENAL is OFF 2008-11-02 15:16:17 +00:00
COPYING Biiig commit! Thanks to 2-3 weeks of cvs freeze... 2004-12-27 19:28:52 +00:00
Makefile Patch from GSR that a) fixes a whole bunch of GPL/BL license 2008-04-16 22:40:48 +00:00
README Patch #17310: Fixing urls in main README 2008-07-12 06:18:06 +00:00
SConstruct some scons command line args were not working since recent changes- 2008-11-18 05:47:19 +00:00

Welcome to the fun world of open source.

For instructions on building and installing Blender, please see the file named
INSTALL.


---------------------.Blanguages and the .blender directory---------------------

The .blender directory holds various data files for Blender.
In the 2.28a release those are the .Blanguages file containing a list of
translations, the translations themselves and a default ttf font.

Blender checks for the presence of this directory in several locations:
	- the current directory
	- your home directory
	- On OSX, the blender bundle is also checked 
	- On Windows, the installation dir is checked.

If you get a 'File ".Blanguages" not found' warning, try to copy the .blender
dir to one of these locations (your home directory being recommended).



-------------------------------------Links--------------------------------------

Getting Involved:
http://www.blender.org/community/get-involved

Community:
http://www.blender.org/Community

Main blender development site:
http://www.blender.org

The Blender project homepage:
http://projects.blender.org/projects/bf-blender

Documentation:
http://www.blender.org/education-help

Bug tracker:
http://www.blender.org/development/report-a-bug

Feature request tracker:
http://wiki.blender.org/index.php/Requests