Search Home Members Contacts
About Us
Products
Downloads
Community
Support
Pages: [1]
  Print  
Author Topic: rotate camera around a point but retain all the look at angles  (Read 687 times)
wildsurfer
Community Member
*
Posts: 77


« on: January 07, 2008, 08:55:29 PM »

hi all,


i wanted to rotate a camera around a point with the camera still looking at the point. How can i do that?i tried using the tvmath.movearoundpoint but the camera just move around the point but doesn't retain the look at angles. Can anybody help me with this?


Thanx a lot!
Logged

wildsurfer
kwazai
Community Member
*
Posts: 168


« Reply #1 on: January 07, 2008, 11:31:40 PM »

you might try something like this-(use alt-arrow to rotate round, ctrl to move in and out, shift to move leftrightupdown)-
Code:
    Private Sub mylayoutprogramfrm_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
        VALUE = radius / 10
        If InputEngine.IsKeyPressed(TrueVision3D.CONST_TV_KEY.TV_KEY_UP) And InputEngine.IsKeyPressed(TrueVision3D.CONST_TV_KEY.TV_KEY_ALT_LEFT) Then
            V_Ang = V_Ang + 1
        End If
        If InputEngine.IsKeyPressed(TrueVision3D.CONST_TV_KEY.TV_KEY_DOWN) And InputEngine.IsKeyPressed(TrueVision3D.CONST_TV_KEY.TV_KEY_ALT_LEFT) Then
            V_Ang = V_Ang - 1
        End If
        If InputEngine.IsKeyPressed(TrueVision3D.CONST_TV_KEY.TV_KEY_LEFT) And InputEngine.IsKeyPressed(TrueVision3D.CONST_TV_KEY.TV_KEY_ALT_LEFT) Then
            H_Ang = H_Ang - 1
        End If
        If InputEngine.IsKeyPressed(TrueVision3D.CONST_TV_KEY.TV_KEY_RIGHT) And InputEngine.IsKeyPressed(TrueVision3D.CONST_TV_KEY.TV_KEY_ALT_LEFT) Then
            H_Ang = H_Ang + 1
        End If
        If InputEngine.IsKeyPressed(TrueVision3D.CONST_TV_KEY.TV_KEY_UP) And InputEngine.IsKeyPressed(TrueVision3D.CONST_TV_KEY.TV_KEY_LEFTCONTROL) Then
            radius = radius - VALUE
        End If
        If InputEngine.IsKeyPressed(TrueVision3D.CONST_TV_KEY.TV_KEY_DOWN) And InputEngine.IsKeyPressed(TrueVision3D.CONST_TV_KEY.TV_KEY_LEFTCONTROL) Then
            radius = radius + VALUE
        End If
        campos = tvmath.MoveAroundPoint(camlookat, radius, H_Ang, V_Ang)
        cam.SetCamera(campos.x, campos.y, campos.z, camlookat.x, camlookat.y, camlookat.z)
        VALUE = radius / 10
        TS1 = radius / 10
        TS2 = radius / 10
        If InputEngine.IsKeyPressed(TrueVision3D.CONST_TV_KEY.TV_KEY_RIGHT) And InputEngine.IsKeyPressed(TrueVision3D.CONST_TV_KEY.TV_KEY_LEFTSHIFT) = True Then
            TS1 = TS1 + VALUE
            cam.MoveRelative(0, 0, -TS1 / 2)
        End If
        If InputEngine.IsKeyPressed(TrueVision3D.CONST_TV_KEY.TV_KEY_LEFT) And InputEngine.IsKeyPressed(TrueVision3D.CONST_TV_KEY.TV_KEY_LEFTSHIFT) = True Then
            TS1 = TS1 + VALUE
            cam.MoveRelative(0, 0, TS1 / 2)
        End If
        If InputEngine.IsKeyPressed(TrueVision3D.CONST_TV_KEY.TV_KEY_DOWN) And InputEngine.IsKeyPressed(TrueVision3D.CONST_TV_KEY.TV_KEY_LEFTSHIFT) = True Then
            TS2 = TS2 + VALUE
            cam.MoveRelative(0, TS2 / 2, 0)
        End If
        If InputEngine.IsKeyPressed(TrueVision3D.CONST_TV_KEY.TV_KEY_UP) And InputEngine.IsKeyPressed(TrueVision3D.CONST_TV_KEY.TV_KEY_LEFTSHIFT) = True Then
            TS2 = TS2 + VALUE
            cam.MoveRelative(0, -TS2 / 2, 0)
        End If
        campos = cam.GetPosition()
        camlookat = cam.GetLookAt()
    End Sub
Logged

murphys law-28th corollary- if there are five ways for something to go wrong and you circumvent all five , a sixth will promptly develop.
wildsurfer
Community Member
*
Posts: 77


« Reply #2 on: January 08, 2008, 12:41:48 AM »

thanx kwazai!


but i don't understand your codes..Can u please explain? To make my questions clearer, i created a diagram below:

This is what i wanted:


This is what i get using the tvmath.movearoundpoint:


the red figure is the meshes/landscape.

I wanted the camera to rotate around an object/landscape but still focusing on the same object.

i hope u guys get what im trying to say.

Thanx a lot!

Logged

wildsurfer
Raine
Customers
Community Member
*****
Posts: 1190


« Reply #3 on: January 08, 2008, 12:55:54 AM »

Basically you want to keep the LookAt at the same point?
Logged

Lordtek
Customers
Community Member
*****
Posts: 35


« Reply #4 on: January 08, 2008, 01:37:19 AM »

ONCE YOU GET THE CAM CORDS TO MOVE AROUND THE OBJECT SIMPLY SET THE LOOK POINT
USING .SETCAMERA X,Y,Z,LOOKX,LOOKY,LOOKZ
Logged

common sense isn't common anymore
ZaPPZion
Community Member
*
Posts: 341


« Reply #5 on: January 08, 2008, 02:04:59 AM »

but make sure you type it with caps lock off, or the compiler will go crazy Tongue
Logged
wildsurfer
Community Member
*
Posts: 77


« Reply #6 on: January 08, 2008, 02:13:20 AM »

yes, i want the camera to keep looking at a point.

How do i get the camera coords to move around the object?bcoz, if the object moves, the coords will not be the same..And i want the camera to move around the object when i push a button i.e alt+arrow or hold right mouse button.
Logged

wildsurfer
newborn
Customers
Community Member
*****
Posts: 2437


WWW
« Reply #7 on: January 08, 2008, 07:16:32 AM »

Lordtek had your answer just there....
Logged

kwazai
Community Member
*
Posts: 168


« Reply #8 on: January 08, 2008, 08:12:44 AM »

Code:
campos = tvmath.MoveAroundPoint(camlookat, radius, H_Ang, V_Ang)
        cam.SetCamera(campos.x, campos.y, campos.z, camlookat.x, camlookat.y, camlookat.z)

all the rest of the code previously posted is in regard to which button does what- alt-arrow (rotate), shift-arrow (slide), ctrl-arrow (zoom). the code adjusts the radius, H_ang,V_ang.
the .moverelative command does the slide.
your code just needs the .setcamera command after .movearaoundpoint.

mike
Logged

murphys law-28th corollary- if there are five ways for something to go wrong and you circumvent all five , a sixth will promptly develop.
wildsurfer
Community Member
*
Posts: 77


« Reply #9 on: January 09, 2008, 01:03:34 AM »

oo..ok..i'll give it a try..Thanx a lot guys!
Logged

wildsurfer
Pages: [1]
  Print  
 
Jump to:  

Powered by SMF 1.1.3 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks