Perfect 3D Bounding Box

Posts 115 of 32 · Page 1 of 3
Perfect 3D Bounding Box
What I've done:
-Made it rescale to fit character size.
You should no longer experience the bug where it doesn't fit properly, **EVEN** when crouched.

Enjoy.

Code:
__forceinline void RenderBoundingBox(LPDIRECT3DDEVICE9 D3DDevice, CFPlayer* Player, D3DCOLOR ESPColor) {
	PlayerObject* ThisObject = (Player -> Object);
	D3DXVECTOR3 Head = GetBonePosition(ThisObject, 6);
	D3DXVECTOR3 FootMidpoint = D3DXVECTOR3(Head.x, GetBonePosition(ThisObject, 28).y, Head.z);
	float HeightFactor = ((CalculateAbsoluteValue((Head - FootMidpoint).y) / 2) * 1.15);
	D3DXVECTOR3 BaseDrawPoint = (GetMidpoint(Head, GetBonePosition(ThisObject, 3)) - D3DXVECTOR3(0, (HeightFactor / 2), 0));
	D3DXVECTOR3 DrawPoint1 = (BaseDrawPoint + D3DXVECTOR3(-50, HeightFactor, -50));
	D3DXVECTOR3 DrawPoint2 = (BaseDrawPoint + D3DXVECTOR3(-50, -HeightFactor, -50));
	D3DXVECTOR3 DrawPoint3 = (BaseDrawPoint + D3DXVECTOR3(50, -HeightFactor, -50));
	D3DXVECTOR3 DrawPoint4 = (BaseDrawPoint + D3DXVECTOR3(50, HeightFactor, -50));
	D3DXVECTOR3 DrawPoint5 = (BaseDrawPoint + D3DXVECTOR3(-50, HeightFactor, 50));
	D3DXVECTOR3 DrawPoint6 = (BaseDrawPoint + D3DXVECTOR3(-50, -HeightFactor, 50));
	D3DXVECTOR3 DrawPoint7 = (BaseDrawPoint + D3DXVECTOR3(50, -HeightFactor, 50));
	D3DXVECTOR3 DrawPoint8 = (BaseDrawPoint + D3DXVECTOR3(50, HeightFactor, 50));
	if (WorldToScreen(D3DDevice, &DrawPoint1) && WorldToScreen(D3DDevice, &DrawPoint2) && WorldToScreen(D3DDevice, &DrawPoint3) && WorldToScreen(D3DDevice, &DrawPoint4) && WorldToScreen(D3DDevice, &DrawPoint5) && WorldToScreen(D3DDevice, &DrawPoint6) && WorldToScreen(D3DDevice, &DrawPoint7) && WorldToScreen(D3DDevice, &DrawPoint8)) {
		DrawD3DLine(D3DDevice, DrawPoint1.x, DrawPoint1.y, DrawPoint2.x, DrawPoint2.y,  ESPColor);
		DrawD3DLine(D3DDevice, DrawPoint2.x, DrawPoint2.y, DrawPoint3.x, DrawPoint3.y,  ESPColor);
		DrawD3DLine(D3DDevice, DrawPoint3.x, DrawPoint3.y, DrawPoint4.x, DrawPoint4.y,  ESPColor);
		DrawD3DLine(D3DDevice, DrawPoint4.x, DrawPoint4.y, DrawPoint1.x, DrawPoint1.y,  ESPColor);
		DrawD3DLine(D3DDevice, DrawPoint5.x, DrawPoint5.y, DrawPoint6.x, DrawPoint6.y,  ESPColor);
		DrawD3DLine(D3DDevice, DrawPoint6.x, DrawPoint6.y, DrawPoint7.x, DrawPoint7.y,  ESPColor);
		DrawD3DLine(D3DDevice, DrawPoint7.x, DrawPoint7.y, DrawPoint8.x, DrawPoint8.y,  ESPColor);
		DrawD3DLine(D3DDevice, DrawPoint8.x, DrawPoint8.y, DrawPoint5.x, DrawPoint5.y,  ESPColor);
		DrawD3DLine(D3DDevice, DrawPoint1.x, DrawPoint1.y, DrawPoint5.x, DrawPoint5.y,  ESPColor);
		DrawD3DLine(D3DDevice, DrawPoint2.x, DrawPoint2.y, DrawPoint6.x, DrawPoint6.y,  ESPColor);
		DrawD3DLine(D3DDevice, DrawPoint3.x, DrawPoint3.y, DrawPoint7.x, DrawPoint7.y,  ESPColor);
		DrawD3DLine(D3DDevice, DrawPoint4.x, DrawPoint4.y, DrawPoint8.x, DrawPoint8.y,  ESPColor);
	};
};
Credits:
Me - rewriting it to improve the code
iFlux - the original code
So many leechers lol.. 44 views and no one says thanks, but I guarantee someone took it
Say thanks if you're gonna use something
I will not use it but I already thank you : p
actually its the same as 3d box?
Thanks , Keep Going
Quote Originally Posted by _Mike92 View Post
actually its the same as 3d box?
are you high? you clearly didn't even test it
iFlux's original box hangs off like 1/3 of the character size when standing, and like 1/2 when crouching
stop shitposting
Quote Originally Posted by Goocolax View Post
are you high? you clearly didn't even test it
iFlux's original box hangs off like 1/3 of the character size when standing, and like 1/2 when crouching
stop shitposting
thats why i do not want to comment. you're always angry.
if you want to share then be calm...
tsk tsk.
Quote Originally Posted by jayjay153 View Post
thats why i do not want to comment. you're always angry.
if you want to share then be calm...
tsk tsk.
im not angry, stop assuming things
whether or not i have an abrasive personality is a WHOLE other world of discussion
im a very different person on d1sc0rd
Quote Originally Posted by Goocolax View Post
im not angry, stop assuming things
whether or not i have an abrasive personality is a WHOLE other world of discussion
im a very different person on d1sc0rd
what a kind of attitude is that hahahaha good luck...
Quote Originally Posted by Goocolax View Post
are you high? you clearly didn't even test it
iFlux's original box hangs off like 1/3 of the character size when standing, and like 1/2 when crouching
stop shitposting
yes I didnt cuz you drawing to much. but if you post this only for this virtual "thanks" on this forum, here is your virtual thank you! u can make this func smaller just using a little bit of math

Quote Originally Posted by jayjay153 View Post
thats why i do not want to comment. you're always angry.
if you want to share then be calm...
tsk tsk.
ure right haha
Quote Originally Posted by _Mike92 View Post
yes I didnt cuz you drawing to much. but if you post this only for this virtual "thanks" on this forum, here is your virtual thank you! u can make this func smaller just using a little bit of math



ure right haha
could it be smaller? yes, the code also wouldnt look as good (aesthetics and readability matter too, moron)
could I draw less? no, it would take the same amount of drawline calls either way, its a 3d box what do you expect

it doesnt lag at all so i dont see why you're complaining noob
it works just fine

when YOU do better, when YOU release it, please come say something... otherwise dont complain unless its actually constructive

oh, and fyi, " Originally Posted by jayjay153
thats why i do not want to comment. you're always angry.
if you want to share then be calm...
tsk tsk.
ure right haha"

he's not right, I'm never angry

and no I didn't post it just for thanks, so please stop assuming things
whether or not I want thanks is irrelevant, i posted it so people could benefit
the only reason i said something is so that people stop leeching it w/ no credit
Quote Originally Posted by Goocolax View Post
could it be smaller? yes, the code also wouldnt look as good (aesthetics and readability matter too, moron)
could I draw less? no, it would take the same amount of drawline calls either way, its a 3d box what do you expect

it doesnt lag at all so i dont see why you're complaining noob
it works just fine

when YOU do better, when YOU release it, please come say something... otherwise dont complain unless its actually constructive

oh, and fyi, " Originally Posted by jayjay153
thats why i do not want to comment. you're always angry.
if you want to share then be calm...
tsk tsk.
ure right haha"

he's not right, I'm never angry

and no I didn't post it just for thanks, so please stop assuming things
whether or not I want thanks is irrelevant, i posted it so people could benefit
the only reason i said something is so that people stop leeching it w/ no credit
Quote Originally Posted by Goocolax View Post
So many leechers lol.. 44 views and no one says thanks, but I guarantee someone took it
Say thanks if you're gonna use something
your words? ya sorry your implementation of code is the best
dont be angry, now u have 6 virtual "thanks"
Quote Originally Posted by _Mike92 View Post
your words? ya sorry your implementation of code is the best
dont be angry, now u have 6 virtual "thanks"
at this point you're just harassing, stop now or be reported.
Based on this article:
PT-BR ( https://pt.wikipedia.org/wiki/Caixa_...ra_m%C3%ADnima ).
EN-US ( https://en.wikipedia.org/wiki/Bounding_volume ).



Dynamic 3D Boxes based on player AABB.

Code:
template<class it, class actor>
void CESPFunctions<it, actor>::AABB3D( void ) const
{
	D3DXVECTOR3 vec[ 8 ] { D3DXVECTOR3( 0, 0, 0 ) };

	D3DXVECTOR3 max = this->getEntityIterator( )->getLTObject( )->BoxMax;
	D3DXVECTOR3 min = this->getEntityIterator( )->getLTObject( )->BoxMin;

	if( pEngine->worldToScreen( min, &vec[ 0 ] ) &&
	    pEngine->worldToScreen( max, &vec[ 1 ] ) &&
	    pEngine->worldToScreen( D3DXVECTOR3( max.x, min.y, min.z ), &vec[ 2 ] ) &&
	    pEngine->worldToScreen( D3DXVECTOR3( min.x, max.y, min.z ), &vec[ 3 ] ) &&
	    pEngine->worldToScreen( D3DXVECTOR3( min.x, min.y, max.z ), &vec[ 4 ] ) &&
	    pEngine->worldToScreen( D3DXVECTOR3( min.x, max.y, max.z ), &vec[ 5 ] ) &&
	    pEngine->worldToScreen( D3DXVECTOR3( max.x, min.y, max.z ), &vec[ 6 ] ) &&
	    pEngine->worldToScreen( D3DXVECTOR3( max.x, max.y, min.z ), &vec[ 7 ] ) )
	{
		pRender->Line( vec[ 0 ].x, vec[ 0 ].y, vec[ 4 ].x, vec[ 4 ].y, Color( dwColor ) );
		pRender->Line( vec[ 1 ].x, vec[ 1 ].y, vec[ 7 ].x, vec[ 7 ].y, Color( dwColor ) );
		pRender->Line( vec[ 2 ].x, vec[ 2 ].y, vec[ 6 ].x, vec[ 6 ].y, Color( dwColor ) );
		pRender->Line( vec[ 3 ].x, vec[ 3 ].y, vec[ 5 ].x, vec[ 5 ].y, Color( dwColor ) );

		pRender->Line( vec[ 0 ].x, vec[ 0 ].y, vec[ 2 ].x, vec[ 2 ].y, Color( dwColor ) );
		pRender->Line( vec[ 0 ].x, vec[ 0 ].y, vec[ 3 ].x, vec[ 3 ].y, Color( dwColor ) );
		pRender->Line( vec[ 7 ].x, vec[ 7 ].y, vec[ 2 ].x, vec[ 2 ].y, Color( dwColor ) );
		pRender->Line( vec[ 7 ].x, vec[ 7 ].y, vec[ 3 ].x, vec[ 3 ].y, Color( dwColor ) );

		pRender->Line( vec[ 1 ].x, vec[ 1 ].y, vec[ 5 ].x, vec[ 5 ].y, Color( dwColor ) );
		pRender->Line( vec[ 1 ].x, vec[ 1 ].y, vec[ 6 ].x, vec[ 6 ].y, Color( dwColor ) );
		pRender->Line( vec[ 4 ].x, vec[ 4 ].y, vec[ 5 ].x, vec[ 5 ].y, Color( dwColor ) );
		pRender->Line( vec[ 4 ].x, vec[ 4 ].y, vec[ 6 ].x, vec[ 6 ].y, Color( dwColor ) );
	}
}
Posts 115 of 32 · Page 1 of 3
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Need help?