I don't see any boxes now, am I missing something? :P
Code:void Worldtoscreen(LPDIRECT3DDEVICE9 Device) { ModelInfo_t* pModel = new ModelInfo_t; D3DXMATRIX ProjMatrix, ViewMatrix, WorldMatrix; D3DXVECTOR3 VectorMiddle(0, 0, 0), ScreenMiddle(0, 0, 0); Device->GetVertexShaderConstantF(204, ProjMatrix, 4); Device->GetVertexShaderConstantF(223, ViewMatrix, 4); D3DXMatrixIdentity(&WorldMatrix); D3DXMatrixTranspose(&ViewMatrix, &ViewMatrix); D3DXMatrixTranspose(&ProjMatrix, &ProjMatrix); D3DXVec3Project(&VectorMiddle, &pModel->Position3D, &Viewport, &ProjMatrix, &ViewMatrix, &WorldMatrix); if (VectorMiddle.z < 1.0f && ProjMatrix._44 < 1.0f) //not sure { pModel->Position2D.x = VectorMiddle.x; pModel->Position2D.y = VectorMiddle.y; } }
Stride and SetTexture(1.. worked for me, pixel shader was buggy. To log the shader use this:
Code:void doDisassembleShader(LPDIRECT3DDEVICE9 pDevice,char* FileName) { std::ofstream oLogFile(FileName,std::ios::trunc); if (!oLogFile.is_open()) return; IDirect3DVertexShader9* pShader; pDevice->GetVertexShader(&pShader); UINT pSizeOfData; pShader->GetFunction(NULL,&pSizeOfData); BYTE* pData = new BYTE[pSizeOfData]; pShader->GetFunction(pData,&pSizeOfData); LPD3DXBUFFER bOut; D3DXDisassembleShader(reinterpret_cast<DWORD*>(pData),NULL,NULL,&bOut); oLogFile << static_cast<char*>(bOut->GetBufferPointer()) << std::endl; oLogFile.close(); delete[] pData; pShader->Release(); } in drawindexedp: if(Stride == 40) if (GetAsyncKeyState(VK_F9) & 1) doDisassembleShader(pDevice, "shader1.txt"); or if (GetAsyncKeyState(VK_F10) & 1) if(Stride == 40) doDisassembleShader(pDevice, "shader2.txt");
ves23 (04-18-2015)
Looks similar to what I logged two patches ago, so worldtoscreen should work. I left out GetViewport maybe that's the problem?
Code:.. Device->GetViewport(&Viewport); Device->GetVertexShaderConstantF(204, ProjMatrix, 4); Device->GetVertexShaderConstantF(223, ViewMatrix, 4); ..
ves23 (04-19-2015)
Works :P puu.sh/hjnd7/c3444eb5e3.jpg Aiming at feet, but I guess I'll find the head chams, or body chams. Or maybe just fix the Y coord where the mouse goes.
Thanks for your source, your time, and the will to help some random guy
Code:void Worldtoscreen(LPDIRECT3DDEVICE9 Device) { ModelInfo_t* pModel = new ModelInfo_t; D3DXMATRIX ProjMatrix, ViewMatrix, WorldMatrix; D3DXVECTOR3 VectorMiddle(0, 0, 0), ScreenMiddle(0, 0, 0); Device->GetViewport(&Viewport); Device->GetVertexShaderConstantF(204, ProjMatrix, 4); Device->GetVertexShaderConstantF(223, ViewMatrix, 4); D3DXMatrixIdentity(&WorldMatrix); D3DXMatrixTranspose(&ViewMatrix, &ViewMatrix); D3DXMatrixTranspose(&ProjMatrix, &ProjMatrix); D3DXVec3Project(&VectorMiddle, &pModel->Position3D, &Viewport, &ProjMatrix, &ViewMatrix, &WorldMatrix); // if (VectorMiddle.z < 1.0f && ProjMatrix._44 < 1.0f) //not sure // { pModel->Position2D.x = VectorMiddle.x; pModel->Position2D.y = VectorMiddle.y; //} ModelInfo.push_back(pModel); }
Even if I use the head only chams, its still drawing a box, aiming at the feet. Why is that?
All's working good now. Thanks once again.
puu.sh/hl7G6/70572b3f7e.jpg
Hey I can use this W2S? too.
Code:bool WorldToScreen(D3DXVECTOR3 inpos, D3DXVECTOR3 &outpos, LPDIRECT3DDEVICE9 pDevice) { DWORD dwRenderData = (DWORD)GetModuleHandleA("i3GfxDx.dll") + 00000; CRenderData* RenderData = (CRenderData*)(dwRenderData); D3DXVECTOR3 vScreen; D3DVIEWPORT9 g_ViewPort; pDevice->GetViewport(&g_ViewPort); g_ViewPort.X = g_ViewPort.Y = 0; g_ViewPort.MinZ = 0; g_ViewPort.MaxZ = 1; D3DXVec3Project(&vScreen, &inpos, &g_ViewPort, &RenderData->RenderData->ProjectMatrix, &RenderData->RenderData->ViewMatrix, &RenderData->RenderData->WorldMatrix); if (vScreen.z < 1.0f && vScreen.x > 0.0f && vScreen.y > 0.0f && vScreen.x < g_ViewPort.Width && vScreen.y < g_ViewPort.Height) { outpos.x = vScreen.x; outpos.y = vScreen.y; outpos.z = vScreen.z; return true; } return false; }
Ivous, I require your help again, doing it now for a different game, UE3 Engine.
Logged this
Which one am I supposed to use? I've tried them all, if I use 4, it kinda works, rotating my screen moves the boxes, but they're all in the middle of my screenCode:// ViewProjecti******** c0 4 // CameraPosition c4 1 // BoneMatrices c5 225 // LocalToWorld c230 4 // WorldToLocal c234 3
I can make videos, if neededCode:Device->GetVertexShaderConstantF(0, ProjMatrix, 4); Device->GetVertexShaderConstantF(4, ViewMatrix, 4);
Last edited by ves23; 04-25-2015 at 02:52 PM.