AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Snippets and Tutorials (https://forums.alliedmods.net/forumdisplay.php?f=112)
-   -   [Effect Snippet] Bounding Box (https://forums.alliedmods.net/showthread.php?t=174743)

Mitchell 12-24-2011 14:26

[Effect Snippet] Bounding Box
 
This is a snippet i had developed a while ago, and i just now perfected it to use less variables other than what i used before, i hope it comes in handy as a effect of editing or just for fun. I have seen it in some plugins but this was made by scratch it was mainly for learning purposes.

Code:

#define RED    0
#define GRE    1
#define BLU    2
#define WHI    3

#define X    0
#define Y    1
#define Z    2

new colort[4][4] = { {255, 0, 0, 255}, {0, 255, 0, 255}, {0, 0, 255, 255}, {255, 255, 255, 255} };
new g_sprite;

public OnPluginStart()
{
    g_sprite = PrecacheModel("materials/sprites/laser.vmt");
}

stock LaserP(const Float:start[3], const Float:end[3], const color[4])
{
    TE_SetupBeamPoints(start, end, g_sprite, 0, 0, 0, 0.1, 3.0, 3.0, 7, 0.0, color, 0);
    TE_SendToAll();
}
stock LaserBOX2(const Ent)
{
    new Float:posMin[4][3], Float:posMax[4][3];
    new Float:orig[3];
   
    GetEntPropVector(Ent, Prop_Send, "m_vecMins", posMin[0]);
    GetEntPropVector(Ent, Prop_Send, "m_vecMaxs", posMax[0]);
    GetEntPropVector(Ent, Prop_Send, "m_vecOrigin", orig);

    // Incase the entity is a player i want to make the box fit..
    new String:edictname[32];
    GetEdictClassname(Ent, edictname, 32);
    if (StrEqual(edictname, "player"))
    {
        posMax[0][2] += 16.0;
    }
    //
    /*
        0    =    X
        1    =    Y
        2    =    Z
    */
    posMin[1][X] = posMax[0][X];
    posMin[1][Y] = posMin[0][Y];
    posMin[1][Z] = posMin[0][Z];
    posMax[1][X] = posMin[0][X];
    posMax[1][Y] = posMax[0][Y];
    posMax[1][Z] = posMax[0][Z];
    posMin[2][X] = posMin[0][X];
    posMin[2][Y] = posMax[0][Y];
    posMin[2][Z] = posMin[0][Z];
    posMax[2][X] = posMax[0][X];
    posMax[2][Y] = posMin[0][Y];
    posMax[2][Z] = posMax[0][Z];
    posMin[3][X] = posMax[0][X];
    posMin[3][Y] = posMax[0][Y];
    posMin[3][Z] = posMin[0][Z];
    posMax[3][X] = posMin[0][X];
    posMax[3][Y] = posMin[0][Y];
    posMax[3][Z] = posMax[0][Z];
   
    AddVectors(posMin[0], orig, posMin[0]);
    AddVectors(posMax[0], orig, posMax[0]);
    AddVectors(posMin[1], orig, posMin[1]);
    AddVectors(posMax[1], orig, posMax[1]);
    AddVectors(posMin[2], orig, posMin[2]);
    AddVectors(posMax[2], orig, posMax[2]);
    AddVectors(posMin[3], orig, posMin[3]);
    AddVectors(posMax[3], orig, posMax[3]);
   
    /*
    RED        =    RED
    BLUE    =    BLU
    GREEN    =    GRE
    WHITE    =    WHI
    */
   
    //LaserP(posMin[0], posMax[0], colort[RED]);
    //LaserP(posMin[1], posMax[1], colort[BLU]);
    //LaserP(posMin[2], posMax[2], colort[GRE]);
    //LaserP(posMin[3], posMax[3], colort[WHI]);
   
    //UP & DOWN
   
    //BORDER
    LaserP(posMin[0], posMax[3], colort[WHI]);
    LaserP(posMin[1], posMax[2], colort[WHI]);
    LaserP(posMin[3], posMax[0], colort[WHI]);
    LaserP(posMin[2], posMax[1], colort[WHI]);
    //CROSS
    LaserP(posMin[3], posMax[2], colort[WHI]);
    LaserP(posMin[1], posMax[0], colort[WHI]);
    LaserP(posMin[2], posMax[3], colort[WHI]);
    LaserP(posMin[3], posMax[1], colort[WHI]);
    LaserP(posMin[2], posMax[0], colort[WHI]);
    LaserP(posMin[0], posMax[1], colort[WHI]);
    LaserP(posMin[0], posMax[2], colort[WHI]);
    LaserP(posMin[1], posMax[3], colort[WHI]);
   
   
    //TOP
   
    //BORDER
    LaserP(posMax[0], posMax[1], colort[WHI]);
    LaserP(posMax[1], posMax[3], colort[WHI]);
    LaserP(posMax[3], posMax[2], colort[WHI]);
    LaserP(posMax[2], posMax[0], colort[WHI]);
    //CROSS
    LaserP(posMax[0], posMax[3], colort[WHI]);
    LaserP(posMax[2], posMax[1], colort[WHI]);
   
    //BOTTOM
   
    //BORDER
    LaserP(posMin[0], posMin[1], colort[WHI]);
    LaserP(posMin[1], posMin[3], colort[WHI]);
    LaserP(posMin[3], posMin[2], colort[WHI]);
    LaserP(posMin[2], posMin[0], colort[WHI]);
    //CROSS
    LaserP(posMin[0], posMin[3], colort[WHI]);
    LaserP(posMin[2], posMin[1], colort[WHI]);
   
}


LeGone 02-21-2012 08:49

Re: [Effect Snippet] Bounding Box
 
Thanks ;)

Mitchell 02-22-2012 14:54

Re: [Effect Snippet] Bounding Box
 
atleast some one likes that i posted the code :D!

tjdgns9246 02-23-2012 21:17

Re: [Effect Snippet] Bounding Box
 
Quote:

Originally Posted by Mitchell (Post 1655339)
atleast some one likes that i posted the code :D!

this will come in handy :)

thanks

Blowst 02-28-2012 15:41

Re: [Effect Snippet] Bounding Box
 
it is easy to understand.

Thanks :D

Mitchell 02-28-2012 21:14

Re: [Effect Snippet] Bounding Box
 
I think i have a more simplified one that dosent add a lot of vectors, but i would have to find it.


All times are GMT -4. The time now is 18:37.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.