1

I have x,y,z vector in the 3D world and I want to make that vector have the same direction with the current camera vector position.

I use Delphi/GLScene

genpfault
  • 51,148
  • 11
  • 85
  • 139
zac
  • 4,495
  • 15
  • 62
  • 127
  • I don't understand what you're asking here. Are you asking what the current camera direction is? OpenGL doesn't have a camera; it only has matrices. So how are you building your transformations? – Nicol Bolas Feb 04 '12 at 01:22
  • I use GLScene components for Delphi it is based on OpenGL. I placed a camera with depth view of 1000 and focal length = 200.. now I have a vector with local axis and I want to transform these axis to have the same direction of the camera axis so the user can see the related vector object....thanks – zac Feb 04 '12 at 02:14
  • GLscene is a very comprehensive library. You need to spend some time exaiming the demos supplied with, and reading the help and reference http://glscene.sourceforge.net/wikka/HomePage – Simon Feb 04 '12 at 07:28

1 Answers1

2

If you wish for your vector to have the same direction as the camera, you can simply use the GLCamera.Direction vector property.

So, e.g. if your camera is currently pointing along the x axis the Direction property will be (1,0,0). You can use this vector and simply copy these x,y,z values and assign them to your x,y,z values of your vector.

If on the other hand you wish for the camera to view your object, GLScene Camera object has a property called TargetObject which will always aim the camera at your object.

Please see the general GLScene help and the GLCamera Reference help

Simon
  • 9,197
  • 13
  • 72
  • 115
  • thanks alot is there any book(s) I should get about GLScene the help seems to be missing alot of details and outdated. – zac Feb 04 '12 at 11:37
  • also one question please. I have a vector its x,y,z is 4,30,-760 this is coordinates of a mouse click I want to make the z axis = 40 but when I make this the vector appear correctly in z = 40 but x axis is wrong how to adjust it ? thanks... – zac Feb 04 '12 at 12:57
  • I think there is some demo source that show, mouse moving while restricting a value on 1 axis think this is it: http://prdownloads.sourceforge.net/glscene/ObjectsMoving.zip?download – Simon Feb 05 '12 at 05:00
  • 1
    Install all these demos, run them and have a look at what each one does. It will help: http://prdownloads.sourceforge.net/glscene/_All_GLScene_Demos.zip?download – Simon Feb 05 '12 at 05:01