PDA

View Full Version : API Xray


Tranimatronic
05-15-2009, 06:45 PM
Is there any way to query whether Xray is on or off using API ?
Ive looked in MCamera, M3dView and MDrawRequest...... nothing ;(
The only reference ive found to xray is in M3DModelView, but im pretty sure this isnt what im looking for.
I have created an MPxHardwareShader which renders solid in Xray mode. Im trying to query whether its on or not and if so set the transparent flag in the shader.

Anyone any ideas ?

T

JoshM
05-15-2009, 07:54 PM
I'm not sure where or how many times you are going to be calling this but you may be able to use:


MCommandResult myCmd;
MGlobal::executeCommand("modelEditor -q -xray modelPanel", myCmd);
myCmd.getResult()



I know making a lot of these calls will slow down the performance of your plug-in but if its only during initialization I don't think it would be too much of a problem.

HTH,
Josh

Keilun
05-15-2009, 08:13 PM
Yeah unfortunately I think the only way to go about this is to queue up some MUiMessage::add3dViewPreRenderCallback() and query the xray flag via MEL as JoshM said per panel, per draw. The MEL call isn't that expensive, but it's unfortunate that it needs to be executed per frame/per view.

Tranimatronic
05-15-2009, 08:38 PM
Thanks for the pointers guys - I was trying to keep away from MEL as this check is in the geometry() section of the shader and if true it will alter the transparency value of the output, but I suppose I could add a boolean into the shaderNode and add a callback that changes this value and keep a check on xray...... maybe

it seems a long way round of doing it as I can get almost every other state from MDrawRequest and M3dView....

anyway - thanks for the help !
T

Keilun
05-15-2009, 09:05 PM
In order to get the transparency to work properly, I believe you also need to modify the hasTransparency() or transparencyOptions() method as well. While the geometry() method is fine to set the transparency for the shader, the object won't be sorted properly if the hasTransparency() method doesn't let Maya know that it is a transparent object. I'm pretty sure transparencyOptions()/hasTransparency() is invoked prior to the geometry() and the bind() call to determine if the object shaded by your shader needs to be binned as a transparent object.

Tranimatronic
05-15-2009, 09:57 PM
aaah - okay - well that might actually work in my favour - meaning I call the checks elsewhere, change the isTransparent() and then a refresh when the value changes.


actually on thinking about it - could I not set the object as transparent in the init and change the openGL transparency depending on a "xray on" boolean added to the shader - letting openGL do the work ??

Ill post my results

Thanks again :thumbsup:

CGTalk Moderation
05-15-2009, 09:57 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.