[Closed] Please Help? Moving Objects With Images
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 est2.jpg
xColor = GetPixels xBitmap [(xBitmap.widthMapCoord.x), (xBitmap.height – xBitmap.heightMapCoord.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.
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
(
[size=1]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.widthMapCoordx.x), (xBitmap.height – xBitmap.heightMapCoordx.y)] 1
xColor2 = GetPixels xBitmap [(xBitmap.widthMapCoordy.x), (xBitmap.height – xBitmap.heightMapCoordy.y)] 1
xColor3 = GetPixels xBitmap [(xBitmap.widthMapCoordz.x), (xBitmap.height – xBitmap.heightMapCoordz.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)
)
)
)
[/size]
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
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.widthMapCoordx.x), (xBitmap.height – xBitmap.heightMapCoordx.y)] 1
xColor2 = GetPixels xBitmap [(xBitmap.widthMapCoordy.x), (xBitmap.height – xBitmap.heightMapCoordy.y)] 1
xColor3 = GetPixels xBitmap [(xBitmap.widthMapCoordz.x), (xBitmap.height – xBitmap.heightMapCoordz.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)
)
)
)
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.zxColor1 = 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)
)
)
)
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.widthMapCoordx.x), (xBitmap.height – xBitmap.heightMapCoordx.y)] 1
xColor2 = GetPixels xBitmap [(xBitmap.widthMapCoordy.x), (xBitmap.height – xBitmap.heightMapCoordy.y)] 1
xColor3 = GetPixels xBitmap [(xBitmap.widthMapCoordz.x), (xBitmap.height – xBitmap.heightMapCoordz.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
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
^^