Deleting an Array? Maybe!

Hi!
Just a quick question, I hope you can help, I'm not fantastically literate in Maxscript and am struggling with deleting my object.
I have got my sphere to rotate etc up to a certain point and my faces to "burst" outwards, however I then need it to delete from my scene at something like frame 75.
Any chance anybody could give me a hand with what I need to add to the end.
Everything I've tried so far just seems to delete my object before its even appeared.

Thanks!

(

obj = sphere()
scale obj [0.5,0.5,0.5]
convertToPoly obj
for f in (obj.faces as bitarray) do polyop.detachFaces obj f

mapped fn moveFace f =
(
obj.selectedFaces = #{f}
fNormal = polyop.getFaceNormal obj f
fCenter = polyop.getFaceCenter obj f
move obj.selectedFaces (fCenter+(fNormal*100))
)

animate on at time 40 obj.pos = [80,0,60]

animate on at time 70 moveFace ((obj.faces as bitarray) as array)

animate on at time 70 rotate obj (angleaxis 360 [0,0,6])

)

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
bat_banana's picture

That's exactly the tracks on

That's exactly the tracks on the i need to be on! Thanks for your help...I really appreciate it :)

cheers again :)

barigazy's picture

i've made a small edit in

i've made a small edit in code below.
Remove line "deleteObjFace = polyop.deleteFaces".

barigazy

barigazy's picture

maybe someone else has a

maybe someone else has a better solution for this,
But you can try this.
You may not see the difference in viewport but in animation your object
will disappear when timeslider cross the 75 frame.
Deleting faces is not smart move.Is also slow.
I've suggest to use visibilyty controller.
This is your code:

(
	-- Create sphere and convert to poly
	--no need to scale just set the radius, name, segments etc
	obj = Sphere radius:15 name:(uniquename "diskoBall") smooth:off segs:16 chop:0 \
	slice:off sliceFrom:0 sliceTo:0 wirecolor:blue	convertToPoly (obj)
	--don't use polyop struct in for loop (place outside)
	detachObjFace = polyop.detachFaces
	obj.visibility = bezier_float() 
	-- Go through each face and detatch to element
	for f in (obj.faces as bitarray) do (detachObjFace obj f)
	-- Mapped function will move each face in the object 100 units along it's normal
	mapped fn moveFace f =
	(
		obj.selectedFaces = #{f}
		fNormal = polyop.getFaceNormal obj f
		fCenter = polyop.getFaceCenter obj f
		move obj.selectedFaces (fCenter+(fNormal*100))
	)
	animate on 
	(
		at time 0 (obj.visibility.controller.value = 1.0)
		at time 40 (obj.pos = [80,0,60])
		at time 70 
		(
			moveFace ((obj.faces as bitarray) as array)
			rotate obj (angleaxis 360 [0,0,6])
		)
		at time 74 (obj.visibility.controller.value = 1.0)
		at time 75 (obj.visibility.controller.value = 0.0)
	)
)

barigazy

barigazy's picture

You don't twice call "animate

You don't twice call "animate on at time 70" do it like this

animate on 
(
	at time 40 (obj.pos = [80,0,60])
	at time 70 
	(
		moveFace ((obj.faces as bitarray) as array)
		rotate obj (angleaxis 360 [0,0,6])
	)
)

If I understood you well you need to delete all faces at frame 75?
Maybe this?

faceCount = polyop.getnumFaces $
deleteObjFace = polyop.deleteFaces
for face in faceCount to 1 by -1 do deleteObjFace $ face

barigazy

bat_banana's picture

Thanks for cleaning up my

Thanks for cleaning up my animate part.

the code you have suggested...call me stupid, but where do i need to include this? you're right i do want to delete all the faces at frame 75, but this code doesnt say frame 75 in it?

i'm sorry...very new at this!

Thanks :)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.