Maya

5
Maya tutorial In this tutorial we will augment a real scene with virtual objects. This tutorial assumes that you have downloaded the file Maya.zip from the course web page and extracted it somewhere. 1 Camera calibration The first step is to calibrate our camera, so that we can set the camera parameters in Maya. This is done using Matlab and the camera calibration toolbox. 1. Start Matlab and change the working directory to the location where you extracted the files 2. Add the path to the calibration toolbox (folder TOOLBOX_calib) to the path using File->Set Path 3. Run calib_gui and select ’Standard’ 4. In the calibration GUI click on the button ’Image names’ and enter ’pattern’ for the basename, then enter ’j’ for jpeg 5. In the calibration GUI click on the button ’Extract grid corners’ 6. Answer all questions with the default values by pressing enter 7. Select the corners of the inner 7x5 grid in the first image in the order upper left, upper right, lower right, lower left and answer all question by pressing enter (see figure 1) 8. Select the corners of the inner 7x5 grid in the second image in the order lower left, upper left, upper right, lower right and answer all question by pressing enter (see figure 1) 9. In the calibration GUI click on the button ’Calibration’. The resulting pixel errors should be smaller than one pixel (if you clicked well they should be around 0.18) 1

Transcript of Maya

Page 1: Maya

Maya tutorial

In this tutorial we will augment a real scene with virtual objects. This tutorialassumes that you have downloaded the file Maya.zip from the course web pageand extracted it somewhere.

1 Camera calibrationThe first step is to calibrate our camera, so that we can set the camera parametersin Maya. This is done using Matlab and the camera calibration toolbox.

1. Start Matlab and change the working directory to the location where youextracted the files

2. Add the path to the calibration toolbox (folder TOOLBOX_calib) to thepath using File->Set Path

3. Run calib_gui and select ’Standard’

4. In the calibration GUI click on the button ’Image names’ and enter ’pattern’for the basename, then enter ’j’ for jpeg

5. In the calibration GUI click on the button ’Extract grid corners’

6. Answer all questions with the default values by pressing enter

7. Select the corners of the inner 7x5 grid in the first image in the order upperleft, upper right, lower right, lower left and answer all question by pressingenter (see figure 1)

8. Select the corners of the inner 7x5 grid in the second image in the orderlower left, upper left, upper right, lower right and answer all question bypressing enter (see figure 1)

9. In the calibration GUI click on the button ’Calibration’. The resulting pixelerrors should be smaller than one pixel (if you clicked well they should bearound 0.18)

1

Page 2: Maya

The second step is to find the external camera parameters of the image which wewant to augment. This is also done using the camera calibration toolbox.

1. In the calibration GUI select ’Comp. Extrinsic’ and enter ’scene’ and ’j’ toselect the image

2. Answer all questions by pressing enter and click the corners of the inner 7x5grid in the order upper left, upper right, lower right, lower left (see figure 1)

3. Run createMayaScene(KK,Rc_ext,Tc_ext,’scene.jpg’) to create the MEL-script which sets up the scene in Maya. KK are the internal camera param-eters, Rc_ext and Tc_ext are the external camera parameters of the cameraviewing our scene and the last parameter is the name of the image which isto be used as the backgound of the scene.

Figure 1: Corner points on pattern1 and pattern2 and the world coordinate systemof the scene

The next steps will be done in Maya.

1. Start Maya

2. Go to Window->Settings/Preferences->Preferences: Under Settings set theup-axis to z and under Settings->Cameras set the far clip plane to 100000.Save the changes

3. Go to Window->General Editors->Script Editor: Select File->Source Scriptand open the script you just created (setupScene.mel). Close the script edi-tor

4. Change the active camera to camera 1, by selecting Panels->Perspective->camera1 in the view panel

5. In the view go to View->Camera Attribute Editor and set the far clip planeto 10000

2

Page 3: Maya

6. In the view go to View->Image Plane->Image Plane Attributs->imagePlane1and set the depth to 9000

7. Go to Create->Polygon Primitives and disable Interactive Creation

8. Click somewhere in the view panel and press ’6’ to enable shaded rendering.Now the middle of the calibration grid should be gray.

9. Right click on the plane over the calibration grid and keep the button pressed

10. Select Assign New Material->Lambert

11. On the right in the attribute editor click on the little checkerboard next tocolor and select Checker. The plane should now show a checkerboard pat-tern. To make it look like the real calibration grid we have to change somesettings. In the attribute editor go to the second tab called place2dTexture1.Set Repeat UV to 2.5 and 3.5 respectively and Offset to 0.5 and 0.0 respec-tively and press enter. Now the checkerboard should look correct.

12. Go to Create->Polygon Primitives->Sphere to create a sphere

13. In the attribute editor go to the polySphere1 tab and set the radius to 20. Inthe pSphere1 tab set the z-value of the translation to 20. The sphere shouldnow be lying on the table.

14. Assign a color to the sphere by right clicking and selecting Assign NewMaterial->Phong. Set the color in the attribute editor to yellow.

15. Go to Create->CV Curve Tool and draw a curve on the table by setting con-trol points. Make sure that the curve also passes behind the book holders.Press enter after you set the last point.

16. In the attribute editor set the translation to 20 units in the z-direction

17. In the lower region of the window set the length of the sequence to 1000 (inthe field which contains 24.00)

18. Select animation from the drop-down menu below the menu-bar. Selectthe sphere and while holding the shift-key select the curve. go to Animate->Motion Paths->Attach to Motion Path. When you click on the play buttonin the lower right hand corner of the window you should see the spheremoving on the table. However it is still visible when passing behind thebook holders.

3

Page 4: Maya

19. Create a construction plane (Create->Construction Plane). Go to plane1 inthe attribute editor and set the rotation about the x-axis to 90 degrees. Setthe translation to -200, 110 and 100 respectively and the scaling to 350, 100and 1 respectively. Now it should be passing through the middle of the bookholders.

20. Make the plane live (Modify->Make Live). The plane should turn green andyou cannot see the bookholders anymore. To change this uncheck Planes inthe show menu in the view panel.

21. Select Polygons from the drop-down menu below the menu bar. SelectMesh->Create Polygon Tool. Press ’4’ to switch to wireframe mode. Followthe outline of the bookholders starting with the duck. Before closing thepolygon we still need to remove the small hole at the back of the duck.To do this click the first vertex of the hole while holding the ctrl button.Release the ctrl button and set the other vertices normally. Once you set thelast vertex press enter. Repeat the same procedure for the elephant. Press’6’ to go to the shaded rendering.

22. Assign the background color material to the polygons (Right click and hold,Assign New Material->Use Background). You will not see a change in theview.

23. Render the scene (Rendering in drop down menu, Render->Render CurrentFrame) and you should only see the sphere without the polygons.

24. Create a ground plane (Create->Polygon Primitives->Plane), covering thewhole table (set it’s size to 1000x2000). Move it by -1 in the z-direction.give it the background material

25. Add an ambient light (Create->Lights->Ambient Light)

26. Add a spot light (Create->Lights->Spot Light). In the attribute editor setthe intensity to 0.8 and the cutoff angle to 140. Go to the light settings andenable depth-map shadows. Set the translation to -200 100 400.

27. Go to the render settings. Select image sequence, avi and set the range of theframes to render to 1-1000. Make certain that the render camera is camera1.

28. In the Render menu select Batch Render and wait until the rendering isdone. (This can take a while).

4

Page 5: Maya

Figure 2: Screenshots of the scene after working steps 4, 11, 14, 16, 18, 19, 21and 22

5