![]() |
|
TransformTranslate3D newbie question - 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: TransformTranslate3D newbie question (/showthread.php?tid=3973) |
TransformTranslate3D newbie question - lloyd32552 - 05-02-2016 I am creating one offset polygon (1 out of 10) correctly and am attempting to draw the other 9 in a circle around the center point. I believe it is creating 10 segments but they are being drawn on top of each other. I have the TranslateTransform3D function being populated with x and z values that are calculated with a changing angle in a 'for' loop. Am I going in the right direction? Thanks for your help. RE: TransformTranslate3D newbie question - abenedik - 05-02-2016 You have forgotten to multiply x and y radius values by the scale that you are using - the correct code would be ("* mult" was missing): Code: double OutRX = 3.804 * mult;Also CreateExtrudedMeshGeometry method requires additional shapeYVector parameter - without that parameter I get exception that shapeYVector and extrudeVectors are parallel. The changed CreateModel3D method looks like: Code: private Model3D CreateModel3D()After that the following objects were created: After that I have see that you also need to rotate the created object. To do that you can use the RotateTransform3D and AxisAngleRotation3D - for example: Code: private void Page_Loaded(object sender, RoutedEventArgs e)This code produces the following result: I hope that this is what you wanted. The AxisAngleRotation3D rotates around the specified axis - up vector in our case (0,1,0) - and for the specified angle (this time in degrees). The AxisAngleRotation3D is used to create RotateTransform3D that can be set to the Transform property. The trick in your case is that RotateTransform3D by default rotates around (0,0,0) point (you can also specify any other center of rotation). And because your object is created at the exact position on the "circle" around the (0,0,0), you can simply rotate it around (0,0,0) and you get the other parts. If your object would be created so that its center would be at (0,0,0), the the RotateTransform3D would rotate it around its own center. In this case you would first need to translate it to the circle (using TranslateTransform3D(radius, 0, 0) and the apply the rotation (you can group two or more transformation with Transform3DGroup). For example you can quickly check that the objects are not intersecting with applying slight y translation to each part - this can be done with the following code: Code: var transform3DGroup = new Transform3DGroup();RE: TransformTranslate3D newbie question - lloyd32552 - 05-02-2016 Perfect!. It is just what I was hoping to see and I can't thank you enough for your support and your wonderful library. Having never programmed in 3D and being new to WPF, the learning curve is no less steep than I thought it would be, but I'm already feeling like I'm over the first hump and seeing how all the pieces fit together. I wonder, though - am I doing the right thing by having a multiplier? If I use actual dimensions, the images I draw are quite small and when I zoom into them, the magnification causes the movements to be very jerky. By multiplying everything by a static number, I can still work with actual calculated dimensions but the images draw at a much larger size and the jerkiness goes away. It's likely a better way to do this, though and if that is the case, it would be great to switch to it now. Thanks again, Abenedik! RE: TransformTranslate3D newbie question - abenedik - 05-03-2016 Hm, what do you mean by jerkiness? I have removed the modifier and it worked well for me - but I needed to lower the initial camera distance. RE: TransformTranslate3D newbie question - lloyd32552 - 05-03-2016 I just noticed if I had to zoom in a LOT, small movements in my mouse made big movements on the screen. This probably goes away if you start with the camera closer and so that is my question. If the images I want to draw are small (5" - 10"), should I draw them at full size and just use a camera that is close or should I multiply all the dimensions by a factor to start with a larger drawing. I know its all vector graphics and so it really shouldn't matter, but perhaps there is a better way to size the graphics and I'd like to start with your best practices advice. Thanks! |