Quick Links: Gideros Home | Download Gideros | Developer Guide
liquidFun from C++ to Lua
  • I'm reading some information about liquidFun and this script has "b2DestructionListener"

    When I was checking gideros source
    "Line 73"
    "Line 484"

    virtual void 	SayGoodbye (b2ParticleGroup *group)
    virtual void SayGoodbye (b2ParticleSystem *particleSystem, int32 index)
    virtual bool ShouldCollide (b2Fixture *fixture, b2ParticleSystem *particleSystem, int32 particleIndex)
    virtual bool ShouldCollide (b2ParticleSystem *particleSystem, int32 particleIndexA, int32 particleIndexB)

    don't exist, but you can call it with Flags (this functionality is ready on gideros "Line 31")
    --b2.ParticleSystem.FLAG_PARTICLE_CONTACT_FILTER = 2^17
    --b2.ParticleSystem.FLAG_FIXTURE_CONTACT_FILTER = 2^16
    --b2.ParticleSystem.FLAG_REPULSIVE = 2^13 = 8192 --With high repulsive force.
    --b2.ParticleSystem.FLAG_REACTIVE = 2^12 = 4096 --Makes pairs or triads with other particles.
    --b2.ParticleSystem.FLAG_STATIC_PRESSURE = 2^11 = 2048 --Less compressibility.
    --b2.ParticleSystem.FLAG_BARRIER = 2^10 = 1024 --Prevents other particles from leaking.
    --b2.ParticleSystem.FLAG_DESTRUCTION_LISTENER = 2^9 = 512 --Call b2DestructionListener on destruction.
    --b2.ParticleSystem.FLAG_COLOR_MIXING = 2^8 = 256 --Mix color between contacting particles.
    --b2.ParticleSystem.FLAG_TENSILE = 2^7 = 128 --like a ocean, scum
    --b2.ParticleSystem.FLAG_POWDER = 2^6 = 64 --like a boiled // Without isotropic pressure.
    --b2.ParticleSystem.FLAG_VISCOUS = 2^5 = 32 --like a rice
    --b2.ParticleSystem.FLAG_ELASTIC = 2^4 = 16 --stable jelly (if on the world doesn't exist strength)
    --b2.ParticleSystem.FLAG_SPRING = 2^3 = 8 --really jelly
    --b2.ParticleSystem.FLAG_WALL = 2^2 = 4 --like a sponge or water drops on surface // Zero velocity
    --(it only works with two Particles group like
    --minium but another particles group must have different Flag)
    --b2.ParticleSystem.FLAG_ZOMBIE = 2^1 = 2 --Removed after next simulation step.
    --b2.ParticleSystem.FLAG_WATER = 0 --water

    Sample: b2.ParticleSystem.FLAG_COLOR_MIXING | b2.ParticleSystem.FLAG_WALL
    The particle type. Can be combined with the | operator


    It would be interesting than we have b2ContactFilter -Line 99- as event Read more information here) so when we'll use lifespan, we can do something in that event specific

    896 x 609 - 243K
  • Ok review some information here

    and here too
    see lines from 346 to 422

    I Tried the next code
    require "box2d"
    local cw=application:getContentWidth()
    local ch=application:getContentHeight()
    -- this table holds the dynamic bodies and their sprites
    local actors = {}
    -- create world
    local world = b2.World.new(0, 9.8)
    -- create ground body
    local ground = world:createBody({})
    -- create an edge shape, and attach it to the ground body as a fixture
    local shapeb = b2.EdgeShape.new(0, ch, cw, ch)
    local shapet = b2.EdgeShape.new(0, 0, cw, 0)
    local shapel = b2.EdgeShape.new(0, 0, 0, ch)
    local shaper = b2.EdgeShape.new(cw, 0, cw, ch)
    ground:createFixture({shape = shapeb, density = 0})
    ground:createFixture({shape = shaper, density = 0})
    ground:createFixture({shape = shapel, density = 0})
    ground:createFixture({shape = shapet, density = 0})
    local shape1 = b2.PolygonShape.new()
    shape1:setAsBox(200, 50)
    local shape2 = b2.PolygonShape.new()
    shape2:setAsBox(200, 100)
    local ps1= world:createParticleSystem({ radius=5})
    color = 0xFFFF00,
    flags=4|256|2^15 --on BeginContactParticle and on BeginContactParticle 2, I suppose in the first case too
    --Doesn't Work or maybe I missed something
    local function onBeginContactParticle(e)
    local fixture = e.fixture
    local index = e.index
    local system = e.system
    print("Hello Particle",fixture,index,system)
    local function onBeginContactParticle2(e)
    local indexA = e.indexA
    local indexB = e.indexB
    local system = e.system --<-- I get nil value
    print("Hello Particle 2",indexA,indexB,system)
    color = 0xFF0000,
    color = 0x0000FF,
    local function onEnterFrame(e) world:step(1/60, 8, 3) end
    stage:addEventListener(Event.ENTER_FRAME, onEnterFrame)

    (*/ Read More Information Here)

    As I said in my first post better are
    b2.ParticleSystem.FLAG_PARTICLE_CONTACT_FILTER = 2^17
    b2.ParticleSystem.FLAG_FIXTURE_CONTACT_FILTER = 2^16

    But these functions are not yet available on Gideros I don't know if core team will implementation these function

    On another hand something had tried Event.BEGIN_CONTACT_PARTICLE 'cos it doesn't work for me but maybe I'm doing It Wrong

  • Gideros is open source, we need someone to update to the latest LiquidFun and add all the missing and new api commands. Do you want to do it?
  • Well, If I'll try this may happen much later 'cos my cpp knowdelege are minimal (a lot time without write in this programing language) , added to the above never I've tried the Lua C API so I couldn't give you a certain end date.

    On the other hand, How Can I test these changes? How Can I know if I'm on the right way? :-/
    I remember asking these matters when Gideros changed to open source, but nobody told me how to create the installation files if you changed something on the source code...
    Currently Does exist some tutorial for it?
  • This is a interesting one, the flags are there so if you change your code to...

    ... then the events trigger - BUT only one of them can be active at one time. So if you comment out your Particle2 listener then the first one should work. Same if you add two end contact listeners, only one of the four will work.

    Also neither of them get e.system, even though it looks like it's pushed to Lua by Gideros. On lines 488-489 here..


    ... and getb2 looks like it's working for world and fixture, but not the particle system.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Login with Facebook Sign In with OpenID

In this Discussion

Top Posters