2009-05-15 5 views
1

나는 물리 엔진을 사용할 수 있도록 인체를 구성하는 이미지 세트를 생성 중입니다. 생성 된 이미지는 각 이미지의 크기와 좌표를 설정하는 특정 사용자 정의 컨트롤에 있습니다. 그런 다음 해당 사용자 정의 컨트롤을 다른 사용자 정의 컨트롤에로드 할 수 있지만 이미지가로드 될 때 어떤 이유로 특정 이름의 이미지 (rightBicep)가 오른쪽으로 이동합니다. 이미지가있는 곳 alt text http://img193.imageshack.us/img193/592/imageshift.jpgSilverlight 특정 이미지 오른쪽으로 이동

내가 점선 이미지의 위치가, 녹색 점선 이미지를 배치 할 위치에 다스 려되는 설명하고, 빨간색 점선은 : 여기 스크린 샷입니다 표시됩니다.

괴괴 망측 한 것이 그 아래에있는 이미지 (rightForearm이라 부름)입니다.이 부분은 LeftPosition이며, 디버깅 중에는 leftproperty와 정확히 같은 값을가집니다. 다음 구문이다 :

 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(); 
     } 

지금 내가 함께 추가하고 모든 값이 나는 사전 복식의 그룹은, 그리고 속성 faceRight은 인체의 어디에 위치를 결정하기 위해이 오른쪽을 향하게 또는 왼쪽 경우 dertmine하는 것입니다 (오른손이 인체가 다른 방향으로 회전 할 때 왼쪽면을 본다면).

rightforearm이 rightbicep의 왼쪽 속성을 사용하고 있다는 것을 알게되면 기술적으로는 오른쪽 아래쪽이 표시되지 않습니다. 나는 또한 사용자 정의 컨트롤을 디버깅했으며 둘 다 -2의 왼쪽 속성을 갖는다.

추신. 모든 imageOpened 이벤트가 모두 트리거되었을 때 이벤트가 호출 될 때 rightbicepLoadedrightforearmLoaded 메서드를 호출합니다.

왜 그런지에 대한 아이디어가 있습니까?

답변

0

내 방법 비율에서 hieght 및 너비가 있어야하며 대신 2 hieghts를 넣어야합니다.