Jump to content

  • Log In with Google      Sign In   
  • Create Account

Kjell Andersson

Member Since 28 Nov 1999
Offline Last Active Aug 10 2016 03:09 PM

Posts I've Made

In Topic: Text Rendering In D3D11/12

07 August 2016 - 03:17 AM

If you want to go all-in for a good implementation of text rendering you should look up the concept of "Signed Distance Field Text Rendering".

 

The original article that introduced the concept was written by Valve and can be found here: http://www.valvesoftware.com/publications/2007/SIGGRAPH2007_AlphaTestedMagnification.pdf


In Topic: Caustics Generator for Mac OS X

27 June 2016 - 07:43 AM

The Caustics Generator is now also available in a Free version for all you Mac hobby developers.


In Topic: Help me decide - shadow under hood/cowl or not?

15 June 2016 - 11:37 AM

I like the one with the eyes more. It gives the character more personality.

 

You could go half way and keep a small shadow instead of going all black.


In Topic: Exporting mesh vertex group to text.

10 March 2016 - 12:09 PM

The following code provides you with vertices and face indices from a D3DXMesh. You will have to write the code that saves it to file yourself, but that should be easy.

LPD3DXMESH m_pD3DMesh;

void MeshXWrapper::GetMeshData(int *pMeshVertexCount, dVector3 **ppMeshVertices,
                               int *pMeshIndexCount, int **ppMeshIndices)
{
    LPDIRECT3DVERTEXBUFFER9 pVB = NULL;
    m_pD3DMesh->GetVertexBuffer(&pVB);

    struct MY_FVF {
        float x;
        float y;
        float z;
    };

    void *pbVertexData;
    if (SUCCEEDED(pVB->Lock(0, 0, &pbVertexData, D3DLOCK_READONLY))) {
        DWORD numBytesPerVertex = m_pD3DMesh->GetNumBytesPerVertex();

        int numVertices = m_pD3DMesh->GetNumVertices();
        *ppMeshVertices = new dVector3[numVertices];
        unsigned char *pVBDataPos = (unsigned char*)pbVertexData;
        for (int i=0; i < numVertices; i++) {
            (*ppMeshVertices)[i][0] = ((MY_FVF*)pVBDataPos)->x;
            (*ppMeshVertices)[i][1] = ((MY_FVF*)pVBDataPos)->y;
            (*ppMeshVertices)[i][2] = ((MY_FVF*)pVBDataPos)->z;
            (*ppMeshVertices)[i][3] = 0;
            pVBDataPos += numBytesPerVertex;
        }
        pVB->Unlock();
        *pMeshVertexCount = m_pD3DMesh->GetNumVertices();
    }


    // Index buffer

    LPDIRECT3DINDEXBUFFER9 pIB;
    m_pD3DMesh->GetIndexBuffer(&pIB);
    D3DINDEXBUFFER_DESC indexDesc;
    pIB->GetDesc(&indexDesc);

    LPVOID pbIndexData;
    if (SUCCEEDED(m_pD3DMesh->LockIndexBuffer(D3DLOCK_READONLY, &pbIndexData))) {
        *pMeshIndexCount = indexDesc.Size / sizeof(unsigned short);
        *ppMeshIndices = new int[*pMeshIndexCount];
        for (int i=0; i<(*pMeshIndexCount)/3; i++) {
            unsigned short i0 = ((unsigned short*)pbIndexData)[i*3+0];
            unsigned short i1 = ((unsigned short*)pbIndexData)[i*3+1];
            unsigned short i2 = ((unsigned short*)pbIndexData)[i*3+2];

            (*ppMeshIndices)[i*3+0] = i0;
            (*ppMeshIndices)[i*3+1] = i1;
            (*ppMeshIndices)[i*3+2] = i2;
        }
        m_pD3DMesh->UnlockIndexBuffer();
    }

    pIB->Release();
    pVB->Release();
}


In Topic: IOTD broken

27 February 2016 - 10:46 AM

Oh, forgot to mention that it was the IOTD game I meant. Silly me. But it seems to be working now again so it's all right.


PARTNERS