Notifications
Clear all

[Closed] vertex baker

trying to write a vertex baker. I am familiar with the cloth trick but was hoping to write a script that does this via a simple click. This scripts bakes teapot001’s animated vertex position to the target object (teapot002). It works for individual frames but doesn’t work when it comes to looping through the animation range. any help is appreciated.

global StartTime = animationRange.start
global endTime = animationRange.end
global SourceObj = $teapot001
global SourceVertPos =#()
global SourceVerts = polyop.getNumVerts SourceObj
global TargetObj = $teapot002
global emptyArray = #()
animate on
for t = StartTime to endtime by 1 do
(
–slidertime = t
at time t
SourceVertPos = emptyArray
for i=1 to SourceVerts do*
(
local Vertpos = polyop.getvert SourceObj i
Append SourceVertPos Vertpos
polyop.setvert TargetObj i SourceVertPos[i]
–TargetObj[4][12][i].value = SourceVertPos[i]
–animateVertex TargetObj SourceVerts
)
update
)

6 Replies

Give this a try, I think your at time t was the issue or your update call, not sure.

(
   local SourceObj = $teapot001
   local TargetObj = $teapot002
   with animate on
   (
      for t = animationRange.start to animationRange.end by 1 do
      (
         slidertime = t
         for i = 1 to (polyop.getNumVerts SourceObj) do
         (
            polyop.setvert TargetObj i (polyop.getvert SourceObj i)
         )
      )
   )
)

to move slidertime is not a good idea. first, it’s slow. second, it looks bad


fn bakePolyVerts source target transform:(Matrix3 1) range: =
(
   if iskindof source Editable_Poly and iskindof target Editable_Poly do
   (
      if not iskindof range Interval do range = animationrange
      
      numverts = amin target.numverts source.numverts
      getvert = polyop.getvert
      setvert = polyop.setvert
      
      animate on
      (
         for t = range.start to range.end do at time t
         (
            for v=1 to numverts do setvert source v ((getvert target v) * transform)
         )
      )
      redrawviews()
      numverts
   )
)


test scene setup


delete objects
s = teapot name:#source radius:5 wirecolor:green
t = teapot name:#target radius:5 wirecolor:red
converttopoly #(s, t)
animate on at time 20
(
   t.transform = translate (rotateZ (scalematrix [2,2,2]) 90) [40,0,0]
)
bakePolyVerts s t transform:(scalematrix [1,1,-1]) range:(interval 0 20)



Good stuff

thanks guys… PEPE you work with Denis mejonies? character artist?

1 Reply
(@pepetd)
Joined: 10 months ago

Posts: 0

Yep I work with Dennis you know him?
I do not know Why my script does that I shall investigate!

One thing i noticed about your script pepe, is that it also changes the local axis of the target object to be the same as the source object. Mean while my old script, while simliar in nature, keeps the target object local axis in its native state. is there a reason for this? neither of our scripts address the axis, yet the setvert loop behaves differently in yours.

Thanks

Ruoyu