필터 지우기
필터 지우기

Position of sphere updated based on camera position/pan/rotation

조회 수: 2 (최근 30일)
Rheeda
Rheeda 2017년 3월 20일
편집: Rheeda 2017년 3월 23일
Hi,
I have a gui, where I want to plot a sphere whose position gets updated based on the camera properties.Basically, if the camera rotates, the sphere all rotates, so all movement is mirrored.
I have code which extracts the cam Position, cam Target, cam ViewAngle, camViewVector, cam RightVector and cam UpVector.
Does anyone have an idea on an efficient way this can be done?
Thanks, Rheeda

채택된 답변

Alain Kuchta
Alain Kuchta 2017년 3월 22일
I understand you would like to transform the position and rotation of a sphere based on data from a camera.
You can use an hgtransform object to apply a transformation to one or many graphics objects in unison. Using an hgtransform in your project could work as follows:
  1. Create your sphere
  2. Create an hgtransform object
  3. Make the transform the parent of the sphere graphics object
  4. Create a transformation matrix using makehgtransform based on your camera data
  5. Set the transformation matrix as the 'Matrix' property of the hgtransfrom
  6. Update the figure by calling drawnow
  7. Repeat steps 6-7 as the camera moves and rotates.
The "Transforming Objects Independently" example from the hgtransform documentation can help you get started. It can be found at the follow link:
  댓글 수: 1
Rheeda
Rheeda 2017년 3월 23일
편집: Rheeda 2017년 3월 23일
Thank you, just wondering in step 4, what do I use as the input of the makehgtransform, the camera position or the change in the camera view vector (where view vector= cam target- camera pos)?

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Graphics Performance에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by