Inside Sabertooth
Learn how Sabertooth uses 3ds Max to create 3D interactive projects, including HBO Go’s Game of Thrones interactive experience
  • 1/3
You are here: Forum Home / Autodesk® Maya® / Wishlist / Promote default camera clipping planes to the preferences?
  RSS 2.0 ATOM  

Promote default camera clipping planes to the preferences?
Rate this thread
 
39057
 
Permlink of this thread  
avatar
  • cl1234
  • Posted: 24 January 2010 11:24 PM
  • Total Posts: 2
  • Joined: 25 April 2009 04:32 AM

Can we please add the default near/far clipping planes of cameras to the maya preferences.

This is a simple and I hope sensible request for Maya 2011.

Let me explain where the issue comes up. The default far clip plane is 1000 units. Let’s say the studio uses the convention 1 maya unit = 10 cm (a convention I have seen at a few studios). This means the far clip plane is 100m. For large environment work the scope of the set can be larger than 100m. For the render camera this isn’t a big deal, just set the far clip once.

The area where this is an issue is lighting. Say you want to look through a light (MMB from outliner for example). Maya adds a camera dynamically to the light - the default far clip 1000 units. For large scenes or scenes where the light is far away you either see a clipped scene or no scene at all. You must then select the shape and set the far clip to something like 10 million - voila your scene appears and you tumble the light. Then when you look through another light the first camera disappears and a second is created. If you go back to the first light you need to repeat the process all over again.

I would hope exposing this pref would be trivial. Once implemented a TD can set the default far clip to 10 million or some other large number. I hope the autodesk developers have visibility on this forum. This is a seemingly minor usability issue that would have a big impact if resolvled.

cheers,

cl



Replies: 0
avatar
  • THNKR
  • Posted: 25 January 2010 05:09 AM

There is really no need to do this anymore, except perhaps explaining how it works.

Maya stores preferences in optionVars. There are two sets of optionVars that affect cameras. The first set affects the default Cameras persp, top front, etc. The values for their clip planes are stored in the optionVars “defaultCameraFarClipValue” and “defaultCameraNearClipValue”. Their values can be set in the preferences, under Cameras.

This setting does NOT affect new cameras created by the Create > Cameras commands. Those cameras get their prefences from their own menu options. The optionVars involved are “cameraNearClip” and “cameraFarClip”. Their cvalues can be set in the option window for each command by clicking on the option box.

Lastly you have the cameras that are created from the Panels > Perspective > New command. They use neither of the optionVars mentioned above, so that command could be considered “broken”. Fortunately you can fix that yourself. I would like a new perspective camera that I create from the Panels menu to use the setting from the preferences, not the new camera options. I edited the buildPerspLookthruMenu.mel script to fix that.

The command buildPerspLookthruMenu should be changed to :

global proc buildPerspLookthruMenu( string $parentstring $panel )
{
 string $cameras[] 
= `listCameras -perspective`;

 
// Rebuild menu
 //

 
setParent -m $parent;

 
menu --deleteAllItems $parent;

 
python("from maya.app.stereo import stereoCameraRig")
 
for ($camera in $cameras)
 {
 
// Prune out any children of camera rigs. Non camera
 // rigs only have 1 camera.
 //
 
int $isMono python("stereoCameraRig.rigRoot('"+$camera+"') == ''")
 
if ($isMono)
 {
 menuItem 
-l $camera -command
  (
"lookThroughModelPanel "+$camera+" "+$panel)
 }
 }

 menuItem 
-divider true;  
 
menuItem -label (uiRes("m_buildPerspLookthruMenu.kNew")) 
 
-c ("{string $camera[] = `camera -n persp -hc \"viewSet -p Êmera\" -ncp " +
 `
optionVar -q "defaultCameraNearClipValue"` + 
 
" -fcp " 
 `
optionVar -q "defaultCameraFarClipValue"` + "`; " 
 
"viewSet -p $camera[0]; " +
 
"lookThroughModelPanel $camera[0] "+$panel+"; }")
}


Replies: 0
avatar
  • lxdengar
  • Posted: 02 June 2010 10:37 AM

I just found this message - thank you for your explanation THNKR, but I believe there’s still one area where the above code won’t solve, which is the most common way to switch camera to light positions in Maya: middle mouse dragging a light into the viewport.

This from what I could tell just does “createNode camera”. And the near and far clipping planes are the values that are set as default when these parameters are created in the C++ api, think camera as a plugin node. These are compiled into maya. 

Can anyone suggest a way to set these values, or a hook after this camera is created so we can set the clipping planes?



Replies: 0
avatar
  • THNKR
  • Posted: 02 June 2010 01:50 PM

I didn’t mention that there are two other optionVars, “ltsFarClip” and “ltsNearClip” that control the clipping plane values for a new camera created by Look Through Selected Camera. You can set the values in the option window.

MM dragging a light into the view ignores those optionVars. What I think gets executed is the lookThru command, the same that Look Through Selected Camera uses, but seems to ignore the clipping planes when you drag a light from the Outliner and default to -100000 100000. You can try for example lookThru directionalLight1 modelPanel4; that seems to do the same thing that MM dragging directionalLight1 into modelPanel4 has.

It’s not possible for us to change the way that lookthru works, but it would be very possible to come up with a way to set the clipping planes of newly created cameras with a script that is triggered by scriptJob -e cameraChange for example.



Replies: 0
avatar
  • lxdengar
  • Posted: 02 June 2010 03:03 PM

Thanks, THNKR. We will look into possible using scriptjob. We’ve avoided scriptjobs in general - it’s an overhead cost we’ve shied away from - our scenes are already complex enough, any slowdowns or overt monitoring by additional processes is costly.

You’re saying its not possible to change lookthru() with calculated bounding boxes, or default values from the prefs?

Anyway, thanks for the info. It’s definitely let us fix at least out buildPerspLookthruMenu() function.



Replies: 0
avatar
  • THNKR
  • Posted: 20 April 2011 02:05 PM

I was asked how to write a scripJob that will set the clip planes for a new camera to the a custom default when a light is MMB dragged into the persp view. This example gets the values from the default camera preferences.

proc fixClipPlane(){
    $cam 
= `lookThru -q`;
    
// ignore the default cameras
    
if ($cam == "perspShape"{
        
return;
    
}
    
else if ($cam ==  "topShape"{
        
return;
    
}
    
else if ($cam ==  "frontShape"{
        
return;
    
}
    
else if ($cam ==  "sideShape"{
        
return;
    
}
    else{
        
        
print ($cam "looks like a new camera, fix clip planes\n"); 
        
setAttr ($cam ".nearClipPlane") `optionVar -q "defaultCameraNearClipValue"`;
        
setAttr ($cam ".farClipPlane") `optionVar -q "defaultCameraFarClipValue"`; 
    
}
}

scriptJob 
-e cameraChange fixClipPlane;


Replies: 0