|
|
sponsored advertisements
|
|
15th February 2010, 12:17 PM
|
#1
|
Master Contributor
|
Radar class
Simple radar class, it uses D3D9 but it can operate without D3D9 (engine)
Code:
#ifndef __RADAR_HEADER__
#define __RADAR_HEADER__
class Radar
{
public:
void SetWidth( int w );
void SetHeight( int h );
void SetX( int x );
void SetY( int y );
void SetBounds( int x, int y, int w, int h );
void Render( IDirect3DDevice9* pDevice );
private:
bool CalcPoint( vec3_t Origin, int *cx, int *cy, float range );
bool IsInSpace( int x, int y );
int rx, ry, rw, rh;
};
#endif
Code:
#include "stdafx.h"
#include "Radar.h"
void Radar::SetWidth( int w ){ this->rw = w; }
void Radar::SetHeight( int h ){ this->rh = h; }
void Radar::SetX( int x ){ this->rx = x; }
void Radar::SetY( int y ){ this->ry = y; }
void Radar::SetBounds( int x, int y, int w, int h )
{
SetX( x );
SetY( y );
SetWidth( w );
SetHeight( h );
}
void Radar::Render( IDirect3DDevice9* pDevice )
{
D3DRender Render( pDevice );
//Radar Base
Render.Fill( rx, ry, rw, rh, D3DCOLOR_RGBA( 128, 128, 128, 255 ) );
Render.Outline( rx, ry, rw, rh, 1, D3DCOLOR_RGBA( 0, 0, 0, 255 ) );
Render.Fill( rx + ( rw / 2 ), ry, 1, rw, D3DCOLOR_RGBA( 0, 0, 0, 255 ) );
Render.Fill( rx, ry + ( rh / 2 ), rw, 1, D3DCOLOR_RGBA( 0, 0, 0, 255 ) );
refDef_t *pRef = GEngineHelper.GetRef();
if( pRef == NULL )
return;
entity_t *pLocalEntity = GEngineHelper.GetEntityByIndex( GEngineHelper.GetLocalIndex() );
if( pLocalEntity == NULL )
return;
client_info_t *pLocalInfo = GEngineHelper.GetClientInfoByIndex( GEngineHelper.GetLocalIndex() );
if( pLocalInfo == NULL )
return;
for( int i = 0; i < 18; i++ )
{
entity_t *pEntity = GEngineHelper.GetEntityByIndex( i );
if( pEntity == NULL )
continue;
client_info_t *pEntityInfo = GEngineHelper.GetClientInfoByIndex( i );
if( pEntityInfo == NULL )
continue;
if( pEntity->IsAlive() == false )
continue;
if( pLocalEntity->Index == pEntity->Index )
continue;
int cx = 0, cy = 0;
if( CalcPoint( pEntity->Origin, &cx, &cy, 10.f ) == false )
continue;
D3DCOLOR RenderColor = ( pEntityInfo->IsOnSameTeam( pLocalInfo ) ) ?
D3DCOLOR_RGBA( 0, 0, 255, 255 ) : D3DCOLOR_RGBA( 255, 0, 0, 255 );
cx -= 3;
cy -= 3;
Render.Outline( cx, cy, 6, 6, 1, D3DCOLOR_RGBA( 0, 0, 0, 255 ) );
Render.Fill( cx + 1, cy + 1, 5, 5, RenderColor );
}
}
bool Radar::CalcPoint( vec3_t vec, int *nx, int *ny, float flRange )
{
float fy = ( D3DXToRadian( GEngineHelper.GetViewAngles()[ YAW ] ) - 180.f );
float fc = cos( fy );
float fs = sin( fy );
float dx = vec[ 0 ] - GEngineHelper.GetRef()->m_viewOrigin[ 0 ];
float dy = vec[ 1 ] - GEngineHelper.GetRef()->m_viewOrigin[ 1 ];
float px = dy * ( -fc ) + ( dx * fs );
float py = dx * ( -fc ) - ( dy * fs );
int irrx = ( rx + ( rw / 2 ) ) + int( px / flRange );
int irry = ( ry + ( rh / 2 ) ) + int( py / flRange );
if( IsInSpace( irrx, irry ) == false )
return false;
*nx = irrx;
*ny = irry;
return true;
}
bool Radar::IsInSpace( int x, int y )
{
return ( ( x >= rx && y >= ry ) && ( x <= ( rx + rw ) && y <= ( ry + rh ) ) );
}
The D3DRender class simply handles some D3D9 rendering techniques, replace that with your engine drawing class/functions
The colors are static, meaning you have to change them in the class, but ill upload a pic soon
|
s0beit is offline
|
|
|
15th February 2010, 03:15 PM
|
#2
|
Master Contributor
|
nice wurk
|
Ælius is offline
|
|
15th February 2010, 04:19 PM
|
#4
|
Hacked North Korea
|
Super-Terrific Neat-o job!
__________________
(12:07:17 AM) uNrEaL: One man's slap in the face is another man's slit throat
|
CallMeEclipse is offline
|
|
16th February 2010, 12:02 PM
|
#5
|
|
On a mission to release your entire project feature-by-feature? :P
|
Chod is offline
|
|
17th February 2010, 06:01 PM
|
#6
|
Master Contributor
|
not really, i just had a tiny bit of trouble converting it from source engine and thought i would save somebody some time, lol.
honestly, other than detection i don't know whats stopping anybody from making a full, awesome hack.
everything is on these boards.
|
s0beit is offline
|
|
17th February 2010, 06:10 PM
|
#7
|
|
Quote:
Originally Posted by s0beit
honestly, other than detection i don't know whats stopping anybody from making a full, awesome hack.
|
lack of skills perhaps?
|
Chod is offline
|
|
17th February 2010, 06:47 PM
|
#8
|
Broken Moderator
|
Nawh, some people just keep some things to themselves.
|
kolbybrooks is offline
|
|
18th February 2010, 08:09 PM
|
#9
|
|
Quote:
Originally Posted by s0beit
Code:
float fy = ( D3DXToRadian( GEngineHelper.GetViewAngles()[ YAW ] ) - 180.f );
|
Awesome. Thanks a lot for the source. I am adding this to my BoxESP.
What is exactly "YAW" in GetViewAngles()[ YAW ]?
|
sph4ck is offline
|
|
18th February 2010, 08:23 PM
|
#10
|
|
Code:
#define PITCH 0
#define YAW 1
#define ROLL 2
PITCH: up and down, YAW: left and right, ROLL: side to side
|
.Encore is offline
|
|
18th February 2010, 09:20 PM
|
#11
|
|
Thanks a lot
|
sph4ck is offline
|
|
All times are GMT. The time now is 09:28 PM.
|
|
sponsored advertisement |
| | |