Find Target -> Particles

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
Old 09 September 2008   #16
Can you post a screenshot of the flow?
Are you positive the Script Operator updates the Find Target on every frame?
Can I also see the source code of the Script Operator?
__________________
Bobo
 
Old 09 September 2008   #17
That makes sense since Bobo says I shouldn't use the follow target animation. However, that makes it very hard to make the asteroid-belt I was thinking about.

The plan was to use a torus as a scatter-area, and then animate the torus to rotate slightly, so that the belt rotated around a planet, while using a spin operator on the asteroids so that they would spin in different directions.

edit:

Didn't see your post before I replied, Bobo. I'll post a screenie in a min.

Sourcecode:
 on ChannelsUsed pCont do
(
pCont.useVector = true
pCont.usePosition = true
)
on Init pCont do 
(
 
)
on Proceed pCont do 
(
count = pCont.NumParticles()
theOtherSystem = $PF_Asteroids
count2 = theOtherSystem.NumParticles()
minCount = amin #(count, count2)
for i in 1 to minCount do
(
pCont.particleIndex = i
theOtherSystem.particleIndex = i
pCont.particleVector = theOtherSystem.particlePosition
)
)
on Release pCont do 
(
 
)
Attached Images
File Type: gif asteroid8.gif (44.7 KB, 16 views)

Last edited by krifos : 09 September 2008 at 05:37 PM.
 
Old 09 September 2008   #18
It seems to be working (better) now ... I think the reason why it didn't update properly was because I used the "cache"-operator. It was set to update always, but it didn't ... Deleting it and the rockets are following the asteroids when I'm moving the box.


However, another problem occured - as soon as one of the rockets has hit it's target, some of the other rockets suddenly change theirs.

When the animation starts, all rockets has different target, but this is what happens in the end. The greens are asteroids, the reds are impacts.
Attached Images
File Type: gif asteroid9.gif (37.7 KB, 12 views)
 
Old 09 September 2008   #19
Originally Posted by krifos: However, another problem occured - as soon as one of the rockets has hit it's target, some of the other rockets suddenly change theirs.

When the animation starts, all rockets has different target, but this is what happens in the end. The greens are asteroids, the reds are impacts.


This was to be expected and can be fixed by using particleID instead of particleIndex.

What happens is this: The Script Operator asks how many targets are there in the other system. It also checks the count in the current event. Let's say you have 6 asteroids and 5 rockets. So it takes the lesser of the two and sends 5 rockets to 5 asteroids. Then a rocket, say #3, hits asteroid #3. The rocket is sent out and deleted, which gives you only 4 rockets in the event, 1,2,4 and 5. So suddenly rocket 4 has index 3 and 5 has index 4. Both have to change course and attack asteroids 3 and 4 instead of 4 and 5, because the count in the rockets container has changed.

But BornIDs are unique and given to particles at their birth. This makes them solid and unchanging. Thus, rocket 5 will always be rocket 5, even if its index is a different number because others have been deleted.

I have this case covered in my upcoming DVD about Scripting Particle Flow which I finished recording last month (but is awaiting the new download system of CG-Academy to get released). Here is the general idea:


on ChannelsUsed pCont do
  (
  	 pCont.useVector = true
  )
  
  on Init pCont do 
  (
   
  )
  
  on Proceed pCont do 
  (
  	count = pCont.NumParticles()
  	otherSystem = $PF_Asteroids
  	for i in 1 to count do
  	(
  		pCont.particleIndex = i --set the current rocket's index
  		local pIndex = 0 --init. a variable
   --see if the other system has a particle with the same BornID as the current rocket ID:
  		otherSystem.hasParticleID pCont.particleID &pIndex
  		if pIndex > 0 do --if it does, 
  		(
  			otherSystem.particleIndex = pIndex --set that asteroid as the current one
  			pCont.particleVector = otherSystem.particlePosition --and grab its position
  		)	
  	)
  )
  
  on Release pCont do 
  (
   
  )


As result, if you give birth to 5 rockets in the second system, they will get Born IDs from 1 to 5 and KEEP THEM. If you have 6 asteroids in the other system, they will also be numbered from 1 to 6. If you delete rocket with ID 3, asteroid 3 will never be attacked again because the rockets with IDs 4 and 5 will always attack asteroids with IDs 4 and 5, regardless of the order inside the event's container.
__________________
Bobo

Last edited by Bobo : 09 September 2008 at 06:32 PM.
 
Old 09 September 2008   #20
Great, that worked Thanks so much for the help. That DVD of yours, what difficulty is it targeted at? Beginners / intermediate / experts etc?

I would love to learn som scripting, but somehow my brain is totally malfunctioning whenever it comes to anything that looks like programming / scripting. It's like watching a big question-mark.



edit: by the way, when I add a spawn-operator after the find target operator (in the same event), it messes up the script, all the rockets then change targets and some of the asteroids gets hit by multiple rockets.

I've added a spawn by travel so that the rockets will create smoke-effect, which works perfect when I'm not using the script-op.


In my current system it seems that the last 6 of the 10 rockets are sent directly to the center of world space (0,0,0). The first 4 is working as they should. This changes as I change the settings of the spawn by travel.



edit2: this seems to be related to that they are spawning one each 2nd frame. When they all spawn on the same frame, they all find their targets.



edit3: could this be because they generate new particles which gets IDs equal to the asteroid IDs? So when the first rocket spawn, it travels, generates new particles, and thus "spending" all the asteroid IDs.

Guess that could be fixed by offsetting all the ID's in the smoke-event with +1000 or so? Possible to do this via script?


edit: .flv-video: http://threedee.krifos.com/wp-conte...rticletest2.zip
Attached Images
File Type: gif asteroid10.gif (42.9 KB, 9 views)

Last edited by krifos : 09 September 2008 at 07:19 PM.
 
Old 09 September 2008   #21
Originally Posted by krifos: Great, that worked Thanks so much for the help. That DVD of yours, what difficulty is it targeted at? Beginners / intermediate / experts etc?

I would love to learn som scripting, but somehow my brain is totally malfunctioning whenever it comes to anything that looks like programming / scripting. It's like watching a big question-mark.




edit3: could this be because they generate new particles which gets IDs equal to the asteroid IDs? So when the first rocket spawn, it travels, generates new particles, and thus "spending" all the asteroid IDs.

Guess that could be fixed by offsetting all the ID's in the smoke-event with +1000 or so? Possible to do this via script?


The DVD will be targeted at people like you who know enough (intermediate level) PFlow but do not script much. From my point of view, it is an introduction into scripting Particle Flow, so it covers the basics. So I tried to keep it simple. Some math knowledge wouldn't hurt though. My "The Matrix:Explained" DVD would be a good companion.

Now to your problem - yes, you fire the rockets over multiple frames, and the trails of the first rocket "eat up" your IDs. The simplest solution would be to give birth to all your rockets on frame 0, then keep them invisible in the initial event and "fire" them by using an Age Test or something like that (a Script Test could also be used for more controlled firing). Thus, the rockets would always get the first N IDs, then you can spawn at your heart's will. Note that you can assign local Render operators to make particles invisible to the renderer in specific events.

The scripted alternative would be to use a Script Operator which initializes and increments a global "rocket launcher" counter and writes the rocket's number into its Script Integer channel. So instead of using the ID, you would be handing out the numbers and use the Script Integer channel of each particle inside the targeting Script Operator to decide which asteroid to attack. In addition, you could generate RANDOM values to store in the Script Integer channel based on the amount of asteroid particles, so you could have multiple rockets targeting the same asteroid (if desired), or any other special decisions like "never target asteroid 3" and so on. But this is more complicated and requires a bit of scripting knowledge, so try the first approach first...
__________________
Bobo

Last edited by Bobo : 09 September 2008 at 07:31 PM.
 
Old 09 September 2008   #22
Great - Hope it's released soon


And, I'll go for the first approach and mess around to see if I can get the results I want

Thanks again for great help!
 
Old 09 September 2008   #23
Hi Bobo,

When will your DVD be released? Any chances to order it in advance?

Looking forward to it.

-Jignesh
__________________
www.jhjariwala.com
Demoreel 2012

Last edited by jigu : 09 September 2008 at 03:47 AM.
 
Old 09 September 2008   #24
Originally Posted by jigu: Hi Bobo,

When will your DVD be released? Any chances to order it in advance?

Looking forward to it.

-Jignesh


It looks like it will be the first title by CG-Academy to be released as a downloadable tutorial. So in the beginning it won't be a DVD technically speaking. But you don't have to order in advance, as you would be able to buy it online and download it immediately the day it is released.

I finished "principal recording" in August. It needs to be edited into the final product which includes illustrations, transitions, menus and so on. So I cannot really tell when it will be out. It is mostly up to CG-Academy from now on. Keep your eyes open for posts by Chris Thomas...
__________________
Bobo
 
Old 09 September 2008   #25
Thanks bobo for the information. I look forward to it.

Hope to get it this "Diwali"(Hindu's new year) in November...
__________________
www.jhjariwala.com
Demoreel 2012
 
Old 10 October 2008   #26
see in november :-)
 
Old 10 October 2008   #27
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 10:51 PM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.