COLLADA - Issue importing animation with yfov + aspect ratio #32237

Closed
opened 2012-08-02 09:29:14 +02:00 by Philippe Blanc · 15 comments

%%%Blender 2.63
Mac OS X Lion

Overview:
Try to import an animation where the camera Focal Length is animated. If the collada file use xfov + aspect ratio the animation is correctly imported, but if the collada file use yfov + aspect ratio then the animation is not imported. I tried also with only yfov and that doesn't work neither.

How to reproduce:
Attached two collada files originaly exported from Blender. Open Blender, delete everything in the scene then import one of the file, then select the camera and see if the Focal Length parameter has its two keyframes. The file using xfox load the animation fine the one with yfov does not.

Resources:
The COLLADA spec states:

The element must contain either a single element, a single element, both and elements, or one of or and the <aspect_ratio> element. These describe the field of view of the camera.

I found some code in blender which show that particular logic is actually implemented in blender:
http:www.letworyinteractive.com/blendercode/db/d3b/DocumentImporter_8cpp_source.html (line 800):- - - - -
switch(camera->getDescriptionType()) {
case COLLADAFW::Camera::ASPECTRATIO_AND_Y:
...
break;
/* XXX correct way to do following four is probably to get also render size and determine proper settings from that somehow */
case COLLADAFW::Camera::ASPECTRATIO_AND_X:
case COLLADAFW::Camera::SINGLE_X:
case COLLADAFW::Camera::X_AND_Y:
...
//- - - - -

I am suspecting that the OpenCollada lib may not return the correct value for camera->getDescriptionType()

Tl;dr: Oh! My! Another bug report!%%%

%%%Blender 2.63 Mac OS X Lion Overview: Try to import an animation where the camera Focal Length is animated. If the collada file use xfov + aspect ratio the animation is correctly imported, but if the collada file use yfov + aspect ratio then the animation is not imported. I tried also with only yfov and that doesn't work neither. How to reproduce: Attached two collada files originaly exported from Blender. Open Blender, delete everything in the scene then import one of the file, then select the camera and see if the Focal Length parameter has its two keyframes. The file using xfox load the animation fine the one with yfov does not. Resources: The COLLADA spec states: The <perspective> element must contain either a single <xfov> element, a single <yfov> element, both <xfov> and <yfov> elements, or one of <xfov> or <yfov> and the <aspect_ratio> element. These describe the field of view of the camera. I found some code in blender which show that particular logic is actually implemented in blender: http:*www.letworyinteractive.com/blendercode/db/d3b/DocumentImporter_8cpp_source.html (line 800):*- - - - - switch(camera->getDescriptionType()) { case COLLADAFW::Camera::ASPECTRATIO_AND_Y: ... break; /* XXX correct way to do following four is probably to get also render size and determine proper settings from that somehow */ case COLLADAFW::Camera::ASPECTRATIO_AND_X: case COLLADAFW::Camera::SINGLE_X: case COLLADAFW::Camera::X_AND_Y: ... //- - - - - I am suspecting that the OpenCollada lib may not return the correct value for camera->getDescriptionType() Tl;dr: Oh! My! Another bug report!%%%
Author

Changed status to: 'Open'

Changed status to: 'Open'

%%%Gaia, would you be around to look into this? Thanks!%%%

%%%Gaia, would you be around to look into this? Thanks!%%%
Author

%%%Dear Gaia,

Thank you for looking into this issue. I have some update for you:
and do work correctly inside the camera definition. I attached two files where I setup the initial camera using the two tag and that did work. So what seem broken is only the animation part. The animation will correctly load in case of but not for . Which mean I was wrong when I suspected openCollada to doesn't return the correct value for camera->getDescriptionType() in the blender code I cited in the original report.

Feel free to contact me if you need me to run some test or for any questions

Thanks!
%%%

%%%Dear Gaia, Thank you for looking into this issue. I have some update for you: <xfov> and <yfov> do work correctly inside the camera definition. I attached two files where I setup the initial camera using the two tag and that did work. So what seem broken is only the animation part. The animation will correctly load in case of <xfov> but not for <yfov>. Which mean I was wrong when I suspected openCollada to doesn't return the correct value for camera->getDescriptionType() in the blender code I cited in the original report. Feel free to contact me if you need me to run some test or for any questions Thanks! %%%
Author

%%%Attached a better test/debugging file.

You just need to change

to

to switch between the two cases.

The initial setup of the camera work fine with both and only the animation is broken when controlled by . I wonder if this also broken when you try to load an animation with <aspect_ratio>%%%

%%%Attached a better test/debugging file. You just need to change <channel source="#Camera_lens_-sampler" target="Camera-camera/xfov"/> to <channel source="#Camera_lens_-sampler" target="Camera-camera/yfov"/> to switch between the two cases. The initial setup of the camera work fine with both <xfov> and <yfov> only the animation is broken when controlled by <yfov>. I wonder if this also broken when you try to load an animation with <aspect_ratio>%%%
Author

%%%http://www.letworyinteractive.com/blendercode/dc/d75/AnimationImporter_8cpp_source.html (line 920)
Seem to only define the case for CAMERA_XFOV%%%

%%%http://www.letworyinteractive.com/blendercode/dc/d75/AnimationImporter_8cpp_source.html (line 920) Seem to only define the case for CAMERA_XFOV%%%
Member

%%%The FOV in blender is not animatable in 2 dimensions.
Actually it looks like the animation always scales in both dimensions using the output aspect ratio (from the render settings)
I am not sure how i would have to apply the yfov values here.

Meanwhile i believe that the best we can do is to just check whether
the collada file contains an xfov or an yfov animation, and if there is one, then add that animation as it is.

This should do the trick because i believe that blender's viewport aspect ratio is 1:1 anyways
I have added a patch which works with current trunk (revision 49559)

It would be a good idea if i could get some more input from someone who is familiar witgh the
camera settings, aspect ratios and animation of fov.%%%

%%%The FOV in blender is not animatable in 2 dimensions. Actually it looks like the animation always scales in both dimensions using the output aspect ratio (from the render settings) I am not sure how i would have to apply the yfov values here. Meanwhile i believe that the best we can do is to just check whether the collada file contains an xfov or an yfov animation, and if there is one, then add that animation as it is. This should do the trick because i believe that blender's viewport aspect ratio is 1:1 anyways I have added a patch which works with current trunk (revision 49559) It would be a good idea if i could get some more input from someone who is familiar witgh the camera settings, aspect ratios and animation of fov.%%%
Member

%%%I committed the patch as initial support for yfov/ymag in revision 49565
Please check if this solves your issue and give advise if further improvement is needed here.%%%

%%%I committed the patch as initial support for yfov/ymag in revision 49565 Please check if this solves your issue and give advise if further improvement is needed here.%%%
Member

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'
Author

%%%Thank you I will test it and let you know. I really appreciate your work. I should be able to get back to you in one hour.%%%

%%%Thank you I will test it and let you know. I really appreciate your work. I should be able to get back to you in one hour.%%%
Author

%%%Ran the test - This partially fix the issue. meaning that is actually loading now (I didn't check ymag but I see that you fixed the issue as well).
What is messing is the conversion (and more on that later) are defined as the angle but for blender to be able to animate the fov this need to be converted to mm.
The conversion code exists inside DocumentImporter.cpp and it's used to correctly initialize the camera. So it's only a matter of reusing the same code to convert the

It seem to me that the implementation before you patch was already bugged at the value for animation was loaded without conversion.
I am working on a crude patch - my c/c++ is really rusty. So you can see what I mean. meanwhile I attached two screenshot explaining the situation, I don't think they are totally accurate as the fov is given by the rapport between the aspect ratio and one of the angle, yet I think that will help this conversation.

Tell me if you prefer that I open another bug report regarding the conversion


"The FOV in blender is not animatable in 2 dimensions.
Actually it looks like the animation always scales in both dimensions using the output aspect ratio (from the render settings)
I am not sure how i would have to apply the yfov values here." -> you are perfectly right.%%%

%%%Ran the test - This partially fix the issue. meaning that <yfov> is actually loading now (I didn't check ymag but I see that you fixed the issue as well). What is messing is the conversion <yfov> (and <xfov> more on that later) are defined as the angle but for blender to be able to animate the fov this need to be converted to mm. The conversion code exists inside DocumentImporter.cpp and it's used to correctly initialize the camera. So it's only a matter of reusing the same code to convert the <yfov> It seem to me that the implementation before you patch was already bugged at the <xfov> value for animation was loaded without conversion. I am working on a crude patch - my c/c++ is really rusty. So you can see what I mean. meanwhile I attached two screenshot explaining the situation, I don't think they are totally accurate as the fov is given by the rapport between the aspect ratio and one of the angle, yet I think that will help this conversation. Tell me if you prefer that I open another bug report regarding the conversion - - - "The FOV in blender is not animatable in 2 dimensions. Actually it looks like the animation always scales in both dimensions using the output aspect ratio (from the render settings) I am not sure how i would have to apply the yfov values here." -> you are perfectly right.%%%
Author

%%%Errata: the conversion process is in two step for : to and then to mm%%%

%%%Errata: the conversion process is in two step for <yfov>: <yfov> to <xfov> and then <xfov> to mm%%%
Author

%%%I attached the patch against revision 49566. It's ugly as hell but should help. Ideally the code used in DocumentImporter.cpp should be shared but I don't really see how. While my c/c++ is rusty hacking blender was fun... I may try to do that more...%%%

%%%I attached the patch against revision 49566. It's ugly as hell but should help. Ideally the code used in DocumentImporter.cpp should be shared but I don't really see how. While my c/c++ is rusty hacking blender was fun... I may try to do that more...%%%
Member

%%%@philippeBRARD: thanks for the patch. that helped a lot to fix this issue.

Blender does now export camera animations with FOV data, and also imports the FOV data correctly.
Fixed in revisions: svn49588%%%

%%%@philippeBRARD: thanks for the patch. that helped a lot to fix this issue. Blender does now export camera animations with FOV data, and also imports the FOV data correctly. Fixed in revisions: svn49588%%%
Author

%%%@Gaia Thank you for the fix! I really appreciate it. I found a new bug in the way the is converted to . I am opening a new bug ticket for this one. I'm also working on a patch to add support to some of the collada extension (FCOLLADA and modo401). This should let Blender read and set the sensor size for the camera. I will open another ticket for this patch but I'm not sure that the correct procedure, as this is not so much a bug fix but a new feature, please advice.

Tl;dr: Thank you! found another bug but I can deal with it by myself and how I become a blender developer as that a fun things to do.

Thanks!%%%

%%%@Gaia Thank you for the fix! I really appreciate it. I found a new bug in the way the <yfov> is converted to <xfov>. I am opening a new bug ticket for this one. I'm also working on a patch to add support to some of the collada extension (FCOLLADA and modo401). This should let Blender read and set the sensor size for the camera. I will open another ticket for this patch but I'm not sure that the correct procedure, as this is not so much a bug fix but a new feature, please advice. Tl;dr: Thank you! found another bug but I can deal with it by myself and how I become a blender developer as that a fun things to do. Thanks!%%%
Author

%%%@Gaia I just submitted a bug report and a patch for the bad conversion, because it somewhat related to this issue you may want to be the one in charge of it. This is a really straightforward patch: http://projects.blender.org/tracker/?func=detail&aid=32348&group_id=9&atid=498%%%

%%%@Gaia I just submitted a bug report and a patch for the bad <yfov> conversion, because it somewhat related to this issue you may want to be the one in charge of it. This is a really straightforward patch: http://projects.blender.org/tracker/?func=detail&aid=32348&group_id=9&atid=498%%%
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#32237
No description provided.