![]() |
|
Rotate and move transform - Printable Version +- AB4D Forum (https://forum.ab4d.com) +-- Forum: Products Forums (https://forum.ab4d.com/forumdisplay.php?fid=4) +--- Forum: Ab3d.PowerToys (https://forum.ab4d.com/forumdisplay.php?fid=9) +--- Thread: Rotate and move transform (/showthread.php?tid=4200) |
Rotate and move transform - kreativasas - 06-22-2020 Hi I need an hand. I'm using a modelmover and a model rotator to move my meshes. here is the code for modelrotator and modelmover: Code: For modelrotator i use rotatetransform3d and everything works perfetctly, but with model mover i use translatetransform3d with the same parameters but nothing change! Where i'm wrong? RE: Rotate and move transform - abenedik - 06-23-2020 I have quickly checked the code and did not find a reason why the translation would not be shown. However, the way you apply transformations is not correct - if you have multiple transformations, they should be apply with first applying scale, then rotation and finally translation. If you translate the object before rotating it, the object will be moved away from the center of rotation (0,0,0) and this will create a different rotation then it would be if the objects would be first rotated and then translated. To solve that I would advise you that for each 3D object you create a Transform3DGroup and add a RotateTransform3D and a TranslateTransform3D to the group - then assign a new instance of that Transform3DGroup to each 3D object in your scene. When you have a rotation or movement then just adjust the already applied translation or rotation. This way you will be also able to read the already applied rotation and when starting a rotation you will be able to rotate the ModelRotator to already rotated angles. Another option is to use StandardTransform3D object from Ab3d.Utilities namespace. It provides TranslateX, TranslateY, TranslateZ, ScaleX, ScaleY, ScaleZ, RotateX, RotateY and RotateZ properrties. Note that because it is not possible to derive from Transform3D, this object cannot be assigned to Transform property. Instead the StandardTransform3D provides a public Transform of type MatrixTransform3D that can be assigned to the object's Transform property. The StandardTransform3D can be assigned to the Tag property (when using objects from BaseVisual3D). If you are working on Model3D objects or ModelVisual3D objects that doe not provide Tag property, you will need to define a Disctionary<Model3D,StandardTransform3D> that will link the Model3D and StandardTransform3D. RE: Rotate and move transform - kreativasas - 08-04-2020 I'm getting crazy!!! I don't know why the translatetransform doesn't work. No matter if i have multiple transformation, they are used in different part of the code, i simply need to understand why it doesn't work. I simply create a translatetransform3d(public var myvector) and then modify values of myvector during the ModelMoved event. I use the same code with a rotatetransform3d and it works!! why!! Can someone help me? is very important! Thanks RE: Rotate and move transform - abenedik - 08-05-2020 I assume that your object was already transformed by some other transformation or its parent was transformed. For example, if the parent is rotated by 90 degrees around y axis and you then add a translation along x axis, because of the parent rotation the object will be actually translated along z axis. You can check your scene with stoping at a breakpoint, then opening Immediate Windows in Visual Studio and execute the following command there: MainViewport.DumpHierarchy(); This will display the hierarchy of your 3D scene with details about each object. The transformations are displayed as matrices - if there is only translation applied (no rotation and no scale), then the first part of the matrix is: 1 0 0 0 0 1 0 0 0 0 1 0 - after that there is translation part: OffestX OffestY OffsetY 1 So check if the object that you are moving or any of the parent objects have some rotation or other type of non-translation transformation applied. RE: Rotate and move transform - kreativasas - 08-05-2020 No other transformation! To be sure i wrote anoter simple code with only a modelmover but nothing! where i'm wrong Here's the code Code: Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.LoadRE: Rotate and move transform - abenedik - 08-05-2020 Could you please attach vb and xaml file so I can take a closer look at the whole code. Or use feedback page (https://www.ab4d.com/Feedback.aspx) and send the sample files in a zip. RE: Rotate and move transform - kreativasas - 08-10-2020 Solved! I add transformation on modelmoved handler and not on modemovedstarted and it works. Here is the code Code: Sub rotatedmove(ssender As Object, args As ModelMovedEventArgs) |