Topic: Particles: BRAINSTORMING(Need help)

I am trying to HACK OUT a way to do particles in maratis: And I do mean hack!
PunBB bbcode test

I added an explosion physics effect to a subdivided cube. I then added ONE BONE to the cube. I saved the maratis mesh out at the first frame, then at a few frames later, and then at a few frames after that etc.

So now I have several meshes from that one particle system. (I could have baked in ambient occlusion also)

I could use a little bit of scripting to make it iterate between the meshes to create a sort of animation.

But this is PAINFULLY SLOW, especially if I wanted every frame (I only had 14 frames, but still). And this is only one way to do it (could use render to texture somehow, or texture animation (hmmm, sounds like a good idea)).

But what if I want the objects to actually be 3D?

Anyone have any brainstorming ideas on how I could hack some particles in a better way?

So far my lua script looks like this:

part1 = getObject("1")
part2 = getObject("2")
part3 = getObject("3")
part4 = getObject("4")

spawn = true

particles = {part1,part2,part3,part4}

Last edited by Tutorial Doctor (2013-10-18 16:50:13)

Re: Particles: BRAINSTORMING(Need help)

Tutorial Doctor wrote:

I am trying to HACK OUT a way to do particles in maratis: And I do mean hack!
PunBB bbcode test

I added an explosion physics effect to a subdivided cube. I then added ONE BONE to the cube. I saved the maratis mesh out at the first frame, then at a few frames later, and then at a few frames after that etc.

So now I have several meshes from that one particle system. (I could have baked in ambient occlusion also)

I could use a little bit of scripting to make it iterate between the meshes to create a sort of animation.

But this is PAINFULLY SLOW, especially if I wanted every frame (I only had 14 frames, but still). And this is only one way to do it (could use render to texture somehow, or texture animation (hmmm, sounds like a good idea)).

But what if I want the objects to actually be 3D?

Anyone have any brainstorming ideas on how I could hack some particles in a better way?

This depends on how close you will be to the object, A Texture Animation on a plane would be good for most things, there is a tutorial on the forums here . http://forum.maratis3d.com/viewtopic.php?id=301 and http://forum.maratis3d.com/viewtopic.php?id=98 if your not using blender thats fine you should be able to work out how its done in your own 3d package.

Partical with physics is here http://forum.maratis3d.com/viewtopic.php?id=550 just keep the particle count down.

Re: Particles: BRAINSTORMING(Need help)

Thanks Zester. I have been looking at the Special Effects demo to see what is wrong with it (it crashes Maratis if I hit the space bar too close together.)

I also got a texture animation into Maratis for water (I wonder if I can use some of those After Effects effects hmm)

I do wonder however if there is a way to export every frame as an object automatically?

Re: Particles: BRAINSTORMING(Need help)

Tutorial Doctor wrote:

Thanks Zester. I have been looking at the Special Effects demo to see what is wrong with it (it crashes Maratis if I hit the space bar too close together.)

I also got a texture animation into Maratis for water (I wonder if I can use some of those After Effects effects hmm)

I do wonder however if there is a way to export every frame as an object automatically?

Honestly I can't really say as I don't know, I only really use Maratis for simple games and I use it to teach game development to my kids other than that I use my own engine a"Horde3D" fork, or Ogre3D

https://lh4.googleusercontent.com/-U6kw6dCmOY0/T7GcntK0wdI/AAAAAAAAAPU/JjT9e0ABqVU/w303-h238-n-k/horde3d.png

https://lh5.googleusercontent.com/-jRVMKS4m4Rw/T7GcmIQ34qI/AAAAAAAAAPE/xJDIlOWEQlw/w307-h184-n-k/horde3d2.png

https://lh5.googleusercontent.com/-PrZm-f8hM8k/T7Gck7CcFXI/AAAAAAAAAO8/feY1fWWTnHw/w310-h184-n-k/horde3d3.png

https://lh4.googleusercontent.com/-oiB9XKV_uhk/T7GckkgQUyI/AAAAAAAAAO0/6uYaPlTiudg/w306-h184-n-k/horde3d4.png

https://lh4.googleusercontent.com/-gzJC-0WZut8/T7GcmogAJ5I/AAAAAAAAAPM/-T6ST89EotU/w398-h238-n-k/horde3d1.png

Lua Example Code

-- Create Window Object
win = Window()
win:init()
win:openWindow(800, 600, 8, 8, 8, 8, 24, 0, 0) -- Open Window, Set Max Colors, Alpha, Depth, Stencel 
win:setWindowTitle("Hydra Example v0.0.1a") -- Set Window Title
win:clearColor(0.50, 0.0, 0.0, 1.0) -- Set Window RGBA background color

-- Create GraphicsEngine Object
graphics = GraphicsEngine()
graphics:init()

graphics:setOption(7, 1)
graphics:setOption(5, 0)
graphics:setOption(8, 0)
graphics:setOption(4, 4)
graphics:setOption(9, 2048)

forwardPipeRes = graphics:addResource(9, "pipelines/forward.pipeline.xml", 0)
knightres = graphics:addResource(1, "models/knight/knight.scene.xml", 0)
logoMatRes = graphics:addResource(4,  "overlays/logo.material.xml", 0) 
lightMatRes = graphics:addResource(4,  "materials/light.material.xml", 0) 
envRes = graphics:addResource(1,  "models/platform/platform.scene.xml", 0) 
skyBoxRes = graphics:addResource(1,  "models/skybox/skybox.scene.xml", 0) 

graphics:loadResourcesFromDisk("../content") 

cam = graphics:addCameraNode(1, "Camera", forwardPipeRes)
graphics:setNodeTransform( cam, 10, 50, 200, 0, 0, 0, 1, 1, 1 )

env = graphics:addNodes(1, envRes)
graphics:setNodeTransform(env, 0, 0, 0, 0, 0, 0, 5, 5, 5)

sky = graphics:addNodes(1, skyBoxRes)
graphics:setNodeTransform(sky, 0, 0, 0, 2, 2, 2, 500, 500, 500)
graphics:setNodeFlags( sky, 2, true )

knight = graphics:addNodes(1, knightres )
graphics:setNodeTransform( knight,  0, 0, 40, 0, 0, 0, 1, 1, 1 )

light = graphics:addLightNode(1, "Light1", lightMatRes, "LIGHTING", "SHADOWMAP" )
graphics:setNodeTransform( light, 0, 100, 50, -30, 0, 0, 10, 10, 10 )
graphics:setNodeParamF( light, 501, 0, 200 )
graphics:setNodeParamF( light, 502, 0, 90 )
graphics:setNodeParamI( light, 505, 3 )
graphics:setNodeParamF( light, 506, 0, 0.9 )
graphics:setNodeParamF( light, 507, 0, 0.001 )
graphics:setNodeParamF( light, 503, 0, 0.9 )
graphics:setNodeParamF( light, 503, 1, 0.7 )
graphics:setNodeParamF( light, 503, 2, 0.75 )

graphics:setNodeParamI( cam, 609, 0 );
graphics:setNodeParamI( cam, 610, 0 );
graphics:setNodeParamI( cam, 611, 800 );
graphics:setNodeParamI( cam, 612, 600 );
graphics:setupCameraView(cam, 45.0, 800 / 600, 0.5, 2048.0);
graphics:resizePipelineBuffers( forwardPipeRes, 800, 600 );


-- Create 3D Sound Object
sound = Sound()
sound:init() -- Initalize it
sound:createSound("../content/sounds/Scoldt-From_My_Guts.mp3") -- Load Music File
sound:setMode(0) -- Set Mode
sound:play() -- Play Music
sound:upDateSystem() -- Update Sound System

-- Create Network Client Object
networkClient = NetworkClient()
networkClient:init("testgame","1") -- Initalize it
networkClient:setAddress("81.168.26.50") -- Set Network Address

-- Start Game Loop
i = 0
while i == 0 do
    win:clear(0) -- Clear Window

    i = win:getKey(257) or win:getWindowParam(0) -- Get ESC and Window Close Button Click

    -- Rendering code goes here --
    graphics:render( cam )
    graphics:finalizeFrame()
    graphics:clearOverlays()

    win:swapBuffers() -- Swap Graphic Buffers
end

Re: Particles: BRAINSTORMING(Need help)

Here are a couple different effects I got playing with the Maratis Particle Effects example.

I disabled physics for all examples, performance was excellent.

100 Particles
https://lh6.googleusercontent.com/-kNAjRIf4Oto/Uk0CiWoOGuI/AAAAAAAABG0/Ul0FatOde9Y/w860-h646-no/snapshot33.png

20 Particles
https://lh3.googleusercontent.com/-6Lt6N65rlaE/Uk0CirDgtuI/AAAAAAAABGw/uoTO3qbIkyk/w862-h646-no/snapshot36.png

20 Particles
https://lh5.googleusercontent.com/-ryAigR1nmtI/Uk0CiiyIN4I/AAAAAAAABG4/vOBjYEQ1yeQ/w864-h646-no/snapshot37.png


Using a Cone Shape(Rotating) with some debri parented to the cone, an animated texture and a small particle emitter at the bottom of the cone using a dust particle I bet you could make a pretty cool looking tornado.


If your creative and don't emit more than 200-250 particles you can defiantly get some decent effects. The particle count is so low do to lua and not the graphics engine, I hit the threshold regardless if I use my on-board intel gpu or my Nvidia GT 640 card.

You could probable get 2000+ particles if done in c++.

Here are the particle textures I used.

https://lh3.googleusercontent.com/-qRYKbvmVBuE/Uk0H375skrI/AAAAAAAABHc/YXBGINqhhE8/w640-h360-no/45126915_640.jpg

https://lh6.googleusercontent.com/-xKgbblIM0fM/Uk0H7MXimLI/AAAAAAAABHk/o-rcSiRMP1I/w198-h197-no/fire.png

And my changes to the effects.lua script

-----------------------------------------------------------------------------------
-- Maratis
-- effects.lua
-----------------------------------------------------------------------------------

-- GUI
Camera = getObject("Camera")
GUIScene = getScene("GUI")
enableCameraLayer(Camera, GUIScene)

-- pseudo particle system
Emitter = getObject("Emitter")
Particle = getObject("Particle")


-- particles functions
function getRandomDir(force)

    return {(math.random()-0.5)*force, (math.random()-0.5)*force, (math.random()-0.5)*force}

end

function initParticle(particle)

    size = 10.0 + math.random()
    life = math.max(0.50, math.random())

    setAnimationSpeed(particle, life) -- we use the animation speed to control the particle life
    changeAnimation(particle, 0)
    setCurrentFrame(particle, 0)

    clearForces(particle)
    setPosition(particle, getPosition(Emitter))
    setScale(particle, {size, size, size})
    --addCentralForce(particle, getRandomDir(1))
    
end

function createParticle()

    particle = getClone(Particle)
    initParticle(particle)

    return particle
    
end

function addParticle()
    table.insert(particlesList, #particlesList + 1, createParticle())
end

function updateParticle(particle)

    if isAnimationOver(particle) then
        deactivate(particle)
    end

    if onKeyDown("SPACE") then

        activate(particle)
        initParticle(particle)

    end
    
end


-- create particle system (64 particles + 1)
particlesList = {Particle}

initParticle(Particle)

for i=1, 20 do
    addParticle()
end


-- scene update
function onSceneUpdate()

    for i=1, #particlesList do
        updateParticle(particlesList[i])
    end

end

Note I moved my emitter to the ceiling and rotated to shoot downwards.

Last edited by zester (2013-10-03 06:03:54)

Re: Particles: BRAINSTORMING(Need help)

Tutorial Doctor wrote:

I have been looking at the Special Effects demo to see what is wrong with it (it crashes Maratis if I hit the space bar too close together.)

TD, the crash is due to a small bug in the activate()/deactivate() functions that Anaël has fixed in r204.
If you don't use an up to date build, I've posted a turnaround here:

http://forum.maratis3d.com/viewtopic.php?id=757

Basically you ensure that an object is active before deactivating it or that it is inactive before activating it.

Re: Particles: BRAINSTORMING(Need help)

I am wondering if I could use this particle system with Maratis's constraints to create multiple characters.

Edit: I was able to use it with a 3d object! now for an animated one!

Last edited by Tutorial Doctor (2013-10-28 18:13:23)