Jump to content


Software rendering - camera problem


2 replies to this topic

#1 kurlyak

    Member

  • Members
  • PipPip
  • 93 posts

Posted 06 February 2013 - 08:19 AM

Hello.

I trying to make application myself without Graphics API (like DirectX or OpenGL). I wrote my own 3D Math Library for this.

I take structure C++ for vertex buffer and I render 3D image of simple cube with perspective correct texture mapping. And now my cube in static way render good. I can rotate camera around cube. But I have one bug.

Suppose I take first tri cube, first tir of front face. Then I rotate camera from right to left by 360 degree. My tri disappears behind left edge of monitor and appears from right edge of monitor - its right. But when my tri appears from right edge monitor after rotate, it looks inverted - inverted from top-to-down and inverted from left-to-right. What is the matter? I think all problem in my software camera. Who are know why cube looks inverted? My camera had built in traditional way - is vRight, vUp, vLook vectors, then they rotate by mouse about vUp (left-right) and vRight (up-down), and then fill View Matrix with this value. In static way my camera no have bug. But when camera move by 360 degree - bug. Why?

#2 v71

    Valued Member

  • Members
  • PipPipPipPip
  • 354 posts

Posted 06 February 2013 - 09:20 AM

That sounds strange, check your visibility function, normally you have to do a cross product between the surface normal and the view direction of your camera, chances are that when you rotate the camera or the model something gets corrupted with normals, log your surfaces and normals and do a paper check , normally this is what i do when i face this kind of problems. Do you recompute surface normals on the fly ?? you shouldn't, the common way to do that is to compute the shared vertices normals for each vertex and rotate them accordingly to the camera transformations.
Check my code in the c/c++ section :
http://www.binpress.com/browse/c

#3 Stainless

    Member

  • Members
  • PipPipPipPip
  • 581 posts
  • LocationSouthampton

Posted 06 February 2013 - 09:36 AM

Sounds like a depth buffer problem to me.

When you look at it from one direction you are seeing the outside of the cube, so it looks correct.

When you look at it from the other direction you end up seeing the inside of the cube





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users