D3D9 Rendering Issues 1.12.1.5875 menu

User Tag List

Results 1 to 1 of 1
  1. #1
    derekman007's Avatar Member
    Reputation
    6
    Join Date
    Aug 2008
    Posts
    6
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    D3D9 Rendering Issues 1.12.1.5875

    DrawPrimitive returns S_OK but I don't see the points connected.

    I have an EndScene hook where I am doing the drawing. I've injected a DLL and I hooked LoadLibrary while the process is suspended to hook Direct3DCreate9 and eventually hook the VMT containing the EndScene function.

    I've rewrote a lot of the code for wowmapper and wrote some code for Recast to generate NavMeshes for vanilla wow.
    I can successfully generate a path given two locations and I am trying to render the points connected in my EndScene hook using DrawPrimitive with the D3DPT_LINELIST primitive type.

    I'll admit that I am just beginning to learn Direct X, but any direction would be appreciated.

    I've disabled lighting, z buffer, vertex and pixel shaders and I have the vertex format set to D3DFVF_XYZRHW | D3DFVF_DIFFUSE, so the vertex data is prepared in screen coordinates.

    I know the code is not great(creating a vertex buffer every frame but I'm just trying to get something working before I refactor).

    The DrawBox and DrawLine methods use IDirect3DDevice9::Clear to draw lines.

    WoWScrnShot_090916_183027.jpg

    https://i.imgur.com/Z8Az6oy.jpg

    Code:
    struct line_vertex {
    	float x, y, z, rhw;  // The transformed(screen space) position for the vertex.
    	DWORD colour;        // The vertex colour.
    };
    
    HRESULT WINAPI EndScene_Hook(IDirect3DDevice9 *thisPtr)
    {
    	if (bRunning) {
    		std::lock_guard<std::mutex> guard(objManager.mutexObjectList);
    		for (std::vector<UnitObject*>::iterator iter = objManager.unitObjectList.begin(); iter != objManager.unitObjectList.end(); iter++) {
    			D3DXVECTOR3 in;
    			D3DXVECTOR3 inTop;
    			D3DXVECTOR3 out;
    			D3DXVECTOR3 outTop;
    			in.x = (*iter)->pos.x;
    			in.y = (*iter)->pos.y;
    			in.z = (*iter)->pos.z;
    			inTop.x = (*iter)->pos.x;
    			inTop.y = (*iter)->pos.y;
    			inTop.z = (*iter)->pos.z + 2.0f;
    			if (WorldToScreen(thisPtr, in, &out)) {
    				WorldToScreen(thisPtr, inTop, &outTop);
    				float height = abs(out.y - outTop.y);
    				float width = height / 2.0f;
    				DrawBox(thisPtr, out.x - width / 2.0f, out.y - height, width, height, D3DCOLOR_ARGB(0, 255, 0, 0));
    			}
    		}
    
    		//Draw generated path
    		if (pathLength != 0) {
    			D3DXVECTOR3* outPath = new D3DXVECTOR3[pathLength];
    			for (int i = 0; i < pathLength; i++) {
    				D3DXVECTOR3 inPath;
    				inPath.x = path[i].x;
    				inPath.y = path[i].y;
    				inPath.z = path[i].z;
    				if (WorldToScreen(thisPtr, inPath, &outPath[i])) {
    					DrawLineH(thisPtr, outPath[i].x, outPath[i].x + 5, outPath[i].y, 5, D3DCOLOR_ARGB(0, 0, 255, 0));
    				}
    			}
    
    			line_vertex* vertData = new line_vertex[pathLength];
    			for (int i = 0; i < pathLength; i++) {
    				vertData[i].x = outPath[i].x;
    				vertData[i].y = outPath[i].y;
    				vertData[i].z = 0.0f;
    				vertData[i].rhw = 1.0f;
    				vertData[i].colour = D3DCOLOR_ARGB(0, 0, 0, 255);
    			}
    			IDirect3DStateBlock9* pStateBlock;
    			thisPtr->CreateStateBlock(D3DSBT_ALL, &pStateBlock);
    			pStateBlock->Capture();
    			IDirect3DVertexBuffer9* vertexBuffer;
    
    			thisPtr->CreateVertexBuffer(sizeof(line_vertex) * pathLength, D3DUSAGE_WRITEONLY, D3DFVF_XYZRHW | D3DFVF_DIFFUSE, D3DPOOL_DEFAULT, &vertexBuffer, NULL);
    
    			VOID* pVoid;
    			vertexBuffer->Lock(0, 0, (void**)&pVoid, 0);
    			memcpy(pVoid, vertData, sizeof(line_vertex) * pathLength);
    			vertexBuffer->Unlock();
    
    			thisPtr->SetRenderState(D3DRS_LIGHTING, FALSE);
    			thisPtr->SetRenderState(D3DRS_ZENABLE, D3DZB_FALSE);
    			thisPtr->SetVertexShader(NULL);
    			thisPtr->SetPixelShader(NULL);
    			thisPtr->SetTexture(0, NULL);
    
    			thisPtr->SetFVF((D3DFVF_XYZRHW | D3DFVF_DIFFUSE));
    			thisPtr->SetStreamSource(0, vertexBuffer, 0, sizeof(line_vertex));
    			thisPtr->DrawPrimitive(D3DPT_LINELIST, 0, pathlength - 1); //S_OK
    
    			if (vertexBuffer != NULL)
    				vertexBuffer->Release();
    
    			pStateBlock->Apply();
    		}
    	}
    	return origEndScene(thisPtr);
    }
    Thanks for taking a look! maybe after some more sleep I'll find the issue.

    D3D9 Rendering Issues 1.12.1.5875

Similar Threads

  1. DirectX Rendering Overlay Issues
    By lanman92 in forum WoW Memory Editing
    Replies: 1
    Last Post: 09-05-2011, 01:10 AM
  2. DBC More issues.
    By dela in forum WoW ME Questions and Requests
    Replies: 3
    Last Post: 09-29-2006, 07:46 PM
  3. How do I render Vid's in fraps?
    By theillbehaviored in forum World of Warcraft General
    Replies: 0
    Last Post: 09-25-2006, 09:54 AM
  4. patching issue
    By Marlo in forum World of Warcraft General
    Replies: 0
    Last Post: 07-22-2006, 07:35 PM
  5. [Patch 1.11] - Known Issues (6-20-06)
    By Cypher in forum World of Warcraft General
    Replies: 1
    Last Post: 06-24-2006, 12:42 AM
All times are GMT -5. The time now is 01:52 AM. Powered by vBulletin® Version 4.2.3
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Google Authenticator verification provided by Two-Factor Authentication (Free) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search