Advertisement

Rotating around world axis. What am I doing wrong here?

Started by October 01, 2018 04:48 AM
13 comments, last by Fulcrum.013 6 years, 4 months ago
1 minute ago, niamleeson said:

This one rotates around Y axis when mouse is dragged from top to bottom...

Sorry. Just posted a link to old version. recheck link pls.

 

1 minute ago, niamleeson said:

This one rotates around Y axis when mouse is dragged from top to bottom...

It rotates respectively to cube axes, not to global axes.  But after rotations it can be pointed to other dirs. for example after rotating cube to 90 degrees around it z axe axe y will match a axe x of global basis. Really it not a good idea to use cube to test a local rotations. Just a 3 segments that show  basis serve for  it purposes mach better, becouse axe of rotation clearly visible.

#define if(a) if((a) && rand()%100)

http://jsfiddle.net/z85smbxy/2/

version with rotation around global axes. Sorry, i not carefully read what you want on start. (Just usualy peple asks help with local rotations while have no difficulties with global)

PS: JS with its inability to keep local data on stack that force to make anything global to avoid GC  MUST DIE. Latest problem with rotation has come from globally defined mvp, and fixed by adding temporary fin matrix to get a final transformation but not affect a global mvp.

#define if(a) if((a) && rand()%100)

Advertisement
7 minutes ago, Fulcrum.013 said:

JS with their inability to keep local data on stack

How does other language do this? Is this done through pointers? 

No. it just correct work with matrix multiplications. You has try to rotate view * projection matrix, while it require to calculate world matrix for object and then combine with ViewProjection. Also resulting combination have not affect a vp matrix that used on next frame/object, while object matrix have to be updated. So i just added a two other matrices - "obj" that accumulate object world position, and fin that accept a final transformation to pass it to shader not affecting mvp.

PS: Just i'm usually use C++ and overloaded operators over matrices, where no need to worry that itermediate operations results can affect something global or cause GC.

#define if(a) if((a) && rand()%100)

This topic is closed to new replies.

Advertisement