Simon Bjork
Forum Replies Created
-
Yes, I think so too. It would have been nice if it internally changed 0 to 0.0001 or something. I guess the only way around this is to build the matrices from scratch manually.
Or just alert the user if the scale is 0.
-
Thanks for the reply Dan.
Yes, that would work. But as the toWorlVec is both rotation and scale, I guess rotation is lost as well in that case?
I’m exporting objects to other applications and therefore I need to extract the world matrix of objects.
-
Simon Bjork
December 12, 2020 at 1:08 pm in reply to: How to get the same result as timeToFrames with scripting?It almost feels like the whole thing is random? Things that worked stopped working the next day etc?
-
Simon Bjork
December 11, 2020 at 9:11 pm in reply to: How to get the same result as timeToFrames with scripting?It still seems like it’s doing some rounding errors.
In the above code it seems to work if the getFrameRange function adds a Math.floor to each value before it returns them.
I also struggled with setting the startFrame of a comp. From what I understand you can use comp.displayStartFrame directly now, but as far as I can tell that won’t work in older AE versions.
This seems does seem to work, but I’m not sure for older ones as well if there a different rounding error.
function setStartFrame(frame, comp){
if(app.project.displayStartFrame == 1){
var frame = frame-1
}
var startFrameSec = framesToTime(frame, comp) + 0.00001;
comp.displayStartTime = startFrameSec;
} // function setStartFrame(comp, frame){
var frame = 231
// Tested with different frame rates, 8, 24, 300.
var comp = app.project.activeItem;
setStartFrame(frame, comp); -
Simon Bjork
December 11, 2020 at 9:45 am in reply to: How to get the same result as timeToFrames with scripting?Thanks for the reply and example code Dan!
I started over from scratch with your code and it actually seems to be that simple.
The things that always seemd to mess up my calculations were custom start frames on the composition and how the frame was setup in the TimeDisplayStyle was set (to 0 or 1).
Here’s some example code that in my first tests seem to work. Does it look correct to you?
function timeToFrames(theTime,theComp){
return Math.round(theTime/theComp.frameDuration);
}
function framesToTime(theFrames,theComp){
return theFrames*theComp.frameDuration;
}
function getFrameRange(como){
var first = (app.project.displayStartFrame) + (comp.displayStartTime/comp.frameDuration)
var last = first + timeToFrames(comp.duration, comp) -1;
return [first, last];
}
function print(x){
$.writeln(x);
}
var comp = app.project.activeItem;
// Print the frame range to the console.
print(getFrameRange());
// Now try to set the time indicator at a specific frame.
// 1. Create a comp that has a start frame on 1031
// 2. In TimeDisplayStyle set the frame count to start at 1.
var frame = 1035
var startFrameTime = framesToTime(app.project.displayStartFrame, comp);
var time = (framesToTime(frame, comp) - framesToTime(comp.displayStartTime/comp.frameDuration, comp));
// Need to add some small number for this to work?
var timeFix = time - startFrameTime + 0.000000001;
// Move the time indicator to a given frame.
comp.time = timeFix; -
Hm, I actually seems like toWorldVec does work with poi. But it seems to break in some situations?
-
Simon Bjork
November 13, 2020 at 9:51 am in reply to: Extract scale values from matrix (toWorldVec)?Thanks a lot Dan, that seems to work perfectly!
* I haven’t asked a question here in 10 years, and from what I remember you helped me that last time as well. Simply amazing work!