|
Участник форума
Регистрация: 06.11.2016
Сообщений: 150
С нами:
5008255
Репутация:
18
|
|
Сообщение от iAmerican
convertScreenCoordsTo3D поделитесь функцией пожалуйста , а то найти не могу.
сразу ещё вопросик , как я знаю , там есть при переводе , переменная для указания глубины , как эта глубина вообще работает?
Если надо то вот вам...
C++:
Код:
#define ADDR_MENU 0xBA67A4
void
CalcScreenCoors
(
CVector
*
vecWorld
,
CVector
*
vecScreen
)
{
D3DXMATRIX
m
(
(
float
*
)
(
0xB6FA2C
)
)
;
DWORD
*
dwLenX
=
(
DWORD
*
)
(
0xC17044
)
;
DWORD
*
dwLenY
=
(
DWORD
*
)
(
0xC17048
)
;
vecScreen
->
fX
=
vecWorld
->
fZ
*
m
.
_31
+
vecWorld
->
fY
*
m
.
_21
+
vecWorld
->
fX
*
m
.
_11
+
m
.
_41
;
vecScreen
->
fY
=
vecWorld
->
fZ
*
m
.
_32
+
vecWorld
->
fY
*
m
.
_22
+
vecWorld
->
fX
*
m
.
_12
+
m
.
_42
;
vecScreen
->
fZ
=
vecWorld
->
fZ
*
m
.
_33
+
vecWorld
->
fY
*
m
.
_23
+
vecWorld
->
fX
*
m
.
_13
+
m
.
_43
;
float
fRecip
=
1.0f
/
vecScreen
->
fZ
;
vecScreen
->
fX
*=
fRecip
*
(
*
dwLenX
)
;
vecScreen
->
fY
*=
fRecip
*
(
*
dwLenY
)
;
}
void
DrawTextB
(
int
uiLeft
,
int
uiTop
,
int
uiRight
,
int
uiBottom
,
unsigned
long
ulColor
,
const
char
*
szText
,
float
fScaleX
,
float
fScaleY
,
unsigned
long
ulFormat
,
LPD3DXFONT pDXFont
)
{
if
(
pDXFont
)
{
uiLeft
=
unsigned
int
(
(
float
)
uiLeft
*
(
1.0f
/
fScaleX
)
)
;
uiTop
=
unsigned
int
(
(
float
)
uiTop
*
(
1.0f
/
fScaleY
)
)
;
uiRight
=
unsigned
int
(
(
float
)
uiRight
*
(
1.0f
/
fScaleX
)
)
;
uiBottom
=
unsigned
int
(
(
float
)
uiBottom
*
(
1.0f
/
fScaleY
)
)
;
RECT rect
;
SetRect
(
&
rect
,
uiLeft
,
uiTop
,
uiRight
,
uiBottom
)
;
m_font
->
DrawTextA
(
NULL
,
szText
,
-
1
,
&
rect
,
ulFormat
,
ulColor
)
;
}
}
//Sprite *sp = new Sprite(200, 200, D3DCOLOR_ARGB(255, 255, 255, 255));
HRESULT D3DHook
::
Present
(
CONST RECT
*
pSourceRect
,
CONST RECT
*
pDestRect
,
HWND hDestWindowOverride
,
CONST RGNDATA
*
pDirtyRegion
)
{
D3DCOLOR fontColor
=
D3DCOLOR_ARGB
(
255
,
255
,
0
,
0
)
;
CVector vecScreenPosition
;
float
*
position
=
(
*
(
DWORD
*
)
0xB6F5F0
)
?
(
float
*
)
(
*
(
DWORD
*
)
(
*
(
DWORD
*
)
0xB6F5F0
+
0x14
)
+
0x30
)
:
NULL
;
if
(
position
!=
NULL
)
{
CalcScreenCoors
(
new
CVector
(
position
[
0
]
,
position
[
1
]
,
position
[
2
]
+
1.3f
)
,
&
vecScreenPosition
)
;
}
int
iScreenPosX
=
static_cast
(
vecScreenPosition
.
fX
)
;
int
iScreenPosY
=
static_cast
(
vecScreenPosition
.
fY
)
;
if
(
*
(
PBYTE
)
ADDR_MENU
==
0
)
//В меню рендерить не будет, можно убрать если у вас по другому.
{
DrawTextB
(
iScreenPosX
,
iScreenPosY
,
iScreenPosX
,
iScreenPosY
,
D3DCOLOR_ARGB
(
255
,
255
,
255
,
255
)
,
"LocalPed"
,
1.0f
,
1.0f
,
DT_NOCLIP
|
DT_CENTER
,
m_font
)
;
}
return
origIDirect3DDevice9
->
Present
(
pSourceRect
,
pDestRect
,
hDestWindowOverride
,
pDirtyRegion
)
;
}
Сообщение от Спойлер
C++:
Код:
#ifndef __CVector_H
#define __CVector_H
#ifdef WIN32
#include
#endif
#include
#define FLOAT_EPSILON 0.0001f
/**
* CVector Structure used to store a 3D vertex.
*/
class
CVector
{
public
:
float
fX
,
fY
,
fZ
;
CVector
(
)
{
this
->
fX
=
0
;
this
->
fY
=
0
;
this
->
fZ
=
0
;
}
;
CVector
(
float
fX
,
float
fY
,
float
fZ
)
{
this
->
fX
=
fX
;
this
->
fY
=
fY
;
this
->
fZ
=
fZ
;
}
float
Normalize
(
void
)
{
float
t
=
sqrt
(
fX
*
fX
+
fY
*
fY
+
fZ
*
fZ
)
;
if
(
t
>
FLOAT_EPSILON
)
{
float
fRcpt
=
1
/
t
;
fX
*=
fRcpt
;
fY
*=
fRcpt
;
fZ
*=
fRcpt
;
}
else
t
=
0
;
return
t
;
}
float
Length
(
void
)
const
{
return
sqrt
(
(
fX
*
fX
)
+
(
fY
*
fY
)
+
(
fZ
*
fZ
)
)
;
}
float
LengthSquared
(
void
)
const
{
return
(
fX
*
fX
)
+
(
fY
*
fY
)
+
(
fZ
*
fZ
)
;
}
float
DotProduct
(
const
CVector
*
param
)
const
{
return
fX
*
param
->
fX
+
fY
*
param
->
fY
+
fZ
*
param
->
fZ
;
}
void
CrossProduct
(
const
CVector
*
param
)
{
float
_fX
=
fX
,
_fY
=
fY
,
_fZ
=
fZ
;
fX
=
_fY
*
param
->
fZ
-
param
->
fY
*
_fZ
;
fY
=
_fZ
*
param
->
fX
-
param
->
fZ
*
_fX
;
fZ
=
_fX
*
param
->
fY
-
param
->
fX
*
_fY
;
}
// Return a perpendicular direction
CVector
GetOtherAxis
(
void
)
const
{
CVector vecResult
;
if
(
std
::
abs
(
fX
)
>
std
::
abs
(
fY
)
)
vecResult
=
CVector
(
fZ
,
0
,
-
fX
)
;
else
vecResult
=
CVector
(
0
,
-
fZ
,
fY
)
;
vecResult
.
Normalize
(
)
;
return
vecResult
;
}
CVector
operator
+
(
const
CVector
&
vecRight
)
const
{
return
CVector
(
fX
+
vecRight
.
fX
,
fY
+
vecRight
.
fY
,
fZ
+
vecRight
.
fZ
)
;
}
CVector
operator
-
(
const
CVector
&
vecRight
)
const
{
return
CVector
(
fX
-
vecRight
.
fX
,
fY
-
vecRight
.
fY
,
fZ
-
vecRight
.
fZ
)
;
}
CVector
operator
*
(
const
CVector
&
vecRight
)
const
{
return
CVector
(
fX
*
vecRight
.
fX
,
fY
*
vecRight
.
fY
,
fZ
*
vecRight
.
fZ
)
;
}
CVector
operator
*
(
float
fRight
)
const
{
return
CVector
(
fX
*
fRight
,
fY
*
fRight
,
fZ
*
fRight
)
;
}
CVector
operator
/
(
const
CVector
&
vecRight
)
const
{
return
CVector
(
fX
/
vecRight
.
fX
,
fY
/
vecRight
.
fY
,
fZ
/
vecRight
.
fZ
)
;
}
CVector
operator
/
(
float
fRight
)
const
{
float
fRcpValue
=
1
/
fRight
;
return
CVector
(
fX
*
fRcpValue
,
fY
*
fRcpValue
,
fZ
*
fRcpValue
)
;
}
CVector
operator
-
(
)
const
{
return
CVector
(
-
fX
,
-
fY
,
-
fZ
)
;
}
void
operator
+=
(
float
fRight
)
{
fX
+=
fRight
;
fY
+=
fRight
;
fZ
+=
fRight
;
}
void
operator
+=
(
const
CVector
&
vecRight
)
{
fX
+=
vecRight
.
fX
;
fY
+=
vecRight
.
fY
;
fZ
+=
vecRight
.
fZ
;
}
void
operator
-=
(
float
fRight
)
{
fX
-=
fRight
;
fY
-=
fRight
;
fZ
-=
fRight
;
}
void
operator
-=
(
const
CVector
&
vecRight
)
{
fX
-=
vecRight
.
fX
;
fY
-=
vecRight
.
fY
;
fZ
-=
vecRight
.
fZ
;
}
void
operator
*=
(
float
fRight
)
{
fX
*=
fRight
;
fY
*=
fRight
;
fZ
*=
fRight
;
}
void
operator
*=
(
const
CVector
&
vecRight
)
{
fX
*=
vecRight
.
fX
;
fY
*=
vecRight
.
fY
;
fZ
*=
vecRight
.
fZ
;
}
void
operator
/=
(
float
fRight
)
{
float
fRcpValue
=
1
/
fRight
;
fX
*=
fRcpValue
;
fY
*=
fRcpValue
;
fZ
*=
fRcpValue
;
}
void
operator
/=
(
const
CVector
&
vecRight
)
{
fX
/=
vecRight
.
fX
;
fY
/=
vecRight
.
fY
;
fZ
/=
vecRight
.
fZ
;
}
bool
operator
==
(
const
CVector
&
param
)
const
{
return
(
(
fabs
(
fX
-
param
.
fX
)
=
FLOAT_EPSILON
)
||
(
fabs
(
fY
-
param
.
fY
)
>=
FLOAT_EPSILON
)
||
(
fabs
(
fZ
-
param
.
fZ
)
>=
FLOAT_EPSILON
)
)
;
}
}
;
#endif
|