PDA

View Full Version : distance from a moving object


loran
10-07-2009, 05:35 PM
I want to create keyframe for objects depending of their distance from a moving object.
Need help!

denisT
10-07-2009, 05:55 PM
I want to create keyframe for objects depending of their distance from a moving object.
Need help!

try to explain better what you want to do...

do you have a set of static objects and do you want to create a key for any object of this set depending of the distance between this object and some moving object not from this set? What kind of key (type of controller) do you need to create?

loran
10-07-2009, 06:49 PM
Ok, imagine many objects in a scene, then a SphereDummy moving trough the scene. When object is in the sphere radius a keyframe is created in visibility then another 15 frame later with a new visibility value. Basically the SphereDummy contact with object make them appear.
I just can't find a good basis for detecting distance along the time...
I am learning So I need some help. Thank you.

here is my very start:
for o in objects do
(o.visibility = bezier_float()

with animate on
(--rndm = random 0 10
fr1 =
duration = 15

at time (fr1) o.visibility.controller.value = 0
at time (fr1+duration) o.visibility.controller.value = 1
)
)

denisT
10-07-2009, 07:09 PM
Ok, imagine many objects in a scene, then a SphereDummy moving trough the scene. When object is in the sphere radius a keyframe is created in visibility then another 15 frame later with a new visibility value. Basically the SphereDummy contact with object make them appear.
I just can't find a good basis for detecting distance along the time...
I am learning So I need some help. Thank you.

here is my very start:

do you want to generate keys in real time or you want to create and bake keys using existent animation of some object?

in the first case you have to use some moving callback to check a current distances like:
when transform moving_obj changes handleAt:#timeChange do
(
at time currenttime with animate on with undo off
(
for obj in static_list where (d = distance obj moving_obj) < something do
obj.visibility = <whatevere you want>
)
)

it's better to organize it as a function and define an ID for this change handler


second case:

define the time interval for baking and time step...
lets say interval is (interval 0 100f) and step is 1 frame

for f=0 to 100 do at time f
(
for obj in static_list where (d = distance obj moving_obj) < something do
with animate on obj.visibility = <whatevere you want>
)


i can't check the code, so use this as an idea...

denisT
10-07-2009, 07:14 PM
... of course if you want to make kinda "fade in - fade out" effect you have to check the distance for less and more, and create keys for both conditions if it's necessary.

denisT
10-07-2009, 07:24 PM
oops.. my bad...
of course it must be obj.visibility = ... --- (not obj.visible)

loran
10-07-2009, 08:09 PM
interested in second case... but i m lost!!

this doesn't work :/


for o in objects where (d = distance o $SphereGizmo01) < 50 do
(with animate on
(

for f=0 to 50 do at time f o.visibility.controller.value = 0
for f=0 to 50 do at time f+ 15 o.visibility.controller.value = 1
)
)

denisT
10-07-2009, 08:27 PM
lets define the task more exactly...

1. we have a list of static objects and one moving object
2. every object from the list has bezier float type of visibility controller
3. if the distance between some object from the list and the moving object becomes less then something it sets visibility of the object to 0 (step key)
4. any object from the list can't stay invisible longer then 15 frames (or has to stay invisible during 15 frames).

am i right?

denisT
10-07-2009, 08:40 PM
ok... we have to bake visibility animation based on the moving object animation on current animation range interval...
1. apply bezier float controller to visibility track of every object of the list
for obj in list do
(
obj.visibility.track = bezier_float()
deletekeys obj.visibility.track #allkeys
obj.visibility = 1.0 -- make visible by default
)
2. create pair of visibility keys (hide/unhide) for objects which are closer then something to the moving object
for t=animationrange.start to animationrange.end do at time t
for obj in list where (d = distance obj moving_obj) < something do
(
-- check if visibility of this obj is not already animated (skip if it's already hidden)
if obj.visibility >= 1.0 do
(
-- hide
k0 = addnewkey obj.visibility.track t
k0.value = 0.0
k0.inTangentType = k0.outTangentType = #step
-- unhide 15 frames later
k1 = addnewkey obj.visibility.track (t+15f)
k1.value = 1.0
k1.inTangentType = k1.outTangentType = #step
)
)

loran
10-07-2009, 09:14 PM
thank you DenisT...
what does that mean?
k0.inTangentType = k0.outTangentType = #step

denisT
10-07-2009, 09:19 PM
thank you DenisT...
what does that mean?

it means the key's in and out tangent types are #step. The controller works like BOOLEAN (true or false). 1.0 == true, 0.0 == false... There is no interpolation between keys.

check bezier controller keys reference in MXS help for details...

loran
10-07-2009, 09:23 PM
thank you man, I m learning many things tonight :)
I will dig the way you tell me...

denisT
10-07-2009, 09:27 PM
if you want to get smooth transition from 0. to 1. (fade in) set #smooth type for OUT of key at time t and for IN and OUT for key (t+15f)

denisT
10-07-2009, 09:36 PM
probably i'm wrong... for key at time (t+15f) OUT has to be #step in both cases...

loran
10-08-2009, 02:55 PM
hey! I done it! :))

video 1 (http://laurent.renaud.free.fr/maxscripts/VizPainter/vizpainter00.mov)
video 2 (http://laurent.renaud.free.fr/maxscripts/VizPainter/vizpainter01.mov)

http://laurent.renaud.free.fr/maxscripts/VizPainter/VizPainter.jpg

loran
10-09-2009, 09:58 AM
ok the script is ok now, but I want to use several brushes (BrushGizmo01,BrushGizmo02,BrushGizmo03 ...)

I try something like this but with no success

global BrushArray = $BrushGizmo* as array

NumBrush = BrushArray.count

(
for i = 1 to NumBrush do BrushArray[i] ...

)


VizPainter (http://laurent.renaud.free.fr/maxscripts/VizPainter/vizPainter.ms)

PEN
10-09-2009, 11:01 AM
404 on both links loran

loran
10-09-2009, 01:10 PM
ooops! Sorry Paul. ok its correct now. But here they are again:

demo video for ::VizPainter::
>video1 (http://laurent.renaud.free.fr/maxscripts/VizPainter/vizpainter00.mov)
>video2 (http://laurent.renaud.free.fr/maxscripts/VizPainter/vizpainter01.mov)

CGTalk Moderation
10-09-2009, 01:10 PM
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.