Zap!

Daily 09/10/03 am

tureCoords[1] = D3DXVECTOR2(1.0f, 1.0f);
        pTextureCoords[2] = D3DXVECTOR2(0.0f, 0.0f);
        pTextureCoords[3] = D3DXVECTOR2(1.0f, 0.0f);
        *ppTextureCoords = pTextureCoords;
    }
    return S_OK;
}
 

Short and sweet. Just the way I like it. Now to expand this class so that we can create thick polylines and thick curves/splines. That'll come later. I think the hardest part of doing the polylines would be getting the miter or bend at the joints properly. Then again, that's not that hard.

I was also going to look into the PolyTrans exporter. That'll have to wait till tomorrow. I want to get some sleep tonight :)

Woohoo! Phaser done! I modified the phaser class to use a textured quad instead of point sprites. Much easier to manage and it looks better too. I was even able to get the alex expand/collapse in there. Isn't it funny how much power the art director has? 

 

Along with the Phaser, I added a generic "ThickLine" class. This is actually what the phaser uses. We can also use this  class for any number of things. Maybe showing movement paths, large arrows or markers on the screen, the possibilities are almost endless. Notice that I added the blue light too :) I might be going overboard with the lights, but any little tweaks will help. It looks especially good when it's animated. Speaking of animation, we can also animate the texture so we can do that funny zappy/jiggly weapon that brad wanted. Cool! Hey, I just thought of combining this with a billboarded sprite to get a long torpedo. Oooh, better yet, alpha blend the endpoints and connect the lines to get the vapor trails,  just like in Homeworld!!! Boy, this is going to be exciting!!

If you're interested, here's the guts of the code.

HRESULT CThickLineGenerator::Generate(D3DXVECTOR3 vStart,
                                      D3DXVECTOR3 vEnd,
                                      float fStartWidth,
                                      float fEndWidth,
                                      LPD3DXVECTOR3* ppPoints,
                                      LPD3DXVECTOR2* ppTextureCoords,
                                      DWORD* pdwNumPoints)
{
    // Generate points for a triangle strip.
    if(pdwNumPoints)
        *pdwNumPoints = 4; // There are always 4 points.

    // Get the vector from start to end
    D3DXVECTOR3 vDir = vEnd - vStart;
    D3DXVec3Normalize(&vDir, &vDir);

    // Use the z-axis as the other vector. For GC, these
    // lines will end up on the plane
    D3DXVECTOR3 vUp(0.0f, 0.0f, 1.0f);

    // Get the cross product
    D3DXVECTOR3 vStartRight;
    D3DXVec3Cross(&vStartRight, &vDir, &vUp);
    D3DXVec3Normalize(&vStartRight, &vStartRight);
    D3DXVECTOR3 vEndRight = vStartRight;

    // Scale the right vector by half the width
    vStartRight *= fStartWidth * 0.5f;
    vEndRight *= fEndWidth * 0.5f;

    // Calculate the points.
    //    vEnd
    // 2 ---+--- 3
    // |         | ^
    // |         | |
    // |         | |
    // 0 ---+--- 1 vDir
    //    vStart   vRight-->
    if(ppPoints)
    {
        LPD3DXVECTOR3 pPoints = new D3DXVECTOR3[4];
        pPoints[0] = vStart - vStartRight;
        pPoints[1] = vStart + vStartRight;
        pPoints[2] = vEnd - vEndRight;
        pPoints[3] = vEnd + vEndRight;
        *ppPoints = pPoints;
    }
    else
        return E_INVALIDARG;

    // Calculate the tex coords based on the above map
    if(ppTextureCoords)
    {
        LPD3DXVECTOR2 pTextureCoords = new D3DXVECTOR2[4];
        pTextureCoords[0] = D3DXVECTOR2(0.0f, 1.0f);
        pTex

7,823 views 1 replies
Reply #1 Top
Looks good.

Can't wait to see the high polygon colony ship in with the high res texture map.