Silverlight Image Matching Right

I create a lot of images to shape the human body so that I can use it for the physics engine. The generated images are in a specific custom control where I set the dimensions and coordinates of each image. This usercontrol is then loaded into another custom control, but for some reason when loading images, one particular image, which I named (rightBicep), is shifted to the right. Here's a screenshot:

alt text http://img193.imageshack.us/img193/592/imageshift.jpg

I've illustrated the positions of the images with dashed lines, the green dashed line refers to where the image should be positioned, and the red dotted line where the image is displayed.

The strange thing is that the image below it (called rightForearm) takes away LeftPosition from it, and when during debugging they have the same leftProperty value. Here's the syntax:

        public void generateRightBicep(string imageUrl)
        {
            rightBicep = new Image();            
            rightBicep.Name = CharacterName + "rightbicep";
            Uri imageUri = new Uri(imageUrl, UriKind.Relative);
            LayoutRoot.Children.Add(rightBicep);

            rightBicep.Source = new BitmapImage(imageUri);
            rightBicep.ImageOpened += new EventHandler<RoutedEventArgs>(bodyPart_ImageOpened);

        }

       public void rightBicepLoaded()
        {
            var bi = waitTillImageLoad(rightBicep.Name);
            rightBicep.Height = elbowToArmpit + (2 * palm);
            rightBicep.Width = ratio(bi.PixelHeight, bi.PixelHeight, rightBicep.Height); // to be determined

            Vector2 topVector;
            topVector.X = (float)(Convert.ToDouble(torso.GetValue(Canvas.LeftProperty)) - palm);
            topVector.Y = (float)(Convert.ToDouble(neck.GetValue(Canvas.TopProperty)) + neck.Height);

            if (!faceRight)
            {
                perspectiveVectorHeight(ref topVector, ref rightBicep, torso.Width);
                rightBicep.Width = ratio(bi.PixelHeight, bi.PixelHeight, rightBicep.Height);
            }

            rightBicep.SetValue(Canvas.LeftProperty, Convert.ToDouble(topVector.X));
            rightBicep.SetValue(Canvas.TopProperty, Convert.ToDouble(topVector.Y));
            rightBicep.SetValue(Canvas.ZIndexProperty, rightBicepZindex);
            generateRightShoulder();
        }


public void generateRightForearm(string imageUrl)
        {
            rightForearm = new Image();
            rightForearm.Name = CharacterName + "rightforearm";
            Uri imageUri = new Uri(imageUrl, UriKind.Relative);
            LayoutRoot.Children.Add(rightForearm);
            rightForearm.Source = new BitmapImage(imageUri);
            rightForearm.ImageOpened += new EventHandler<RoutedEventArgs>(bodyPart_ImageOpened);

        }

 public void rightForearmLoaded()
        {
            var bi = waitTillImageLoad(rightForearm.Name);
            rightForearm.Height = (elbowToHandTip - handLength) + palm;
            rightForearm.Width = ratio(bi.PixelHeight, bi.PixelWidth, rightForearm.Height);

            Vector2 topVector;
            if (faceRight)
            {
                topVector.X = (float)(Convert.ToDouble(rightBicep.GetValue(Canvas.LeftProperty)));
                topVector.Y = (float)(Convert.ToDouble(rightBicep.GetValue(Canvas.TopProperty)) + rightBicep.Height - palm);
            }
            else
            {
                topVector.X = (float)(Convert.ToDouble(leftBicep.GetValue(Canvas.LeftProperty)));
                topVector.Y = (float)(Convert.ToDouble(leftBicep.GetValue(Canvas.TopProperty)) + leftBicep.Height - palm);

                perspectiveVectorHeight(ref topVector, ref rightForearm, torso.Width);
                rightForearm.Width = ratio(bi.PixelHeight, bi.PixelWidth, rightForearm.Height);
            }

            rightForearm.SetValue(Canvas.LeftProperty, Convert.ToDouble(topVector.X));
            rightForearm.SetValue(Canvas.TopProperty, Convert.ToDouble(topVector.Y));
            rightForearm.SetValue(Canvas.ZIndexProperty, rightForearmZIndex);
            generateRightElbow();
        }

      

Now all the values ​​that I add together are a group of doublings that I set, and the faceRight property is dertmine if the human body is facing right or left to determine where the body positions are located (since if the right hand is facing the left, when the human body turns the other way).

If you notice that rightforearm uses the left property of the rightbicep, so technically it should appear in the drawing, under which it is not. I've also debugged a custom control and both have a property to the left of -3.

PS. I call the methods rightbicepLoaded

and rightforearmLoaded

when the event is called when all imageOpened events have all been fired.

Any ideas on why this is happening?

+1


a source to share


1 answer


Found out why in my method the ratio should occupy hieght and width, and I put, and I put 2 hieghts instead



0


a source







All Articles