Need to change rotation order of camera object



  • HI Team,

    I am facing a strange issue as I am not able to change the "rotation order" of my camera object from HPB to XYZ or to anything else(for both local and global). I am using cameraObj->SetRotationOrder(ROTATIONORDER_XYZLOCAL); but it is not changing the rotation order of the camera object. It is always giving the same result i.e. default HPB order. I have also used cameraObj->SetParameter(); But no success.

    How can I change the rotation order to whatever I want? Please help me.

    Thanks in advance.


  • Global Moderator

    Hello,

    I tried it in R20 and it seems to work fine:

    CameraObject* const cam = static_cast<CameraObject*>(object);
    
    cam->SetRotationOrder(ROTATIONORDER::XYZLOCAL);
    

    Do you call EventAdd() after you changed the object? Can you show your code?

    best wishes,
    Sebastian



  • @s_bach HI Sebastian,

    I tried your suggestion of adding EventAdd() after changing the rotation order but it didn't work. Also, I am sorry I can't show the code to you because of some disclosure issues.
    Can you please suggest some other ways to change the rotation order of the camera object?
    I am trying to rotate the camera order inside User Area functions.

    Thanks in Advance.


  • Global Moderator

    Hi gogeta, thanks for following up.

    With regard to what suggested by @s_bach I confirm it's actually working without any hassle in the code snippet below.

    {
    	if (!doc)
    		return maxon::IllegalArgumentError(MAXON_SOURCE_LOCATION);
    	
    	BaseObject* activeObj = doc->GetActiveObject();
    	if (!activeObj || !activeObj->IsInstanceOf(Ocamera))
    	{
    		DiagnosticOutput("No camera selected");
    		return maxon::OK;
    	}
    	
    	ROTATIONORDER rotOrder = activeObj->GetRotationOrder();
    	DiagnosticOutput("current camera rotation order: @", rotOrder);
    	activeObj->SetRotationOrder(ROTATIONORDER::XYZGLOBAL);
    	EventAdd();
    	rotOrder = activeObj->GetRotationOrder();
    	DiagnosticOutput("new camera rotation order: @", rotOrder);
    	
    	return maxon::OK;
    }
    

    With regard to your case, would also great if you could better elaborate:

    I am trying to rotate the camera order inside User Area functions.

    Last but not least, it would be very handy to check the code you're using or at least to discuss the design you're implementing to better understand what's wrong. If you don't feel safe to share here consider to send an email to sdk_support@maxon.net.

    Cheers, Riccardo



  • @r_gigante Hi Riccardo,
    Sorry for the late reply but I was not able to achieve the same with your code as well. But I did some tweaks with regards to the planes and it is working fine now.
    Though I appreciate your help a lot. Thank you guys for the help😇 .

    Regards
    Gogeta


  • Global Moderator

    Hi Gogeta, glad that in the end it worked out properly.

    Please, in order to close the topic, mark the post that actually solved your initial question or simply mark the thread as solved from the Topic Tools menu

    Cheers, Riccardo