void LHBezierNode::initPathPointsFromDictionary(LHDictionary* bezierDict)
{	
    LHArray* curvesInShape = bezierDict->objectForKey("Curves")->arrayValue();    
    int MAX_STEPS = 25;    
	CCPoint conv = LHSettings::sharedInstance()->convertRatio();
	
	int i = 0;
    for(int j = 0; j < curvesInShape->count(); ++j)
    {
        LHDictionary* curvDict = curvesInShape->objectAtIndex(j)->dictValue();
        
        CCPoint endCtrlPt   = LHPointFromString(curvDict->objectForKey("EndControlPoint")->stringValue());
        CCPoint startCtrlPt = LHPointFromString(curvDict->objectForKey("StartControlPoint")->stringValue());
        CCPoint endPt       = LHPointFromString(curvDict->objectForKey("EndPoint")->stringValue());
        CCPoint startPt     = LHPointFromString(curvDict->objectForKey("StartPoint")->stringValue());
		
		CCPoint pos_offset = LHSettings::sharedInstance()->possitionOffset();
        
		if(!isLine)
        {
            for(float t = 0; t <= (1 + (1.0f / MAX_STEPS)); t += 1.0f / MAX_STEPS)
            {
                CCPoint vPoint = LHBezierNode::pointOnCurve(startPt,
                                                            startCtrlPt,
                                                            endCtrlPt,
                                                            endPt,
                                                            t);
				
                vPoint = ccp(vPoint.x*conv.x, winSize.height - vPoint.y*conv.y);
                
                vPoint.x += pos_offset.x;
                vPoint.y -= pos_offset.y;
                                
                pathPoints.push_back(vPoint);
            }
			
            pathPoints.pop_back();
        }
        else
        {
            CCPoint sPoint =  ccp(startPt.x*conv.x, 
                                  winSize.height - startPt.y*conv.y);
            
            sPoint.x += pos_offset.x;
            sPoint.y -= pos_offset.y;
            
            pathPoints.push_back(sPoint);

            
            if(i == curvesInShape->count()-1)
            {
                CCPoint ePoint = ccp(endPt.x*conv.x,
                                     winSize.height - endPt.y*conv.y);
                ePoint.x += pos_offset.x;
                ePoint.y -= pos_offset.y;
                
                pathPoints.push_back(ePoint);
            }
            ++i;            
        }
	}		
}
void LHBezierNode::initTileVerticesFromDictionary(LHDictionary* bezierDict)
{
    float scale = CCDirector::sharedDirector()->getContentScaleFactor();
    
	CCPoint convert = LHSettings::sharedInstance()->convertRatio();
	LHArray* fixtures = bezierDict->arrayForKey("TileVertices");
    
    if(NULL != fixtures)
    {
        for(int i = 0; i < fixtures->count(); ++i)
        {
            LHArray* fix = fixtures->objectAtIndex(i)->arrayValue();
        
            std::vector<CCPoint> triagle;
        
            for(int j = 0; j < fix->count(); ++j)
            {
                CCPoint point = LHPointFromString(fix->objectAtIndex(j)->stringValue());
			
                CCPoint pos_offset = LHSettings::sharedInstance()->possitionOffset();
            
                point.x = point.x* convert.x;
                point.y = winSize.height - point.y*convert.y;
			
                //point.x*=scale;
                //point.y*=scale;

                point.x += pos_offset.x;
                point.y -= pos_offset.y;

                triagle.push_back(point);
            }
            trianglesHolder.push_back(triagle);
        }	
	}
	
	if(isVisible)
	{
		LHArray* curvesInShape = bezierDict->objectForKey("Curves")->arrayValue();
		
		int MAX_STEPS = 25;
		
        for(int i = 0; i < curvesInShape->count(); ++i)
		{
            LHDictionary* curvDict = curvesInShape->objectAtIndex(i)->dictValue();
            
			CCPoint endCtrlPt   = LHPointFromString(curvDict->objectForKey("EndControlPoint")->stringValue());
			CCPoint startCtrlPt = LHPointFromString(curvDict->objectForKey("StartControlPoint")->stringValue());
			CCPoint endPt       = LHPointFromString(curvDict->objectForKey("EndPoint")->stringValue());
			CCPoint startPt     = LHPointFromString(curvDict->objectForKey("StartPoint")->stringValue());
			
            CCPoint pos_offset = LHSettings::sharedInstance()->possitionOffset();
                        
			if(!isLine)
			{
				CCPoint prevPoint;
				bool firstPt = true;
				
				for(float t = 0; t <= (1 + (1.0f / MAX_STEPS)); t += 1.0f / MAX_STEPS)
				{
					CCPoint vPoint = LHBezierNode::pointOnCurve(startPt,
                                                                startCtrlPt,
                                                                endCtrlPt,
                                                                endPt,
                                                                t);
					
					if(!firstPt)
					{
						CCPoint pt1 = CCPointMake(prevPoint.x*convert.x, 
												  winSize.height - prevPoint.y*convert.y);
						CCPoint pt2 = CCPointMake(vPoint.x*convert.x, 
												  winSize.height - vPoint.y*convert.y);
						
                        pt1.x *=scale;
                        pt1.y *=scale;
                        
                        pt2.x *=scale;
                        pt2.y *=scale;
                        
                        pt1.x += pos_offset.x;
                        pt1.y -= pos_offset.y;
                        
                        pt2.x += pos_offset.x;
                        pt2.y -= pos_offset.y;
                        
                        linesHolder.push_back(pt1);
                        linesHolder.push_back(pt2);
					}
					prevPoint = vPoint;
					firstPt = false;					
				}
			}
			else
			{
				
				CCPoint pos1 = CCPointMake(startPt.x*convert.x, 
										   winSize.height - startPt.y*convert.y);
				CCPoint pos2 = CCPointMake(endPt.x*convert.x, 
										   winSize.height - endPt.y*convert.y);
				
                pos1.x*=scale;
                pos1.y*=scale;
                
                pos2.x*=scale;
                pos2.y*=scale;
                
                pos1.x += pos_offset.x;
                pos1.y -= pos_offset.y;
                
                pos2.x += pos_offset.x;
                pos2.y -= pos_offset.y;
                
                linesHolder.push_back(pos1);
                linesHolder.push_back(pos2);				
			}
		}
	}
}