Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 07/10/19 in all areas

  1. For long time i considered to do something with physics in mta. For now doing even simplest things such falling box, tree on flat area looks cartoonish. In my history of i saw few attempts of doing simple physics, mostly it was in closed area without bigger interactions with poor performance due you just can't calculate collision in other way than processLineOfSight, isLineOfSightClear or read directly .col file as Tederis did. I started with something to render things, thats how FBX https://github.com/multitheftauto/mtasa-blue/pull/1093 to bypass default rendering to handle future i'll introduce in future. That's how bullet physics project born, first idea how to use react physics, works simillar but is lighter and general smaller project but 0x416c69 suggested to use bullet. I'll use this topic also to prepare long list of features it contains for future copy paste to PR and wiki page The main assumption is to allow for create multiple world with completly independed simulations, get and set detailed information about current step of simulation, fully control how everything is simulated, quality of collision tests, speed and a lot more. i'm trying keep amount of functions low, because if that most stuff is packed into one function. Syntax and name of some function might change in future or along suggestions. Not all properties supports every physics element, some are only get, other set only, however most of them are set/get Current stage: I already implemented function such a: physics physicsCreateWorld() - responsible for creating new world for simulations, return element which will use later. physics-rigidbody physicsCreateRigidBody( shape-type, mixed arguments ) - creates rigid body which is use to simulation bahaviour of non-static shapes, collisions ( currently only few models in mta can do this in simple way ). physics-rigidbody physicsCreateRigidBodyFromModel( model ) - used to create rigid body directly from collision data taken from gta model. physics-static-collision physicsCreateStaticCollision( shape-type, mixed arguments ) - creates static collision which will not move at all ( it is still possible to move it by Lua script ) physics-shape physicsAddShape( shape-type, mixed arguments ) - if you create compound shape, this function let you add more shapes into static collision or rigid body bool physicsSetProperties( any physics element, physics-property, mixed arguments ) - main function to control physics, rigid bodies, static collisions, shapes. Works in simillar way as handling functions. mixed physicsGetProperties( any physics element, physics-property ) - same as above, but getting properties bool physicsDrawDebug( physics ) - use to visualization of world, must be used in render function bool physicsSetDebugMode( physics-debug-mode, enabled ) - use to turn off/on debugging features bool physicsBuildCollisionFromGTA( physics ) - used to create static collisions in specified world from original collisions, doesn't create whole world instantly, require to move player around world to load collision data. physics-constraint physicsCreateConstraint( physics, physics-rigid-body, physics-rigid-body, constraint-type, mixed arguments ) - use to connecting two or more rigid bodies into one entity bool physicsApplyForce( physics-rigid-body, vector from, vector to ) - pushing rigid body in particular point you choosed. bool physicsApplyCentralForce( physics-rigid-body, vector direction ) - apply force from central position of rigid, it's more like "accelereate", should be used more than once at the some period of time bool physicsApplyCentralImpulse( physics-rigid-body, vector direction ) - setting position from center of rigid bool physicsApplyDamping( physics-rigid-body, float force ) - i'm not sure, but it should slow down velocity and rotation of model by specified amount of units physicsApplyImpulse( physics-rigid-body, vector direction ) - i'm not sure how it works physicsApplyTorque( physics-rigid-body, vector rotation ) - same as physicsApplyCentralForce but for rotation physicsApplyTorqueImpulse( physics-rigid-body, vector rotation ) - setting rotation speed physics-properties: "mass", "position" ,"rotation", "sleepingthresholds", "restitution", "scale" "debugcolor", "filtermask", "filtergroup", "stiffness" `sleepingthresholds` means how slow rigid must move/rotate to sleep, it makes stops moving at all but still can be pushed by other rigids `restitution` bounciness, between 0-1 but accept any value above `stiffness` - for fixed constraint `filtermask` i still figuring out how it work, but should let you use 32 bit mask to set which rigid with which should collide Bullet documentation: https://github.com/bulletphysics/bullet3/blob/master/docs/Bullet_User_Manual.pdf page 13 contains useful information when which shape should be used physics-constraints: "pointtopoint", "hidge", "fixed", "slider" Physics-shapes: "box", "sphere", "capsule", "cone", "cylinder", "heightfieldterrain", "compound", "trianglemesh", "convexhull" `compound` is used for constructing rigid made of various shapes Plans for future: "heightfieldterrain" shape type accept black-white texture for faster creation Support for cloths, soft bodies Media: Videos are availiable at my youtube channel https://www.youtube.com/channel/UC95MpsQ1JppDNpMvl_7c1rg screenshots and gifs of current progress: Documentation i use: https://pybullet.org/Bullet/BulletFull I'm waiting for your suggestions Topic not finishedd
    2 points
  2. @playerpocket https://forum.multitheftauto.com/forum/127-programação-em-Lua/ General MTA > Other languages > Portuguese / Português > Programação em Lua = https://forum.multitheftauto.com/forum/71-scripting/ MTA Community > Scripting (+ Língua portuguesa) = Thank you, IIYAMA
    1 point
  3. To be honest, I haven't encountered any issues with it yet. But I am pretty sure that it can have issues when memory has been wiped because of an <unknown situation>. I would suggest following Awang his suggestion: If applied, you probably do not need that onClientRestore event. It might also improve performance, because it is static. local texture = dxCreateTexture(dxGetTexturePixels(rt)) dxSetShaderValue(theShader, "gTexture", texture)
    1 point
  4. @IIYAMA Oh ! Wasn't aware about it. I thought that game elements needed to be like a normal draw (Rendered each frame). Thats are even better news for me respecting the CPU Usage I have the last question. onClientRestore must be present on the code when the player minimize and restore to prevent issues ?
    1 point
  5. Just don't render it with renderContent. Shaders applied to game elements do not require updates every frame. (Unless you want to update them with Lua > update the texture or update the shader values)
    1 point
  6. @IIYAMA Yes, its working pretty well, but Im not sure if that its causing the problem about what Im talking at the following lines @Awang Well, basically I have been doing what you have just said. But I have a weird bug. I tried to do a simple (very simple) version of the code. Why the image is being drawn on the car and the screen ? I just want to draw it on the car but, weird ... function loadMain() theVehicle = createVehicle(411,0,0,5) theShader = dxCreateShader("lights.fx") theRenderTarget = dxCreateRenderTarget(960, 540, true) engineApplyShaderToWorldTexture(theShader, "decalmap", theVehicle) drawContentInRT(theRenderTarget) end function drawContentInRT(rt) if rt then dxSetRenderTarget(rt, true) dxDrawImage(480,220,210,210,"img/test1.png",0,0,0,tocolor(255,255,255,255)) dxDrawImage(510,220,210,210,"img/test2.png",0,0,0,tocolor(255,255,255,255)) dxSetRenderTarget() dxSetShaderValue(theShader, "gTexture", rt) addEventHandler("onClientRender",root,renderContent) end end function renderContent() if theRenderTarget then dxDrawImage(0,0,960,540,theRenderTarget,0,0,0,tocolor(255,255,255,255)) end end loadMain() --## SHADER texture gTexture; technique hello { pass P0 { Texture[0] = gTexture; } }
    1 point
  7. da o Thanks no meu comentário mano, se não for pedir de mais
    1 point
  8. O painel dx deve ser feito no client, a parte dos botões você usa essa função function buttons(_,state) if isEventHandlerAdded("onClientRender", root, dxPainel) then --configurando os botões com essas funcões end end addEventHandler("onClientClick", root, buttons) você seta os elementos e dentro do server usa o get pra configurar as funções tem mais explicado na wiki https://wiki.multitheftauto.com/wiki/Main_Page
    1 point
  9. I suggest you to make shaders for every player or you can optimalize the method by create shaders for players who are in streamed in and destroy for who are exiting from the streaming range. Because MTA only can use 1 core of your CPU in client side, its a good tactic to depend more on memory instead on CPU by making texture moving in the render function before every player. local streamed_players = {} function render() for player in pairs(streamed_players) do -- Do what you want with the shader and renderTarget end end addEventHandler( "onClientElementStreamIn",root,function() if getElementType(source) == "player" then streamed_players[source] = {shader = dxCreateShader(shaderFile), renderTarget = dxCreateRenderTarget(arg1, arg2, true)} end end) addEventHandler( "onClientElementStreamOut",root,function() if getElementType(source) == "player" then streamed_players[source] = nil end end) About RenderTargets, some videocard not really like them, so I suggest you, if you want to just put some material together and after you not want to really change them, than you can read the texture from the target and save out into a simple texture. local target = dxCreateRenderTarget(arg1, arg2, true) dxSetRenderTarget(target) dxDrawImage(...) dxDrawText(...) dxSetRenderTarget() local texture = dxCreateTexture(dxGetTexturePixels(target)) target = nil Basically, you burn together the textures and after you save out, but you cant change it after all.
    1 point
  10. @Overkillz You can do it with 1 shader, and just before drawing, switch the texture value of it foreach player. But I am not sure, how high the performance penalty is. So both ways will work, but I am not sure which one is the best one.
    1 point
  11. https://wiki.multitheftauto.com/wiki/OnDgsElementScroll
    1 point
  12. UPDATE -Update to MTA 1.5.7 -Fixed a reload animation skip glitch when pressing C+R quickly -Updated dynamic lighting to use new "areVehicleLightsOn" function when the client meets the requirements -Removed the need of pressing "W" to enable debugging for staff members, added new setPlayerScriptDebugLevel instead -Updated Berlin-Mitte to latest version -Fixed an annoying warning of admin panel -Fixed fire rate of Remington Mod. 11 and Sjögren Inertia shotguns Future technical improvements I am never stopping to learn and in the meantime i managed to improve some shader effects, namely dynamic lighting and the water shader. While the new dynamic lighting will most likely not be implemented in SAAW-WW2 (it is very demanding for weak PCs), the improved water shader will most likely hit SAAW-WW2 with a coming update. The changes in detail: Dynamic lighting has been enhanced by a "night-mode" that can actually make nights realistically dark. This effect is demanding and will not be implemented in WW2 but it is a core feature of my next server. Dynamic lighting can also support lightmapping (Textures on objects/vehicles/players that can self-illuminate in the darkness). The follwing picture shows a dark environment at 2:00 AM with a robot that has glowing eyes. Better implementation of dynamic lighting with normal shading - the current lighting method has some issues because it is not compatible with the sun shader. Sun shader will not be used in my next server project, thats why i can make dynamic lighting fully compatible with everything: OLD STANDARD GTA AT NIGHT CURRENT DYNAMIC LIGHTING + NEW NIGHT MODE NEW DYNAMIC LIGHTING + NEW NIGHT MODE COMPATIBLE And now lets get to the most interesting aspect (at least for me, lol, it was a bunch of work) Shore fading! Objects in water do now fade out when they sink deeper into the water, the water is no longer a "hard" surface where suddenly everything disappears. The effect is not 100% finished yet but i think it could be done really quick. OLD WATER SHADER: NEW WATER SHADER:
    1 point
  13. We will set up everything this weekend. I hope MTA team will fix some important bugs soon. I want to create some new nice stuff.
    1 point
×
×
  • Create New...