Ñò
�^xNc           @   sm   d  d k  Z  d  d k Z e Z d d
 d „  ƒ  YZ d „  Z d „  Z d d d „  ƒ  YZ d d d	 „  ƒ  YZ d S(   iÿÿÿÿNt   PhysicsTurretShapec           B   s­   e  Z h d+ d 6d, d 6d- d	 6d. d 6d/ d 6d0 d 6d1 d 6d2 d 6d3 d 6d4 d 6d5 d 6d6 d 6d7 d  6d8 d" 6d9 d$ 6Z d% „  Z d& „  Z d' „  Z d( „  Z d) „  Z d* „  Z RS(:   g        g       @g      ð?i    t   zScaleg       Ài   t   zPosi   t   xScalei   t   xPosi   t   yScalei   t   yPosg      à?i   t	   zRoundinggš™™™™™¹?i   t   zRoundingCenteri   t	   xRoundingi	   t   xRoundingCenteri
   t   xSlopei   t   xSlopeCenterg333333ã?i   t   zSlopei   t   zSlopeCenteri   t   topSlopec         C   sZ   d  |  _ t t t i i ƒ  d „  t i i ƒ  Dƒ ƒ ƒ |  _ |  i	 | | ƒ t
 |  _ d  S(   Nc         s   s   x |  ] } | d  Vq Wd S(   i   N(    (   t   .0t   d(    (    s$   scripts/common/PhysicsTurretShape.pys	   <genexpr>   s   	 (   t   Nonet   _PhysicsTurretShape__polyst   dictt   zipR    t   PARAMS_DESCt   iterkeyst
   itervaluest   _PhysicsTurretShape__paramst   setTurretBoxt   Truet   _PhysicsTurretShape__isDirty(   t   selft   bbMint   bbMax(    (    s$   scripts/common/PhysicsTurretShape.pyt   __init__   s    	4c         C   s.   t  i | ƒ t  i | ƒ f |  _ t |  _ d  S(   N(   t   Matht   Vector3t   _PhysicsTurretShape__boxR   R   (   R   R   R   (    (    s$   scripts/common/PhysicsTurretShape.pyR   #   s    !c         C   sA   t  i | } t | d t | d | ƒ ƒ |  i | <t |  _ d  S(   Ni    i   (   R    R   t   maxt   minR   R   R   (   R   t   namet   valueR   (    (    s$   scripts/common/PhysicsTurretShape.pyt   setParam'   s    'c         C   s   |  i  | S(   N(   R   (   R   R&   (    (    s$   scripts/common/PhysicsTurretShape.pyt   getParam,   s    c         C   s(   |  i  o |  i ƒ  t |  _  n |  i S(   N(   R   t    _PhysicsTurretShape__recalcPolyst   FalseR   (   R   (    (    s$   scripts/common/PhysicsTurretShape.pyt   getPolygons3   s    

c   ?      C   ss  |  i  } |  i \ } } | i | i } | i | i } | i | i } | | d } | | d } | | d }	 | i | d | d }
 |
 | d } |
 | d } | i | d | d } | |	 d } | |	 d } | i | d | d } | | d } | | d } |	 | d } |	 | } | | | d	 | d } | | d } | | d } | | d
 } | | } | | | d | d } | | d } | | d } d | d } | |	 } | | } | | }  | | d | d | d |	 }! |! | d }" |! | d }# |" | | d	 |  d }$ |$ |  d }% |$ |  d }& d | d }' |' | }( | |' }) | |' }* | |( d | d | d | }+ |+ |( d }, |+ |( d }- |, |) | d |* d }. |. |* d }/ |. |* d }0 t i | | | f ƒ t i | | | f ƒ t i | | | f ƒ t i | | | f ƒ t i | | | f ƒ t i | | | f ƒ t i | | | f ƒ t i | | | f ƒ t i |0 | |" f ƒ t i |- | |% f ƒ t i |- | |& f ƒ t i |0 | |# f ƒ t i |/ | |# f ƒ t i |, | |& f ƒ t i |, | |% f ƒ t i |/ | |" f ƒ g }1 t i |1 d ƒ }2 | d | d | | |2 _ |1 d }3 |2 |3 }4 |4 i d j  o t i d% ƒ }5 no |3 |1 d }6 |6 i d j  o# t i d |4 i |4 i f ƒ }5 n |6 |4 }5 |5 i d j  o t i d& ƒ }5 n x^ t d d ƒ D]M }7 |1 |7 }8 |1 |7 d }9 t	 |3 |5 |8 |9 ƒ }: |8 |: |9 |8 |1 |7 d <q(Wd' d( d) d* d+ d, d- d. d/ d0 f
 }; t
 |1 ƒ |; f |  _ t o¶ t d$ ƒ }< d }= x“ |; D]‹ }> x‚ t t |> ƒ ƒ D]n }7 |1 |> |7 }6 |1 |> |7 d t |> ƒ }4 |< i t |= |6 i |= |6 i f |= |4 i |= |4 i f ƒ ƒ qëWqÒW|< i ƒ  n d  S(1   NR   R   R   g      à?R   R   R   R   R   R	   R
   g      ð?R   R   R   R   i   R   i   gü©ñÒMbP?g        i   i   i   i   i   i   i   i    i	   i
   i   i   i   i   t   turret(   g        g      ð?g        (   g        g      ð?g        (   i   i   i   i   i   i   i   i    (   i   i	   i
   i   i   i   i   i   (   i    i   i	   i   (   i   i   i
   i	   (   i   i   i   i
   (   i   i   i   i   (   i   i   i   i   (   i   i   i   i   (   i   i   i   i   (   i   i    i   i   (   R   R#   t   xt   yt   zR!   R"   t   lengtht   xranget   _intersectPlaneSegmentt   tupleR   t   _DEBUG_WITH_SVGt   _Scenet   lent   addt   _Linet	   write_svg(?   R   t   paramsR   R   t   wt   ht   lt   swt   sht   slt   centerYt   minYt   maxYt   centerZt   minZt   maxZt   centerXt   minXt   maxXt   roundedDeltaZt   alignedDeltaZt   roundingCenterZt   alignedMinZt   alignedMaxZt   roundedDeltaXt   alignedDeltaXt   roundingCenterXt   alignedMinXt   alignedMaxXt	   zTopScalet   topLt   roundedTopDeltaZt   alignedTopDeltaZt
   topCenterZt   topMinZt   topMaxZt   topRoundingCenterZt   topAlignedMinZt   topAlignedMaxZt	   xTopScalet   topWt   roundedTopDeltaXt   alignedTopDeltaXt
   topCenterXt   topMinXt   topMaxXt   topRoundingCenterXt   topAlignedMinXt   topAlignedMaxXt   vertst   ptt   plPtt   v2t   plNt   v1t   it   s1t   s2t   tt   indst   scenet   offst   face(    (    s$   scripts/common/PhysicsTurretShape.pyt   __recalcPolys:   sÎ    	




"


"

#
 
	  F(   g        g       @g      ð?i    (   g       Àg       @g        i   (   g        g       @g      ð?i   (   g       Àg       @g        i   (   g        g       @g      ð?i   (   g       Àg       @g        i   (   g        g      ð?g      à?i   (   g        gš™™™™™¹?g      à?i   (   g        g      ð?g      à?i   (   g        g      ð?g      à?i	   (   g        g      ð?g      à?i
   (   g        g      ð?g      à?i   (   g        g      ð?g333333ã?i   (   g        g      ð?gš™™™™™¹?i   (   g        g      ð?g      à?i   (	   t   __name__t
   __module__R   R    R   R(   R)   R,   R*   (    (    (    s$   scripts/common/PhysicsTurretShape.pyR       s,   
					c         C   s>   | i  | | ƒ } | | d j  o d S| i  |  | ƒ | S(   Ng:Œ0âŽyE>g        (   t   dot(   t   planePtt   planeNt   seg1t   seg2Rz   (    (    s$   scripts/common/PhysicsTurretShape.pyR3   µ   s    c         C   s   t  |  | ƒ S(   N(   R    (   R   R   (    (    s$   scripts/common/PhysicsTurretShape.pyt   createPhysicsTurretShape¼   s    R6   c           B   sD   e  Z d  d d d „ Z d „  Z d „  Z d d „ Z d d „ Z RS(	   Rt   i�  c         C   s(   | |  _  g  |  _ | |  _ | |  _ d  S(   N(   R&   t   itemst   heightt   width(   R   R&   R�   R‚   (    (    s$   scripts/common/PhysicsTurretShape.pyR    À   s
    				c         C   s   |  i  i | ƒ d  S(   N(   R€   t   append(   R   t   item(    (    s$   scripts/common/PhysicsTurretShape.pyR8   Ç   s    c         C   sW   d d |  i  |  i f d d g } x! |  i D] } | | i ƒ  7} q, W| d g 7} | S(   Ns   <?xml version="1.0"?>
s   <svg height="%d" width="%d" >
s+    <g style="fill-opacity:1.0; stroke:black;
s     stroke-width:1;">
s    </g>
</svg>
(   R�   R‚   R€   t   strarray(   R   t   varR„   (    (    s$   scripts/common/PhysicsTurretShape.pyR…   É   s    	
  c         C   sW   | o | |  _  n |  i d |  _  t |  i  d ƒ } | i |  i ƒ  ƒ | i ƒ  d  S(   Ns   .svgR<   (   t   svgnameR&   t   opent
   writelinesR…   t   close(   R   t   filenamet   file(    (    s$   scripts/common/PhysicsTurretShape.pyR:   Ò   s    
t   explorerc         C   s*   d d  k  } | i d | |  i f ƒ d  S(   Niÿÿÿÿs   %s %s(   t   ost   systemR‡   (   R   t   progRŽ   (    (    s$   scripts/common/PhysicsTurretShape.pyt   displayÜ   s    N(   Rx   Ry   R    R8   R…   R   R:   R‘   (    (    (    s$   scripts/common/PhysicsTurretShape.pyR6   ¿   s
   			
R9   c           B   s   e  Z d  „  Z d „  Z RS(   c         C   s   | |  _  | |  _ d  S(   N(   t   startt   end(   R   R’   R“   (    (    s$   scripts/common/PhysicsTurretShape.pyR    â   s    		c         C   s3   d |  i  d |  i  d |  i d |  i d f g S(   Ns+     <line x1="%d" y1="%d" x2="%d" y2="%d" />
i    i   (   R’   R“   (   R   (    (    s$   scripts/common/PhysicsTurretShape.pyR…   ç   s    (   Rx   Ry   R    R…   (    (    (    s$   scripts/common/PhysicsTurretShape.pyR9   á   s   	(    (    (    (	   t   BigWorldR!   R   R5   R    R3   R   R6   R9   (    (    (    s$   scripts/common/PhysicsTurretShape.pyt   <module>   s   ¯		"