Volker Posted December 15, 2009 Share Posted December 15, 2009 I have a ship and an exploding mine. The mine shall create a shockwave which affects the ship. Playing with AddBodyForceAtPoint() did not lead me in the right direction. I could do a pointentity() from mine to ship and shoot an invisible body, but I don't like the idea. Inspirations, please. Quote Core2DuoE6570 / Windows7 64bit / 4 Gb RAM / Geforce GTX 260 896Mb / LE 2.3 Dell Inspiron 1720 / Vista SP2 / C2D 2.4 / 8600 GM Link to comment Share on other sites More sharing options...
TylerH Posted December 15, 2009 Share Posted December 15, 2009 You need to do a ForEachEntityInAABBDo on the mine, and run the a function to add massive amounts of force in vectors equivalent to the entity's position minus the mine position. Basically: for each entity in the bounding box (radius or whatever) of the mine forcevector = entity.position - mineposition AddBodyForce(entity, forcevector*500) // 500 is your force scalar or whatever repeat Quote nVidia 530M Intel Core i7 - 2.3Ghz 8GB DDR3 RAM Windows 7 Ultimate (64x)----- Visual Studio 2010 Ultimate Google Chrome Creative Suite 5 FL Studio 10 Office 15 ----- Expert Professional Expert BMX Programmer ----- Link to comment Share on other sites More sharing options...
Flexman Posted December 15, 2009 Share Posted December 15, 2009 I don't think Newton has repulsive forces. But maybe can be simulated. This is off the top of my head but I would tackle Mk1 like this... Using something like ForEachEntityInAABBDo and give your mine a key that specifies the size of the AABB bounding box (this would be the area of effect). From what I understand, when the mine detonates you want to apply a force to all bodies within that volume around the mine. The amount of force would be distance from the mine entity (with some falloff factor). And supply AddBodyForce with the vector from the ship to the mine (see TFormVector) and your calculated explosive force. Other ideas anyone? Quote 6600 2.4G / GTX 460 280.26 / 4GB Windows 7 Author: GROME Terrain Modeling for Unity, UDK, Ogre3D from PackT Tricubic Studios Ltd. ~ Combat Helo Link to comment Share on other sites More sharing options...
TylerH Posted December 15, 2009 Share Posted December 15, 2009 Thanks, I had forgotten the TFormVector to make sure the forces are local. Falloff as well, as that makes it more realistic. I do the same thing with the bullets in the Weaponwerks library. Quote nVidia 530M Intel Core i7 - 2.3Ghz 8GB DDR3 RAM Windows 7 Ultimate (64x)----- Visual Studio 2010 Ultimate Google Chrome Creative Suite 5 FL Studio 10 Office 15 ----- Expert Professional Expert BMX Programmer ----- Link to comment Share on other sites More sharing options...
Volker Posted December 16, 2009 Author Share Posted December 16, 2009 Thanks guys, got something sufficient working. Quote Core2DuoE6570 / Windows7 64bit / 4 Gb RAM / Geforce GTX 260 896Mb / LE 2.3 Dell Inspiron 1720 / Vista SP2 / C2D 2.4 / 8600 GM Link to comment Share on other sites More sharing options...
TylerH Posted December 17, 2009 Share Posted December 17, 2009 Could you possibly share how you did it? I would like to add explosives to Weaponwerks as a native projectile type Quote nVidia 530M Intel Core i7 - 2.3Ghz 8GB DDR3 RAM Windows 7 Ultimate (64x)----- Visual Studio 2010 Ultimate Google Chrome Creative Suite 5 FL Studio 10 Office 15 ----- Expert Professional Expert BMX Programmer ----- Link to comment Share on other sites More sharing options...
Volker Posted December 17, 2009 Author Share Posted December 17, 2009 Hello Tyler, Could you possibly share how you did it? I really wanted to do that, but I thought my solution is not really good. That's why I wrote "sufficient". Ok, here it is. Code in Blitzmax: Function ApplyShockwave(position:tvec3, intensity:Float) Local body:TBody For Local gameobject:TGameObject = EachIn TGameObject.list body = gameobject.body If body <>NULL ' create a marker to make point of shockwave visible, replace with a pivot later ' Local marker:TMesh = CreateCylinder(8) PositionEntity(marker, position) Local mpos:TVec3 = EntityPosition(marker) Local spos:TVec3 = EntityPosition(body) Local distance:Float = EntityDistance(marker, body) Local force:TVec3 = New TVec3 ' substract position vecs and calculate force to apply' force.x = (spos.x - mpos.x) / distance force.y = (spos.y - mpos.y) / distance force.z = (spos.z - mpos.z) / distance If distance < 1 Then distance = 1 ' because of massive force if <1 ' force.x = force.x / distance * intensity force.y = force.y / distance * intensity force.z = force.z / distance * intensity Local tforce:TVec3 = TFormVector(force, marker, Null) ' thanks Flexman! ' If EntityDistance(TEntity(body), marker) < 10 ' shcokwave only affects bodies in this distance AddBodyForce(body, tforce) EndIf EndIf Next I am cycling through all my gameobjects because I couldn't figure out how to pass the two vec3s to TAABB in Blitzmax at the moment. Local t:TAABB = New TAABB.Create(Vec2(10, 10), Vec2(0, 0)) throws an error. Quote Core2DuoE6570 / Windows7 64bit / 4 Gb RAM / Geforce GTX 260 896Mb / LE 2.3 Dell Inspiron 1720 / Vista SP2 / C2D 2.4 / 8600 GM Link to comment Share on other sites More sharing options...
TylerH Posted December 18, 2009 Share Posted December 18, 2009 It is throwing an error because you are passing two Vec2s, it needs Vec3(X,Y,Z) Quote nVidia 530M Intel Core i7 - 2.3Ghz 8GB DDR3 RAM Windows 7 Ultimate (64x)----- Visual Studio 2010 Ultimate Google Chrome Creative Suite 5 FL Studio 10 Office 15 ----- Expert Professional Expert BMX Programmer ----- Link to comment Share on other sites More sharing options...
VicToMeyeZR Posted December 18, 2009 Share Posted December 18, 2009 I don't know if you just missed it in your copy and paste, but your missing a closing ' at the end of this " shcokwave only affects bodies in this distance" Which is commenting out your function closing's Quote AMD Phenom II x6 1100T - 16GB RAM - ATI 5870 HD - OCZ Vertex 2 60GB SSD Link to comment Share on other sites More sharing options...
Volker Posted December 18, 2009 Author Share Posted December 18, 2009 @Tyler Yes, of course. Vec3s needed. But it throws the error already at the create method "Compile Error: Identifier 'Create' not found". @ VicToMeyeZR Thats just because the forum uncourteous changed code to comments. I had to add a ' at the end of every comment and forget that one. Quote Core2DuoE6570 / Windows7 64bit / 4 Gb RAM / Geforce GTX 260 896Mb / LE 2.3 Dell Inspiron 1720 / Vista SP2 / C2D 2.4 / 8600 GM Link to comment Share on other sites More sharing options...
macklebee Posted December 18, 2009 Share Posted December 18, 2009 @Tyler Yes, of course. Vec3s needed. But it throws the error already at the create method "Compile Error: Identifier 'Create' not found". @ VicToMeyeZR Thats just because the forum uncourteous changed code to comments. I had to add a ' at the end of every comment and forget that one. don't know if i am following this correctly but couldn't you create a mesh at the size you want, then just get the AABB of the mesh using GetEntityAABB? Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
Volker Posted December 18, 2009 Author Share Posted December 18, 2009 don't know if i am following this correctly but couldn't you create a mesh at the size you want, then just get the AABB of the mesh using GetEntityAABB? Yes, you are following correctly. Nice workaround. Will add it to my function. Quote Core2DuoE6570 / Windows7 64bit / 4 Gb RAM / Geforce GTX 260 896Mb / LE 2.3 Dell Inspiron 1720 / Vista SP2 / C2D 2.4 / 8600 GM Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.