Raised This Month: $ Target: $400
 0% 

[Effect Snippet] Bounding Box


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Mitchell
~lick~
Join Date: Mar 2010
Old 12-24-2011 , 14:26   [Effect Snippet] Bounding Box
Reply With Quote #1

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]);
    
}

Last edited by Mitchell; 12-24-2011 at 14:27.
Mitchell is offline
LeGone
Senior Member
Join Date: Dec 2006
Location: Germany
Old 02-21-2012 , 08:49   Re: [Effect Snippet] Bounding Box
Reply With Quote #2

Thanks ;)
LeGone is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 02-22-2012 , 14:54   Re: [Effect Snippet] Bounding Box
Reply With Quote #3

atleast some one likes that i posted the code !
Mitchell is offline
tjdgns9246
Member
Join Date: Dec 2009
Old 02-23-2012 , 21:17   Re: [Effect Snippet] Bounding Box
Reply With Quote #4

Quote:
Originally Posted by Mitchell View Post
atleast some one likes that i posted the code !
this will come in handy

thanks
__________________
Sorry for my strange grammar.
I'm Korean who you might already know.
So, I need your understanding.
Thanks.
tjdgns9246 is offline
Blowst
Senior Member
Join Date: Feb 2011
Location: Korea, Republic of
Old 02-28-2012 , 15:41   Re: [Effect Snippet] Bounding Box
Reply With Quote #5

it is easy to understand.

Thanks
__________________
Sorry about my poor English


Last edited by Blowst; 02-28-2012 at 15:42.
Blowst is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 02-28-2012 , 21:14   Re: [Effect Snippet] Bounding Box
Reply With Quote #6

I think i have a more simplified one that dosent add a lot of vectors, but i would have to find it.
Mitchell is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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