1

I'm trying to show a rotating cube on Direct3D9. I can draw it with success, but during rotation some pixels are not drawn. I'd like to show every part of the cube during rotation. Each face has 0.5f as size and it's rotating with Pitch Yaw Roll from point 0, 0, 0. I tried to disable Z-Buffer or set high Z values of viewport without success. Any advice? Oh, I'm rendering it in wireframe mode. cutted image

EDIT: I confirm that the problem is on Z Buffer. I tried to translate the cube between the Z axis and it's clear that the view is between 0.0 and 1.0, but SetViewport doesn't change it and I don't understand why...

EDIT: The vertices are still cutted also if I disable ZBUFFER. I tried to set a new projection matrix with this implementation (http://pastebin.com/EVCRG6f7) using parameters (m, 90, 800 / 480, -0.1, 100) but the problem persists. cutted image 2

EDIT: I tried with OpenGL the same vertices and view matrix that I used on Direct3D9 and I have my cube correctly draw. I'm initializing it with these values:

                m_pp.BackBufferWidth            = width;
                m_pp.BackBufferHeight           = height;
                m_pp.BackBufferFormat           = D3DFMT_X8R8G8B8;
                m_pp.BackBufferCount            = 0;
                m_pp.MultiSampleType            = D3DMULTISAMPLE_NONE;
                m_pp.MultiSampleQuality         = 0;
                m_pp.SwapEffect                 = D3DSWAPEFFECT_FLIP;
                m_pp.hDeviceWindow              = hWnd;
                m_pp.Windowed                   = !fullscreen;
                m_pp.EnableAutoDepthStencil     = TRUE;
                m_pp.AutoDepthStencilFormat     = D3DFMT_D24S8;
                m_pp.Flags                      = 0;
                m_pp.FullScreen_RefreshRateInHz = (fullscreen) ? 60 : 0;

                p_device->SetRenderState( D3DRS_CULLMODE, D3DCULL_NONE );
                p_device->SetRenderState( D3DRS_FILLMODE, D3DFILL_SOLID );
                p_device->SetRenderState( D3DRS_LIGHTING, FALSE );
                p_device->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE );
                p_device->SetRenderState( D3DRS_ALPHATESTENABLE, FALSE );
                p_device->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_SRCALPHA );
                p_device->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA );
                p_device->SetRenderState( D3DRS_SCISSORTESTENABLE, FALSE );
                p_device->SetRenderState( D3DRS_ZENABLE, TRUE );
fedorqui
  • 275,237
  • 103
  • 548
  • 598
user3040937
  • 81
  • 10
  • It seems the back part of your lines are missing. What is the value of the far plane of your projection matrix? Maybe the far plane is too close and cuts of the lines. I'm not sure about the gaps. Does the backbuffer size match the window size? If the picture is scaled down when presented, gaps in lines can occur. – cdoubleplusgood Dec 21 '13 at 20:16
  • I tried to set MinZ and MaxZ with IDirect3DDevice9::SetViewport from -999.f to 999.f but it doesn't change anything. Same story if I try to disable or enable D3DRS_ZENABLE. When I took the screenshot, the window was a bit smaller than the backbuffer, but it doesn't affect the main problem : – user3040937 Dec 21 '13 at 21:43
  • The standard values for MinZ and MaxZ in the viewport are 0 and 1, respectively. I mean the values for the near and far planes specified in the projection matrix, e.g. when using `D3DXMatrixPerspectiveFovLH` or similar. – cdoubleplusgood Dec 22 '13 at 12:20
  • I'm not using D3DXMatrixPerspectiveFovLH, but an open source implementation of gluPerspective (http://pastebin.com/EVCRG6f7). If I set the values 90, 800 / 480, -0.1, 100 I obtain a distorted cube and when I rotate it, it still cut even if I disable ZBUFFER. I'll update the main post with new informations. – user3040937 Dec 22 '13 at 14:22
  • Having a negative value for the near plane seems strange. What are you trying to achieve? Have you tried +0.1 for the near plane? What happens if you set a higher value for the far plane, e.g. 1000? – cdoubleplusgood Dec 23 '13 at 10:28
  • Else if I invert near and far and I set positive or negative values (1, 100, 1000), the result is similar or the same as last two screenshots. I tried also other implementations of gluPerspective, but all of them gives me the same problem. If I use an identity matrix for view, the result is the same as the first two screenshots. Honestly I don't understand so much of 3D programming, but still I didn't found anything on the web that helps me : – user3040937 Dec 24 '13 at 15:41
  • Keep in mind that OpenGL uses column-major, right-handed coordinates. Direct3D 9 legacy fixed-function pipeline uses row-major, left-handed coordinates. Technically with the programmable shader pipeline, you can use whatever as long as you are consistent, but many developers stick with row-major, left-handed coordinates. – Chuck Walbourn Jul 08 '14 at 19:06

0 Answers0