Community Tip - Want the oppurtunity to discuss enhancements to PTC products? Join a working group! X
it would be very helpful if you could set the center of rotation of a model widget in vuforia studio as you like
Hi @ebeman ,
regarding to the question how to set the center of rotation - the basic answer of this is mentioned in the Post https://community.ptc.com/t5/Vuforia-Studio/Mechanism-Concept-in-Vuforia-Studio-How-to-make-rotation-more/td-p/552743
For models created in Creo Parametric always a component (part or subassembly but also the root assembly ) will rotate about the Default CSYS. Means that Coordinate System Feature in Creo Parametric what you can create via (some thing like) Datum> Coordinate System > Default Csys
This means that when you start the design and you know how thats components should rotate - e.g. the hinges axes you can consider this on the model Creation. Often is that not possible - or we have already an assembly and we need to redefine the behavior.
My opinion this could be defined only via JavaScript which will translated the rotation on specific space axis to a model Item x,y,z , rx,ry,rz . This should always work but you need to calculate it first. Creo Parametric could calculated this e.g. in Mechanism mode. Here in Studio we do not have such tools and need to develop them.
So what you need first is to extract the transformation matrix for a specific Root assembly for all components (ModelItems widgets) to the world coordinate system (Model Widget)
Then we need to create the inverse Euler transform - to calculate from transformation matrix the Euler x,y,z, rx,ry,rz. That's all but is not need some programming work to be implemented in JavaScript.
In my opinion, it should be in the functional scope of the software to rotate a model around the axis of a cylinder surface, for example. The fact that you need a function in JavaScript for this should be considered a temporary workaround.
Hello @pjahn ,
unfortunately this is not implemented yet. The question if this should be implemented or not is a question which could be discussed with different points of view. Yes, the most Cad systems provide tools to rotate component to a any space axis but this always required some preparations. E.g. In Creo Parametric we can not actually rotate any components. We can rotate components first when we create a specific constrain or mechanism join axis on the desired axis. Later when we want to move this axis - it is not trivial so we have to redefine the constrains or the mechanism connection joins so that new requirements could be achieved. On graphical system based on WebGL and Three we need to use some mathematics to have the correct space transformation. So, in Studio we can achieve such space rotations but we need some code.
I want to provide here a simple example (sample project) of the rotation where we can define dynamically the space axis of rotations. This example is simple - it will work only for component with one level deep path - and it will rotate only one component at the same time. Anyway it will demonstrate the basic principle of such solution. To rotate many components will be also easy repeating the code there . To rotate a complete subassembly - it will more complicated and requires to calculate all transformation along the part components path (the parts contained by the subassembly)
So as we can see on the gif animations we can select different parts component where we can define dynamically the rotation axis. This example is only a study - with the goal to test and demonstrate the requested functionality. Of course this functionality could extended later to a rotation of subassemblies where the component parts are located on different levels ( so means the PathID path is longer >1 and many parts are rotated at the same time around a specific space axis)
I apologize for a error in the attached project - so it is working only in preview mode. The reason is the usage of the following code which works only in preview mode:
tx = $scope.getWidgetProp("model-3","x");
ty = $scope.getWidgetProp("model-3","y");
tz = $scope.getWidgetProp("model-3","z");
rx = $scope.getWidgetProp("model-3","rx");
ry = $scope.getWidgetProp("model-3","ry");
rz = $scope.getWidgetProp("model-3","rz"); }
adapted to this (Lines Home.js 309-322:
if(window.twx.app.isPreview()) {
tx = $scope.getWidgetProp("model-3","x");
ty = $scope.getWidgetProp("model-3","y");
tz = $scope.getWidgetProp("model-3","z");
rx = $scope.getWidgetProp("model-3","rx");
ry = $scope.getWidgetProp("model-3","ry");
rz = $scope.getWidgetProp("model-3","rz"); }
else { //because this above works only in preview mode ! below imlmented slider values+ filters
tx = (50 - $scope.app.view['Home'].wdg['slider-1']['value'] )/25;
ty = (50 - $scope.app.view['Home'].wdg['slider-2']['value'] )/25;
tz = (50 - $scope.app.view['Home'].wdg['slider-3']['value'] )/25;
rx = 90*(50 - $scope.app.view['Home'].wdg['slider-4']['value'] )/50;
ry = 90*(50 - $scope.app.view['Home'].wdg['slider-5']['value'] )/50;
rz = 90*(50 - $scope.app.view['Home'].wdg['slider-6']['value'] )/50;}
so now it should work also on mobile device. Please, let me know if there is an issue with it.
Thanks (new version attached)
Regarding the models: If you use spatial tracking, you can move the spatial target to adjust the rotation center.
thx but it's about the rotation center of the model itself or parts of the model ... not the rotation center of experience preview
@ebeman The only way i think is going back again to Creo, changing the root co-ordinates (wherever you want )and then importing back to Vuforia Studio.
Sometimes while creating animations we need to change the center point to rotate the objects properly, in that case quick solution is available in illustrate as shown below :
Hi @Mohit_Kabra27 ,
I think the functionality what you mentioned is a good way to define a hinge for transformation in Creo Illustrate. Means you can define a hinge for rotation and rotate a component regarding specific axis. So such rotation along desired axis could be used into a new recorded sequence and could be played in Vuforia Studio.
... But so far I know this hinge is not available in Studio when you want to rotate outside the recorded sequence by setting of some property at run time.
The much better way is to redefine the assembly in Creo Parametric. In this case:
.. we already tried that but without success ... seems like studio isn't impressed by setting another default csys and always uses its own csys