Jump to content

CYOS Rotation


david028
 Share

Recommended Posts

Hi I am learning to write shaders and I have noticed that there are a lot of different view spaces and it is not always easy to differentiate and test the output without the ability to rotate the object. It gets more complicated when spaces have to be combined such as bump mapping + environment mapping.

For example, in the cell shading demo I notice that the spot light appears to stick to the object and I would want to know if this was because I am orbiting the light source or if it would remain static when I rotated the object alone.

Is it possible to rotate the object without orbiting the camera on the CYOS site? Could this feature be added if not?

http://www.babylonjs.com/cyos/

Link to comment
Share on other sites

hi use this 2d and 3d functions

 

  vec2  rotate_xy(vec2 pr1,vec2  pr2,float alpha) {vec2 pp2 = vec2( pr2.x - pr1.x,   pr2.y - pr1.y );return  vec2( pr1.x + pp2.x * cos(alpha*3.14159265/180.) - pp2.y * sin(alpha*3.14159265/180.),pr1.y + pp2.x * sin(alpha*3.14159265/180.) + pp2.y * cos(alpha*3.14159265/180.));}
vec3  r_y(vec3 n, float a,vec3 c) {vec3 c1 = vec3( c.x,  c.y,   c.z );c1.x = c1.x;c1.y = c1.z;vec2 p = rotate_xy(vec2(c1.x,c1.y), vec2( n.x,  n.z ), a);n.x = p.x;n.z = p.y;return n; } 
 vec3  r_x(vec3 n, float a,vec3 c) {vec3 c1 = vec3( c.x,  c.y,   c.z );c1.x = c1.y;c1.y = c1.z;vec2 p = rotate_xy(vec2(c1.x,c1.y), vec2( n.y,  n.z ), a);n.y = p.x;n.z = p.y;return n; } 
 vec3  r_z(vec3 n, float a,vec3 c) {  vec3 c1 = vec3( c.x,  c.y,   c.z );vec2 p = rotate_xy(vec2(c1.x,c1.y), vec2( n.x,  n.y ), a);n.x = p.x;n.y = p.y;return n; }

http://babylonjs.com/cyos/#NF2XL without normal

http://babylonjs.com/cyos/#NF2XL#1 with normal

 

rotate_xy( [ point 1] ,  [ point 2 ] , [ angle : deg]    )   rotate point1 around point 2

r_x or r_y or r_z ( [vec3:point] , [angle: deg ] , [vec3: center] ) rotate point around center in x or y or z

http://babylonjs.com/cyos/#NF2XL#2

 

* dont forget  normal always need rotate in   center point

http://babylonjs.com/cyos/#NF2XL#3

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...