Results 1 to 9 of 9

Thread: Rotating an object to face the camera.

  1. #1

    Thread Starter
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    I would like an algorithm to "point" a surface of an object toward the camera. I know the position of the camera, and I know the centerpoint of the surface. Would anyone here know how to accomplish this?
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  2. #2
    Frenzied Member
    Join Date
    Mar 2000
    Posts
    1,089
    I know the maths behind it and should be able to come up with an algorithm, but I'd need to know more about how you're storing your surface. And other parts of your object.
    If it wasn't for this sentence I wouldn't have a signature at all.

  3. #3

    Thread Starter
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    It's just a simple quad in OGL that has two sides, mapped with a texture. It's located in variables stars(i).x,stars(i).y,stars(i).z, and the camera is cam.x, cam.y, cam.z. After translation, the points are

    -1.0,-1.0, 0.0
    -1.0, 1.0, 0.0
    1.0, 1.0, 0.0
    1.0,-1.0, 0.0

    If you use OGL you will know what I mean. It means that the center point of translation is now 0. This makes it easy to make coordinate systems for each polygon.

    There are two surfaces, and obviously I would just do a Y rotation of 180 degrees to get the opposite side. I am running a particle engine and the stars must be visible at all times.
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  4. #4

    Thread Starter
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    Unfortunately I cannot understand it, HarryW. I need VB CODE to do this, PLEASE! Don't refer me to a website, I will get confused. I need CODE!!!
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  5. #5
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827
    Hey, that was just a geometry tutorial, I already said I'll let Sam handle this since I don't understand it too well. The geometry tutorial was something you might want to look at if you want to learn some more geometry.
    Harry.

    "From one thing, know ten thousand things."

  6. #6
    Frenzied Member
    Join Date
    Mar 2000
    Posts
    1,089
    I'm afraid I've never used OGL so that doesn't help much.


    Can you get the coordinates of 2 other points on the surface
    ? I could do it off that. You'll also need the coords of the point you wish to rotate the object about. (If you want to rotate about the centre of the surface then it's much easier, so tell me if that's what you want to do)


    I'll have to refresh my memory on the maths first but I'll put the algo up when I work it out.
    If it wasn't for this sentence I wouldn't have a signature at all.

  7. #7

  8. #8
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    you could get the cross product of 2 offsetvectors of the surface, divide it by it's length and multiply with distance to camera.
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  9. #9

    Thread Starter
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    mebbe some code would be more helpful..
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width