[Closed] Please Help? Moving Objects With Images
Hi,
I’m needing help with one of my work of late. And simply put, its to move the subs Elements of an object on either ZYX axis using the values of either RGBa.
However, I have come to encounter a problem. I realised that in the way I was scripting, I had to define exactly how many objects I had in the shot before it would work. (eg: divide image resolution by number of geometry on X axis then by Y Axis)
So after much thinkin, I was wondering if anyone know any ways to call out the average channel values of a single element that has a planar bitmap applied to it?
I thought that doing so would not require me to say have a definite 100 by 100 boxes just to achieve a similar effect like the “9 Inch Nails” video by Digital Domain.
Would greatly appreciate any advise or help.
Much Much Thanks
^^
Hi.
I don’t quite understand your problem. Do you need to find out the average red/green/blue value of a certain object (or rather of the material that you have attached it to) in your scene?
Hi,
Thanks for the reply.
I’m trying to make blocks that moves accordingly to a image sequences in a single axis. However as the different shots are all inconsistent, I cannot be creating these blocks constantly in a 100 by 100 kinda array.
So I thought that If there was a way to average out the pixel values assigned to each element of a geometry (by pixel value I mean the material bitmap/image sequence) on a planar axis. I could animate these elements base on this “averaged values”. Thus meaning that this effect can be done on objects even if they vary in size or numbers.
It seems that Maxscript does not have a call function for this and it has to be done using a variant of commands. Ones which I am not yet sure of as I’m still pretty beginner to Maxscripting.
Generally my thoughts are:
Assign material to Geometry on planar axis
Average out pixel value of assigned material on element based on same planar axis
Divide value into steps within the preset movement constraints (eg: -100 to 100)
Move element into position and set animation key.
Repeat with every element
Proceed to next frame and repeat until animation end.
I have only just started and am still in the planning part of it.
Would appreciate any help or advise on this.
Much thanks
So I realise that I do not have the means to find the average pixel information yet. Despite thar, I have set down to begin writing the other parts of the script.
As Below:-
rollout unnamedRollout “” width:168 height:344
(
spinner TimeS “Start” pos:[24,128] width:128 height:16 range:[0,1000,0] controller:””
spinner TimeE “End” pos:[24,152] width:128 height:16 range:[0,1000,0] controller:””
spinner TimeI “Interval” pos:[24,176] width:128 height:16 range:[1,100,0] controller:””
button btn4 “Animate” pos:[16,32] width:138 height:24
spinner Maxi “Maximum” pos:[24,232] width:128 height:16 range:[-1000,1000,0]
spinner Mini “Minimum” pos:[24,256] width:128 height:16 range:[-1000,1000,0]
mapButton btn5 “Select Bitmap” pos:[16,64] width:138 height:24
groupBox grp1 “Animation Range” pos:[8,104] width:152 height:96
groupBox grp2 “Controls” pos:[8,16] width:152 height:80
groupBox grp3 “Limits” pos:[8,208] width:152 height:72
groupBox grp4 “Axis” pos:[8,288] width:152 height:40
radioButtons Axial “” pos:[40,304] width:97 height:16 labels:#(“X”, “Y”, “Z”) columns:3
on btn4 pressed do
(
tstart = TimeS.value – these are the values for the panels
tend = TimeE.value – but for some reason they do not appear
tinter = TimeI.value – so I have keyed in variables instead
LMax = Maxi.value – for the purpose of testing
LMin = Mini.value – and to move on forward
vx = 0.0 – values determining the initial change in movement
vy = 0.0
vz = 0.0
Stp = LMax – LMin – divides the color channel values
StpV = (255/Stp) – and changes them to steps accoring to Lmax/min limits
animate on
(
for i = tstart to tend by tinter do
(
at time i
for obj in $ do
(
Vchange = (StpV*Avalue)+LMin – Determine the amount to change within the limits
if anix = true do
( vx = Vchange) – to check user selection no which axis
if aniy = true do
( vy = Vchange) – to base animation on
if aniz = true do
( vz = Vchange) – and to apply change value accordingly
orix = obj.pivot.x – preserves the original X axis based on the pivot
oriy = obj.pivot.y – preserves the original Y axis ” ” “
oriz = obj.pivot.z – preserves the original Z axis ” ” “
obj.pos = [(orix + vx), (oriy + vy), (oriz + vz)] – apply change to current cood.
obj.pivot = [ orix, oriy, oriz ] – changes pivot back as information for initial position
)
)
)
)
Heres some of the problems I have encountered.
The Floating Panel doesnt seem to work in Max 9. Did I do something wrong?
The fixing of the Pivot in the Animation Loop seemed to screw up the animation. Is there any better way to store the initial position as I wont want the geometry to keep incrementally move away.
Lastly, I am still searching for the means of averaging the pixel values on the geometry.
The compromises I have made so far seems that I am no longer using SubObject Elements – cant seem to find the scripts to move Elements.
Also I am looking for other means of using the pixel values. Maybe not using an average, but simply the single value of a pixel in the geometry centre or something.
Would greatly appreciate advise on this ^^
Thanks
Create a dialog after the rollout declaration:
createDialog unnamedRollout
Or a rollout floater:
global g_rlf
-- rollout definition here
-- etc.
try(closeRolloutFloater g_rlf) catch()
g_rlf = newrolloutfloater "" 168 344
addrollout unnamedRollout g_rlf
you probably forgot to close your last bracket. And then just enter ypuech’s code to create a floater. That should work.
Ok… seems good so far.
I have decided to give up on setting the initial positions on the pivots as they screw up the animation. So I’m looking now to counting the obj in $ and assigning those values as variants instead.
Still needing help on the information transfer from Image Pixel value to Geometry if you guys have any experience on it.
As some information, this is kinda the first full script I am actually writing. So please bear with me
^^
Regards
One advice: it’s better to use selection than $:
for obj in selection do...
$ is not safe. $ is only useful for quick development and debug but if you want clean code use selection object set or getCurrentSelection().
Still needing help on the information transfer from Image Pixel value to Geometry if you guys have any experience on it.
I just read that you referred to the NIN video.
These threads might be helpfull:
In this thread various beginners (me too) demonstrate and discuss ways of reading color from images and transfer them to geometry:
CgTalk Maxscript Challenge 008: “BACK TO BASICS: Bitmap to Planes”
http://forums.cgsociety.org/showthread.php?f=98&t=271753&highlight=challenge
As I understand you are targeting for an animated solution. In this thread Bobo offers an lightweight pflowsetup that could be easily extended:
Bitmap to rotation – particle challenge
http://forums.cgsociety.org/showthread.php?f=98&t=489438&highlight=pflow
Hope this helps,
Georg