realbasic-games
[Top] [All Lists]

Re: trimesh particles demo, version 2

To: realbasic-games at lists dot realsoftware dot com
Subject: Re: trimesh particles demo, version 2
From: "Lars Jensen" <larsjensen at gmail dot com>
Date: Thu, 5 Oct 2006 01:05:58 -0700
Delivered-to: listarchive at realsoftware dot com
Delivered-to: realbasic-games at lists dot realsoftware dot com
Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=mBevQEnVvCWDGb8z0cZL9sb1H8DsNyGxyJwRlcPMP3BWYWAPwq7G8QObinhBNaUZyBtpK5aUmlA02S2mw4OFHBbDcqPKUHpxcYuZTWF1m90bfbYrylSTbjJAeoggZmL4nM/gKGa/nXfPT90ai7l3FFvCi6wXFj950ae5XlwDhG4=
www.jcquan.com/RB/TrimeshParticles2.zip

Beautiful!

I noticed the bursts had a slightly squarish initial shape, so I
changed it to randomize initial particle positions using spherical
coordinates instead of Cartesian coordinates. In the two trimesh
constructors, I changed this line:

 Direction.Append New Vector3D(Rnd-0.5, Rnd-0.5, Rnd-0.5)

to this:

 Direction.Append RandomSphericalVector3D

and added this function:

===================

Function RandomSphericalVector3D() As Vector3D

 const Pi  = 3.1415926536
 const Pi2 = 6.2831853072

 dim Lon as double = Rnd*Pi2
 dim Lat as double = (Rnd-0.5)*Pi
 dim CosLat as double = Cos(Lat)

 dim Ret as new Vector3D(CosLat*Cos(Lon), CosLat*Sin(Lon), Sin(Lat))

 Ret.MultiplyBy Rnd // scale radius from 0-1

 return Ret

End Function

===================

In this version, particles will be denser toward the origin, but
that's how explosions are, so it looks good. One could get a uniform
density within a sphere simply by generating vectors the original way
and rejecting ones that fall outside a given radius.

I think it helps the look of the demo, although it might not matter in
a game if other stuff is happening at the same time.

lj
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>


<Prev in Thread] Current Thread [Next in Thread>