Download presentation
Presentation is loading. Please wait.
Published byDavid Elwin French Modified over 9 years ago
1
고려대학교 그래픽스 연구실 Cameras and Lights - The Inventor mentor 고려대학교 그래픽스 연구실 2001.8.8 민 성환
2
19 February 2016Sunghwan Min 2 Using Lights and Cameras Two classes of nodes that affect how the 3D scene appears : light and cameras Inventor provides different classes of lights for you to use in your scene Light bulbs The sun Theatrical spotlights Cameras are our “eyes” for viewing the scene
3
19 February 2016Sunghwan Min 3 Cameras A camera node generates a picture of everything after it in the scene graph A scene graph should contain only one active camera Camera position in space is affected by the current geometric transformation
4
19 February 2016Sunghwan Min 4 SoCamera Abstract base class Fields viewportMapping – treatment when the camera’s aspect ratio is different from the viewport’s aspect ratio position – location of the camera viewpoint orientation – describes how the camera is rotated aspectRatio – ratio of the camera viewing width to height nearDistance farDistance focalDiatance – distance from the camera viewpoint to the point of focus (used by the examiner viewer) ??
5
19 February 2016Sunghwan Min 5 SoCamera Methods pointAt(const SBVec3f &targetPoint) – replace the value in a camera’s orientation field viewAll(SoNode *sceneRoot, const SbViewportRegion &vpRegion, float slack =1.0) – set the camera to view an entire scene graph The slack parameter is used to position the near and far clipping planes getViewVolume – return the camera’s view
6
19 February 2016Sunghwan Min 6 Subclasses of SoCamera SoPerspectiveCamera Field heightAngle – specifies the vertical angle in radians of the camera view volume –widthAngle= heightAngle*aspectRatio
7
19 February 2016Sunghwan Min 7 Subclasses of SoCamera (cont.) SoOrthographicsCamera Field Height
8
19 February 2016Sunghwan Min 8 Mapping Mapping the Camera Aspect Ratio to the Viewport A viewport is the rectangular area where a scene is rendered Allows you to specify how to map the camera projection into the viewport when the aspect ratios of the camera and viewport differ Crop the viewport to fit the camera projection CROP_VIEWPORT_FILL_FRAME CROP_VIEWPORT_LINE_FRAME CROP_VIEWPORT_NO_FRAME
9
19 February 2016Sunghwan Min 9 Mapping (cont.) Adjust the camera projection to fit the viewport ADJUST_CAMERA – the projected image is not distorted LEAVE_ALONE – the camera image is resized
10
19 February 2016Sunghwan Min 10 Viewing a Scene with Different Cameras Example 4-1 shows a scene viewed by an orthographic camera and two perspective cameras in different positions.It uses a blinker node
11
19 February 2016Sunghwan Min 11 Example 4-1 주요 코드 SoBlinker *myBlinker = new SoBlinker; root->addChild(myBlinker); // Create three cameras. Their positions will be set later. // This is because the viewAll method depends on the size // of the render area, which has not been created yet. SoOrthographicCamera *orthoViewAll =new SoOrthographicCamera; SoPerspectiveCamera *perspViewAll = new SoPerspectiveCamera; SoPerspectiveCamera *perspOffCenter =new SoPerspectiveCamera; myBlinker->addChild(orthoViewAll); myBlinker->addChild(perspViewAll); myBlinker->addChild(perspOffCenter);
12
19 February 2016Sunghwan Min 12 Example 4-1 // Establish camera positions. // First do a viewAll on all three cameras. // Then modify the position of the off-center camera. SbViewportRegion myRegion(myRenderArea->getSize()); orthoViewAll->viewAll(root, myRegion); perspViewAll->viewAll(root, myRegion); perspOffCenter->viewAll(root, myRegion); SbVec3f initialPos; initialPos = perspOffCenter->position.getValue(); float x, y, z; initialPos.getValue(x,y,z); perspOffCenter->position.setValue(x+x/2., y+y/2., z+z/4.);
13
19 February 2016Sunghwan Min 13 Lights A scene graph also needs at least one light (with the default lighting model : Phong) Determines two things What the light illuminates Where the light is located in 3D space ( location or direction) All light-source nodes is that lights accumulate Each time you add a light to the scene graph,the scene appears brighter
14
19 February 2016Sunghwan Min 14 SoLight The abstract base class for All lights Fields on (SoSFBool) – whether the light is on intensity (SoSFFloat) – brightness of the light (0.0 ~ 1.0) color (SoSFColor) – color of the light
15
19 February 2016Sunghwan Min 15 Subclasses of SoLight Subclass SoPointLight SoDirectionalLight SoSpotLight Computation cost Directional light < Point light < Spot light
16
19 February 2016Sunghwan Min 16 SoPointLight Like a star,radiates light equally in all directions from a given location in 3D space Additional field Location (SoSFVec3f) – 3D location of a point light source
17
19 February 2016Sunghwan Min 17 SoDirectionalLight Illuminates uniformly along a particular direction Since it is infinitely far away, it has no location in 3D space Additional field Direction (SoSFVec3f) – specifies the direction of the ray from a directional light source All rays of incident light are parallel
18
19 February 2016Sunghwan Min 18 SoSpotLight Illuminate from a point in space along a primary direction Like a theatrical spotlight, its illumination is a cone of light diverging from light’s position
19
19 February 2016Sunghwan Min 19 SoSpotLight (cont.) Additional fields Location (SoSFVec3f) Direction (SoSFVec3f) dropOffRate (SoSFFloat) Rate at which the light intensity drops off from the primary direction (0.0 =constant intensity, 1.0=sharpest drop-off) cutOffAngle (SoSFFloat) This angle is measured from one edge of the cone to the other
20
19 February 2016Sunghwan Min 20 Using Multiple Lights You can now experiment by adding different lights to a scene Example 4-2 contains two light sources
21
19 February 2016Sunghwan Min 21 Example 4-2 // Add a directional light SoDirectionalLight *myDirLight = new SoDirectionalLight; myDirLight->direction.setValue(0, -1, -1); myDirLight->color.setValue(1, 0, 0); root->addChild(myDirLight); // Add the point light below the transformSeparator SoPointLight *myPointLight = new SoPointLight; myTransformSeparator->addChild(myPointLight); myPointLight->color.setValue(0, 1, 0);
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.