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…
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
^^
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
^^
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?
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:
[left](
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.widthxPoint.x, xBitmap.height – xBitmap.heightxPoint.y] 1
)[/left]
But somehow I cant get it to work. Neither of the variants seems to register itself.
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 : –
[size=1][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]
[/size]
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.
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 ><
^^
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
[color=cyan]$Plane:Plane01 @ [0.000000,0.000000,0.000000]
$Editable_Mesh:Plane01 @ [0.000000,0.000000,0.000000]
[6,1,7]
[/color]– 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
[size=3]><
[/size]
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]
[color=cyan][6,1,7]
[16,11,17]
meshop.getmapvert p 1 theMapFace.x
[color=cyan][0,0.25,0][/color]
[color=#00ffff][/color]
[size=2]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[/size]
[size=2][/size]
[size=2]Now to retrieve the Pixel Values from the Bitmap [/size]
[size=2][/size]
[size=2]^^
[/size][/color]