// -----------------------------------------------------------------------------
// CTestPlatAlfVisual::TestAlfImageBrushSetAndGetParaL
// -----------------------------------------------------------------------------
//
TInt CTestPlatAlfVisual::TestAlfImageBrushSetAndGetParaL( CStifItemParser& /*aItem*/ )
    {
    _LIT( KTestPlatAlfVisual, "TestPlatAlfVisual" );
    _LIT( KTestAlfImageBrushSetAndGetParaL, "TestAlfImageBrushSetAndGetParaL" );
    TestModuleIf().Printf( 0, KTestPlatAlfVisual, KTestAlfImageBrushSetAndGetParaL );
    // Print to log file
    iLog->Log( KTestAlfImageBrushSetAndGetParaL );
    
    TAlfImage vImage;
    TUid vUid = { 0x00000000 };
    CAlfTextureManager* vTextManager = iAlfEnv->CreateSharedTextureManagerL( vUid );
    CAlfTexture* vText = &( vTextManager->BlankTexture() );
    vImage.SetTexture( *vText );
    CAlfImageBrush* vBrush = CAlfImageBrush::NewLC( *iAlfEnv, vImage );
    vBrush->SetScale( CAlfImageVisual::EScaleFitHeight );
    TAlfImage vNewImage;
    CAlfTexture* vNewText = &( vTextManager->BlankTexture() );
    vNewImage.SetTexture( *vNewText );
    vBrush->SetImage( vNewImage );
    vBrush->SetBorders( 1, 1, 1, 1 );
    TAlfTimedPoint vPoint( 1, 1 );
    vBrush->SetOffset( vPoint );
    TAlfTimedValue vValue( 1 );
    vBrush->SetScale( vValue );
    vBrush->Image();
    vBrush->BorderDrawingEnabled();
    vBrush->CenterDrawingEnabled();
    vBrush->Offset();
    vBrush->Scale();
    
    CleanupStack::PopAndDestroy( vBrush );
    
    return KErrNone;
    }
예제 #2
0
파일: cam.c 프로젝트: mantauav/paparazzi
/** Computes the right angles from target_x, target_y, target_alt */
void cam_target( void ) {
#ifdef TEST_CAM
  vPoint(test_cam_estimator_x, test_cam_estimator_y, test_cam_estimator_z,
     test_cam_estimator_phi, test_cam_estimator_theta, test_cam_estimator_hspeed_dir,
     cam_target_x, cam_target_y, cam_target_alt,
     &cam_pan_c, &cam_tilt_c);
#else
#ifdef POINT_CAM
  vPoint(estimator_x, estimator_y, estimator_z,
     estimator_phi, estimator_theta, estimator_hspeed_dir,
     cam_target_x, cam_target_y, cam_target_alt,
     &cam_pan_c, &cam_tilt_c);
#endif
#endif
  cam_angles();
}
예제 #3
0
파일: cam.c 프로젝트: AxSt/paparazzi
/** Computes the right angles from target_x, target_y, target_alt */
void cam_target( void ) {
#ifdef TEST_CAM
  vPoint(test_cam_estimator_x, test_cam_estimator_y, test_cam_estimator_z,
         test_cam_estimator_phi, test_cam_estimator_theta, test_cam_estimator_hspeed_dir,
         cam_target_x, cam_target_y, cam_target_alt,
         &cam_pan_c, &cam_tilt_c);
#else
  struct EnuCoor_f* pos = stateGetPositionEnu_f();
  struct FloatEulers* att = stateGetNedToBodyEulers_f();
  vPoint(pos->x, pos->y, pos->z,
         att->phi, att->theta, *stateGetHorizontalSpeedDir_f(),
         cam_target_x, cam_target_y, cam_target_alt,
         &cam_pan_c, &cam_tilt_c);
#endif
  cam_angles();
}
CCPoint LHBezierNode::pointOnCurve(CCPoint p1, CCPoint p2, CCPoint p3, CCPoint p4, float t){    
	float var1, var2, var3;
    CCPoint vPoint(0.0f, 0.0f);
    
    var1 = 1 - t;
    var2 = var1 * var1 * var1;
    var3 = t * t * t;
    vPoint.x = var2*p1.x + 3*t*var1*var1*p2.x + 3*t*t*var1*p3.x + var3*p4.x;
    vPoint.y = var2*p1.y + 3*t*var1*var1*p2.y + 3*t*t*var1*p3.y + var3*p4.y;
    return(vPoint);				
}
// -----------------------------------------------------------------------------
// CTestPlatAlfVisual::TestAlfLayoutSetAndGetL
// -----------------------------------------------------------------------------
//
TInt CTestPlatAlfVisual::TestAlfLayoutSetAndGetL( CStifItemParser& /*aItem*/ )
    {
    _LIT( KTestPlatAlfVisual, "TestPlatAlfVisual" );
    _LIT( KTestAlfLayoutSetAndGetL, "TestAlfLayoutSetAndGetL" );
    TestModuleIf().Printf( 0, KTestPlatAlfVisual, KTestAlfLayoutSetAndGetL );
    // Print to log file
    iLog->Log( KTestAlfLayoutSetAndGetL );
    
    CAlfLayout* vLayout = CAlfLayout::AddNewL( *iAlfCtl );
    CAlfImageVisual* vVisualOne = CAlfImageVisual::AddNewL( *iAlfCtl );
    TUid vUid = { 0x00000000 };
    TAlfImage vFirstImage( vUid, EAknsAppIconTypeList, 
            TSize( 1, 1), EAspectRatioPreserved, 0, 0, 0, 0 );
    vVisualOne->SetImage( vFirstImage );
    
    CAlfImageVisual* vVisualTwo = CAlfImageVisual::AddNewL( *iAlfCtl );
    TUid vSecUid = { 0x00000001 };
    TAlfImage vSecImage( vSecUid, EAknsAppIconTypeList, 
            TSize( 1, 1), EAspectRatioPreserved, 0, 0, 0, 0 );
    vVisualTwo->SetImage( vSecImage );
    
    vLayout->Append( vVisualOne );
    vLayout->Append( vVisualTwo );
    
    vLayout->EnableScrollingL();
    vLayout->Scrolling();
    TAlfTimedPoint vPoint( 0, 0 );
    vLayout->SetScrollOffset( vPoint );
    vLayout->ScrollOffset();
    TPoint vPos( 0, 1);
    TSize vSize( 1, 1 );
    vLayout->ChildOrdinal( 1 );
    vLayout->ChildPos( 0, vPos );
    vLayout->ChildSize( 0, vSize );
    
    TAlfXYMetric vXYMetric;
    vLayout->SetInnerPadding( vXYMetric );
    vLayout->InnerPaddingAsMetric();
    const TPoint vConstPos( 1, 1);
    vLayout->SetInnerPadding( vConstPos );
    vLayout->InnerPadding();
    vLayout->SetTransitionTime( 1 );
    
    vLayout->TransitionTime();
    vLayout->HorizontalInnerPadding();
    vLayout->VerticalInnerPadding();
    vLayout->InnerPaddingInBaseUnits();
    vLayout->EffectiveLayoutOrdinal( *vVisualTwo );
    
    return KErrNone;
    }
예제 #6
0
파일: Voro.cpp 프로젝트: hiroMTB/ob_ios
void Voro::addVertices(const vector<BrushData> & data, ob::plot::TYPE type, float minRad, float maxRad){

    static const glm::vec2 xAxis(1,0);

    for(int i=0; i<data.size(); i++){
        
        const PlotData & p = data[i].plot.at(type);
        const glm::vec2 & pos1 = p.stPos;
        glm::vec2 n1 = glm::normalize(pos1);
        float angle = glm::orientedAngle(xAxis, n1);
        
        if(minRad<angle && angle<=maxRad){
            vPs.push_back(vPoint(pos1.x, pos1.y));
        }
    }
}
예제 #7
0
bool  EventManager::checkNext(const QPoint &next_m, const QPoint &next_f, const QPoint &next_s, const QPoint &next_t)
{
  if (!isOutside(next_s) || !isEatingHimself(next_s, next_m))
    return false;

  static const QPoint arr[] = {next_f, next_s, next_t};
  vector<QPoint> vPoint (arr, arr + sizeof(arr) / sizeof(arr[0]));
  /*
  std::vector<QPoint> vPoint;
  vPoint.push_back(next_f);
  vPoint.push_back(next_s);
  vPoint.push_back(next_t);
  */
  
  for (int i = 0;  i < vPoint.size(); ++i)
    if (_land.getCell(vPoint[i]).getContent() == 'f')
      {
	_land.getCell(vPoint[i]).setContent(0);
	digest();
      }
  /*
  if (_land.getCell(next_f).getContent() == 'f')
    {
      _land.getCell(next_f).setContent(0);
      digest();
    }
  else if (_land.getCell(next_s).getContent() == 'f')
    {
      _land.getCell(next_s).setContent(0);
      digest();
    }
  else if (_land.getCell(next_t).getContent() == 'f')
    {
      _land.getCell(next_t).setContent(0);
      digest();
    }
  */
  return true;
}
예제 #8
0
/**
 * @brief compute middlePoints for each quadrant of a circle
 *
 * 0 middlePoints snaps to axis intersection at 0, 90, 180 and 270 degree (getNearestEndpoint) \n
 * 1 middlePoints snaps to 45, 135, 225 and 315 degree \n
 * 2 middlePoints snaps to 30, 60, 120, 150, 210, 240, 300 and 330 degree \n
 * and so on
 *
 * @param coord coordinates to compute, e.g. mouse cursor position
 * @param dist double pointer to return distance between mouse pointer and nearest entity point
 * @param middlePoints number of middle points to compute per quadrant (0 for endpoints)
 * @return the nearest of equidistant middle points of the circles quadrants.
 */
RS_Vector RS_Circle::getNearestMiddle(const RS_Vector& coord,
                                      double* dist /*= nullptr*/,
                                      const int middlePoints /*= 1*/) const
{
	if( data.radius <= RS_TOLERANCE) {
        //circle too short
        if ( nullptr != dist) {
            *dist = RS_MAXDOUBLE;
        }
        return RS_Vector(false);
    }

    RS_Vector vPoint( getNearestPointOnEntity( coord, true, dist));
    int iCounts = middlePoints + 1;
	double dAngleSteps = M_PI_2 / iCounts;
	double dAngleToPoint = data.center.angleTo(vPoint);
    int iStepCount = static_cast<int>((dAngleToPoint + 0.5 * dAngleSteps) / dAngleSteps);
    if( 0 < middlePoints) {
        // for nearest middle eliminate start/endpoints
        int iQuadrant = static_cast<int>(dAngleToPoint / 0.5 / M_PI);
        int iQuadrantStep = iStepCount - iQuadrant * iCounts;
        if( 0 == iQuadrantStep) {
            ++iStepCount;
        }
        else if( iCounts == iQuadrantStep) {
            --iStepCount;
        }
    }

	vPoint.setPolar( data.radius, dAngleSteps * iStepCount);
	vPoint.move( data.center);

	if(dist) {
        *dist = vPoint.distanceTo( coord);
    }

    return vPoint;
}
예제 #9
0
bool CPlayAreaManager::UpdateEntityLayers()
{
	m_vEntityLayerElements.clear();
	
	CWorldManagerWrapper worldManager;
	worldManager.Attach("GameSystem","WorldManager");

	CVector vTerrainMins,vTerrainMaxs;	
	IGenericTexture *piColorMap=NULL;
	if(worldManager.m_piTerrain){worldManager.m_piTerrain->GetTerrainColorMap(NULL,&piColorMap);}
	if(worldManager.m_piTerrain){worldManager.m_piTerrain->GetTerrainBBox(&vTerrainMins,&vTerrainMaxs);}
	if(piColorMap==NULL)
	{
		REL(piColorMap);
		return false;
	}

	CVector vTerrainSize=vTerrainMaxs-vTerrainMins;
	unsigned int nTextureWidth=0,nTextureHeight=0;
	piColorMap->GetSize(&nTextureWidth,&nTextureHeight);


	//	Generacion de objetos basada directamente en ColorMap
	for(unsigned long l=0;l<m_vEntityLayers.size();l++)
	{
		SEntityLayerData *pLayer=&m_vEntityLayers[l];
		if(pLayer->m_EntityType.m_piEntityType==NULL){continue;}

		set<CVector,SEntityGenerationPositionKey> vEntities;
		set<CVector,SEntityGenerationPositionKey>::iterator i;

		double dSeparation=pLayer->m_LayerConfig.dSeparation;// in Entities
		double dJitter=pLayer->m_LayerConfig.dPositionJitter;// in Entities
		double dYawJitter=pLayer->m_LayerConfig.dYawJitter;// 0-360
		
		SEntityTypeConfig vConfig;
		CVector vEntitiesMins,vEntitiesMaxs;
		IEntityTypeDesign *piEntityTypeDesign=QI(IEntityTypeDesign,pLayer->m_EntityType.m_piEntityType);
		if(piEntityTypeDesign){piEntityTypeDesign->GetEntityTypeConfig(&vConfig);}
		REL(piEntityTypeDesign);
		
		if(vConfig.vBBoxes.size())
		{
			vEntitiesMins=vConfig.vBBoxes[0].vMins;
			vEntitiesMaxs=vConfig.vBBoxes[0].vMaxs;
			for(unsigned int b=0;b<vConfig.vBBoxes.size();b++)
			{
				vEntitiesMins.Mins(vEntitiesMins,vConfig.vBBoxes[0].vMins);
				vEntitiesMaxs.Maxs(vEntitiesMaxs,vConfig.vBBoxes[0].vMaxs);
			}
		}
			
		CVector vEntitiesize=vEntitiesMaxs-vEntitiesMins;
		if(vEntitiesize.c[0]==0 || vEntitiesize.c[2]==0){continue;}
		
		srand(0);

		for(double dX=vTerrainMins.c[0];dX<=vTerrainMaxs.c[0];dX+=(dSeparation*vEntitiesize.c[0]))
		{
			for(double dZ=vTerrainMins.c[2];dZ<=vTerrainMaxs.c[2];dZ+=(dSeparation*vEntitiesize.c[2]))
			{
				double dRandMaxCenter=((double)RAND_MAX)/2.0;

				CVector vPoint(dX,0,dZ);
				vPoint.c[0]+=((dRandMaxCenter-(double)rand())/(double)RAND_MAX)*dJitter*vEntitiesize.c[0];
				vPoint.c[2]+=((dRandMaxCenter-(double)rand())/(double)RAND_MAX)*dJitter*vEntitiesize.c[2];
				vPoint.c[1]=0;

				// check this point against the texture.
				CVector vPixel;
				vPixel.c[0]=(vPoint.c[0]-vTerrainMins.c[0])*((double)nTextureWidth)/vTerrainSize.c[0];
				vPixel.c[1]=((double)nTextureHeight-1.0)-(vPoint.c[2]-vTerrainMins.c[2])*((double)nTextureHeight)/vTerrainSize.c[2];
				CVector vPixelColor=piColorMap->GetPixelColor((unsigned long)vPixel.c[0],(unsigned long)vPixel.c[1]);

				CVector vYUVDiffence=HSVDifference(vPixelColor,pLayer->m_LayerConfig.vColor);
				if( fabs(vYUVDiffence.c[1])<=pLayer->m_LayerConfig.dColorSaturationMargin&& 
					fabs(vYUVDiffence.c[0])<=pLayer->m_LayerConfig.dColorValueMargin)
				{
					double dHeight=0;
					worldManager.m_piTerrain->GetTerrainHeightAt(vPoint,&dHeight);
					vPoint.c[1]=dHeight+FP_PRECISION*10;
					vEntities.insert(vPoint);
				}
			}
		}
		srand(0);

		for(i=vEntities.begin();i!=vEntities.end();i++)
		{
			CPlayAreaEntityWrapper wrapper;
			wrapper.Create(m_piSystem,"CPlayAreaEntity","");
			if(wrapper.m_piElement)
			{
				wrapper.m_piElement->SetEntityType(pLayer->m_EntityType.m_piEntityType);
				wrapper.m_piElement->SetPosition(*i);
				wrapper.m_piElement->SetAngles(CVector(((double)rand()/(double)RAND_MAX)*dYawJitter,0,0));
				m_vEntityLayerElements.push_back(wrapper);
			}
		}
		RTTRACE("Generated %d entities",vEntities.size());
	}
	REL(piColorMap);
	return true;
}
예제 #10
0
 inline vPoint operator * (float val) const
 {
     return vPoint(x*val, y*val);
 }
예제 #11
0
 inline vPoint operator + (const vPoint &p) const
 {
     return vPoint(x+p.x, y+p.y);
 }
예제 #12
0
 inline vPoint operator - (const vPoint &p) const
 {
     return vPoint(x-p.x, y-p.y);
 }
예제 #13
0
파일: appbase.cpp 프로젝트: newobj/taz
void CAppBase::Render()
{
//	SDL_SysWMinfo wmi = { 0 };
//	SDL_GetWMInfo(&wmi);
//	SetWindowPos(wmi.window, HWND_TOPMOST, NULL, NULL, NULL, NULL, SWP_NOREPOSITION |SWP_NOSIZE);

	CCamera Camera;
	Camera.SetViewportDims(CVec2i(GetVideo()->GetWidth(), GetVideo()->GetHeight()));
	GetRender()->SetCamera(&Camera);
	
	CVec3f vDirection;
	vDirection.Point(g_fAzimuth, g_fElevation);
	Camera.SetDirection(-vDirection);
	
	CVec3f vPosition(0,0,0);
	vDirection *= g_fZoom;
	Camera.SetPosition(vPosition+vDirection+CVec3f(160,0,160));
//	Camera.SetFOV(60.0f);
//	Camera.SetAspectRatio(4.0f/3.0f);
	static ITube* s_pTube = NULL;
	if ( !s_pTube )
	{
		s_pTube = ITube::Create();
		s_pTube->SetShader("shaders/tube.shader");
		CVec3f vPoint(0,0,0);
		for ( int i = 0 ; i < 100 ; ++i )
		{
			s_pTube->AddControlPoint(CVec3f(160+20.0f*sin(float(i)/10.0f), i, (160+20.0f*cos(float(i)/10.0f))));
		}
	}

	GetRender()->BeginProjection(eProjectionPerspective);
	{
		GetRender()->BeginRenderPass(eRenderPassAccum);
		{
			GetScene()->Render3d();
			GetRender()->RenderTube(s_pTube);
		}
		GetRender()->EndRenderPass(eRenderPassAccum);

		GetRender()->BeginRenderPass(eRenderPassNormal);
		{
			GetScene()->Render3d();
			GetRender()->RenderTube(s_pTube);

			static bool once = true;
			static CVec3f vSrc;
			static CVec3f vDest;
//				if ( once )
			{
				vSrc = GetRender()->Unproject(NULL, g_vMousePos, 10.0f);
				vDest = GetRender()->Unproject(NULL, g_vMousePos, 10000.0f);
				once=false;
			}

			CVec3f vDir = vDest-vSrc; vDir.Normalize();
			IObject* pObject = NULL;
			if ( pObject = GetScene()->PickObject(vSrc, vDir) )
			{
				Debug("Picked %s", pObject->GetClass()->GetClassDef()->GetName().c_str());
			}

			CPlane3f plane(CVec3f(0,1,0), 0.0f);
			if ( plane.IntersectRay(CRay3f(vSrc, vDir), &g_vCursor3d) )
			{
//				Debug("x,y,z = %f,%f,%f", g_vCursor3d.x, g_vCursor3d.y, g_vCursor3d.z);
			}
			else
			{
//				Debug("...");
			}

//				GetRender()->RenderLine(CVec3f(160,0,160), vDest, CRGBA(255,255,0,255));
//				GetRender()->RenderLine(CVec3f(0,0,0), vDest, CRGBA(0,255,0,255));
//				GetRender()->RenderModelSkinned(&s_ModelSkinned);
		}
		GetRender()->EndRenderPass(eRenderPassNormal);
	}
	GetRender()->EndProjection(eProjectionPerspective);
	GetRender()->BeginProjection(eProjectionOrtho);
	{
		GetUi()->Render();
	}
	GetRender()->EndProjection(eProjectionOrtho);

	GetRender()->SetCamera(NULL);

	GetRender()->Swap();
}