1
- tx ,ty ,tz = 91 ,100 ,502 -- The position of the element
1
+ tx ,ty ,tz = 100 ,100 ,15000 -- The position of the element
2
2
local hideX ,hideY ,hideZ = 0 ,0 ,0 -- where to hide the local player
3
3
local rz = 0 -- The current rotation
4
4
local maxRadius = 5
@@ -23,6 +23,7 @@ function browserSetElementModel ( elemID, model )
23
23
setModel [elemID ](model )
24
24
end
25
25
end
26
+
26
27
function setModel .vehicleID ( model )
27
28
local randomOffset = ((getTickCount () % 20 ) / 100 ) + 0.001
28
29
@@ -60,26 +61,31 @@ function setModel.vehicleID ( model )
60
61
setCameraMatrix ( tx - realDistance , ty , tz + elevation + randomOffset ,
61
62
tx , ty + moveLeft , tz + randomOffset )
62
63
end
64
+
63
65
function setModel .objectID ( model )
64
66
local randomOffset = ((getTickCount () % 20 ) / 100 ) + 0.001
65
67
66
68
if not browser .mainElement then
67
- browser .mainElement = createObject (model , tx , ty , tz , 0 , 0 , rz )
69
+ browser .mainElement = createObject (model , tx , ty , tz , 0 , 0 , rz , true )
70
+ setElementDoubleSided (browser .mainElement , guiCheckBoxGetSelected (browserGUI .doubleside ))
68
71
setElementDimension ( browser .mainElement , BROWSER_DIMENSION )
69
72
setElementInterior (browser .mainElement , 14 )
70
73
else
71
74
setElementModel (browser .mainElement , model )
72
75
end
73
76
74
- setElementPosition (browser .mainElement , tx , ty , tz + randomOffset )
77
+ setElementPosition (browser .mainElement , tx , ty , tz )
75
78
setElementAlpha (browser .mainElement , 255 )
76
79
77
- local radius = getElementRadius (browser .mainElement )
78
- browserElementLookOptions .distance = 14
79
- setObjectScale ( browser .mainElement , maxRadius / radius )
80
- setCameraMatrix ( tx - 17 , ty , tz + 3 + randomOffset ,
81
- tx , ty + 2 , tz + randomOffset )
80
+ local a ,b ,c ,d ,e ,f = getElementBoundingBox (browser .mainElement )
81
+ local radius = math.max (7 , getElementRadius (browser .mainElement )* 2.1 )
82
+ radius = math.max (radius , math.sqrt ((c * c )+ (f * f ))* 2 )
83
+ browserElementLookOptions .distance = radius
84
+ local offset = radius * 0.2
85
+ setCameraMatrix ( tx - radius - offset , ty + offset , tz + radius * 0.25 ,
86
+ tx - offset , ty + offset , tz )
82
87
end
88
+
83
89
function setModel .skinID ( model )
84
90
local randomOffset = (getTickCount () % 20 ) / 100
85
91
@@ -108,9 +114,27 @@ function rotateMesh ()
108
114
if ( initiatedType ) == " vehicleID" then
109
115
setElementRotation ( browser .mainElement ,0 ,0 ,newRotation )
110
116
elseif ( initiatedType ) == " objectID" then
111
- setElementRotation ( browser .mainElement , 0 , 0 ,newRotation )
117
+ _previewRotate ( browser .mainElement ,newRotation )
112
118
elseif ( initiatedType ) == " skinID" then
113
- setPedRotation ( browser .mainElement ,newRotation )
119
+ setPedRotation ( browser .mainElement ,newRotation )
114
120
end
115
121
end
116
122
123
+ function _previewRotate (object , rotation )
124
+ -- https://github.com/multitheftauto/mtasa-resources/commit/117759a6df540c21515d2666794e05dcf9c76254
125
+ local a ,b ,c ,d ,e ,f = getElementBoundingBox (object )
126
+
127
+ local halfCenterX = (a + d ) * 0.25
128
+ local halfCenterY = (b + e ) * 0.25
129
+ local halfCenterZ = (c + f ) * 0.25
130
+
131
+ local rad = math.rad (rotation )
132
+ local cZ , sZ = math.cos (rad ), math.sin (rad )
133
+
134
+ local oX = halfCenterX * cZ - halfCenterY * sZ
135
+ local oY = halfCenterX * sZ + halfCenterY * cZ
136
+ local oZ = halfCenterZ
137
+
138
+ setElementPosition (object , tx - oX , ty - oY , tz - oZ )
139
+ setElementRotation (object , 0 , 0 , rotation )
140
+ end
0 commit comments