XNA Creators Club Online
Page 1 of 1 (5 items)
Sort Posts: Previous Next

Determing if a 3D Model face is facing the camera

Last post 10/16/2008 8:24 PM by Tigernado. 4 replies.
  • 10/16/2008 3:38 PM

    Determing if a 3D Model face is facing the camera

    My teacher and I are trying to find a way to see if the face of a 3D model is facing the camera.

    For example, we want to model an object with a barcode on some part of it. We would want to detect when the face with the barcode on it is facing the camera.

    I was wondering if anyone here did something similiar and might have some tips.

    Leave luck to heaven.
  • 10/16/2008 4:14 PM In reply to

    Re: Determing if a 3D Model face is facing the camera

    Use the dot product of the vector representing the direction your camera is facing and the normal vector of the face the barcode is on.  Both vectors need to be normalized, of course.  The dot product is then the cosine of the angle between the vectors, and will approach -1 as the barcode more directly faces the camera; it will be zero if the barcode face is perpendicular to the camera, and will approach +1 as the barcode faces more directly away from the camera.

    Good judgment comes from experience, and experience comes from bad judgment.  -- Barry LePatner

    Sixty years ago I knew everything; now I know nothing; education is a progressive discovery of our own ignorance. -- Will Durant, American philosopher/author [1885-1981]

  • 10/16/2008 4:19 PM In reply to

    Re: Determing if a 3D Model face is facing the camera

    Get the front vector of your object.

    Get the vector from the object to the camera, and normalize it.

    Take the dot product of these two vectors.

    This will give you the cosine of the angle between them. 1 means they are exactly facing. 0 means they are at right angles. -1 means they are facing exactly opposite directions.


    XNA Framework Developer - blog - homepage
  • 10/16/2008 5:37 PM In reply to

    Re: Determing if a 3D Model face is facing the camera

    Are you talking about a virtual object and virtual camera, or a real object and a real camera? If you want to do image recognition, then I suggest you look for things that look like bar codes, and if you find something that looks enough like a bar code, that's the front. In general, image recognition of object orientation and features is becoming more of a known art these days, but it was an unsolved problem 10 years ago except for very narrow cases.

    No. Not even in the face of Armageddon. Never compromise.

    Engineering is defined as the art of skillful compromise. If you're in a school where you're trying to become a software engineer, I think you're in the wrong business...


    Jon Watte, Direct3D MVP
    Tweets, occasionally
    kW X-port 3ds Max .X exporter
    kW Animation source code
  • 10/16/2008 8:24 PM In reply to

    Re: Determing if a 3D Model face is facing the camera

    jwatte:
    Are you talking about a virtual object and virtual camera, or a real object and a real camera? If you want to do image recognition, then I suggest you look for things that look like bar codes, and if you find something that looks enough like a bar code, that's the front. In general, image recognition of object orientation and features is becoming more of a known art these days, but it was an unsolved problem 10 years ago except for very narrow cases.

    No. Not even in the face of Armageddon. Never compromise.

    Engineering is defined as the art of skillful compromise. If you're in a school where you're trying to become a software engineer, I think you're in the wrong business...


     Er, I meant in-game, sorry if I didn't make that clear enough.   My sig is from Watchmen fyi, not really reflective of how I develop or think, lol.  

     

    Thanks for the responses guys, looks to be exactly what I was looking for.

    Leave luck to heaven.
Page 1 of 1 (5 items) Previous Next