mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-01 09:23:03 -04:00
add rootCamera
This commit is contained in:
parent
9d40ea1184
commit
daed41f05e
@ -26,10 +26,12 @@ reflections, you will need to use a sphere map or a cube map."""
|
|||||||
from pandac.PandaModules import *
|
from pandac.PandaModules import *
|
||||||
from direct.task import Task
|
from direct.task import Task
|
||||||
|
|
||||||
def setupMirror(name, width, height):
|
def setupMirror(name, width, height, rootCamera = None):
|
||||||
# The return value is a NodePath that contains a rectangle that
|
# The return value is a NodePath that contains a rectangle that
|
||||||
# reflects render. You can reparent, reposition, and rotate it
|
# reflects render. You can reparent, reposition, and rotate it
|
||||||
# anywhere you like.
|
# anywhere you like.
|
||||||
|
if rootCamera is None:
|
||||||
|
rootCamera = base.camera
|
||||||
|
|
||||||
root = render.attachNewNode(name)
|
root = render.attachNewNode(name)
|
||||||
|
|
||||||
@ -81,9 +83,9 @@ def setupMirror(name, width, height):
|
|||||||
# mirror.
|
# mirror.
|
||||||
def moveCamera(task, cameraNP = cameraNP, plane = plane,
|
def moveCamera(task, cameraNP = cameraNP, plane = plane,
|
||||||
planeNP = planeNP, card = card, lens = lens,
|
planeNP = planeNP, card = card, lens = lens,
|
||||||
width = width, height = height):
|
width = width, height = height, rootCamera = rootCamera):
|
||||||
# Set the camera to the mirror-image position of the main camera.
|
# Set the camera to the mirror-image position of the main camera.
|
||||||
cameraNP.setMat(base.camera.getMat(planeNP) * plane.getReflectionMat())
|
cameraNP.setMat(rootCamera.getMat(planeNP) * plane.getReflectionMat())
|
||||||
|
|
||||||
# And reset the frustum to exactly frame the mirror's corners.
|
# And reset the frustum to exactly frame the mirror's corners.
|
||||||
# This is a minor detail, but it helps to provide a realistic
|
# This is a minor detail, but it helps to provide a realistic
|
||||||
|
Loading…
x
Reference in New Issue
Block a user