That was awesome!!! So much detail :D
With regards to the 3d transform the idea was to avoid integrating the
parent transform explicitly for the child. It really depends on what
you're more comfortable with. In this example, just moving in x and y
either way is fine, but if you find yourself passing a ton of
transformation data you might as well use a 3d transform.
As far as limiting the position you could use a math patch to clamp
using min and max functions.
So, if you wanted to make sure the right edge of the child sprite
couldn't go past the right edge of the parent sprite you could simply
pass the x value which will be used to drive the child sprite into a
math patch which was taking the minimum of the current x position and
the parent width/2 - child width/2 (this represents the right edge of
the parent, minus the width of the child). It always helps to draw
this stuff out on paper.
.xX
On Oct 23, 2007, at 8:23 PM, Andrew Ohlmann wrote:
I've "parented" stuff with 3d transform before, but it's not
necessary for this application, and if I understand you right then
it's not a very complicated solution, but it requires you to get out
the calculator and do a little scaling.
For example, you have a sprite that is .5 x .5, and you want to move
a sprite that is .1 x .1 from the bottom to the top of that sprite
in accordance with how loud your audio is.
Set up your the patch that's moving the big square so that it sends
the Y coordinate to be the last value in a Math patch with three
operands/operations, and hook up the result of your math patch to
the y value of the little sprite you want to move.
set up operation # 1 of the math patch to Multiply, because you want
to scale down the movement caused by the audio input.
Enter in .4 for operand #1. if the small sprite was just one pixel,
then you could set it to .5 or .49 (remember, this is the 'boundary'
dimension of the sprite that we're working with), but since it takes
up .1 units of space, that extra scaling is needed to keep that
sprite in bounds. so if the small sprite was .2 units high, you'd
scale by .3, and so on.
After this, you'll need to adjust the position of the smaller sprite
again. Since audio goes from 0-1 (or rather, 0-.4, now that it's
scaled down) and not -.5 to .5 (or from -.2 to .2), we need to make
it so. just set operation 2 to Add and operand to -.2, so then the
sprite falls neatly inside the box.
There's also stuff you can do like using the conditional patch so
that if falls out of the coordinates of the box that it will reverse
its course and stay in the box, but I don't think that's what you're
looking for.
A second solution that might work better for you, if you plan on
using multiple copies of the nested sprite, would use the Render In
Image patch. This solution might not be as pretty or as processor-
friendly as the previous solution. It would prove to be more
versatile, though, and probably simpler in execution as well!
Start by taking a Render in Image Patch and then hooking it up to
your larger sprite (again, a .5 x .5 square)
go into the render in image patch and then create a sprite that
moves around as you need it to, taking the audio in data and then
scaling it to the screen as you would for the sprite in the previous
instructions (except the dimensions of the screen are 2 by 1.5).
since you're outputting a 2 x 1.5 space to a .5 x .5 square, the
image inside the square will look distorted. You can solve this by
using the inspector on the Render in Image patch and inputting
dimensions (I usually use 512 x 512 pixels for most things) that
match the proportion on the larger square that you're rendering to,
and then the dimensions of the space that you're rendering onto the
sprite become an even 2 x 2 units.
Hope this helps!
Andrew
On Oct 23, 2007, at 1:54 PM, Andrew Larking wrote:
Hi all.
Is it possible to have audio move a sprite, or cube for that
matter, around within a given size which is moving also? Imagine a
square, which is slowly moving downwards. How could I make a
smaller square move within the confines of the larger square
without stepping out of the boundary, which of course would be
moving?
Sorry if I wrote that in the most complex way possible!
Thanks, A.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Quartzcomposer-dev mailing list ([email protected]
)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/quartzcomposer-dev/andrewohlmann%40gmail.com
This email sent to [EMAIL PROTECTED]
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Quartzcomposer-dev mailing list ([email protected]
)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/quartzcomposer-dev/asabatelli%40apple.com
This email sent to [EMAIL PROTECTED]
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Quartzcomposer-dev mailing list ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/quartzcomposer-dev/archive%40mail-archive.com
This email sent to [EMAIL PROTECTED]