Jump to content

AvatoR

Members
  • Posts

    6
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

AvatoR's Achievements

Vic

Vic (3/54)

0

Reputation

  1. Hello, i have this script: thisTXDfileName = 'primring2.txd' mapObjectCoords = { -- filename, scale, objectID, posX, posY, posZ, rotX, rotY, rotZ {"1road_SUB0", 1, 14405, 119.03326416015625, -8.794629096984863, 4000.2884072959423, 0.0, 0.0, 0.0}, {"1road_SUB1", 1, 620, 165.66696166992188, 8.17689037322998, 4000.512966156006, 0.0, 0.0, 0.0}, {"1road_SUB2", 1, 3110, 180.93658447265625, -61.86378479003906, 4003.6350486278534, 0.0, 0.0, 0.0}, {"1wall_SUB0", 1, 3111, -149.37530517578125, -4.85414981842041, 4003.0458328723907, 0.0, 0.0, 0.0}, } function loadMap() local txd = engineLoadTXD(thisTXDfileName, true) outputChatBox("1") for i, v in pairs(mapObjectCoords) do outputChatBox("2 " .. v[1] .. " " .. v[3]) engineImportTXD(txd,v[3]) outputChatBox("2.1") local dff = engineLoadDFF(v[1]..'.dff', 0) outputChatBox("2.2 " .. tostring(dff)) engineReplaceModel(dff,v[3]) outputChatBox("2.3") local col = engineLoadCOL(v[1]..'.col', 0) outputChatBox("2.4 " .. tostring(col)) engineReplaceCOL(col,v[3]) outputChatBox("2.5") engineSetModelLODDistance(v[3], 5000) outputChatBox("3 " .. v[1]) -- debPass() outputChatBox("4 " .. v[1]) objMapSpawned[i] = createObject(v[3], v[4],v[5],v[6], v[7],v[8],v[9], false) -- setElementStreamable(objMapSpawned[i], true) setObjectBreakable(objMapSpawned[i], false) setObjectScale(objMapSpawned[i], v[2]) setElementDimension(objMapSpawned[i], getElementDimension(getLocalPlayer())) end end Pay attention to outputChatBox functions. So i loading to server and console outputs like that: 1 2 1road_SUB0 14405 2.1 2.2 userdata: 000216A9 2.3 2.4 userdata: 000216AA 2.5 3 1road_SUB0 4 1road_SUB0 2 1road_SUB1 620 2.1 2.2 userdata: 000216AC 2.3 2.4 userdata: 000216AD 2.5 3 1road_SUB1 4 1road_SUB1 2 1road_SUB2 3110 2.1 2.2 userdata: 000216AF 2.3 2.4 userdata: 000216B0 2.5 3 1road_SUB2 4 1road_SUB2 2 1wall_SUB0 3111 2.1 2.2 userdata: 000216B2 2.3 2.4 userdata: 000216B3 As you can see, the "1wall_SUB0" object collision can be loaded, but engineReplaceCOL() - not working, and immediately MTA crashes without any log in clientscript file. Crash errors: game_sa.dll Code = 0xC0000005 Offset = 0x0003FB33 EAX=00000000 EBX=6B55C6F8 ECX=00000000 EDX=0B8B0901 ESI=37C76438 EDI=78A1BD58 EBP=0177EDCC ESP=0177EDC0 EIP=0B83FB33 FLG=00210203 CS=0023 DS=002B SS=002B ES=002B FS=0053 GS=002B The "1wall_SUB0": Download here: https://drive.google.com/drive/folders/1lnBhoevsK4KOmFrFIaZgf8ViWVaskL-k?usp=sharing And the other problem: size of created file by Migic.TXD is a bit large:
  2. Yep, thanks, it's finally works.
  3. I have this code: sx, sy = guiGetScreenSize() movedClip = false testAngle = 0 function math.rotVecToEular(x, y, z, rot) -- explained on mta wiki local rotx = math.deg( math.atan2 ( z, (x^2+y^2)^0.5 ) ) % 360 local rotz = math.deg( math.atan2( x, y ) ) % 360 return rotx, rot, rotz end addEventHandler("onClientRender", root, function () local relX, relY = getCursorPosition() local cursorX, cursorY = relX * sx, relY * sy local camX, camY, camZ = getCameraMatrix() local cursorWorldPosX, cursorWorldPosY, cursorWorldPosZ = getWorldFromScreenPosition(cursorX, cursorY, 20) hit, hitX, hitY, hitZ, hitElement, normalX, normalY, normalZ = processLineOfSight(camX, camY, camZ, cursorWorldPosX, cursorWorldPosY, cursorWorldPosZ, true, false, false, true, false, true, false, true) if hit then testAngle = (testAngle + 1) % 360 angleVectorX, angleVectorY, angleVectorZ = math.rotVecToEular(normalX, normalY, normalZ, testAngle) angleVectorX = angleVectorX - 90 -- cone look "up" when testAngle = 0 hitX = normalX*0.2 + hitX -- a bit up from a plane hitY = normalY*0.2 + hitY -- a bit up from a plane hitZ = normalZ*0.2 + hitZ -- a bit up from a plane if isElement(movedClip) then destroyElement(movedClip) end movedClip = createObject(1238, hitX, hitY, hitZ, angleVectorX, angleVectorY, angleVectorZ, true) end end) But i need rotation in other axis, like so: - Need rotation in "Z" axis with ZYX Euler coordinate system. Script doing that in MTA: And in blender "X" axis in XYZ Euler angles: I tried set setElementRotation with 5 argument "ZYX" but it didn't work, like it's swap X and Z angles, not a different coordinate system: local angX = 0 local angY = 0 local angZ = 0 local modelToRotate = false sx, sy = guiGetScreenSize() addEventHandler("onClientRender", root, function () if isCursorShowing() then if getKeyState("4") then angX = (angX + 1) % 360 end if getKeyState("5") then angY = (angY + 1) % 360 end if getKeyState("6") then angZ = (angZ + 1) % 360 end dxDrawText("X:" .. angX .. " Y:" .. angY .. " Z:" .. angZ, 300, 60) local relX, relY = getCursorPosition() local cursorX, cursorY = relX * sx, relY * sy local camX, camY, camZ = getCameraMatrix() local cursorWorldPosX, cursorWorldPosY, cursorWorldPosZ = getWorldFromScreenPosition(cursorX, cursorY, 20) local hit, hitX, hitY, hitZ, hitElement, normalX, normalY, normalZ = processLineOfSight(camX, camY, camZ, cursorWorldPosX, cursorWorldPosY, cursorWorldPosZ, true, false, false, true, false, true, false, true) if isElement(modelToRotate) then destroyElement(modelToRotate) end modelToRotate = createObject(1238, hitX, hitY, hitZ, 0, 0, 0, true) setElementRotation(modelToRotate, angX, angY, angZ, "ZYX") end end ) keys 4, 5, 6 for rotation in X, Y, Z axis. How to rotate a object in Z axis, but to a normal vector from processLineOfSight, like in first attached video?
  4. Если кому не понятно чего я хочу добиться то вот что я получаю при createObject и вращении: А нужно получить вот такое вращение: Функция setElementRotation с 5-ым аргументом "ZXY" вообще никак не меняет ситуацию: local angX = 0 local angY = 0 local angZ = 0 local modelToRotate = false sx, sy = guiGetScreenSize() addEventHandler("onClientRender", root, function () if isCursorShowing() then local relX, relY = getCursorPosition() local cursorX, cursorY = relX * sx, relY * sy local camX, camY, camZ = getCameraMatrix() local cursorWorldPosX, cursorWorldPosY, cursorWorldPosZ = getWorldFromScreenPosition(cursorX, cursorY, 20) local hit, hitX, hitY, hitZ, hitElement, normalX, normalY, normalZ = processLineOfSight(camX, camY, camZ, cursorWorldPosX, cursorWorldPosY, cursorWorldPosZ, true, false, false, true, false, true, false, true) if isElement(modelToRotate) then destroyElement(modelToRotate) end modelToRotate = createObject(1238, hitX, hitY, hitZ, 0, 0, 0, true) setElementRotation(modelToRotate, angX, angY, angZ, "ZXY") end end )
  5. sx, sy = guiGetScreenSize() movedClip = false testAngle = 0 function math.rotVecToEular(x, y, z, rot) -- Описано на вики Мта local rotx = math.deg( math.atan2 ( z, (x^2+y^2)^0.5 ) ) % 360 local rotz = math.deg( math.atan2( x, y ) ) % 360 return rotx, rot, rotz end addEventHandler("onClientRender", root, function () local relX, relY = getCursorPosition() local cursorX, cursorY = relX * sx, relY * sy local camX, camY, camZ = getCameraMatrix() local cursorWorldPosX, cursorWorldPosY, cursorWorldPosZ = getWorldFromScreenPosition(cursorX, cursorY, 20) hit, hitX, hitY, hitZ, hitElement, normalX, normalY, normalZ = processLineOfSight(camX, camY, camZ, cursorWorldPosX, cursorWorldPosY, cursorWorldPosZ, true, false, false, true, false, true, false, true) if hit then testAngle = (testAngle + 1) % 360 angleVectorX, angleVectorY, angleVectorZ = math.rotVecToEular(normalX, normalY, normalZ, testAngle) angleVectorX = angleVectorX - 90 -- так конус смотрит "наверх" hitX = normalX*0.2 + hitX -- немного поднимаем объект относительно нормали hitY = normalY*0.2 + hitY -- немного поднимаем объект относительно нормали hitZ = normalZ*0.2 + hitZ -- немного поднимаем объект относительно нормали if isElement(movedClip) then destroyElement(movedClip) end movedClip = createObject(1238, hitX, hitY, hitZ, angleVectorX, angleVectorY, angleVectorZ, true) end end) Я немного не понимаю, как перевести нормаль, которая возвращается в processLineOfSight, в аргументы углов для createObject. Происходит то-что объект вращается не по правильным координатам: В итоге нужно получить вращение по нормали поверхности которое приходит от processLineOfSight.
×
×
  • Create New...