ItsMods

Full Version: Drawing Lines with the engine
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Quote:hi peoples, here is a method to draw a line with the engine.
you will lose some fps on this method.

PHP Code:
float getAngle(DoublePoint selfDoublePoint target)
{
   
float dx target[0] - self[0]; //calculate the distance to the target on the x-axis
   
float dy target[1] - self[1]; //calculate the distance to the target on the y-axis
        
   
float dist sqrt(pow(dx2) + pow(dy2)); //calculate distance to the target by using pythagoras
   
float dangle;      
        
    if (
dy 0dangle = (M_PI 2) - (acos(dx/dist));
    else 
dangle acos(dx/dist); //calculate the angle
           
    
return dangle;        

PHP Code:
void cEngine::DrawLines()
{
    
float xy;
    
float Screen[2];    
        
DoublePoint dpLocal = {Refdef->Width/2Refdef->Height};    
    
    for(
int i=0i<MAX_PLAYERSi++)
    {
        
CEntitypEnt getValidEnt();

        if(
WorldToScreen(pEnt->vOrig, &Screen)
        {            
            
DoublePoint dpTarget = {Screen[0], Screen[1]};
            
float fAngle getAngle(dpLocaldpTarget);
            
            if(!
fAngle)
                continue;        

            
float fDist getDist();        
            
int size fdist/lineDist;            

            for(
int i=0i<sizei++)
            {
                if(
== 0)
                {
                    
= (dpLocal[0] + lineDist cos(fAngle));
                            
= (dpLocal[1] + lineDist sin(fAngle));
                    
CG_DrawPic(xy1010tRedRegisterShader("compassping_enemyfiring"7));                    
                }else
                                 {                
                        
= (lineDist cos(fAngle));
                                
= (lineDist sin(fAngle));
                        
CG_DrawPic(xy1010tRedRegisterShader("compassping_enemyfiring"7));
                                 }
            }    
        }
    }


by editing the linedist you can also make it look like a real line, or you can use other shaders

Credits:
cardoow