Trin Posted June 15, 2010 Report Share Posted June 15, 2010 Hi lavas, i am wondering how i can give an Orientation vector to 3D picture control camera, now i am using Setup camera method for zooming, but i like to scroll as well, so in addition to zooming, VI has the possiblity of moving upward, downward, left and right . I thought of using Modelview matrix, but really i dont know how , i need some hints, and example if possible. Looking forward for any helps Quote Link to comment
vugie Posted June 15, 2010 Report Share Posted June 15, 2010 Modelview is 4x4 matrix which consist of: - 3x3 rotation matrix in upper left corner - 3x1 translation vector at the right side - 1 in bottom right corner - zeros in the rest (1x3) try googling "modelview matrix" - this term is exactly the same as in OpenGL I think that most convenient method would be to use Setup Camera method for translation as well (storing current camera position and orientation and blocking native LV controller) Quote Link to comment
Trin Posted June 15, 2010 Author Report Share Posted June 15, 2010 I think that most convenient method would be to use Setup Camera method for translation as well (storing current camera position and orientation and blocking native LV controller) Thanks Vugi, but that is exactly my problem, i couldnt find a way to read the current camera position, as far as i understand the method is just for writing to setup camera, but how can i save the current position???? Quote Link to comment
vugie Posted June 15, 2010 Report Share Posted June 15, 2010 If you set Camera Controller to "None", current camera position is that one you recently set I tried to prepare simple example to show how to convert modelview matrix to vectors usable for Setup Camera method, but I found strange issue, which looks like a bug... so I have to dig a little bit more. Quote Link to comment
vugie Posted June 16, 2010 Report Share Posted June 16, 2010 Ok - as usual it was lack of knowledge, not a bug... Here is the method to get camera vectors from modelview matrix: As a target for "Setup Camera" [(direction*any_scalar)+position] may be used. 1 Quote Link to comment
Trin Posted June 16, 2010 Author Report Share Posted June 16, 2010 wow., that is a great sample , it applies whatever i read about modelview matrix till now. i still have some questions, you told me that i have to inactive my spherical camera? did i understand it correctly, if i do so, then i have no movement , even if i set up my camera manually, or may be i didnt understand it correctly ( I am a real newbie ) About the sample, can i use the array that of translation as a zooming factor? i mean the one that we multiply by Rotation matrix? and what do we mean by direction, is it saying how much far or near we are to eye of camera? Thanks again for the sample, i feel that now i am entering the 3D world of Labview. Quote Link to comment
vugie Posted June 16, 2010 Report Share Posted June 16, 2010 you told me that i have to inactive my spherical camera? did i understand it correctly, if i do so, then i have no movement , even if i set up my camera manually, or may be i didnt understand it correctly It applies only to LV native controller. You can change its mode either with control's context menu or with respective property. You can still program your own camera behavior and user interaction. In the other topic (I guess that both refer to the same project) you wrote that you want to catch user clicks on the control. Because native controller bases on left mouse click it would be good to turn it off and implement your own (basing on buttons, touchpad-like area, right-clicking, clicking with modifier, accelerometer based device or anything you want). About the sample, can i use the array that of translation as a zooming factor? i mean the one that we multiply by Rotation matrix? The question is what projection do you use - perspective or orthographic. If the first you can simply use camera position as a zoom. For orthographic projection moving camera along viewing direction has no effect - you have to use projection matrix (from respective property), specifically first two components of its diagonal. You may use this method for perspective projection as well. and what do we mean by direction, is it saying how much far or near we are to eye of camera? Direction is an unit vector pointing along camera's optical axis. in terms of Setup Camera method direction = ( target - position ) / ( | target - position | ) Quote Link to comment
Trin Posted June 18, 2010 Author Report Share Posted June 18, 2010 Dear Vugie, thanks for your example and also your great help on understanding the procedure. i tried to apply your sample on my vi, but the problem is when i run my vi, i have no control on camera orientation, it goes up, down , left and right, but not on my desire, i want when i zoom in, and want to see a point on left side (because of zooming it is not visible) can navigate the object to left. also here you can see my procedure for zooming, but when i want to zoom, i can do it in one face, my vi tries to keep the x and y fix and just change the Z (actually the imaginary depth of computer). after reading some Opengl codes and your hint on camera projection, i realised that there is a methode called frustum, i used it (as you can see on my shot) , i turned off the camera projection, and used it, it will do the zooming exactly like the zooming with mouse and keyboard but for navigation it will strech somehow, i just want to know your opinion, if it is a good idea or not? Thanks again, Trin p.s: i will attach screenshot and also the vi's vertarray_test1 model view and set up camera.vi vertarray_test1 new try.vi Quote Link to comment
vugie Posted June 18, 2010 Report Share Posted June 18, 2010 Dear Vugie, thanks for your example and also your great help on understanding the procedure. i tried to apply your sample on my vi, but the problem is when i run my vi, i have no control on camera orientation, it goes up, down , left and right, but not on my desire, i want when i zoom in, and want to see a point on left side (because of zooming it is not visible) can navigate the object to left. also here you can see my procedure for zooming, but when i want to zoom, i can do it in one face, my vi tries to keep the x and y fix and just change the Z (actually the imaginary depth of computer). after reading some Opengl codes and your hint on camera projection, i realised that there is a methode called frustum, i used it (as you can see on my shot) , i turned off the camera projection, and used it, it will do the zooming exactly like the zooming with mouse and keyboard but for navigation it will strech somehow, i just want to know your opinion, if it is a good idea or not? Thanks again, Trin p.s: i will attach screenshot and also the vi's Frustum defines field of view, but far and near planes are not for zoom - they are for clipping objects behind them. For orthographic projection modifying the rest of parameters may work like zoom, but the effect will be dependent on control proportions - I wouldn't recommend it. BTW, did you try shift-dragging on the control (with perspective projection)? You do strange things in your VIs... i.e. reading modelview, extracting orientation and applying it again without modification... You should relate values of camera movement to size of your object, to be sure that steps you are making are not 100x higher than the object. If you move camera to some absolute position/orientation, turn off native controller, bacause any click will be unpredictable. And assign some default values to y controls, because feeding zeros to Delanulay method crashes LabVIEW (brrrr, I had some calculations ongoing... ) Quote Link to comment
Trin Posted June 22, 2010 Author Report Share Posted June 22, 2010 (edited) You do strange things in your VIs... i.e. reading modelview, extracting orientation and applying it again without modification... :wacko:Strange thing in my vi, oh that frightened me, so i tried to find what cause this strange behaviour, YES! i am a real newbie . I thought that by writing into modelview matrix i am updating it, didnt i ? really, i am trying to wrap this discussion, but every time some new topics come can you please elaborate bit more what do you mean by "BTW, did you try shift-dragging on the control (with perspective projection)?" Edited June 22, 2010 by Trin Quote Link to comment
vugie Posted June 22, 2010 Report Share Posted June 22, 2010 I thought that by writing into modelview matrix i am updating it, didnt i ? That part is OK, but in main loop you read modelview matrix, calculate camera vectors and use them with "Setup Camera" not modifying them at all. can you please elaborate bit more what do you mean by "BTW, did you try shift-dragging on the control (with perspective projection)?" VIDEO By pressing Shift magnifying glass appears. By pressing Ctrl panning cross appears. Quote Link to comment
tonykun Posted June 22, 2011 Report Share Posted June 22, 2011 That part is OK, but in main loop you read modelview matrix, calculate camera vectors and use them with "Setup Camera" not modifying them at all. VIDEO By pressing Shift magnifying glass appears. By pressing Ctrl panning cross appears. hello Vugie, i am doing something about 3D camera position controlling with 3D Picture control, and lernt much about that here by you and Trin, thank you. but i still have a question since i startet, is there anyway to show a coordinate system in the scene, i mean the original axse of the scene? so it is pssible for the user, to adjust the position of the camera more clearly? thank you! Kun Quote Link to comment
Samapico Posted June 22, 2011 Report Share Posted June 22, 2011 (edited) I have a VI that does exactly that. Feed it with your global scene object, and it will add 3 axis in it. By default it puts them at (0,0,0), but you can specify a 4x4 homogeneous transformation matrix to where you want it. If you never used these VI snippets: Drag that image on your desktop to save it as a .png file, and drag the file in an empty block diagram. It will automagically create all the code for you. Edited June 22, 2011 by Samapico Quote Link to comment
tonykun Posted July 20, 2011 Report Share Posted July 20, 2011 thank u so much~~~ I have a VI that does exactly that. Feed it with your global scene object, and it will add 3 axis in it. By default it puts them at (0,0,0), but you can specify a 4x4 homogeneous transformation matrix to where you want it. If you never used these VI snippets: Drag that image on your desktop to save it as a .png file, and drag the file in an empty block diagram. It will automagically create all the code for you. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.