Esempio n. 1
0
  int Mesh::loadPly(const char* plyName)
  {
    Block& b = *(m_blocks.end()-1);

    vector<float> vert;
    vector<int> fac;
    
    _file_ply File1;
   
    if (! File1.open(const_cast<char*>(plyName))){
      File1.read(vert, fac);
      File1.close();
    }

    PointF p1;
    
    colour(PointF(0.7, 0.3, 0.7));

    for(int i = 0; i < fac.size(); ++i)
      {
	p1 = PointF(vert[fac[i]*3],
		    vert[fac[i]*3+1],
		    vert[fac[i]*3+2]);
	point(p1);
      }
  }
Esempio n. 2
0
//---------------------------------------------------------------------------
void __fastcall TForm3D2::Form3DRender(TObject *Sender, TContext3D *Context)
{
	// Set Vertices
	TVertexBuffer * Ver = new TVertexBuffer(TVertexFormats() << TVertexFormat::Vertex <<
		TVertexFormat::TexCoord0, 4);
	Ver->Vertices[0]  = Point3D(-6, 0, -5);
	Ver->TexCoord0[0] = PointF(0, 0);
	Ver->Vertices[1]  = Point3D( 6, 0, -5);
	Ver->TexCoord0[1] = PointF(1, 0);
	Ver->Vertices[2]  = Point3D( 6, 0,  5);
	Ver->TexCoord0[2] = PointF(1, 1);
	Ver->Vertices[3]  = Point3D(-6, 0,  5);
	Ver->TexCoord0[3] = PointF(0, 1);
	// Set Indices
	TIndexBuffer * Idx = new TIndexBuffer(6, TIndexFormat::UInt16);
	Idx->Indices[0] = 0;
	Idx->Indices[1] = 1;
	Idx->Indices[2] = 3;
	Idx->Indices[3] = 3;
	Idx->Indices[4] = 1;
	Idx->Indices[5] = 2;
	// Set matrix
	Context->SetMatrix(TMatrix3D::CreateRotation(TPoint3D::Create(1,0,0), DegToRad(TagFloat)));
	// Set states
	Context->SetContextState(TContextState::csAllFace);
	// Create material
	TMyMaterial *Mat = new TMyMaterial();
	// render
	Context->DrawTriangles(Ver, Idx, Mat, 1);
	// dispose
	delete Mat;
	Ver->Free();
	Idx->Free();
}
void CPenBrushUnit::CalcBsplineMidPoint( POSITION psLeft, POSITION psRight,PointF &pts1,PointF &pts2,UINT &flag,DWORD mouseid)
{
	flag++;
	FPOINT_NODE &fptNode1=m_fptList.GetAt(psLeft), &fptNode2= m_fptList.GetAt(psRight);

	float fDeltaX = fptNode1.fpt.fX - fptNode2.fpt.fX;
	float fDeltaY = fptNode1.fpt.fY - fptNode2.fpt.fY;

	FPOINT_NODE fptNode;
	fptNode.fu = (fptNode1.fu+fptNode2.fu) / 2.f;
	m_bspline[mouseid]->Deboor(fptNode.fu, &fptNode.fpt);

	float fDx1 = fptNode.fpt.fX - fptNode1.fpt.fX;
	float fDy1 = fptNode.fpt.fY - fptNode1.fpt.fY;
	float fDx2 = fptNode2.fpt.fX - fptNode.fpt.fX;
	float fDy2 = fptNode2.fpt.fY - fptNode.fpt.fY;

	float fDotMul = fDx1*fDx2 + fDy1*fDy2;  //向量点乘

	POSITION ps = m_fptList.InsertAfter(psLeft, fptNode);
	if(flag==2)
		pts1=PointF(fptNode.fpt.fX,fptNode.fpt.fY);
	if(flag==3)
		pts2=PointF(fptNode.fpt.fX,fptNode.fpt.fY);
	if(flag<2)
	{
		CalcBsplineMidPoint(psLeft, ps,pts1,pts2,flag,mouseid);
		CalcBsplineMidPoint(ps, psRight,pts1,pts2,flag,mouseid);
	}

}
Esempio n. 4
0
SizeF GDIPluseExt::GetTextBounds(const Font& font,const StringFormat& strFormat,CString szText)
{
#ifndef _UNICODE
	//字符转换
	int str_len = szText.GetLength();
	WCHAR* pstr_w = new WCHAR[str_len];
	MultiByteToWideChar(CP_ACP,0,szText.GetBuffer(),-1,pstr_w,str_len);
	szText.ReleaseBuffer();
	
	GraphicsPath graphicsPathObj;
	FontFamily fontfamily;
	font.GetFamily(&fontfamily);
	graphicsPathObj.AddString(pstr_w,-1,&fontfamily,font.GetStyle(),font.GetSize(),PointF(0,0),&strFormat);
	DEL_P(pstr_w);
#else
	
	GraphicsPath graphicsPathObj;
	FontFamily fontfamily;
	font.GetFamily(&fontfamily);
	graphicsPathObj.AddString(szText,-1,&fontfamily,font.GetStyle(),font.GetSize(),PointF(0,0),&strFormat);


#endif
	
	
	RectF rcBound;
	// 获取边界范围
	graphicsPathObj.GetBounds(&rcBound);
	// 返回文本的宽高
	return SizeF(rcBound.Width,rcBound.Height);
}
Esempio n. 5
0
// ---------------------------------------------------------------------------
void __fastcall TfrmAboutSensors::Timer1Timer(TObject *Sender) {
	String ResultText;
	Single LStep;
	if (FActiveSensor != NULL) {
		switch (FActiveSensor->Category) {
		case TSensorCategory::Location:
			ResultText = GetInfoAboutLocation(FActiveSensor);
			break;
		case TSensorCategory::Environmental:
			ResultText = GetInfoAboutEnv(FActiveSensor);
			break;
		case TSensorCategory::Motion:
			ResultText = GetInfoAboutMotion(FActiveSensor);
			break;
		case TSensorCategory::Orientation:
			ResultText = GetInfoAboutOrientation(FActiveSensor);
			break;
		case TSensorCategory::Mechanical:
			ResultText = GetInfoAboutMechanical(FActiveSensor);
			break;
		case TSensorCategory::Electrical:
			ResultText = GetInfoAboutElectro(FActiveSensor);
			break;
		case TSensorCategory::Biometric:
			ResultText = GetInfoAboutBiometric(FActiveSensor);
			break;
		case TSensorCategory::Light:
			ResultText = GetInfoAboutLight(FActiveSensor);
			break;
		case TSensorCategory::Scanner:
			ResultText = GetInfoAboutScanner(FActiveSensor);
			break;
		}
		lInfo->Text = ResultText;
	}
	if (!FOnOneScreen) {
		if (FShowInfo) {
			if (lInfo->Position->Point.X > (cBorder * 2)) {
				LStep = Width / 5;
				lInfo->Position->Point =
					PointF(lInfo->Position->Point.X - LStep, cBorder);
				lbMain->Position->Point =
					PointF(lbMain->Position->Point.X - LStep, cBorder);
			}
		}
		else {
			if (lbMain->Position->Point.X < cBorder) {
				LStep = Width / 5;
				lInfo->Position->Point =
					PointF(lInfo->Position->Point.X + LStep, cBorder);
				lbMain->Position->Point =
					PointF(lbMain->Position->Point.X + LStep, cBorder);
			}
		}
	}
}
Esempio n. 6
0
SizeF GDIPluseExt::GetBounds(CString strText,CString strFont,INT nfontsize)
{
	StringFormat strformat;
	GraphicsPath path;

#ifdef _UNICODE


	FontFamily  fontFamily(strFont);
	path.AddString(strText,strText.GetLength(), &fontFamily, 
		FontStyleRegular, 
		(REAL)nfontsize,
		PointF(0,0), 
		&strformat );

#else

	//字符转换
	int font_len = strFont.GetLength();
	WCHAR* pfont_w = new WCHAR[font_len];
	MultiByteToWideChar(CP_ACP,0,strFont.GetBuffer(),-1,pfont_w,font_len);
	strFont.ReleaseBuffer();
	//字符转换
	int text_len = strText.GetLength();
	WCHAR* ptext_w = new WCHAR[text_len];
	MultiByteToWideChar(CP_ACP,0,strText.GetBuffer(),-1,ptext_w,text_len);
	strText.ReleaseBuffer();


	FontFamily  fontFamily(pfont_w);

	Font font(&fontFamily, (REAL)nfontsize, FontStyleRegular, UnitPixel);


	path.AddString(ptext_w,wcsnlen_s(ptext_w,text_len), &fontFamily, 
		font.GetStyle(),
		font.GetSize(),
		PointF(0,0), 
		&strformat );


	DEL_P(ptext_w);
	DEL_P(pfont_w);
#endif

	RectF rcBound;
	// 获取边界范围
	path.GetBounds(&rcBound);
	TRACE("Round_Size:%d\r\n",rcBound.Width);

	// 返回文本的宽高
	return SizeF(rcBound.Width,rcBound.Height);
}
Esempio n. 7
0
PointF CArcView::annotationPoint(double percent, double orthoDistance)
{
	//Calculer les distances correspondantes à chaque point
	std::vector<double> travelledDistance;
	travelledDistance.push_back(0);
	Point currentPoint(*pathPoints.begin());
	for(auto it=pathPoints.begin() + 1; it != pathPoints.end(); ++it)
	{
		travelledDistance.push_back(
			travelledDistance.back()
			+ Geometry::Distance(currentPoint, *it));
		currentPoint = *it;
	}

	PointF annotationPoint;
	double travelLocation = percent*travelledDistance.back();
	for(unsigned i = 0; i < travelledDistance.size() - 1; ++i)
	{
		if(travelLocation >= travelledDistance.at(i)
			&& travelLocation < travelledDistance.at(i+1))
		{
			//Définir les points
			PointF pointA = PointF(
				static_cast<Gdiplus::REAL>(pathPoints.at(i).X),
				static_cast<Gdiplus::REAL>(pathPoints.at(i).Y)
				);
			PointF pointB = PointF(
				static_cast<Gdiplus::REAL>(pathPoints.at(i+1).X),
				static_cast<Gdiplus::REAL>(pathPoints.at(i+1).Y)
				);
			
			double dx = pointB.X - pointA.X;
			double dy = pointB.Y - pointA.Y;

			//Déterminer le point au pourcentage donné
			double segmentLocation = travelLocation - travelledDistance.at(i);
			double segmentSize = travelledDistance.at(i+1) - travelledDistance.at(i);
			double segmentPercent = segmentLocation/segmentSize;
			annotationPoint.X = pointA.X + static_cast<Gdiplus::REAL>(dx*segmentPercent);
			annotationPoint.Y = pointA.Y + static_cast<Gdiplus::REAL>(dy*segmentPercent);

			//Décaler le point orthogonalement par rapport au segment
			//Coefficient directeur
			annotationPoint.X += static_cast<Gdiplus::REAL>(orthoDistance*(-dy)/segmentSize);
			annotationPoint.Y += static_cast<Gdiplus::REAL>(orthoDistance*(dx)/segmentSize);

			break;
		}
	}

	//Retourner le point
	return annotationPoint;
}
Esempio n. 8
0
void SonarMonitor::draw()
{
    Point point = m_hud->project(m_point);
    int radius = (m_hud->project(m_point + Point(0, m_radius)) - point).y;
    float scale = static_cast<float>(radius)/m_scale;
    PointF center = PointF(point) - PointF(1.5f);
    RectF rect = RectF(center, SizeF(4, 4));
    Matrix m(1);
    m = glm::scale(m, Vector3D(1, -1, 0));
    m = glm::rotate(m, m_hud->scenario()->yaw(), Vector3D(0, 0, 1));
    m = glm::translate(m, -m_hud->scenario()->position());

    m_hud->fontGreen().draw("T", point + Point(-2, -radius));
    m_hud->fontGreen().draw(QString("%1M").arg(m_scale), Rect(point + Point(-100, radius - 8), SizeF(200, -1)), true, false);
    m_center.draw(rect);

    for (fight::NavPoint *navPoint : m_hud->scenario()->navPoints())
        if (navPoint->isEnabled())
        {
            Vector2D dir = Vector2D(m * Vector4D(navPoint->position(), 1));
            float distance = glm::length(dir);
            if (distance < m_scale)
            {
                rect.setPos(center - dir*scale);
                m_nav.draw(rect);
            }
        }

    for (const auto &entry : m_hud->scenario()->sonar())
    {
        Vector2D dir = Vector2D(m * Vector4D(entry.object->position(), 1));
        float distance = glm::length(dir);
        if (distance < m_scale)
        {
            rect.setPos(center - dir*scale);
            (entry.isFriend ? m_friend : m_enemy).draw(rect);
        }
    }

    fight::Target &target = m_hud->scenario()->target();
    if (target.isLocked())
    {
        Vector2D dir = Vector2D(m * Vector4D(target.position(), 1));
        float distance = glm::length(dir);
        if (distance < m_scale)
        {
            rect.setPos(center - dir*scale);
            m_target.draw(rect);
        }
    }
}
xui_method_explain(xui_family_create_win, get_bits, void*			)( const xui_family& family, u16 wc )
{
	add_font(family);

	gdiinfo* info = m_gdiinfo_map[family.to_string()];

	//draw char
	SolidBrush brush(Color::White);
	info->gdig->SetTextRenderingHint(TextRenderingHintAntiAliasGridFit);
	info->gdig->Clear(Color(0));
	info->gdig->DrawString(
		(LPWSTR)(&wc), 
		1, 
		info->gdif, 
		PointF(0.0f,0.0f), 
		StringFormat::GenericTypographic(), 
		&brush);

	//char size
	RectF rect;
	info->gdig->MeasureString(
		(LPWSTR)(&wc), 
		1, 
		info->gdif, 
		PointF(0.0f, 0.0f), 
		StringFormat::GenericTypographic(), 
		&rect);

	info->size.w = (s32)ceilf(rect.Width ); 
	info->size.h = (s32)ceilf(rect.Height);

	if (info->size.w == 0)
		info->size.w =  family.size / 2;

	//copy buffer
	s32 w = info->size.w;
	s32 h = info->size.h;

	Color color;
	for (s32 y = 0; y < h; ++y)
	{
		for (s32 x = 0; x < w; ++x)
		{
			info->gdib->GetPixel(x, y, &color);
			info->bits[y*w+x] = color.GetAlpha();
		}
	}

	return info->bits;
}
Esempio n. 10
0
void Button::OnPaint( PaintEventArgs* e )
{
	if (_state == Hover)
	{
		set_BackColor(SystemColors::ButtonHighlight);
		Image* image = _stateImages[Hover];
		if (image == null)
			image = _stateImages[Normal];
		set_BackgroundImage(image, false);
	}	
	else if (_state == HoverPressed)
	{
		set_BackColor(SystemColors::ButtonShadow);
		Image* image = _stateImages[Pressed];
		if (image == null)
			image = _stateImages[Normal];
		set_BackgroundImage(image, false);
	}
	else
	{
		set_BackColor(SystemColors::ButtonFace);
		set_BackgroundImage(_stateImages[Normal], false);
	}

	ButtonBase::OnPaint(e);

	Graphics& g = e->Graphics;

	Drawing::Pen pen(Color::Black);
	g.DrawRectangle(pen, 1, 1, get_Size().Width - 1, get_Size().Height - 1);

	SolidBrush brush(SystemColors::ControlText);
	g.DrawString(get_Text(), *SystemFonts::DefaultFont, brush, PointF(3, 3));
}
Esempio n. 11
0
void OsmAnd::MapRasterizer_P::calculateVertex(const Context& context, const PointI& point31, PointF& vertex)
{
    vertex.x = static_cast<float>(point31.x - context.area31.left()) / context.primitivisedObjects->scaleDivisor31ToPixel.x;
    vertex.y = static_cast<float>(point31.y - context.area31.top()) / context.primitivisedObjects->scaleDivisor31ToPixel.y;

    vertex += PointF(context.pixelArea.topLeft);
}
Esempio n. 12
0
STDMETHODIMP CGaugeOverlay::HitTest(/*[in]*/ short X, /*[in]*/ short Y, /*[out, retval]*/ VARIANT_BOOL *retVal)
{
	if (retVal == NULL)
		return E_POINTER;

	*retVal = false;

	long val = 0;

	IMeter *iMeter;
	get_meter(&iMeter);
	if (iMeter && SUCCEEDED(iMeter->GetAsLong(selector, &val)))
	{
		PointF points[1] = { PointF(X, Y) };
		long max, min, length, thickness;
		get_Max(&max);
		get_Min(&min);
		get_Length(&length);
		get_Thickness(&thickness);
		long size = max - min;
		long offset = val - min;

		REAL el[6];
		CumulativeTransform(size, offset, el);
		Matrix transform(el[0], el[1], el[2], el[3], el[4], el[5]);
		transform.Invert();
		transform.TransformPoints(points, 1);

		RectF bounds(0.0, 0.0, (float)length, (float)thickness);
		*retVal = bounds.Contains(points[0]);
	}

	return S_OK;
}
Esempio n. 13
0
void AttractionAffector::updateParticle(const ParticlePtr& particle, float elapsedTime)
{
    if(!m_active)
        return;

    PointF pPosition = particle->getPosition();
    PointF d = PointF(m_position.x - pPosition.x, pPosition.y - m_position.y);
    if(d.length() == 0)
        return;

    PointF direction = PointF(1, 1);
    if(m_repelish)
        direction = PointF(-1, -1);

    PointF pVelocity = particle->getVelocity() + (d / d.length() * m_acceleration * elapsedTime) * direction;
    particle->setVelocity(pVelocity - pVelocity * m_reduction/100.0 * elapsedTime);
}
Esempio n. 14
0
TerrainRenderer::PointF TerrainRenderer::GetBAround(const MapPoint pt, const unsigned char triangle, const unsigned char dir)
{
    PointI ptNb = GetPointAround(PointI(pt), dir);

    Point<int> offset;
    MapPoint t = ConvertCoords(ptNb, &offset);

    return GetB(t, triangle) + PointF(offset);
}
Esempio n. 15
0
void Laser::createGeometry()
{
    shapePoints_.clear();
    shapePoints_.push_back( PointF(0, 0) );
    shapePoints_.push_back( velocityVec_ * 1.5 );

    lineColor_ = BLUE;
    polygonColor_ = BLUE;
}
Esempio n. 16
0
TerrainRenderer::PointF TerrainRenderer::GetTerrainAround(MapPoint pt, const unsigned dir)
{
    PointI ptNb = GetPointAround(PointI(pt), dir);

    PointI offset;
    MapPoint t = ConvertCoords(ptNb, &offset);

    return GetTerrain(t) + PointF(offset);
}
Esempio n. 17
0
void CRichEditDlg::OnPaint(HDC hPaintDc)
{
	CSysUnit::SetWindowToTransparence(m_hWnd, true);

	CRect WndRect = this->GetClientRect();
	m_BmpDc.Create(WndRect.Width(), WndRect.Height());

	HDC hMemoryDC = m_BmpDc.GetSafeHdc();
	HBITMAP hMemoryBitmap = m_BmpDc.GetBmpHandle();
	if (hMemoryDC != NULL && hMemoryBitmap != NULL)
	{
		Graphics DoGrap(hMemoryDC);

		SolidBrush FillBrush(Color(255, 0, 255, 255));
		DoGrap.FillRectangle(&FillBrush, 0, 0, WndRect.Width(), WndRect.Height());

//////////////////////////////////////////////////////////////////////////

		WndRect = this->GetWindowRect();
		CUiMethod::GetScreenBitmap(hMemoryDC, WndRect);

		// GDI 数据
//		m_GaussB.ImageGaussBlur((BYTE *)m_BmpDc.GetBits(), m_BmpDc.GetDcSize().cx, m_BmpDc.GetDcSize().cy, 6, 30, 6, 6);

		// GDI+ 数据
		Bitmap *ptBmp = Bitmap::FromHBITMAP(hMemoryBitmap, NULL);
		BitmapData LockedBmpData;
		ptBmp->LockBits(Rect(0, 0, m_BmpDc.GetDcSize().cx, m_BmpDc.GetDcSize().cy), ImageLockModeRead | ImageLockModeWrite, PixelFormat32bppARGB, &LockedBmpData);
		m_GaussB.ImageGaussBlur((BYTE *)LockedBmpData.Scan0, m_BmpDc.GetDcSize().cx, m_BmpDc.GetDcSize().cy, 6, 30, 6, 6);
		ptBmp->UnlockBits(&LockedBmpData);
		DoGrap.DrawImage(ptBmp, PointF(0, 0));
		delete ptBmp;

//////////////////////////////////////////////////////////////////////////

		// 开始画图
		m_pUiManager->OnPaint(hMemoryDC, WndRect);

		WndRect = this->GetClientRect();
		DrawFetionBkgndLine(hMemoryDC, WndRect);
		DrawGlassLine(hMemoryDC, m_GlassRect);

		{
			WndRect = this->GetWindowRect();
			POINT ptWinPos = {WndRect.left, WndRect.top};
			POINT ptSrc = {0, 0};
			SIZE sizeWindow = {WndRect.Width(), WndRect.Height()};
			::UpdateLayeredWindow(m_hWnd, hPaintDc, &ptWinPos, &sizeWindow, hMemoryDC, &ptSrc, 0, &m_Blend, ULW_ALPHA);
		}

		{
			//	CSysUnit::SetWindowToTransparence(m_hWnd, false);
			//	::BitBlt(hPaintDc, 0, 0, WndRect.Width(), WndRect.Height(),
			//		hMemoryDC, 0, 0, SRCCOPY);
		}
	}
}
Esempio n. 18
0
void GravityAffector::updateParticle(const ParticlePtr& particle, float elapsedTime)
{
    if(!m_active)
        return;

    PointF velocity = particle->getVelocity();
    velocity += PointF(m_gravity * elapsedTime * cos(m_angle), m_gravity * elapsedTime * sin(m_angle));
    particle->setVelocity(velocity);
}
Esempio n. 19
0
 void Mesh::begin(Mode mode, int n_vertex_est, Normal normal)
 {
   Block new_block;
   new_block.mode = mode;
   new_block.normal = normal;
   new_block.vertex.reserve(n_vertex_est);
   new_block.curr_colour = PointF(0,0,0);
   new_block.p_count = 0;
   m_blocks.push_back(new_block);
 }
Esempio n. 20
0
// ---------------------------------------------------------------------------
void __fastcall TfrmAboutSensors::ReAlignComponents() {
	FOnOneScreen = Width > Height;
	if (FOnOneScreen) {
		btnHide->Visible = false;
		lbMain->Position->Point = PointF(cBorder, cBorder);
		lbMain->Width = Width / 2 - cBorder * 2;
		lInfo->Position->Point = PointF(Width / 2 + cBorder, cBorder);
		lInfo->Width = Width / 2 - cBorder * 2;
	}
	else {
		btnHide->Visible = true;
		lbMain->Position->Point = PointF(cBorder, cBorder);
		lbMain->Width = Width - cBorder * 2;
		lInfo->Position->Point = PointF(Width + cBorder, cBorder);
		lInfo->Width = Width - cBorder * 2;
	}
	lbMain->Height = Height - cBorder * 2;
	lInfo->Height = Height - cBorder * 2;
}
Esempio n. 21
0
void FlyingSaucer::createGeometry()
{

    shapePoints_.push_back( PointF(-0.5*MAX_LENGTH, 0) );
    shapePoints_.push_back( PointF(-0.1*MAX_LENGTH, 0.2*MAX_LENGTH) );
    shapePoints_.push_back( PointF(0.1*MAX_LENGTH, 0.2*MAX_LENGTH) );
    shapePoints_.push_back( PointF(0.5*MAX_LENGTH, 0) );
    shapePoints_.push_back( PointF(0.25*MAX_LENGTH, -0.15*MAX_LENGTH) );
    shapePoints_.push_back( PointF(-0.25*MAX_LENGTH, -0.15*MAX_LENGTH) );
    shapePoints_.push_back( PointF(-0.5*MAX_LENGTH, 0) );

    //shapePoints_.push_back( PointF(-0.5*MAX_LENGTH, 0) );
    shapePoints_.push_back( PointF(0.5*MAX_LENGTH, 0) );
    shapePoints_.push_back( PointF(0.25*MAX_LENGTH, 0.1*MAX_LENGTH) );
    shapePoints_.push_back( PointF(-0.25*MAX_LENGTH, 0.1*MAX_LENGTH) );

    lineColor_ = WHITE;
    polygonColor_ = BLACK;
}
Esempio n. 22
0
void CPropSelUser::drawSkin(void)
{

	if(!imgDialog)
		return;
	CDC *pdc=this->GetWindowDC();
	if(!pdc)return;
	CRect rc;
	this->GetWindowRect(&rc);
	Graphics g(pdc->m_hDC);

	int topHeight=32;//GetSystemMetrics(SM_CYFRAME)+GetSystemMetrics(SM_CYSIZE)+6;
	g.DrawImage(imgDialog,RectF(0.0f,0.0f,10.0f,topHeight),0.0f,0.0f,10.0f,topHeight,UnitPixel);
	g.DrawImage(imgDialog,RectF(10.0f,0.0f,rc.Width()-20,topHeight),9.0f,0.0f,1.0f,topHeight,UnitPixel);
	g.DrawImage(imgDialog,RectF((REAL)rc.Width()-10,0.0f,10.0f,topHeight),imgDialog->GetWidth()-10,0.0f,10.0f,topHeight,UnitPixel);
	m_bkColor=pdc->GetPixel(9,topHeight-1);
	m_txtColor^=m_bkColor;
	int bottomHeight=10;
	g.DrawImage(imgDialog,RectF(0.0f,topHeight,10.0f,rc.Height()-topHeight-bottomHeight),0.0f,topHeight,10.0f,imgDialog->GetHeight()-topHeight-bottomHeight,UnitPixel);
	g.DrawImage(imgDialog,RectF(rc.Width()-10.0f,topHeight,10.0f,rc.Height()-topHeight-bottomHeight),
		imgDialog->GetWidth()-10,topHeight,10.0f,1,UnitPixel);

	g.DrawImage(imgDialog,RectF(0,rc.Height()-bottomHeight,imgDialog->GetWidth()-5,bottomHeight),0,imgDialog->GetHeight()-bottomHeight,10,bottomHeight,UnitPixel);
	g.DrawImage(imgDialog,RectF(10,rc.Height()-bottomHeight,rc.Width()-20,bottomHeight),10,imgDialog->GetHeight()-bottomHeight,1,bottomHeight,UnitPixel);
	g.DrawImage(imgDialog,RectF(rc.Width()-10,rc.Height()-bottomHeight,10,bottomHeight),imgDialog->GetWidth()-10,imgDialog->GetHeight()-bottomHeight,10,bottomHeight,UnitPixel);

	CString s="宋体";

	Font font(s.AllocSysString(),12,0,UnitPixel);
	SolidBrush brush(Color(255,255,255));
	s.Format("请选择道具 [%s] 使用对象,当前游戏中有 %d 个可用用户对象",propItemName,maxUser);
	g.DrawString(s.AllocSysString(),-1,&font,PointF(5,5),0,&brush);
	
	StringFormat sf;
	sf.SetAlignment(StringAlignmentCenter);

	m_bnClose.Invalidate(FALSE);
	brush.SetColor(Color(0,0,0));
	Pen pen(&brush);//20081128
	REAL x,y,w,h; //20081128,计算具体图片的位置
	for(int i=0;i<maxUser;i++)
	{
		x=userRect[i].left+(66-userImg[i]->GetWidth())/2;
		y=userRect[i].top+(105-userImg[i]->GetHeight())/2;
		w=userImg[i]->GetWidth();
		h=userImg[i]->GetHeight();
		g.DrawImage(userImg[i],x,y,w,h);//画头像,替换原来的画头像代码
		//画选择区域边框
		g.DrawRectangle(&pen,userRect[i].left , userRect[i].top , 
			userRect[i].Width() , userRect[i].Height());
		g.DrawString(userName[i].AllocSysString() ,-1 ,&font , 
			RectF(userRect[i].left,userRect[i].bottom+5,userRect[i].Width(),30),&sf,&brush);
	}
	g.ReleaseHDC(pdc->m_hDC);
}
Esempio n. 23
0
void Camera::SetDestPos( PointF destPos )
{
  const PointF cameraPos = destPos - m_viewportSize / 2;
  RectBase<float> camera( cameraPos, m_viewportSize );

  const RectBase<float> bound( ( PointF() ), m_fieldSize );

  clamp( camera, bound );

  m_destPos = camera.getTopLeft();
}
Esempio n. 24
0
//²âÊÔ»­Í¼ÐεĵãÒƶ¯ÊÇ·ñÇ¡µ±
void TestDrawItem::Test_DrawStraightLine()
{
#if TestOnce
	ASSERT(DrawTools::ArcSignLeft == 1);

	RectF rect(10,10,390,360);
	std::list<IDataLine*> lines;
	lines.push_back(new DataStraightLine(PointF(400,10.0000),PointF(370.0000,10.0000)));
	lines.push_back(new DrawArcLine(PointF(370.0000,10.0000),PointF(10.0000,370.0000),360.00000,1));
	lines.push_back(new DataStraightLine(PointF(10.0000,370.0000),PointF(400.0000,370.0000)));
	lines.push_back(new DataStraightLine(PointF(400,370.0000),PointF(400,10.0000)));
	DrawItemShape* shape = new DrawItemShape(rect,lines);

	shape->move(PointF(0,0));
	std::list<PointF> points = shape->getAllPoints();
	ASSERT(points.front().Equals(PointF(400,10)));

	delete shape;
#endif
}
// Renders the given text on screen at the given position.
void Rasterizer::DrawText(float x, float y, const WCHAR* string)
{
	// Create all the objects we need to render the string.
	Gdiplus::FontFamily* fontFamily = new FontFamily(L"Courier New");
	Gdiplus::Font* font = new Font(fontFamily, 13, Gdiplus::FontStyleRegular, Gdiplus::UnitPixel);
	Gdiplus::PointF origin = PointF(x, y);
	Gdiplus::PointF shadowOrigin = PointF(x + 1, y + 1);
	Gdiplus::Brush* brush = new SolidBrush(Gdiplus::Color::White);
	Gdiplus::Brush* shadowBrush = new SolidBrush(Gdiplus::Color::Black);

	// Draw the text to string.
	FinishLockBits();
	_graphics->DrawString(string, -1, font, shadowOrigin, shadowBrush); 
	_graphics->DrawString(string, -1, font, origin, brush); 	
	BeginLockBits();

	// Dispose of all objects we created.
	delete fontFamily;
	delete font;
	delete brush;
	delete shadowBrush;
}
Esempio n. 26
0
void Creature::updateJump()
{
    int t = m_jumpTimer.ticksElapsed();
    double a = -4 * m_jumpHeight / (m_jumpDuration * m_jumpDuration);
    double b = +4 * m_jumpHeight / (m_jumpDuration);

    double height = a*t*t + b*t;
    int roundHeight = stdext::round(height);
    int halfJumpDuration = m_jumpDuration / 2;

    // schedules next update
    if(m_jumpTimer.ticksElapsed() < m_jumpDuration) {
        m_jumpOffset = PointF(height, height);

        int diff = 0;
        if(m_jumpTimer.ticksElapsed() < halfJumpDuration)
            diff = 1;
        else if(m_jumpTimer.ticksElapsed() > halfJumpDuration)
            diff = -1;

        int nextT, i = 1;
        do {
            nextT = stdext::round((-b + std::sqrt(std::max<int>(b*b + 4*a*(roundHeight+diff*i), 0.0)) * diff) / (2*a));
            ++i;

            if(nextT < halfJumpDuration)
                diff = 1;
            else if(nextT > halfJumpDuration)
                diff = -1;
        } while(nextT - m_jumpTimer.ticksElapsed() == 0 && i < 3);

        auto self = static_self_cast<Creature>();
        g_dispatcher.scheduleEvent([self] {
            self->updateJump();
        }, nextT - m_jumpTimer.ticksElapsed());
    }
    else
        m_jumpOffset = PointF(0, 0);
}
Esempio n. 27
0
void Particle::Render() const
{
  if( m_time < m_param.hideDelay )
    return;

  const float relTime = m_time / m_param.lifeTime;
  const float relTimeNoDelay = ( m_time - m_param.hideDelay ) / m_param.lifeTime;  
    
  const float scale = Lerp( m_param.scaleStart, m_param.scaleEnd, relTime );  
  const float alpha = ThreePointStepFactor<float>( m_param.alphaStart, m_param.alphaMiddle, m_param.alphaEnd )( relTimeNoDelay );
  
  Point diff = Round( PointF( m_pTex->GetSize() ) / 2 * scale );
  Rect rect( m_pos.x - diff.x, m_pos.y - diff.y, m_pos.x + diff.x, m_pos.y + diff.y );
  Draw( *m_pTex, rect, m_param.texFrame, Color::make_white_af(alpha) );  
}
Esempio n. 28
0
APlayer::APlayer() :
    _backSprite(0),
    _available(true),
    _expW(0),
    _expH(0),
    _speed(0.0),
    _sprite(0),
    _explosionSprite(0),
    _isDead(false),
    _screenWidth(0),
    _screenHeight(0),
    _origin(PointF(0, -1)),
    _shoot(false)
{
}
Esempio n. 29
0
  Sphere::Sphere()
  {
  
    int m_radius = 1;
    int m_division = 20;
  
    int i,j;
    begin((Mesh::Mode)GL_QUADS);
    for (i = 0; i < m_division; ++i) {
      colour(PointF(1.0, (float)i / m_division, 0.0));
      for (j = 0; j < m_division/2; j++) {
	point(PointF((m_radius * sin(2* M_PI * (float)j /m_division)) 
		     * cos(2 * M_PI * (float)i /m_division),
		     m_radius * cos(2 * M_PI * (float)j /m_division),
		     (m_radius * sin(2 * M_PI * (float)j /m_division)) 
		     * sin(2 * M_PI * (float)i /m_division)));
	point(PointF((m_radius * sin(2* M_PI * (float)j /m_division)) 
		     * cos(2 * M_PI * (float)(i+1) /m_division),
		     m_radius * cos(2 * M_PI * (float)j /m_division),
		     (m_radius * sin(2 * M_PI * (float)j /m_division)) 
		     * sin(2 * M_PI * (float)(i+1) /m_division)));
	point(PointF((m_radius * sin(2* M_PI * (float)(j+1) /m_division)) 
		     * cos(2 * M_PI * (float)(i+1) /m_division),
		     m_radius * cos(2 * M_PI * (float)(j+1) /m_division),
		     (m_radius * sin(2 * M_PI * (float)(j+1) /m_division)) 
		     * sin(2 * M_PI * (float)(i+1) /m_division)));
	point(PointF((m_radius * sin(2* M_PI * (float)(j+1) /m_division)) 
		     * cos(2 * M_PI * (float)i /m_division),
		     m_radius * cos(2 * M_PI * (float)(j+1) /m_division),
		     (m_radius * sin(2 * M_PI * (float)(j+1) /m_division)) 
		     * sin(2 * M_PI * (float)i /m_division)));
      }
    }
    end();

    }
void PositionAnimator::beforeDraw(gfx::Engine& painter )
{
	if( enabled() && parent() && isFlag( isActive ) )
	{
    if( fabs(_d->currentPos.x() - _d->stopPos.x() ) > 0.5f 
        || fabs( _d->currentPos.y() - _d->stopPos.y() ) > 0.5f )
		{
			if( _d->stopPos.x() == ANIMATOR_UNUSE_VALUE )
				_d->stopPos.setX( int(_d->currentPos.x() ) );
			if( _d->stopPos.y() == ANIMATOR_UNUSE_VALUE )
				_d->stopPos.setY( int(_d->currentPos.y() ) );

      float fps = 1000.f / float( DateTime::elapsedTime() - _d->lastTimeUpdate + 1 );
      _d->lastTimeUpdate = DateTime::elapsedTime();
			float step = _d->stopPos.getDistanceFrom( _d->startPos ) / float( fps * ( _d->time / 1000.f ) );
			float offsetX = _d->stopPos.x() - _d->currentPos.x();
			float signX = offsetX < 0 ? -1.f : 1.f;
			float offsetY = _d->stopPos.y() - _d->currentPos.y();
			float signY = offsetY < 0 ? -1.f : 1.f;

      if( _d->speed.x() != 0 || _d->speed.y() != 0 )
      {
        offsetX = _d->speed.x();
        offsetY = _d->speed.y();
      }

      _d->currentPos += PointF( signX * std::min<float>( step, fabs( offsetX ) ),
                                signY * std::min<float>( step, fabs( offsetY ) ) );

			parent()->setPosition( _d->currentPos.toPoint() );
		}
		else
		{
			resetFlag( isActive );

			if( isFlag( debug ) )
			{
				parent()->setPosition( _d->startPos );
        return;
			}

			parent()->setVisible( isFlag( showParent ) );
      _afterFinished();
		}
	}

  Widget::beforeDraw( painter );
}