View Full Version : Please Help? Moving Objects With Images
Kamid 06-25-2007, 08:05 AM 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
^^
|
|
mlanser
06-25-2007, 10:25 AM
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?
Kamid
06-25-2007, 01:21 PM
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
Kamid
06-26-2007, 08:44 AM
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
)
)
)
)
Kamid
06-26-2007, 08:50 AM
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
ypuech
06-26-2007, 09:19 AM
Heres some of the problems I have encountered.
The Floating Panel doesnt seem to work in Max 9. Did I do something wrong?
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
mlanser
06-26-2007, 09:29 AM
you probably forgot to close your last bracket. And then just enter ypuech's code to create a floater. That should work.
Kamid
06-26-2007, 09:37 AM
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
ypuech
06-26-2007, 09:49 AM
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
Kamid
06-26-2007, 10:08 AM
Thanks. I will bear that in mind.
Any ideas on how one can generate numbered variant names? (like test01 test02 test03) etc in a loop?
I am currently looking at using selection.count to store the object's initial position into numbered variants based on the obj's number in the selection.
eg: object number 13 will store its initial position information in variant test13
Thanks ^^ for the support
Kamid
06-26-2007, 10:23 AM
Thanks rdg.
Transfering the pixel information from a bitmap to geometry color is definitely helpful, But theres much confusion for me in those scripts. Also, a difference is that those scripts creates new planes accordingly to the resolution of the image.
What I hope to achieve is to animate any group of objects simply by using an averaged value from a bitmap applied to it. if possible. This will allow the script to work on virtually any situation. (which for me will allow me to control visibility options and animations to create a flowing forming up effect)
I will definitely look into the pF forum as well.
Also, It seems I have found the number variable thingy.. seems to be called Arrays
^^ Once again thanks much for all the support
Kamid
06-26-2007, 10:36 AM
Ok to add arrays, I have added this set before the animate part to store the initial position of all the objects in the selection.
Inpos = #()
for obj in selection do
( append Inpos obj.pos )
This creates a variant array called Inpos and the Loop command will store the initial positions into this array so I can call out the information via:
Inpos[2] -- this recalls the pos store in the 2nd object in my selection.
Now....
Anyone knows the command to determine which obj number is being modified in a "for obj in selection command"?
Kamid
06-26-2007, 11:03 AM
Ok cant find the command.. ><
Anyway, I have managed to use a single variant to perform the count.
As below :-
Inpos = #()
Ap = 0
for obj in selection do
( append Inpos obj.pos )
animate on
(
for i = tstart to tend by tinter do
(
at time i
for obj in selection do
(
Ap = Ap + 1 -- Counts object number
obj.pos = Nnum[Ap] -- Resets Object to initial position
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.pos.x -- preserves the original X axis based on the appended data
oriy = obj.pos.y -- preserves the original Y axis " " "
oriz = obj.pos.z -- preserves the original Z axis " " "
obj.pos = [(orix + vx), (oriy + vy), (oriz + vz)] -- apply change to current cood.
If ap == selection.count do -- resets counter on processing the last obj
(ap = 0)
)))
simply by using an averaged value from a bitmap applied to it
Either you roll your own "averaging algorithm", wich is a nice execercise, or you scale the image to the desired size/resolution. This will cause the pixels to get averaged.
copy <source_bitmap> <dest_bitmap>
Copies the source bitmap to the destination bitmap. If the size of the two bitmaps is different, the image will be scaled to fit the destination bitmap.
I have written my own mosaic function [1] - but I think the difference to scaling the image is neglectable.
[1] http://proforma.preset.de/spool/takeColor-.wmv
Zbuffer
06-26-2007, 01:03 PM
Hi,
To create and populate arrays:
ObjList = for obj in selection collect obj is the same as
ObjList=#()
for obj in selection do append ObjList obj
then to loop through the array
for obj in ObjList do (obj.pos=[0,0,0]) is the same as
for i=1 to ObjList.count do (ObjList[i].pos=[0,0,0])
so your code could be:
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
objList = for obj in selection collect obj -- grab the selected objects in the objList array
Inpos = for obj in objList collect obj.pos -- grab the selected objects' position in the Inpos array
animate on
(
for t = tstart to tend by tinter do
(
at time t
for i=1 to objList.count do -- loop through the objects in the
(
objList[i].pos = Inpos[i] -- Resets Object to initial position
Vchange = (StpV*t)+LMin -- Determine the amount to change within the limits
-- check for selected Axis
if Axial.state==1 then (objList[i].pos.x+=Vchange) -- preserves the original X axis
if Axial.state==2 then (objList[i].pos.y+=Vchange) -- preserves the original Y axis
if Axial.state==3 then (objList[i].pos.z+=Vchange -- preserves the original Z axis
)
)
)
Note: in your code, Nnum and Avalue are never defined..
so I suppose Nnum is Inital pos Array
and that Avalue is the time ...
You should read about arrays in the MAxScript help...
Kamid
06-26-2007, 02:27 PM
Oh thanks...
Hmm Yeah.. Nnum was added for me to check on the values between the Array Inputed by Inpos and information recalled in the animated mode. - Forgot to remove them.
Avalue.. its a replacement for the supposed average pixel value which I'm still seeking.
to rdg:
Reducing the image will definitely help with the processing time me thinks. But doing that simply to assign a pixel to each polygon will limit the kind of array i'm animating correct?
What if the boxes are of different sizes? lets say in a reduced image some box may occupy 1 pixel while some may occupy 4 or maybe 6.. that kinda thing?
Averaging a set of bitmap pixel value on a geometry is real hard I guess... Sadly, I have no yet found a bypass means to that myself. It really is my real obstacle.
><
Still I really really appreciate all the support guys ^^
What if the boxes are of different sizes?
Who knows?
Having a 1:1 pixel:object relation certainly eases the task.
As soon as you get used to arrays, reading the help and the various concepts and ways of animating objects in max using maxscript you can extend your system.
If I understand you right you want to preparse the bitmap and then generate a set of object that react to that values. See the bitmap as the first 2d array. Iterate through it, collect values, do some calulations and create a second array.
If you want a box with the width of 3 to represent 3 pixels of the same color in a row and a box with the height of 5 for 5 pixels of same color below each other ... then you might to do a lot of calculations and lookups ... and maybe just a few ... I don't know.
but this is sure a not trivial task.
Kamid
06-26-2007, 05:17 PM
Hmm not trivial I definitely agree.
preparse the bitmap and then generate a set of object that react to that values
Not exactly generate I would say. Rather to put, I have a wall of uneven geometry (different sizes and maybe even different shapes) and I need a way to animate them accordingly in a random and fashionably uniform manner. But in a wave pattern with some noise. Just like some of those "stand up and wave your hands in a chain kinda cheer that organisers use in a stadium"
if you dont get the picture see below
ooooo
Ooooo
OOooo
oOOoo
ooOOo
So generally I need to assign that set of premodelled object with a Bitmap that tells it when to move up or down. Which is a reason why I choose the above methods over all others as.. I cannot seek to modify the geometrys that I am animating. Unlike others in the forum where we prep the Bitmap and generate the geometry from there.
I know this effect can be easily generated in Houdini... But sadly I need the same to work in Max ><
I know this effect can be easily generated in Houdini... But sadly I need the same to work in Max
If you need to use a bitmap to controll the values, then maybe pflow is the better way.
It offers you the perPoint-scripts/Expression to drive instanced/copied geometry you might be looking for.
But you can also generate an array of objects and assign an script-operator that accesses a function the lookup an value in an image.
Still - I guess the pflow link I posted previously is 94% the solution to your task. you just need to change the rotation to scale/translation/whatever and replace the noisemap with you image/movie.
davestewart
06-26-2007, 06:25 PM
In order to get the resampled bitmap values, you could just use the bitmap copy commands.
max reset file
s = sphere radius:50
Viewport.ZoomToBounds false [-10,-10,-10] [10,10,10]
b1 = bitmap 200 200
b2 = bitmap 10 10
b3 = bitmap 200 200
render to:b1
copy b1 b2
display b2
copy b2 b3
display b3
Or a little more interactively:
try(destroydialog ro1);catch()
rollout ro1 "Resample bitmap" width:120 height:300
(
local b1, b2, b3
bitmap bmp1 "Bitmap" width:100 height:100
bitmap bmp2 "Bitmap" width:100 height:100
slider sld1 "Resolution" range:[1,10,10] type:#integer
function setup =
(
max reset file
s = sphere radius:35
Viewport.ZoomToBounds false [-10,-10,-10] [10,10,10]
b1 = bitmap 100 100
render to:b1 vfb:false
bmp1.bitmap = b1
)
function resample n=
(
b2 = bitmap n n
b3 = bitmap 100 100
copy b1 b2
copy b2 b3
bmp2.bitmap = b3
)
on ro1 open do
(
setup()
resample 10
)
on sld1 changed val do
(
resample val
)
)
createdialog ro1
Both these scripts do a scene reset to get a blank canvas for rendering, so save your scene first...
Kamid
06-27-2007, 03:14 AM
Hi davesteward.
Thanks for that information.
Rdg,
PF flow definitely looks more promising. Will try out more of it.
Well oddly after one night's rest I stumble upon a revelation. I realised that I was no longer working on subobjects but actual geometries. So I've figured out some work around for the pixel averaging.
Run a loop counting the UVW coordinates for every vertice for its value in the object then divide the value / Numverts.
Hope this works.. gonna run some tests for it today
^^
Kamid
06-27-2007, 04:06 AM
Heres a loop test I did for using a snapshot instead of having to convert the original geometries
Nnum = #()
obj = sphere() --create a Sphere
Tmesh = snapshotasmesh obj
for v = 1 to getNumVerts Tmesh do --loop through all vertices
(
vert = getVert Tmesh v --get the v-th vertex
append Nnum vert
)
I later did a Print Nnum command and seems like all the coordinates are well stored. Now to figure out the pixel values for the Verts instead of Vertice positions
^^
Kamid
06-27-2007, 04:17 AM
Hmmm Tverts doesnt seem to be working as in the Maxscript Reference.
Tmesh.NumTVerts = 0??
Does seem like a reason why when I placed
vert = getTVert Tmesh v
into my Loop I get a
-- vert: undefined
-- Runtime error: Mesh TVertex index out of range: 1
Anyone has any ideas?
Kamid
06-27-2007, 06:27 AM
OK
Found more information.. Seems like I cannot use Vertices as they do not correspond to Texture Vertices. Unlike Faces.
Found this written by BoBo:
(
xVertIndex = (getVertSelection $ as array)[1] --first selected vertex
theFaces = (meshop.getFacesUsingVert $ xVertIndex) as array --all faces using that vert.
theMeshFace = getFace $ theFaces[1] --first face using the vertex
theMapFace = meshop.getMapFace $ 1 theFaces[1] --the corresponding map face
--get the map vert from the same position in the face:
if theMeshFace.x == xVertIndex do theMapVert = theMapFace.x
if theMeshFace.y == xVertIndex do theMapVert = theMapFace.y
if theMeshFace.z == xVertIndex do theMapVert = theMapFace.z
-- get the REAL map vert. There could be more - one for each face using the mesh vertex!
xPoint = meshop.getMapVert $ 1 theMapVert
xBitmap = $.material.diffuseMap.bitmap --get the bitmap
--get the correct pixel, taking into account origin and bitmap size:
xColor = getpixels xBitmap [xBitmap.width*xPoint.x, xBitmap.height - xBitmap.height*xPoint.y] 1
)
But somehow I cant get it to work. Neither of the variants seems to register itself.
Kamid
06-27-2007, 06:49 AM
Hmm just did this on command on a plane :-
p = plane()
converttomesh p
Nnum = #()
For f = 1 to GetNumFaces p do
(
fface = getFace p f
append Nnum fface
)
print Nnum
And I got back some really suspicious figures : -
[6,1,7][2,7,1][7,2,8][3,8,2][8,3,9][4,9,3][9,4,10][5,10,4][11,6,12][7,12,6][12,7,13]
[8,13,7][13,8,14][9,14,8][14,9,15][10,15,9][16,11,17][12,17,11][17,12,18][13,18,12]
[18,13,19][14,19,13][19,14,20][15,20,14][21,16,22][17,22,16][22,17,23][18,23,17]
[23,18,24][19,24,18][24,19,25][20,25,19]
Yeah they don't correspond.
Also I don't know what you mean with: "subobjects but actual geometries."
When you mentioned houdini, are you used to its workflow?
it is not common in max to take a grid and copy some object to it, which are controlled by per point expressions. -> this could be done with pflow, but it would be a simulation like POPs not like SOPs.
I think it is really easier to do it the max way instead of trying to copy another workflow:
all of this can be scripted, but try it with a few objects manually to get the idea:
create some objects spaced evenly
attach a scriptcontroller to each object's height/radius
create a global function that returns a usefull value taken from an image as lookup.
write an script into every objects-script controller calls that function and sends an unique id (object1 sends 1, object2 sends2 ...)
add an perframe (currentime) offset in the script, so the ids get shifted over time ...
that would be an approach.
Kamid
06-27-2007, 07:34 AM
Yeah they don't correspond.
Also I don't know what you mean with: "subobjects but actual geometries."
I understood now why they dont correspond.. Those were the Index Numbers of Vertices forming the particular Face.
As for subobjects.. I initially wanted to use the script on a single geometry that has say multiple boxes as elements (since its easier to apply the UVW Maps onto it) But it got too hard too quickly.
Well yes I have some familarity with Houdini's workflow and I see that you do know about it too ^^
not common in max to take a grid and copy some object to it, which are controlled by per point expressions
And well I am trying to work out the method thru similar steps as you described. (I think?)
Apply Map to Geometry Set.
Calculate the average pixel value of each geometry
Animate Geometry along single axis with the Pixel value.
If I wanted to use grids then I would have X-linked my objects to a planar grid and use displace modifier to move it (no scripting that way) But to do that can be quite exhausting when the number of boxs reach like 1000 by 1000
I'm currently on the figuring pixel value part. and decided to Calculate the sum of all vertice pixel value in Mesh divided by the total number of Vertices. Its not exactly an accurate Value But I guess it should suffice for my work.
Still working on the Bitmap info retrieval part ><
^^
Kamid
06-27-2007, 07:48 AM
Hmmm obstacle...
According to the Maxscript Reference....
Faces of a Mesh corresponds to Map Faces in both count and indexes.
So why cant
p=plane()
converttomesh p
getFace p 1
meshop.getmapface p 1
$Plane:Plane01 @ [0.000000,0.000000,0.000000]
$Editable_Mesh:Plane01 @ [0.000000,0.000000,0.000000]
[6,1,7]
-- Argument count error: getMapFace wanted 3, got 2
I need those Map faces so I can add the pixel value of the 3 Map Vertices forming it.. then divide by 3 to get the average Face Pixel Value
><
Kamid
06-27-2007, 08:05 AM
p=plane()
converttomesh p
getFace p 1
theMapFace = meshop.getmapface p 1 1
$Plane:Plane01 @ [0.000000,0.000000,0.000000]
$Editable_Mesh:Plane01 @ [0.000000,0.000000,0.000000]
[6,1,7]
[16,11,17]
meshop.getmapvert p 1 theMapFace.x
[0,0.25,0]
Yippee!!! Finally its working to some extend.. Seems like I'm suppose to key in the Mapping Channel.. Nearly got stuck at GetMapVert as well since the Channel and Vertice Index is inverted
Now to retrieve the Pixel Values from the Bitmap
^^
Kamid
06-27-2007, 08:36 AM
Almost to the finish LINE!!
p=plane()
converttomesh p
$Plane:Plane01 @ [0.000000,0.000000,0.000000]
$Editable_Mesh:Plane01 @ [0.000000,0.000000,0.000000] -- I also manually applied a Bitmap Diffuse Map to the obj
theMapFace = meshop.getmapface p 1 1
[16,11,17]
MapCoord = meshop.getmapvert p 1 theMapFace.x
[0,0.25,0]
xBitmap = $.material.diffuseMap.bitmap
BitMap:C:\Documents and Settings\3D\Desktop\test2.jpg
xColor = GetPixels xBitmap [(xBitmap.width*MapCoord.x), (xBitmap.height - xBitmap.height*MapCoord.y)] 1
#((color 255 223 92))
And now to figure out how to dissect this unique value like name.x / name.y / name.z... Too bad xColor.r /xColor.g / xColor.b doesnt work
#((color 255 223 92))
GetPixels returns an array.
xColor[1].r acesses the r component of the first index.
Kamid
06-27-2007, 09:48 AM
Heres a first full version of the script.. It still doesnt work right though.. still tweaking. Some values were not in or manually set due to the incomplete floating panel connection.
tstart = 0
tend = 100
tinter = 5
LMax = 100
LMin = 0
Axial = 3
Objlist = for obj in selection collect obj
animate on
(
for t = tstart to tend by tinter do -- value determined by user interface (time start/end/interval)
(
at time t
Inpos = for obj in selection collect obj.pos
for i = 1 to Objlist.count do
(
Objlist[i].pos = Inpos[i] -- Resets Object to initial position
Tmesh = SnapshotasMesh Objlist[i]
Tvalue = 0
For ff = 1 to Tmesh.NumFaces do
(
theMapFace = meshop.getmapface Tmesh 1 ff
MapCoordx = meshop.getmapvert Tmesh 1 theMapFace.x
MapCoordy = meshop.getmapvert Tmesh 1 theMapFace.y
MapCoordz = meshop.getmapvert Tmesh 1 theMapFace.z
xColor1 = GetPixels xBitmap [(xBitmap.width*MapCoordx.x), (xBitmap.height - xBitmap.height*MapCoordx.y)] 1
xColor2 = GetPixels xBitmap [(xBitmap.width*MapCoordy.x), (xBitmap.height - xBitmap.height*MapCoordy.y)] 1
xColor3 = GetPixels xBitmap [(xBitmap.width*MapCoordz.x), (xBitmap.height - xBitmap.height*MapCoordz.y)] 1
Scolor1 = xColor1 [1]
Scolor2 = xColor2 [1]
Scolor3 = xColor3 [1]
Acolor1 = (Scolor1.r + Scolor1.g + Scolor1.b) / 3
Acolor2 = (Scolor2.r + Scolor2.g + Scolor2.b) / 3
Acolor3 = (Scolor3.r + Scolor3.g + Scolor3.b) / 3
Fvalue = (Acolor1 + Acolor2 +Acolor3) / 3
TValue = Tvalue + Fvalue
)
Avalue = Tvalue / Tmesh.numfaces
Vchange = (StpV*Avalue)+Lmin -- Determine the amount to change within the limits
if Axial==1 then (objList[i].pos.x= objList[i].pos.x + Vchange)
if Axial==2 then (objList[i].pos.y= objList[i].pos.y + Vchange)
if Axial==3 then (objList[i].pos.z= objList[i].pos.z + Vchange)
)
)
)
For some reason the initial position doesnt store correctly. I might have to split the loops up for easier tweaking. Bitmap was set by hand typo. UV was manually set by applying a UVW map as an instance to mulitple objects and collasped
Kamid
06-27-2007, 10:23 AM
Heres an edited version ^^ IT WORKS!! Well.......... sadly only for the first frame.. The array of objects actually move as I want it .. However, I need to find some command to make it realise that the Bitmap is not a still but an animated image.. Any ideas??
tstart = 0
tend = 250
tinter = 5
LMax = 200
LMin = 0
Axial = 3
StpV = 256.000000/(LMax-LMin)
Objlist = for obj in selection collect obj
Inpos = for obj in selection collect obj.pos
animate on
(
for t = tstart to tend by tinter do -- value determined by user interface (time start/end/interval)
(
at time t
for i = 1 to Objlist.count do
(
Objlist[i].pos = Inpos[i] -- Resets Object to initial position
Tmesh = SnapshotasMesh Objlist[i]
Tvalue = 0
For ff = 1 to Tmesh.NumFaces do
(
theMapFace = meshop.getmapface Tmesh 1 ff
MapCoordx = meshop.getmapvert Tmesh 1 theMapFace.x
MapCoordy = meshop.getmapvert Tmesh 1 theMapFace.y
MapCoordz = meshop.getmapvert Tmesh 1 theMapFace.z
xColor1 = GetPixels xBitmap [(xBitmap.width*MapCoordx.x), (xBitmap.height - xBitmap.height*MapCoordx.y)] 1
xColor2 = GetPixels xBitmap [(xBitmap.width*MapCoordy.x), (xBitmap.height - xBitmap.height*MapCoordy.y)] 1
xColor3 = GetPixels xBitmap [(xBitmap.width*MapCoordz.x), (xBitmap.height - xBitmap.height*MapCoordz.y)] 1
Scolor1 = xColor1 [1]
Scolor2 = xColor2 [1]
Scolor3 = xColor3 [1]
Acolor1 = (Scolor1.r + Scolor1.g + Scolor1.b) / 3
Acolor2 = (Scolor2.r + Scolor2.g + Scolor2.b) / 3
Acolor3 = (Scolor3.r + Scolor3.g + Scolor3.b) / 3
Fvalue = (Acolor1 + Acolor2 +Acolor3) / 3
TValue = Tvalue + Fvalue
)
Avalue = Tvalue / Tmesh.numfaces
Vchange = (Avalue/StpV)+Lmin -- Determine the amount to change within the limits
if Axial==1 then (objList[i].pos.x= objList[i].pos.x + Vchange)
if Axial==2 then (objList[i].pos.y= objList[i].pos.y + Vchange)
if Axial==3 then (objList[i].pos.z= objList[i].pos.z + Vchange)
)
)
)
Kamid
06-27-2007, 11:40 AM
AND ITS ALIVE!!!
Below is the working script.. now all it needs is some floatin panels for controls and some refinements
tstart = 0
tend = 250
tinter = 3
LMax = 20
LMin = -50
Axial = 3
StpV = 256.000000/(LMax-LMin)
Objlist = for obj in selection collect obj
Inpos = for obj in selection collect obj.pos
animate on
(
for t = tstart to tend by tinter do -- value determined by user interface (time start/end/interval)
(
at time t
slidertime = t
for i = 1 to Objlist.count do
(
Objlist[i].pos = Inpos[i] -- Resets Object to initial position
Tmesh = SnapshotasMesh Objlist[i]
Tvalue = 0
xBitmap = objlist[i].material.diffuseMap.bitmap
For ff = 1 to Tmesh.NumFaces do
(
theMapFace = meshop.getmapface Tmesh 1 ff
MapCoordx = meshop.getmapvert Tmesh 1 theMapFace.x
MapCoordy = meshop.getmapvert Tmesh 1 theMapFace.y
MapCoordz = meshop.getmapvert Tmesh 1 theMapFace.z
xColor1 = GetPixels xBitmap [(xBitmap.width*MapCoordx.x), (xBitmap.height - xBitmap.height*MapCoordx.y)] 1
xColor2 = GetPixels xBitmap [(xBitmap.width*MapCoordy.x), (xBitmap.height - xBitmap.height*MapCoordy.y)] 1
xColor3 = GetPixels xBitmap [(xBitmap.width*MapCoordz.x), (xBitmap.height - xBitmap.height*MapCoordz.y)] 1
Scolor1 = xColor1 [1]
Scolor2 = xColor2 [1]
Scolor3 = xColor3 [1]
Acolor1 = (Scolor1.r + Scolor1.g + Scolor1.b) / 3
Acolor2 = (Scolor2.r + Scolor2.g + Scolor2.b) / 3
Acolor3 = (Scolor3.r + Scolor3.g + Scolor3.b) / 3
Fvalue = (Acolor1 + Acolor2 +Acolor3) / 3
TValue = Tvalue + Fvalue
)
Avalue = Tvalue / Tmesh.numfaces
Vchange = (Avalue/StpV)+Lmin -- Determine the amount to change within the limits
if Axial==1 then (objList[i].pos.x= objList[i].pos.x + Vchange)
if Axial==2 then (objList[i].pos.y= objList[i].pos.y + Vchange)
if Axial==3 then (objList[i].pos.z= objList[i].pos.z + Vchange)
)
)
)
Kamid
06-28-2007, 07:59 AM
Update!
I've added an interface to the script for ease of control....
However I seem to have encountered some problems.... The loaded Bitmap does not seem to load according to the timeline.. Thus the animation only worked for the 1st frame..
Any ideas?
Axial = 1
Stime = 0
Etime = 100
Itime = 1
LMaxi = 50
LMini = 0
rollout BitMov "Bit.Mover Ultility v1.0" width:168 height:344
(
spinner TimeS "" pos:[48,126] width:104 height:16 range:[0,1000,0]
spinner TimeE "" pos:[48,150] width:104 height:16 range:[0,1000,100]
spinner TimeI "" pos:[80,174] width:72 height:16 range:[1,100,1]
button Simual "Animate" pos:[15,32] width:138 height:24
spinner Maxi "Maximum" pos:[24,232] width:128 height:16 range:[-1000,1000,50]
spinner Mini "Minimum" pos:[24,256] width:128 height:16 range:[-1000,1000,0]
Mapbutton BitSet "Select Bitmap" pos:[15,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 "Animation Axis" pos:[8,288] width:152 height:40
radioButtons SAxis "" pos:[40,304] width:97 height:16 labels:#("X", "Y", "Z") columns:3
label lbl1 "End" pos:[16,150] width:24 height:16
label lbl2 "Start" pos:[16,126] width:24 height:16
label lbl3 "Key Interval" pos:[15,174] width:62 height:16
on TimeS changed val do
(
if TimeS.value >= TimeE.value do
(
Messagebox "Invalid Simulation Start Time!"
TimeS.value = TimeE.value - 1
)
Stime = TimeS.value
)
on TimeE changed val do
(
if TimeE.value <= TimeS.value do
(
Messagebox "Invalid Simulation End Time!"
TimeE.value = TimeS.value + 1
)
Etime = TimeE.value
)
on TimeI changed val do
(
If TimeE.value - TimeS.Value <= TimeI.value do
(
Messagebox "No frames will be generated for this Interval!"
)
Itime = TimeI.value
)
on Simual pressed do
(
if pBitmap == undefined do
(
Messagebox "No Bitmap Assigned. Simulation Halted"
)
if pBitmap != undefined do
(
tstart = Stime
tend = Etime
tinter = ITime
LMax = LMaxi
LMin = LMini
StpV = 256.000000/(LMax - LMin)
Objlist = for obj in selection collect obj
Inpos = for obj in selection collect obj.pos
animate on
(
for t = tstart to tend by tinter do -- value determined by user interface (time start/end/interval)
(
at time t
slidertime = t
xBitmap = pbitmap.bitmap
for i = 1 to Objlist.count do
(
Objlist[i].pos = Inpos[i] -- Resets Object to initial position
Tmesh = SnapshotasMesh Objlist[i]
Tvalue = 0
For ff = 1 to Tmesh.NumFaces do
(
theMapFace = meshop.getmapface Tmesh 1 ff
MapCoordx = meshop.getmapvert Tmesh 1 theMapFace.x
MapCoordy = meshop.getmapvert Tmesh 1 theMapFace.y
MapCoordz = meshop.getmapvert Tmesh 1 theMapFace.z
xColor1 = GetPixels xBitmap [(xBitmap.width*MapCoordx.x), (xBitmap.height - xBitmap.height*MapCoordx.y)] 1
xColor2 = GetPixels xBitmap [(xBitmap.width*MapCoordy.x), (xBitmap.height - xBitmap.height*MapCoordy.y)] 1
xColor3 = GetPixels xBitmap [(xBitmap.width*MapCoordz.x), (xBitmap.height - xBitmap.height*MapCoordz.y)] 1
Scolor1 = xColor1 [1]
Scolor2 = xColor2 [1]
Scolor3 = xColor3 [1]
Acolor1 = (Scolor1.r + Scolor1.g + Scolor1.b) / 3
Acolor2 = (Scolor2.r + Scolor2.g + Scolor2.b) / 3
Acolor3 = (Scolor3.r + Scolor3.g + Scolor3.b) / 3
Fvalue = (Acolor1 + Acolor2 +Acolor3) / 3
TValue = Tvalue + Fvalue
)
Avalue = Tvalue / Tmesh.numfaces
Vchange = (Avalue/StpV)+Lmin -- Determine the amount to change within the limits
if Axial==1 then (objList[i].pos.x= objList[i].pos.x + Vchange)
if Axial==2 then (objList[i].pos.y= objList[i].pos.y + Vchange)
if Axial==3 then (objList[i].pos.z= objList[i].pos.z + Vchange)
)
)
)
)
)
on BitSet picked texmap do
(
pBitmap = texmap
BitSet.text = "Bitmap Selected"
)
on Maxi changed val do
(
if Maxi.value <= Mini.value do
(
Messagebox "Invalid Maximum Limit!"
Maxi.value = Mini.value + 10
)
LMaxi = Maxi.value
)
on Mini changed val do
(
if Mini.value >= Maxi.value do
(
Messagebox "Invalid Minimum Limit!"
Mini.value = Maxi.value - 10
)
LMini = Mini.value
)
On SAxis changed state do
(
Axial = SAxis.state
)
)
createDialog BitMov 168 344
Any ideas?
You could add a button to pick the base grid and another to pick the object/a group of objects to be instanced to the points.
But this wasn't the question ...
Georg
Kamid
06-28-2007, 08:25 AM
Hey rdg ^^ glad to see that your still here
hmm If i were to instance those objects again, it would greatly limit the amount of geometry I can process would it not? (memory consuming factor)
Comparing what I did before and after...
xBitmap = objlist[i].material.diffuseMap.bitmap
VS
on BitSet picked texmap do
(
pBitmap = texmap
BitSet.text = "Bitmap Selected"
)
&
xBitmap = pbitmap.bitmap
If I had chosen to use the applied diffusemap bitmap of the selected objects, it reloads the frames correctly on each and every frame.. However, when I added the interface, I also changed the source of this image to one that can be user selected w/o the need to affect the original texture of the mesh.
It loads correctly, but can seem to load the frames correct (it only loads the first frame)
How can I script it to ask the Bitmap function to head to its next frame?? GoToFrame and <Bitmap>.frame gives me runtime errors as they cannot work on avi and mov files
^^
CGTalk Moderation
06-28-2007, 08:25 AM
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.
vBulletin v3.0.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.