MefistoManna

Member
  • Content count

    25
  • Joined

  • Last visited

Community Reputation

139 Neutral

About MefistoManna

  • Rank
    Member
  1. Changing settings after initialization

    Now I release all and it's working, thank you very much!
  2. Changing settings after initialization

    Do I have to reset my device? because if I use only this function, I get blackscreen.
  3. I am Initializing directx in this way: [source lang="cpp"] D3DPRESENT_PARAMETERS d3dpp; LPDIRECT3D9 g_pD3D = NULL; if( NULL == ( g_pD3D = Direct3DCreate9( D3D_SDK_VERSION ) ) ) return false; ZeroMemory( &d3dpp, sizeof(d3dpp) ); d3dpp.Windowed = true; d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; d3dpp.BackBufferFormat = D3DFMT_A8R8G8B8; d3dpp.AutoDepthStencilFormat = D3DFMT_D16; d3dpp.BackBufferCount = 1; d3dpp.MultiSampleQuality = 0; d3dpp.hDeviceWindow = hwnd; d3dpp.EnableAutoDepthStencil = true; d3dpp.AutoDepthStencilFormat = D3DFMT_D24S8; d3dpp.Flags = 0; d3dpp.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT; d3dpp.MultiSampleType = D3DMULTISAMPLE_8_SAMPLES; //d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; if( FAILED( g_pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hwnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &g_D3DDevice ) ) )[/source] Now how can I change after initialization my settings (for example MultiSampleType)? Sorry for stupid question.
  4. I want to get this result [url="http://www.ventuz.com/support/help/v3_01/TransformationGizmo.html"]http://www.ventuz.co...ationGizmo.html[/url] in my editor for translate, rotate and scale my mesh. But how can I do? I am quite confused. Can I use a mesh for the arrows? ps: My picking system working perfectly for one or more mesh. Thanks you.
  5. Trasform Arrow.

    Hi guys, I am working on a lever editor, I already make a picking, now, for traslate, scale and rotate the meshes I am going to render the arrows (udk, cryengine 3 style): [IMG]http://i45.tinypic.com/1givph.png[/IMG] but they have to: Always point along the x ,y and z axis. Always extend from the center of the object. Always the same size; I don't have any idea for do this.How can I do? Do I have to do with a mesh? Sorry for my english.
  6. Problem with picking

    ahhh for the moment it's working, but if there is a clearest method it' s better.
  7. Problem with picking

    Thanks again, I modified my code like you [i]said[/i]...it's incredible still don't work for scaled mesh... I did some research and this is my same problem [url="http://www.gamedev.net/topic/386313-picking-the-closest-mesh-problem/"]http://www.gamedev.n...t-mesh-problem/[/url] but a concrete solution I did't find. EDIT. I solved by multiply the maximum scale factor of 3 dimensions (x,y,z) for the distance, thanks for your help.
  8. Problem with picking

    It still don't work [img]http://public.gamedev.net//public/style_emoticons/default/wacko.png[/img] .I am doing in this way: [source lang="cpp"] g_D3DDevice_->GetTransform(D3DTS_PROJECTION, &matProj ); g_D3DDevice_->GetTransform(D3DTS_VIEW, &matView); g_D3DDevice_->GetTransform(D3DTS_WORLD, &matWorld); g_D3DDevice_->GetViewport( &m_Viewport ); D3DXMatrixInverse(&ImatView, NULL, &matView ); D3DXMatrixInverse(&ImatWorld, NULL, &matWorld); v.x = ( ( ( 2.0f * Cursor.x ) / m_Viewport.Width ) - 1 ) / matProj._11; v.y = -( ( ( 2.0f * Cursor.y ) / m_Viewport.Height ) - 1 ) / matProj._22; v.z = 1.0f; D3DXMATRIX mWorldView = matWorld * matView; D3DXMATRIX m; D3DXMatrixInverse( &m, NULL, &mWorldView ); rayDir.x = v.x * m._11 + v.y * m._21 + v.z * m._31; rayDir.y = v.x * m._12 + v.y * m._22 + v.z * m._32; rayDir.z = v.x * m._13 + v.y * m._23 + v.z * m._33; rayOrigin.x = m._41; rayOrigin.y = m._42; rayOrigin.z = m._43; D3DXVec3TransformCoord(&rayOrigin,&rayOrigin,&ImatWorld); D3DXVec3TransformNormal(&rayDir,&rayDir,&ImatWorld); D3DXVec3Normalize(&rayDir,&rayDir); D3DXIntersect(g_Mesh[NumModel], &rayOrigin, &rayDir, &picked, NULL, NULL, NULL, &dist, AllHit, HitCount); [/source] If I multiply matworld and matview the picking is completly wrong.
  9. Problem with picking

    Thanks ankhd, I do this, and it works perfectly, but the problem is when the mesh is traformed. I think that it' s a wrong use of matrix. Do I have to use the inverse of matrix obtained with the function GetTrasform or the matrix of single mesh?
  10. Problem with picking

    Hi guys, sorry for my English, I have this problems with picking ray on multiple mesh: 1) if I get the world matrix in this way (with GetTrasform) , the picking result is wrong when I traslate or scale the meshes (work on original position or size) 2) Else if I pass in the function the single meshes 's world matrix (array) the result is correct but if I scale the mesh, the ray pick more distant mesh and I have to get close for get the correct result. Here is my code (I have other function that get the closest mesh, but I am sure that the problems is here): [source lang="cpp"] if(m_Input::MouseButtonDown(0)) { g_D3DDevice_->GetTransform(D3DTS_PROJECTION, &matProj ); g_D3DDevice_->GetTransform(D3DTS_VIEW, &matView); g_D3DDevice_->GetTransform(D3DTS_WORLD, &matWorld); g_D3DDevice_->GetViewport( &m_Viewport ); D3DXMatrixInverse(&ImatView, NULL, &matView ); D3DXMatrixInverse(&ImatWorld,NULL,&matWorld); v.x = ( ( ( 2.0f * Cursor.x ) / m_Viewport.Width ) - 1 ) / matProj._11; v.y = -( ( ( 2.0f * Cursor.y ) / m_Viewport.Height ) - 1 ) / matProj._22; v.z = 1.0f; rayDir.x = v.x*ImatView._11 + v.y*ImatView._21 + v.z*ImatView._31; rayDir.y = v.x*ImatView._12 + v.y*ImatView._22 + v.z*ImatView._32; rayDir.z = v.x*ImatView._13 + v.y*ImatView._23 + v.z*ImatView._33; rayOrigin.x = ImatView._41; rayOrigin.y = ImatView._42; rayOrigin.z = ImatView._43; D3DXVec3TransformCoord(&rayOrigin,&rayOrigin,&ImatWorld); D3DXVec3TransformNormal(&rayDir,&rayDir,&ImatWorld); D3DXVec3Normalize(&rayDir,&rayDir); D3DXIntersect(g_Mesh[NumModel], &rayOrigin, &rayDir, &picked, NULL, NULL, NULL, &dist, NULL, NULL); if(picked) { NumMeshHit[NumHit] = NumModel; MeshDist[NumHit] = dist; NumHit++; } } [/source] Sorry again for my bad English.
  11. Incorrect picking distance

    Any idea? How is it possible? How do you do for trasformated mesh picking?
  12. I read this: [url="http://www.gamedev.net/topic/559814-incorrect-picking-of-scaled-models/"]http://www.gamedev.net/topic/559814-incorrect-picking-of-scaled-models/[/url] and this is a big problem because nobody understood how to do. But these are very old discussion. Currently, there are somebody that know how fix it?
  13. Engine performance optimization

    Thanks, you were very helpful. I will do more experience and I will understand how to do progressively.
  14. What kind of things can I do and what can't I do for earn any FPS? Sorry for my bad English and thanks you.
  15. Sorry for my english ;). I picked mesh with this code: [CODE] void :Pick(int Num, std::vector<LPD3DXMESH> g_Mesh) { if(m_Input::MouseButtonDown(0)) { POINT Cursor; GetCursorPos( &Cursor ); ScreenToClient( m_Input::GetHandle(), &Cursor ); D3DVIEWPORT9 m_Viewport; g_D3DDevice_->GetViewport( &m_Viewport ); D3DXVECTOR3 v; D3DXMATRIX matProj; g_D3DDevice_->GetTransform( D3DTS_PROJECTION, &matProj ); v.x = ( ( ( 2.0f * Cursor.x ) / m_Viewport.Width ) - 1 ) / matProj._11; v.y = -( ( ( 2.0f * Cursor.y ) / m_Viewport.Height ) - 1 ) / matProj._22; v.z = 1.0f; D3DXMATRIX m; D3DXVECTOR3 rayOrigin,rayDir; D3DXMATRIX view; g_D3DDevice_->GetTransform(D3DTS_VIEW, &view); D3DXMatrixInverse( &m, NULL, &view ); rayDir.x = v.x*m._11 + v.y*m._21 + v.z*m._31; rayDir.y = v.x*m._12 + v.y*m._22 + v.z*m._32; rayDir.z = v.x*m._13 + v.y*m._23 + v.z*m._33; rayOrigin.x = m._41; rayOrigin.y = m._42; rayOrigin.z = m._43; D3DXMATRIX matInverse; D3DXMATRIX world; g_D3DDevice_->GetTransform(D3DTS_WORLD, &world); D3DXMatrixInverse(&matInverse,NULL,&world); D3DXVECTOR3 rayObjOrigin,rayObjDirection; D3DXVec3TransformCoord(&rayObjOrigin,&rayOrigin,&matInverse); D3DXVec3TransformNormal(&rayObjDirection,&rayDir,&matInverse); D3DXVec3Normalize(&rayObjDirection,&rayObjDirection); D3DXIntersect(g_Mesh[Num], &rayObjOrigin, &rayObjDirection, &picked, NULL, NULL, NULL, &dist, NULL, NULL); if(picked) { picked[Num] = true; } } } [/CODE] Now, if the mesh is scaled or rotated, this work perfectly. But when it is translated the code doesn't work because after the trasformation, i can pick the mesh only at initial point (0, 0, 0). What can I do? I readed other discussion but i don't find the solution.