3D view.
Methods defined here:
addBookmark
addBookmark(self, name):
Adds the viewport's current location as a bookmark with the given name.
@param name: The name of the new bookmark. [str]
@example:
# Creates a bookmark from current view
view = ce.get3DViews()[0]
view.addBookmark("view1")
# set camera details and store bookmark
view.setCameraPosition(-68,624,107)
view.setCameraRotation(-56, -88, 10)
view.setPoIDistance(390)
view.setCameraAngleOfView(55)
view.setCameraPerspective(True)
view.addBookmark("view2")
frame
frame(self, objects = None):
Frame the given objects.
@param objects: The objects to frame or null to frame all objects. (default = None).
@example:
# Frame objects in scene
views = ce.getObjectsFrom(ce.get3DViews())
views[0].frame()
getBookmarks
getBookmarks(self):
Returns all the avoiable camera bookmarks.
@return: A list of the bookmarks defined in the current scene. [sequence]
@example:
# returns a list of all the current bookmarks
print "bookmarks: " + str(view.getBookmarks())
getCameraAngleOfView
getCameraAngleOfView(self):
Gets the camera angle of view in degrees.
@return: result. [float]
@example:
# get camera angle of view
print ce.get3DViews()[0].getCameraAngleOfView()
getCameraPerspective
getCameraPerspective(self):
Gets the camera perspective mode.
@return: result. [True/False]
@example:
# get camera perspective flag
print ce.get3DViews()[0].getCameraPerspective()
getCameraPoI
getCameraPoI(self):
Gets the camera point of interest in world coordinates.
@return: result. [sequence of float]
@example:
# get camera point of interest (focus point)
print ce.get3DViews()[0].getCameraPoI()
getCameraPosition
getCameraPosition(self):
Gets the camera position in world coordinates.
@return: result. [sequence of float]
@example:
# get camera position
print ce.get3DViews()[0].getCameraPosition()
getCameraRotation
getCameraRotation(self):
Gets the camera rotation in degrees.
@return: result. [sequence of float]
@example:
# get camera rotation
print ce.get3DViews()[0].getCameraRotation()
getCameraTwoPointPerspectiveCorrection
getCameraTwoPointPerspectiveCorrection(self):
Returns whether the camera is using two point perspective correction.
@return: result. [True/False]
getRenderSettings
getRenderSettings(self):
Gets Render Settings.
@return: RenderSettings Object. [RenderSettings]
@example:
view = ce.getObjectsFrom(ce.get3DViews(), ce.isViewport)[0]
renderSettings = view.getRenderSettings()
print renderSettings.getMode()
print renderSettings.getWireframeOnShaded()
print renderSettings.getShadows()
print renderSettings.getAmbientOcclusion()
print renderSettings.getOnCameraLight()
print renderSettings.getSingleSidedLighting()
print renderSettings.getBackFaceCulling()
print renderSettings.getInfoDisplayVisible()
print renderSettings.getAxesVisible()
print renderSettings.getCompassVisible()
print renderSettings.getGridVisible()
print renderSettings.getGizmosVisible()
restoreBookmark
restoreBookmark(self, name, animate = True):
Sets the viewport's setting's to the specified bookmark.
@param name: The name camera bookmark to restore. [str]
@param animate: If true, the camera smoothly moves to the new location. (default = True). [True/False]
@example:
# Restores the bookmark with the given name.
view.restoreBookmark("view1")
# Restores the bookmark immediately (no camera animation)
view.restoreBookmark("init", False)
setCameraAngleOfView
setCameraAngleOfView(self, angle):
Sets the camera angle of view in degrees.
@param angle: Angle of view. [float]
@example:
# set cameras angle fo view
ce.get3DViews()[0].setCameraAngleOfView(50)
setCameraPerspective
setCameraPerspective(self, perspective = True, animate = True):
Sets the camera to perspective mode.
@param perspective: Set camera to perspective mode. (default = True). [True/False]
@param animate: If true, the camera smoothly moves to the new location. (default = True). [True/False]
@example:
# set camera to orthographic mode
ce.get3DViews()[0].setCameraPerspective(False)
setCameraPoI
setCameraPoI(self, pos):
Sets the camera point of interest in world coordinates. Camera positioned using PoI and the PoI distance.
@param pos: [x, y, z] position of the camera's point of interest . [sequence]
@example:
# set camera point of interest, preserving PoI distance
ce.get3DViews()[0].setCameraPoI([-1650,0,-3500])
setCameraPosition
setCameraPosition(self, x, y, z):
Sets the camera position in world coordinates.
@param x: X coordinate. [float]
@param y: Y coordinate. [float]
@param z: Z coordinate. [float]
@example:
# place camera at position (100,100,100)
views = ce.getObjectsFrom(ce.get3DViews(), ce.isViewport)
views[0].setCameraPosition(0, 200, 0)
setCameraRotation
setCameraRotation(self, x, y, z):
Sets the camera rotation in degrees.
@param x: X axis rotation. [float]
@param y: Y axis rotation. [float]
@param z: Z axis rotation. [float]
@example:
# reset camera rotation
ce.get3DViews()[0].setCameraRotation(-15,0,0)
setCameraTwoPointPerspectiveCorrection
setCameraTwoPointPerspectiveCorrection(self, twoPointCorrection = True, animate = True):
Sets two point perspective correction.
@param twoPointCorrection: Set two point perspective correction (default = True). [True/False]
@param animate: If true, the camera smoothly moves to the new location. (default = True). [True/False]
setPoIDistance
setPoIDistance(self, distance):
Sets the point of interest distance directly infront of the camera.
@param distance: Desired distance to the PoI. [float]
@example:
# set distance to camera point of interest
ce.get3DViews()[0].setPoIDistance(2000)
setRenderSettings
setRenderSettings(self, settings):
Sets Render Settings.
@param settings: RenderSettings Object . [RenderSettings]
@example:
renderSettings = RenderSettings()
renderSettings.setMode(RenderSettings.MODE_SHADED)
renderSettings.setMode(RenderSettings.MODE_WIREFRAME)
renderSettings.setMode(RenderSettings.MODE_TEXTURED)
renderSettings.setWireframeOnShaded(True)
renderSettings.setShadows(True)
renderSettings.setAmbientOcclusion(True)
renderSettings.setOnCameraLight(True)
renderSettings.setSingleSidedLighting(True)
renderSettings.setBackFaceCulling(False)
renderSettings.setInfoDisplayVisible(True)
renderSettings.setAxesVisible(True)
renderSettings.setCompassVisible(True)
renderSettings.setGridVisible(True)
renderSettings.setGizmosVisible(True)
view = ce.getObjectsFrom(ce.get3DViews(), ce.isViewport)[0]
view.setRenderSettings(renderSettings)
snapshot
snapshot(self, filesystemPath, width = -1, height = -1):
Take a snapshot of this 3D viweport.
@param filesystemPath: Path to the destination image (must be a filesystem path). [str]
@param width: Width of snapshot. (default = -1). [int]
@param height: Height of snapshot. (default = -1). [int]
@example:
# snapshot current inspector view
views = ce.getObjectsFrom(ce.get3DViews())
if len(views) < 1 : print "no view found"
else :
views[0].frame()
ce.waitForUIIdle()
views[0].snapshot(ce.toFSPath('images')+"/snapshot.png")