10 Replies Latest reply on Nov 12, 2009 3:33 PM by TomDelorenzi

    Likely bug in Rotate3D

    TomDelorenzi Level 1

      I just wanted to verify this is a bug before I created a bug. I was experimenting with the rotate3d. I wanted to have an effect where I flip one screen over and another is on the back of it. When I do a rotate 90 it appears to rotate about 100 or so instead.

      You can verify the bug on tour de flex as it does the same thing:

      http://www.adobe.com/devnet/flex/tourdeflex/web/#sampleId=31300;illustIndex=0;docIndex=0

       

      Set it to 1 repeat, no reverse and 90 y. You will see it rotate to far. The interesting thing is if hit the go button again it is closer to 90 and then on the third attempt it actually does it correctly.

        • 1. Re: Likely bug in Rotate3D
          Chet Haase Level 3

          Go ahead and file a bug, or else post a simple case for us to look at. It's easier for me to tell whether it's a problem with code than the description

           

          Thanks,

          Chet.

          • 2. Re: Likely bug in Rotate3D
            TomDelorenzi Level 1

            Do I need to make a project for you guys with the code? The code is in the link to Tour De Flex I put in the message.

            • 3. Re: Likely bug in Rotate3D
              Chet Haase Level 3

              Ah, okay. No, that's good enough. I didn't realize it was exactly that code, I just thought you were saying there was a similar artifact there.

               

              Chet.

              • 4. Re: Likely bug in Rotate3D
                Chet Haase Level 3

                Nope, not a bug. It's more an understanding issue with how projection works.

                 

                By default, we center the 3D projection on the object. That means that if you rotate the object around its left axis (which this sample does), you will see part of the object because you're not viewing it end-on, but rather from the center of the original object.

                 

                If you then rotate it to 90 again, we will pick a new projection center, again based on the 2D center of the object. But since that object is now much thinner, the projection center is closer to the left edge, so the projection distortion is not as great. And if you keep doing it, we'll keep setting a projection center that is closer and closer to the left edge (because the object is thinner and thinner, so it is that much smaller in 2D), so eventually you'll see it disappear as you expected at first, because the projection center is essentially coincident with the left edge.

                 

                There are two ways to work around this issue, depending on your situation:

                - set the transformCenter to be coincident with the projection center. Try setting autoCenterTransform=true, and you'll rotate the object around the middle of the object, which happens to be the same place as the projection center, so you'll get the effect you were looking for (albeit around a different rotation center, which may not be what you want).

                - set the projection center to be some other point. If you set autoCenterProjection to false, it will default to the 0,0 point of the object, so the rotation center and the projection center will be coincident on the left edge of the object. If you set applyLocalProjection to false, it will use the default projection center of the parent (centered on the parent), so it will at least be the same every time instead of moving with the 2D size of the object.

                 

                Chet.

                • 5. Re: Likely bug in Rotate3D
                  TomDelorenzi Level 1

                  Thanks for the detailed answer. Only question to follow up is on the tour de flex example when you rotate the 2nd time, it appears to reset the animation and repeat the exact same rotation. Should it not end up with the same end result then? It doesn't seem like its rotating it 90, and then 90 more, but rather 90 and then reset back to 0 and the same 90.

                   

                  I did the email reply thing but it didn't show. Perhaps it takes longer though.

                  • 6. Re: Likely bug in Rotate3D
                    TomDelorenzi Level 1

                    Thanks for the detailed answer. Only question to follow up is on the tour de flex example when you rotate the 2nd time, it appears to reset the animation and repeat the exact same rotation. Should it not end up with the same end result then? It doesn't seem like its rotating it 90, and then 90 more, but rather 90 and then reset back to 0 and the same 90.

                    • 7. Re: Likely bug in Rotate3D
                      Chet Haase Level 3

                      It might be a little confusing in the sample, but it is correct for the reasons I explained. If you actually want to do the same rotation operation, then you really need to reset the object before you begin the effect.

                       

                      Chet.

                      • 8. Re: Likely bug in Rotate3D
                        TomDelorenzi Level 1

                        Ok thanks. I resolved the jira issue.

                        I am still struggling to get a 3d cube of my company logo heh.

                        Doing

                         

                         

                        img1.transformAround(new Vector3D(0,0,0),null,new Vector3D(0,90,0));
                        img2.transformAround(new Vector3D(0,0,0),null,new Vector3D(0,180,0));
                        img3.transformAround(new Vector3D(0,0,0),null,new Vector3D(0,270,0));

                         

                        produces the images at the right angles but all centered as expected. Adding transforms on the x or z axis makes them go all over the place though.

                        I am used to working in opengl where you rotate the projection around the model isntead of rotating the model. I did see some projection functions but I am not sure if thats the way to approach this.

                         

                        I also noticed that I don't think they are respecting a depth buffer of any kind as they probably are rendering in child order. So the guy in the farther z plane sometimes covers the guy in the front.

                         

                         

                        Thanks for your time on this issue!

                        • 9. Re: Likely bug in Rotate3D
                          TomDelorenzi Level 1

                          So I realized I should have centered my transition around 0,0,imgWidth/2. Sadly that didn't fix the problem.

                          When I changed that my gui didn't render apart from the outer panel. Like even parent elements of the stuff i am mucking with. Restarting it seemed to fix it. I had that happen once before when messing with these translations but I cannot repro it as of yet.

                          • 10. Re: Likely bug in Rotate3D
                            TomDelorenzi Level 1

                            I solved it! Also I had that panel missing thign happen again and just resizing the window makes everything draw again. Now I just have to figure out the depth buffer part.

                             

                            <Edit> doesn't look like the sdk supports a z buffer from some adobe post. Thats too bad maybe I can just make them all transparent a bit

                            Here is the code if someone else needs it some day:

                             

                            //at creation

                            var imgWidth:int=img1.width;
                            img4.transformAround(new Vector3D(imgWidth/2,0,imgWidth/2),null,new Vector3D(0,0,0));
                            img1.transformAround(new Vector3D(imgWidth/2,0,imgWidth/2),null,new Vector3D(0,90,0));
                            img2.transformAround(new Vector3D(imgWidth/2,0,imgWidth/2),null,new Vector3D(0,180,0));
                            img3.transformAround(new Vector3D(imgWidth/2,0,imgWidth/2),null,new Vector3D(0,270,0));

                             

                            <fx:Declarations>

                                 <s:Rotate3D id="rotateEffect" target="{rotateGroup}" angleYFrom="0" angleYTo="360" duration="5000" repeatCount="0"

                            autoCenterTransform="true"/>

                            <fx:Declarations>

                             

                            <s:Group id="rotateGroup">
                                    <s:Group id="img1">
                                        <s:BitmapImage source="@Embed('assets/images/branding/white_on_blue_logo.png')"/>           
                                    </s:Group>
                                    <s:Group id="img2">
                                        <s:BitmapImage source="@Embed('assets/images/branding/white_on_blue_logo.png')"/>           
                                    </s:Group>
                                    <s:Group id="img3">
                                        <s:BitmapImage source="@Embed('assets/images/branding/white_on_blue_logo.png')"/>           
                                    </s:Group>
                                    <s:Group id="img4">
                                        <s:BitmapImage source="@Embed('assets/images/branding/white_on_blue_logo.png')"/>           
                                    </s:Group>
                                </s:Group>