c# - WPF AxisAngleRotation3D vs. XNA CreateFromAxisAngle -
i pretty dumb 3d, question may be:
i made "viewer" program in wpf renders stuff on screen, , may rotated well. use rotation works taste:
code: wpf
transform3dgroup tg = new transform3dgroup(); tg.children.add(new scaletransform3d(sx, sy, 1)); tg.children.add(new rotatetransform3d(new axisanglerotation3d(new vector3d(1, 0, 0), rx))); tg.children.add(new rotatetransform3d(new axisanglerotation3d(new vector3d(0, 1, 0), ry))); tg.children.add(new rotatetransform3d(new axisanglerotation3d(new vector3d(0, 0, 1), rz))); tg.children.add(new translatetransform3d(x, y, z)); darabka.transform = tg; teljesmodell.children.add(darabka); i decided make program in xna, because seems bit faster, not make work.
tried way (code, xna):
pozició = matrix.createscale(sx, sy, 1f); //méretezés pozició *= matrix.createfromaxisangle(vector3.unitx, rx); //forgatás pozició *= matrix.createfromaxisangle(vector3.unity, ry); pozició *= matrix.createfromaxisangle(vector3.unitz, rz); pozició *= matrix.createtranslation(x, y, z); //középpont i tried createfromyawpitchroll, createrotationx(yz) too, without luck, stuff drawed on screen differently rotated. guessed ask brains here if know what math put between 2 technologies.
thanks in advance.
edit: tried on other forums asked details. copy / paste them here xna code like:
main
... protected override void loadcontent() { t3 = new airplane(); //this "zone" object, having zone regions , zone objects in it. of them give zone static object, player walks in kamera.példány.pozició = new vector3(1362, 627, -757); //starting pozition in zone - camera position player's starting pozition. (camera fps) ... } ... protected override void update(gametime gametime) { ... kameramozgatása(); //kamera mozgatását vezérlő billentyűk //this moves fps camera around } ... protected override void draw(gametime gametime) { ... Általánosgrafikaiobjektumok.effect.view = kamera.példány.idenézünk; //camera views Általánosgrafikaiobjektumok.effect.projection = projectionmatrix; //... , camera views set in kameramozgatása() ... t3.rajzolj(); //draw zone object ... } zone object
constructor: set effect , device same main, set pozició (a matrix containing current position , rotations) origo ... public virtual alapmodel inicializálás(float x, float y, float z, float rx, float ry, float rz, float sx, float sy) { //this initializer starts when coordinates file , not set pozició = matrix....., convert. runs 1 time. overrides set vertex positions , textures vertexdeclaration = new vertexdeclaration(device, vertexpositiontexture.vertexelements); pozició = matrix.createscale(sx, sy, 1f); //méretezés pozició *= matrix.createfromaxisangle(vector3.unitx, rx); //forgatás pozició *= matrix.createfromaxisangle(vector3.unity, ry); pozició *= matrix.createfromaxisangle(vector3.unitz, rz); pozició *= matrix.createtranslation(x, y, z); //középpont //we set starting position - else it, here main loop can modify this,... could.. not. zone, , has static objects - never moving } public void rajzolj() { //this draws object (what can zone or static object in it) foreach (effectpass pass in effect.currenttechnique.passes) { pass.begin(); foreach (elem elem in elemek) { //végigmegyünk az elemeken effect.texture = elem.textúra; //pozicionálás effect.world = pozició; //we take initialized position effect.commitchanges(); //this needed. if not use this, textures screwed device.vertexdeclaration = vertexdeclaration; device.drawuserindexedprimitives<vertexpositiontexture>(primitivetype.trianglelist, poziciók, 0, poziciók.length, elem.indexek, 0, elem.indexek.length / 3); } pass.end(); } } that's it. still guess conversion , not drawing code. else position altered. guessed matrices wpfs stacked transforms - problem , not know math convert between two. wpf code works perfectly, models in zone show good. the xna code bad somehow, because inicializálás() has wrong conversion x,y,z,etc. in it. in need help.
thanks in advance.
i advise against storing orientation in angular fashion way...
but there times when issue can solved in xna version applying z rotation first, x, y.
Comments
Post a Comment