Tuesday 15 June 2010

c# - Having problems with RotateTransform3D -



c# - Having problems with RotateTransform3D -

i'm making programme in which, i'm trying implement several transformations on modelvisual3d. have no problem translatetransform3d, when seek rotate object(modelvisual3d) centerx, centery , centerz coordinates going 0,0,0. don't have thought how remember lastly position of object , when rotate it, object remain there translated it. implemented rotate of object when leftmousebutton double clicked, rotation executing once.here peace of code, corresponds rotatetransform:

myviewport.mousemove += (sender, e) => { if (modelhit != null && e.leftbutton == mousebuttonstate.pressed) { point endposition = e.getposition(griddesigner); vector3d vector3d = gettranslationvector3d(modelhit, startposition, endposition); matrix3d matrix3d = modelhit.transform.value; vector3d += new vector3d(matrix3d.offsetx, matrix3d.offsety, matrix3d.offsetz); matrix3d.offsetx = vector3d.x; matrix3d.offsety = 0.2f; matrix3d.offsetz = vector3d.z; modelhit.transform = new matrixtransform3d(matrix3d); startposition = endposition; myviewport.mouseleftbuttondown += (sender, m) => { if (modelhit != null && m.leftbutton == mousebuttonstate.pressed) { rotatetransform3d rotatetransform = new rotatetransform3d(); axisanglerotation3d axisanglerotation=new axisanglerotation3d(); matrix3d modelhitcoordinates = modelhit.transform.value; rotatetransform.centerx = modelhitcoordinates.offsetx; rotatetransform.centery = 0.1; rotatetransform.centerz = modelhitcoordinates.offsetz; axisanglerotation.axis = new vector3d(0, 1, 0); axisanglerotation.angle = 0; rotatetransform.rotation = axisanglerotation; if (m.clickcount == 2) { axisanglerotation.angle += 45; modelhit.transform = rotatetransform; } } }; } };

look @ type transforming. if type "vector3d" transform method ignore rotation center. don't think correctly documented.

both type rotating , center have of type "point3d".

the intent of author of method legit. direction in space (a "vector3d") should not depend on center of rotation, translation of rotation center should not necessary. if rotate location in 3d space (a "point3d") however, center of rotation matter.

c# wpf 3d

No comments:

Post a Comment