### Author Topic: Help - world to camera space  (Read 1269 times)

#### Thomas.

• double
• Posts: 833
##### Help - world to camera space
« on: August 20, 2012, 01:01:07 pm »
Please, how can I get vector from world space in camera space?

#### EgonOlsen

• Posts: 11829
##### Re: Help - world to camera space
« Reply #1 on: August 20, 2012, 04:07:17 pm »

#### Thomas.

• double
• Posts: 833
##### Re: Help - world to camera space
« Reply #2 on: August 20, 2012, 04:56:55 pm »
I somehow missed this method But I need transform normalized vector, this method works with SimpleVector like with a point in world space, not like a vector.

#### EgonOlsen

• Posts: 11829
##### Re: Help - world to camera space
« Reply #3 on: August 20, 2012, 09:09:57 pm »
If it's about the direction only, just multiply the vector in question with the matrix returned by Camera.getBack().

#### Thomas.

• double
• Posts: 833
##### Re: Help - world to camera space
« Reply #4 on: August 20, 2012, 09:31:22 pm »
Thanks I have two working versions.

This version seems be faster
Code: [Select]
`SimpleVector vec = new SimpleVector(dir); Matrix back = cam.getBack();back = back.invert();vec.matMul(back);`
and this also working
Code: [Select]
`SimpleVector xA = cam.getXAxis();SimpleVector yA = cam.getYAxis();SimpleVector zA = cam.getZAxis();SimpleVector vec = new SimpleVector();vec.x = dir.x * xA.x + dir.y * xA.y + dir.z * xA.z;vec.y = dir.x * yA.x + dir.y * yA.y + dir.z * yA.z;vec.z = dir.x * zA.x + dir.y * zA.y + dir.z * zA.z;`