Gents,
I was wondering if I could trouble you for help on another Maxscript question. My progress on the flipping tiles animated bumper is going well but I have hit a snag. Below is the section of code that I am having an issue with:
select $Tile_*
GTiles = $ as Array
--print GTiles
clearselection()
select $WAVE
numfaces = selection[1].GetNumFaces()
--print numfaces
STime = 0
for t = 0 to 9 do
(
sliderTime = STime
for x = 1 to numfaces do
(
$.EditablePoly.SetSelection #Face #{x}
plycenter = polyOp.getsafefacecenter $ x
for obj in GTiles where obj.pos == plycenter do
(
select obj
print obj
)
)
STime = STime + 1
)
The issue is this, when I run the code it should: progress through the timeline for the length of the WAVE object's animation. For each frame it loops through each face of the WAVE object and compares each face's position to the GTiles (Get tiles) array looking for a match. If there is a match then we would go on to begin that tile's animation. In my very simple example here the first two frames pass without a "hit" but then the third frame (frame 2 actually due to 0 index) we have one face that indeed overlaps one of the tiles. This is where I receive an error in the MaxScript Listener.
The error I keep getting reads:
-- Error occurred in x loop; filename: C:\Program Files (x86)\Autodesk\3ds Max 9\Scripts\Test1.ms; position: 335
-- Frame:
-- x: 2
-- called in t loop; filename: C:\Program Files (x86)\Autodesk\3ds Max 9\Scripts\Test1.ms; position: 432
-- Frame:
-- t: 2
-- Runtime error: EPoly face index out of range: < 1 or > 1: 2
OK
The concept is to have a master wave shape that will "look" beneath itself and animated any of the tiles that it passes over. Note: The master shape is animated to move exactly one tile per frame.
Attached are two images that show the initial state followed by when the error occurs.
Any help you all could provide would be most appreciated.
Cheers~
Replies
i'm guessing you used the edit_poly modifier to be able to keep the entire plane on the bottom of the modifier stack in case you want to do some variation of control tiles
try this
also you are changing your selection if it hits so that will give you errors
here's an updated version that should work
The following is my current code:
The tiles are properly selected and animated however their start frame remains at 0. It should begin at whatever frame t is at, which is the animation frame of the WAVE object.
Again thanks very much for all the help guys. I hope everyone had or is having a good holiday.
Cheers~
As always any assitance as well as all your help so far, it most appreciated.
I'm learning a lot about Maxscript as a result! It's fun but can be frustrating.
Cheers~
do make sure you don't use the stepped mode then
Cheers~
The WAVE object moves across the "map" however no tile is ever selected or animated.
Much appreciated for any suggestions.
Cheers~
cheers,
cw
http://www.mentallic.com/download/World_Tile_Flip_Work6.max
The goal is to have the WAVE object move across the world map tiles. The WAVE object moves exactly one tile's width each frame. For each frame the script checks the center of each face of the WAVE object. It then compares that face's center to the center of any tile that happens to be at that location. If there is a match then the tile is selected to begin it's animation (30 frames 180 degree turn north to south with a 3 frame delay before the next set of tiles begin their turn)
In the end the desired effect is similar to the "card flipping" seen at sporting events only in this instance the pixelated world appears on the surface of the logo.
Thanks for all the help guys.
Cheers~
1) I worked in 2011, so maybe it has some effect?
2) I cleaned up the script a bit, remove $ reference and things like that where possible.
3) don't try to compare positions exactly, max is not usually so accurate, you need a 'close enough' approacy with a tiny tolerance to get meaningful results.
4) a tiny optimisation in only checking tiles in the bouding box of the wave, because to check them all was a tad slow.
Let me know how it works for you (I'm guessing you're on 2012? make sure you have all service packs etc.)
Thanks much for the quick reply!
Cheers~
Cheers~