static void renderFrameHierarchy(Frame* frame) { if( frame->pParentFrame ) { Line line; Color color = D3DCOLOR_RGBA( 255, 255, 255, 255 ); line.start = dxPos( &frame->LTM ); line.end = dxPos( &frame->pParentFrame->LTM ); dxRenderLine( &line, &color, NULL ); } if( frame->pFrameSibling ) { renderFrameHierarchy( static_cast<Frame*>( frame->pFrameSibling ) ); } if( frame->pFrameFirstChild ) { renderFrameHierarchy( static_cast<Frame*>( frame->pFrameFirstChild ) ); } }
void CameraEffect::beginScene(unsigned int clearMode, const Vector4f& clearColor) { _effectBlocked = true; assert( Camera::_currentCamera == NULL ); Camera::_currentCamera = this; // frame synchronization phase Frame::synchronizeAll(); _dxCR( iDirect3DDevice->SetViewport( &_viewPort ) ); if( _currentEffect == engine::pfxNone || _currentEffect == engine::pfxBloom ) { IDirect3DSurface9* iDirect3DSurface; _renderTarget->iDirect3DTexture()->GetSurfaceLevel( 0, &iDirect3DSurface ); _dxCR( _rts->BeginScene( iDirect3DSurface, &_viewPort ) ); iDirect3DSurface->Release(); } else { IDirect3DSurface9* iDirect3DSurface; _newImage->iDirect3DTexture()->GetSurfaceLevel( 0, &iDirect3DSurface ); _dxCR( _rts->BeginScene( iDirect3DSurface, &_viewPort ) ); iDirect3DSurface->Release(); } if( clearMode ) _dxCR( iDirect3DDevice->Clear( 0, NULL, clearMode, wrap( clearColor ), 1.0f, 0L ) ); // setup transformation matrices if( _frame ) { D3DXMatrixInverse( &Camera::viewMatrix, NULL, &_frame->LTM ); _dxCR( iDirect3DDevice->SetTransform( D3DTS_VIEW, &Camera::viewMatrix ) ); } Camera::projectionMatrix = _projection; _dxCR( iDirect3DDevice->SetTransform( D3DTS_PROJECTION, &_projection ) ); Camera::viewPort = _viewPort; Camera::eyePos = dxPos( &_frame->LTM ); Camera::eyeDirection = dxAt( &_frame->LTM ); Camera::fov = _fov; Camera::nearClipPlane = _nearClipPlane; Camera::farClipPlane = _farClipPlane; // normalize camera eye D3DXVec3Normalize( &eyeDirection, &eyeDirection ); // frustrum planes updateFrustrum(); }
void Frame::rotateRelative(const Vector3f& axis, float angle) { Vector pos = dxPos( &TransformationMatrix ); TransformationMatrix._41 = TransformationMatrix._42 = TransformationMatrix._43 = 0.0f; TransformationMatrix._44 = 1.0f; dxRotate( &TransformationMatrix, &wrap( axis ), angle ); TransformationMatrix._41 = pos.x, TransformationMatrix._42 = pos.y, TransformationMatrix._43 = pos.z, TransformationMatrix._44 = 1.0f; dirty(); }
void ScreenCamera::beginScene(unsigned int clearMode, const Vector4f& clearColor) { assert( Camera::_currentCamera == NULL ); Camera::_currentCamera = this; // frame synchronization phase Frame::synchronizeAll(); _dxCR( iDirect3DDevice->SetViewport( &_viewPort ) ); if( clearMode ) _dxCR( iDirect3DDevice->Clear( 0, NULL, clearMode, wrap( clearColor ), 1.0f, 0L ) ); _dxCR( iDirect3DDevice->BeginScene() ); // setup transformation matrices if( _frame ) { D3DXMatrixInverse( &viewMatrix, NULL, &_frame->LTM ); _dxCR( iDirect3DDevice->SetTransform( D3DTS_VIEW, &viewMatrix ) ); } projectionMatrix = _projection; _dxCR( iDirect3DDevice->SetTransform( D3DTS_PROJECTION, &_projection ) ); viewPort = _viewPort; eyePos = dxPos( &_frame->LTM ); eyeDirection = dxAt( &_frame->LTM ); fov = _fov; nearClipPlane = _nearClipPlane; farClipPlane = _farClipPlane; // normalize camera eye D3DXVec3Normalize( &eyeDirection, &eyeDirection ); // update frustrum planes updateFrustrum(); }
Vector3f Frame::getPos(void) { if( isDirty() ) synchronizeSafe(); return wrap( dxPos( <M ) ); }