CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Jun 2014
    Posts
    2

    orthographic projection

    Can someone help me with orthographic projection?
    I'm not using ogl or dx just VS C++

    So when I flatten each respective axis onto the "view cube" (left image bellow) to create 2d projections of side, top front etc....
    then I draw that projection onto the 2d raster screen.

    The front view is by default the z axis so if I just set all Z vectors to zero I can simply draw the flattened image on the screen as is, corect??. My other question is with the side top and rear views. After I flatten them do I "unfold" them (right image below) by rotating them 90 degrees prior to drawing them as the raster image? so would I just use a standard rotation matrices to project these onto a new vector space?

    thanks you, please bear with me, I am dumb as a rock
    Attached Images Attached Images   

  2. #2
    Join Date
    Apr 2014
    Location
    in northeast ohio
    Posts
    94

    Re: orthographic projection

    this is unclear ,
    what exactly are you attempting to do ?
    are you undertaking a tutorial or trying to teach yourself by attempting a task here.

    orthographic projection vs perspective projection,
    is about how you set up your projection matrix, its really only about that

    provided you have your matrices properly organized
    snaping off a image from any side should be trivial with a orthographic projection matrix,
    or at least a matter of just taking and repeating the proper steps in the proper order

    however you must be clear , as this is a difficult topic to discuss even with correct terms.



    the view matrix can be used with orthographic projection to look at a unmoving object from positions around it
    or you could rotate and reposition your object using a world matrix in front of the camera
    then just get your buffer into a image when you have the proper shot of the object

    i cant understand what you mean by flatten it before rendering it
    doing that would probably cause artifacts most likely and mess up the rendering


    though the above origin explanations are incorrect its still a good operational pic rotational origins are always zero
    the correct term is probably translated object origin you have to understand that these operations are not cumulative
    they can be reversed but they are done in step and order
    Last edited by willmotil; June 24th, 2014 at 02:33 AM.

  3. #3
    Join Date
    Jun 2014
    Posts
    2

    Re: orthographic projection

    Quote Originally Posted by willmotil View Post
    this is unclear , what exactly are you attempting to do ?

    orthographic projection vs perspective projection,
    is about how you set up your projection matrix, its really about just that
    provided you have your matrices properly organized snaping of a image from any side should be trivial

    however you must be clear , as this is a difficult topic to discuss even with correct terms.


    the view matrix can be used with orthographic projection to look at a object
    or you could rotate and reposition your object using a world matrix in front of the camera
    just get your buffer into a image when you have the proper shot of the object
    i cant understand why you would need to flatten a object before rendering it
    thanks for the reply. I'm not asking for perspective projection just ortho and yes you have to project it to a view cube
    "projection" mean flattening in computer graphics or linear algebra for that matter. In general, the term "projection" refers to any dimension-reducing operation.

    So what I'm asking for in a nutshell is the steps to take a bunch of 3D vectors/vertices
    and view them on the 2d screen. Specifically the side and top views.

    Once you project the various orthographic views on to the view cube, do you then rotate the view cube ? if needed?

  4. #4
    Join Date
    Apr 2014
    Location
    in northeast ohio
    Posts
    94

    Re: orthographic projection

    yes you have to project it to a view cube
    ?
    wait are you trying to make a environmental reflection map
    if not
    it seems like your trying to do it backwards normally you already have a picture
    you also map or give your vertices texture uv points that relate to the image
    so each vertice has x,y,z,u,v values

    you project the 3d polygon pixels built from the vertices
    to a single 2d plane i.e. the screen ultimately thru the pixel depth buffer or sometimes called the z buffer
    but the depth buffer only keeps the z value for proper drawing to occlude pixels

    well you can do it one of two ways the second is the easiest if you made a camera class

    1)
    rotate the object to each of its sides in front of the camera and snap shot it
    you have to have set up your view matrix or camera and the object to be in a perpendicular line
    you have to make sure though that the object origin or center is really directly in line
    of the camera's position and to target normal
    you verify that by testing that a dot product of two normals each found by the following
    A = normal (camera_origin , camera_direction)
    and B = normal (camera_origin , object_center)
    dotproduct(A,B) should be 0
    if your cameras view normal is say pointing directly in the z direction 0,0,-1 and its position is 0,0,0
    you just rotate your object to each side and position it 0,0,z somewere within your view frustrum near far plane
    and snap a shot

    second way
    2) you can put your object in the world at some simple place like at position 0,0,0 dont rotate it at all
    and just move your camera around to each side and point it at the object which of course will be at 0,0,0
    then snap a shot
    you usually build a camera class that defines how the view matrix behaves
    like
    someobject.Position = new Vector3(0,0,0);
    // then move your camera
    camera.Position = new Vector3(0,10,0) ; //to the right
    camera.Direction = new Vector3(0,0,0); // point it here look left
    // snap a shot
    camera.Position = new Vector3(0,-10,0) ; //to the left well now be looking right
    ect...

    I'm not using ogl or dx just VS C++
    are you doing this all from scratch and rendering it without dx or open gl like your learning how these work ?
    well when i was younger i built my own software dx like framework just for fun i remember my number 1 problem
    was in not understanding the basic concepts of how everything worked which caused me to learn
    number 1 see how it has been done first instead of reinventing whats already been invented

    sometimes a simple library is good to start learning with have you seen the directxtk
    https://directxtk.codeplex.com/
    Last edited by willmotil; June 24th, 2014 at 03:50 AM.

  5. #5
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    4,626

    Re: orthographic projection

    ortographic "flat" projection as you seem to be needing here is essentially about dropping one of the coordinates and displaying the other 2 coordinates after correcting them for the "unfold".

    so if you have a cube of sides with length M, then the projection of a point (x,y,z) assuming unfolding as in 1
    Code:
                top
    back  left  front  right    (<- note that all these projections will preserve y)
                bottom
                 ^ (and all these projections preserve x)
    none of the projections can really 'preserve' z, since that "pops out" or "puts a hole into" your screen.

    front: -> (x,y)
    left: -> (-z,y)
    back: -> (-M-x,y)
    right: -> (M+z,y)
    bottom:-> (x,-z)
    top: -> (x,M+z)

    this assumes the front has the 0,0 in the left bottom corner, you may need to shift the entire image by (2M,M) if you need it to fit on visible coordinates if your visual projection starts at 0,0.

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

Featured