Flint Particle System Forum - Alternativa Support for FLINT Particles Mon, 12 Dec 2011 02:18:37 +0000 http://flintparticles.org/forum/ Lussumo Vanilla 1.1.10 & Feed Publisher Alternativa Support for FLINT Particles http://flintparticles.org/forum/comments.php?DiscussionID=172&Focus=680#Comment_680 http://flintparticles.org/forum/comments.php?DiscussionID=172&Focus=680#Comment_680 Fri, 13 Feb 2009 11:25:20 +0000 mpelham The Alternativa Engine is, unfortunately, closed source. This could make development difficult, however, much of the structure is deja-vu inducingly familiar to PV3D and Away3D. I've begun writing an AlternativaRenderer, but am coming across a few issues getting the Particles mapped to Object3Ds (DisplayObject3D/Containers in Alternativa's Lingo) and am thinking the better choice is the Sprite3D class. This class can be extended for multiple phases (IE a timeline) relatively easily, supports transparency and is native to the engine.

Maybe I'm the only one out here craving this confluence, but I'll post my delvings here in the hopes that some other braver and wiser soul comes across it:
package {
import flash.display.*;

import org.flintparticles.common.particles.Particle;
import org.flintparticles.common.renderers.RendererBase;
import org.flintparticles.common.utils.Maths;
import org.flintparticles.threeD.papervision3d.utils.Convert;
import org.flintparticles.threeD.particles.Particle3D;

//import org.papervision3d.core.math.Number3D;
//import org.papervision3d.core.math.Quaternion;
import alternativa.utils.MathUtils;

//import org.papervision3d.objects.DisplayObject3D;
//import org.papervision3d.core.proto.DisplayObjectContainer3D;
import alternativa.engine3d.core.Object3D;
import alternativa.engine3d.core.Sprite3D;

//import org.papervision3d.materials.MovieMaterial;
import alternativa.engine3d.materials.SpriteTextureMaterial;
import alternativa.types.Texture;

//import org.papervision3d.objects.primitives.Plane;
import alternativa.engine3d.primitives.Plane;

/**
* Renders the particles in a Papervision3D scene.
*
* <p>To use this renderer, the particles' image properties should be
* Papervision3D objects, renderable in a Papervision3D scene. This renderer
* doesn't update the scene, but copies each particle's properties
* to its image object so next time the Papervision3D scene is rendered the
* image objects are drawn according to the state of the particle
* system.</p>
*/
public class AlternativaRenderer extends RendererBase {
private var _container:Object3D;
public function AlternativaRenderer( container:Object3D ) {
super();
_container = container;
}
override protected function renderParticles( particles:Array ):void {

var o:Sprite3D;
var texture:Texture;
var textureMaterial:SpriteTextureMaterial;
var bd:BitmapData;
for each (var p:Particle3D in particles) {
bd = new BitmapData(DisplayObject(p.image).width, DisplayObject(p.image).height, true, 0x000000);
bd.draw(p.image);

texture = new Texture(bd);

textureMaterial = new SpriteTextureMaterial(texture);
o.material = textureMaterial;

trace(o+":"+o.material); // THIS DOES NOT TRACE - ERROR

o.x = p.position.x;
o.y = p.position.y;
o.z = p.position.z;
o.scaleX = o.scaleY = o.scaleZ = p.scale;

// rotation
/* var r:Number3D = Convert.QuaternionToPV3D( p.rotation ).toEuler();
o.rotationX = Maths.asDegrees( r.x );
o.rotationY = Maths.asDegrees( r.y );
o.rotationZ = Maths.asDegrees( r.z );*/
}
}

override protected function addParticle( particle:Particle ):void {
_container.addChild( Sprite3D( particle.image ) ); //ERROR
}

override protected function removeParticle( particle:Particle ):void {
_container.removeChild( Sprite3D( particle.image ) ); //ERROR
}
}
} ]]>
Alternativa Support for FLINT Particles http://flintparticles.org/forum/comments.php?DiscussionID=172&Focus=685#Comment_685 http://flintparticles.org/forum/comments.php?DiscussionID=172&Focus=685#Comment_685 Sat, 14 Feb 2009 15:32:04 +0000 Richard
I'd like to get Flint working with Alternativa3D, but it's not currently a priority for me so it's great that you're doing it. If you need some pointers, I would be very happy to make suggestions.

One thought - you'll need some Alternativa3D specific initializers to initialize the image to a Sprite3D object and to set this object's texture, similar to the classes in Flint's papervision3D initializers.

Keep posting issues and updates here and hopefully we can encourage you to keep working on it and help you out as necessary.

Richard ]]>
Alternativa Support for FLINT Particles http://flintparticles.org/forum/comments.php?DiscussionID=172&Focus=721#Comment_721 http://flintparticles.org/forum/comments.php?DiscussionID=172&Focus=721#Comment_721 Sun, 08 Mar 2009 01:13:58 +0000 mpelham I'll host them on my site tonight or tomorrow. ]]> Alternativa Support for FLINT Particles http://flintparticles.org/forum/comments.php?DiscussionID=172&Focus=722#Comment_722 http://flintparticles.org/forum/comments.php?DiscussionID=172&Focus=722#Comment_722 Sun, 08 Mar 2009 01:19:14 +0000 mpelham It will currently take any DisplayObject and pass on to the needed ImageClass. No 3D support but hey, I moved on to other projects, sue me :D.
There is a particle test included.

http://www.mattpelham.com/AX/ ]]>
Alternativa Support for FLINT Particles http://flintparticles.org/forum/comments.php?DiscussionID=172&Focus=723#Comment_723 http://flintparticles.org/forum/comments.php?DiscussionID=172&Focus=723#Comment_723 Sun, 08 Mar 2009 01:20:38 +0000 mpelham