PDA

View Full Version : render camera move only


loran
10-12-2009, 09:38 AM
I need to render only frames when the camera is moving...how to detect camera motion then send info to the times output ( 1-50,85-112...)?
thank you for help

I dont know if following access to the render window setting or do its own job...
Render Scene DialogrendPickupFrames -- string

Get/set the Frames string containing the user frames or sequences to render.

ivanisavich
10-12-2009, 10:28 AM
This script will do what you want:


obj = $Camera01 -- change this to the name of your camera
framerange = #()
rangeString = ""

for j in animationrange.start to animationrange.end do
(
at time (j-1) (pastPos = obj.pos;pastRot = obj.rotation)
at time (j+1) (futurePos = obj.pos;futureRot = obj.rotation)
at time j
(
currentPos = obj.pos
currentRot = obj.rotation
if currentPos != pastPos or currentPos != futurePos or currentRot != pastRot or currentRot != futureRot then
(
if firstNum == undefined then
(
firstNum = j
)
framerange[framerange.count + 1] = (j as integer)/160
)else
(
if firstNum != undefined then
(
lastNum = j - 1
rangeString += ((firstNum as integer/160) as string) + "-" + ((lastNum as integer/160) as string) +","
firstNum = undefined
)

)
)
)

if rangeString != "" then
(
rangeString = substring rangeString 1 (rangeString.count - 1)
)

renderscenedialog.close()
rendTimeType = 4
rendPickupFrames = rangeString
renderscenedialog.open()

loran
10-12-2009, 12:31 PM
thank you ivanisavich
mmmm but I can't make it work:/
it just open the render settings windows but doesnt fill the line with frame sequences.

loran
10-12-2009, 12:34 PM
thank you ivanisavich
mmmm but I can't make it work:/
it just open the render settings windows but doesnt fill the line with frame sequences.

ivanisavich
10-12-2009, 01:36 PM
Did you change the first line of the script to have the correct camera name?

Are there position/rotation keyframes on your camera?

loran
10-12-2009, 02:40 PM
yes, but it doesn't work :/

ivanisavich
10-12-2009, 04:21 PM
Try it now :D


obj = $Camera01 -- change this to the name of your camera
framerange = #()
rangeString = ""
global firstnum

for j in animationrange.start to animationrange.end do
(
at time (j-1) (pastPos = obj.pos;pastRot = obj.rotation)
at time (j+1) (futurePos = obj.pos;futureRot = obj.rotation)
at time j
(
currentPos = obj.pos
currentRot = obj.rotation
if currentPos != pastPos or currentPos != futurePos or currentRot != pastRot or currentRot != futureRot then
(
if firstNum == undefined then
(
firstNum = j
)
framerange[framerange.count + 1] = (j as integer)/160
)else
(
if firstNum != undefined then
(
lastNum = j - 1
rangeString += ((firstNum as integer/160) as string) + "-" + ((lastNum as integer/160) as string) +","
firstNum = undefined
)

)
)
)

if rangeString != "" then
(
rangeString = substring rangeString 1 (rangeString.count - 1)
)

renderscenedialog.close()
rendTimeType = 4
rendPickupFrames = rangeString

renderscenedialog.open()

loran
10-12-2009, 04:26 PM
mmm I strated to work on a simplier version. I want to use key number
here is a test:

cam = $Camera01

if numKeys cam.pos.controller != 0 do
(
--keynumber = numKeys cam.pos.controller
--k1=1
--k2=3
range =( (k1 as string)+ "-" +(k2 as string))

renderscenedialog.close()
rendTimeType = 4
rendPickupFrames = range
renderscenedialog.open()
)

loran
10-12-2009, 04:33 PM
Sorry I reply before seing your answer! Thank you.
It works better but instead of cutting sequences it does one seq only.

0-125 instead of 0-10,22-35,55-76,105-125

PiXeL_MoNKeY
10-12-2009, 04:40 PM
Loran, the problem with that approach is it doesn't determine if the camera is moving. For example, if you had 4 keyframes where you have two areas of animation. You would have to make an assumption that the animation is happening between keys 1 and 2, nothing between 2 and 3, and animation again between 3 and 4. But, if that isn't the case then your code will break. ivanisavich code is calculating if there is actual transformation change or not, yours doesn't take that into account.

-Eric

loran
10-12-2009, 04:57 PM
yes that was a try ...

obj = $Camera01 -- change this to the name of your camera
framerange = #()
rangeString = ""
global firstnum

for j in animationrange.start to animationrange.end do
(
at time (j-1) (pastPos = obj.pos;pastRot = obj.rotation)
at time (j+1) (futurePos = obj.pos;futureRot = obj.rotation)
at time j
(
currentPos = obj.pos
currentRot = obj.rotation
if currentPos != pastPos or currentPos != futurePos or currentRot != pastRot or currentRot != futureRot then
(
if firstNum == undefined then
(
firstNum = j
)
framerange[framerange.count + 1] = (j as integer)/160
)else
(
if firstNum != undefined then
(
lastNum = j - 1
rangeString += ((firstNum as integer/160) as string) + "-" + ((lastNum as integer/160) as string) +","
firstNum = undefined
)

)
)
)

if rangeString != "" then
(
rangeString = substring rangeString 1 (rangeString.count - 1)
)

renderscenedialog.close()
rendTimeType = 4
rendPickupFrames = rangeString

renderscenedialog.open()

This one is ok but instead of cutting sequences it does one seq only.

0-125 instead of 0-10,22-35,55-76,105-125

ivanisavich
10-12-2009, 05:01 PM
It does cut sequences up.

If you see only one sequence, that means there is some motion on your camera still (maybe very subtle) in places where it appears to be still.

Try this:

Create a new scene
Create a new camera
Turn auto-key on
Go to frame 40
Move the camera
Now go to frame 60
Set a position key
Now go to frame 80
Move the camera
Now run the script

Your render frame range will now appear as "0-40,60-80"

loran
10-12-2009, 06:06 PM
great! thank you Ivanisavitch. Maybe there was a bezier interpolation between my 2 frames.

The aim is to export rpf render to recreate the camera in After effects. The fact is my sequence is 7000+ frames with long still time, and the after effects camera creation take one hour for that! SO I want to downsize the time by create camera for motion only.
Thank you, you make my day.

PiXeL_MoNKeY
10-12-2009, 06:11 PM
You know there is a script posted to this forum for exporting Max camera to AE javascript. You can find it here (http://forums.cgsociety.org/showthread.php?f=98&t=647215).

-Eric

loran
10-13-2009, 07:59 AM
Try this:

Create a new scene
Create a new camera
Turn auto-key on
Go to frame 40
Move the camera
Now go to frame 60
Set a position key
Now go to frame 80
Move the camera
Now run the script

Your render frame range will now appear as "0-40,60-80"

This works. But try to move the keyframes along the timeline and relaunch the script. Or try to create a global Key "K" (pos,rot,scale) and it doesn't work anymore...:/

CGTalk Moderation
10-13-2009, 07:59 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.