Ejemplo n.º 1
0
void mouseButtonEventHandle(int iMouseID,int iMouseState) {
	if (iMouseID == GLFW_MOUSE_BUTTON_LEFT) {
        CCEGLView* pEGLView = CCEGLView::sharedOpenGLView();
		//get current mouse pos
		int x,y;
		glfwGetMousePos(&x, &y);
		DPoint oPoint((float)x,(float)y);
		/*
		if (!CCRect::CCRectContainsPoint(s_pMainWindow->m_rcViewPort,oPoint))
		{
			CCLOG("not in the viewport");
			return;
		}
		*/
         oPoint.x /= pEGLView->m_fFrameZoomFactor;
         oPoint.y /= pEGLView->m_fFrameZoomFactor;
		int id = 0;
		if (iMouseState == GLFW_PRESS) {
			pEGLView->handleTouchesBegin(1, &id, &oPoint.x, &oPoint.y);

		} else if (iMouseState == GLFW_RELEASE) {
			pEGLView->handleTouchesEnd(1, &id, &oPoint.x, &oPoint.y);
		}
	}
}
Ejemplo n.º 2
0
void mouseButtonEventHandle(int iMouseID,int iMouseState) {
	if (iMouseID == GLFW_MOUSE_BUTTON_LEFT) {
		//get current mouse pos
		int x,y;
		glfwGetMousePos(&x, &y);
		CCPoint oPoint((float)x,(float)y);

		if (!CCRect::CCRectContainsPoint(s_pMainWindow->m_rcViewPort,oPoint)) {
			CCLOG("not in the viewport");
			return;
		}

		s_pMainWindow->m_pTouch->SetTouchInfo((float)(oPoint.x - s_pMainWindow->m_rcViewPort.origin.x) / s_pMainWindow->m_fScreenScaleFactor,
				(float)(oPoint.y - s_pMainWindow->m_rcViewPort.origin.y) / s_pMainWindow->m_fScreenScaleFactor);
		s_pMainWindow->m_pSet->addObject(s_pMainWindow->m_pTouch);
		s_pMainWindow->m_mousePoint = oPoint;

		if (iMouseState == GLFW_PRESS) {
			s_pMainWindow->m_pDelegate->touchesBegan(s_pMainWindow->m_pSet,NULL);

		} else if (iMouseState == GLFW_RELEASE) {
			s_pMainWindow->m_pDelegate->touchesEnded(s_pMainWindow->m_pSet,NULL);
		}
	}
}
Ejemplo n.º 3
0
void					
BF_GUI_TopVMenu::DrawItem(BView *po_Render,int32 i_Index,bool b_ReqDrawBack)
{
	BF_GUI_DlgView_VMenu::DrawItem(po_Render,i_Index,b_ReqDrawBack);
	////
	BF_GUI_TopMenu_VItem *po;
	po = (BF_GUI_TopMenu_VItem*)ploMenu->ItemAt(i_Index);
	ASSERT(po);

	if(po->sTitle!="" && po->sKeyLabel!=""){
		BPoint 	oPoint(0,0);		
		BRect 	oRect(po_Render->Bounds());
		oPoint.y += ((float)(i_Index-iFirstIndex)) * Height();		
		oPoint.x = oRect.Width()-po->fKeyWidth;
		oPoint.y += poFont->fAscent;
		po_Render->DrawString(po->sKeyLabel.String(),oPoint);	
	}
}
Ejemplo n.º 4
0
void SketchUpModel::PopulateObject(Scene & Scene)
{
	float * pEntireVertexData = new float[3 * 3 * m_TriangleCount];
	float * pEntireNormalData = new float[3 * 3 * m_TriangleCount];
	uint8 * pEntireColorData = new uint8[3 * 3 * m_TriangleCount];
	float * pEntireLineVertexData = new float[3 * 3 * m_LineCount];
	size_t nTriangleNumber = 0;
	size_t nLineNumber = 0;

	FCDSceneNode * pNode = m_pDocument->GetVisualSceneRoot();

	size_t nMeshCount = m_pDocument->GetGeometryLibrary()->GetEntityCount();
	for (size_t nMesh = 0; nMesh < nMeshCount; ++nMesh)
	{
		FCDGeometryMesh * pMesh = m_pDocument->GetGeometryLibrary()->GetEntity(nMesh)->GetMesh();

		size_t nPolygonsCount = pMesh->GetPolygonsCount();
		for (size_t nPolygon = 0; nPolygon < nPolygonsCount; ++nPolygon)
		{
			if (pMesh->GetPolygons(nPolygon)->IsTriangles())
			{
				size_t nTriangleCount = pMesh->GetPolygons(nPolygon)->GetFaceCount();
				//float * pVertexData = pMesh->GetVertexSource(0)->GetData();
				float * pVertexData = pMesh->GetPolygons(nPolygon)->GetInput(0)->GetSource()->GetData();
				//float * pNormalData = pMesh->GetSource(1)->GetData();
				float * pNormalData = pMesh->GetPolygons(nPolygon)->GetInput(1)->GetSource()->GetData();
				uint32 * pVertexIndicies = pMesh->GetPolygons(nPolygon)->GetInput(0)->GetIndices();
				uint32 * pNormalIndicies = pMesh->GetPolygons(nPolygon)->GetInput(1)->GetIndices();
				//size_t d = pMesh->GetPolygons(nPolygon)->GetInputCount();
				//printf("d = %d\n", d);

				// Material info
				FCDEffectStandard * effect = nullptr;
				for (size_t nGeometryInstance = 0; nGeometryInstance < m_pDocument->GetVisualSceneLibrary()->GetEntity(0)->GetChild(0)->GetInstanceCount(); ++nGeometryInstance) {
					if (pMesh->GetDaeId() == m_pDocument->GetVisualSceneLibrary()->GetEntity(0)->GetChild(0)->GetInstance(nGeometryInstance)->GetEntity()->GetDaeId()
						&& FCDEntityInstance::Type::GEOMETRY == m_pDocument->GetVisualSceneLibrary()->GetEntity(0)->GetChild(0)->GetInstance(nGeometryInstance)->GetType()
						&& 1 <= reinterpret_cast<FCDGeometryInstance *>(m_pDocument->GetVisualSceneLibrary()->GetEntity(0)->GetChild(0)->GetInstance(nGeometryInstance))->GetMaterialInstanceCount())
					{
						effect = dynamic_cast<FCDEffectStandard *>(reinterpret_cast<FCDGeometryInstance *>(m_pDocument->GetVisualSceneLibrary()->GetEntity(0)->GetChild(0)->GetInstance(nGeometryInstance))->GetMaterialInstance(0)->GetMaterial()->GetEffect()->GetProfile(0));
						break;
					}
				}
				//if (nullptr == effect) printf("no effect: mesh %d, poly %d\n", nMesh, nPolygon);
				if (nullptr == effect) effect = dynamic_cast<FCDEffectStandard *>(m_pDocument->GetMaterialLibrary()->GetEntity(0)->GetEffect()->GetProfile(0));

				//if (pMesh->GetSourceCount() != 3 || 1 != pMesh->GetVertexSourceCount())
				//	printf("wth %d source, %d vertex source\n", pMesh->GetSourceCount(), pMesh->GetVertexSourceCount());

				/*size_t x = 0;
				FCDEntityInstance * inst = nullptr;
				if (pNode->GetChild(nMesh)->GetChildrenCount() == 0)
					inst = pNode->GetChild(nMesh)->GetInstance(0);
				else
					inst = pNode->GetChild(nMesh)->GetChild(0)->GetInstance(0);
				if (nMesh < 50) {
					//printf("%d\n", x);
					//printf("%s\n", inst->GetEntityReference()->GetObjectType().GetTypeName());
					printf("%d: %s\n", nMesh, !pNode->GetChild(nMesh)->GetChildrenCount() ? pNode->GetChild(nMesh)->GetDaeId().c_str() : pNode->GetChild(nMesh)->GetChild(0)->GetDaeId().c_str());
					printf("    %s\n", pMesh->GetPolygons(nPolygon)->GetMaterialSemantic().c_str());
					
					for (size_t Material = 0; Material < m_pDocument->GetMaterialLibrary()->GetEntityCount(); ++Material)
					{
						if (m_pDocument->GetMaterialLibrary()->GetEntity(Material)->GetDaeId() == pMesh->GetPolygons(nPolygon)->GetMaterialSemantic())
						{
							FCDEffectStandard * standardProfile = dynamic_cast<FCDEffectStandard *>(m_pDocument->GetMaterialLibrary()->GetEntity(Material)->GetEffect()->GetProfile(0));
							printf("         DiffuseColor().x = %f\n", standardProfile->GetDiffuseColor().x);
						}
					}
				}*/
				//printf("GetEffectParameterCount %d\n", m_pDocument->GetEffectLibrary()->GetEntity(400)->GetEffectParameterCount());

				/*Wm5::Matrix4f oMatrix(pNode->GetChild(nMesh)->CalculateWorldTransform().m[0][0], pNode->GetChild(nMesh)->CalculateWorldTransform().m[0][1], pNode->GetChild(nMesh)->CalculateWorldTransform().m[0][2], pNode->GetChild(nMesh)->CalculateWorldTransform().m[0][3],
									  pNode->GetChild(nMesh)->CalculateWorldTransform().m[1][0], pNode->GetChild(nMesh)->CalculateWorldTransform().m[1][1], pNode->GetChild(nMesh)->CalculateWorldTransform().m[1][2], pNode->GetChild(nMesh)->CalculateWorldTransform().m[1][3],
									  pNode->GetChild(nMesh)->CalculateWorldTransform().m[2][0], pNode->GetChild(nMesh)->CalculateWorldTransform().m[2][1], pNode->GetChild(nMesh)->CalculateWorldTransform().m[2][2], pNode->GetChild(nMesh)->CalculateWorldTransform().m[2][3],
									  pNode->GetChild(nMesh)->CalculateWorldTransform().m[3][0], pNode->GetChild(nMesh)->CalculateWorldTransform().m[3][1], pNode->GetChild(nMesh)->CalculateWorldTransform().m[3][2], pNode->GetChild(nMesh)->CalculateWorldTransform().m[3][3]);
				if (pNode->GetChild(nMesh)->GetChildrenCount() > 0) {
					Wm5::Matrix4f oMatrix1(pNode->GetChild(nMesh)->GetChild(0)->CalculateLocalTransform().m[0][0], pNode->GetChild(nMesh)->GetChild(0)->CalculateLocalTransform().m[0][1], pNode->GetChild(nMesh)->GetChild(0)->CalculateLocalTransform().m[0][2], pNode->GetChild(nMesh)->GetChild(0)->CalculateLocalTransform().m[0][3],
										   pNode->GetChild(nMesh)->GetChild(0)->CalculateLocalTransform().m[1][0], pNode->GetChild(nMesh)->GetChild(0)->CalculateLocalTransform().m[1][1], pNode->GetChild(nMesh)->GetChild(0)->CalculateLocalTransform().m[1][2], pNode->GetChild(nMesh)->GetChild(0)->CalculateLocalTransform().m[1][3],
										   pNode->GetChild(nMesh)->GetChild(0)->CalculateLocalTransform().m[2][0], pNode->GetChild(nMesh)->GetChild(0)->CalculateLocalTransform().m[2][1], pNode->GetChild(nMesh)->GetChild(0)->CalculateLocalTransform().m[2][2], pNode->GetChild(nMesh)->GetChild(0)->CalculateLocalTransform().m[2][3],
										   pNode->GetChild(nMesh)->GetChild(0)->CalculateLocalTransform().m[3][0], pNode->GetChild(nMesh)->GetChild(0)->CalculateLocalTransform().m[3][1], pNode->GetChild(nMesh)->GetChild(0)->CalculateLocalTransform().m[3][2], pNode->GetChild(nMesh)->GetChild(0)->CalculateLocalTransform().m[3][3]);
					oMatrix = oMatrix1 * oMatrix;
				}*/
				Wm5::Matrix4f oMatrix(Wm5::Matrix4f::IDENTITY);
				if (fstring::npos != m_pDocument->GetAsset()->GetContributor(0)->GetAuthoringTool().find("Google SketchUp 8"))
					for (uint8 i = 0; i < 3; ++i)
						oMatrix[i][i] *= 0.4f;

				for (size_t nTriangle = 0; nTriangle < nTriangleCount; ++nTriangle)
				{
					// Check for and skip degenerate (i.e. zero area) triangles
					{
						Wm5::Triangle3f Triangle(Wm5::Vector3f(pVertexData[3 * pVertexIndicies[3 * nTriangle + 0] + 0], pVertexData[3 * pVertexIndicies[3 * nTriangle + 0] + 1], pVertexData[3 * pVertexIndicies[3 * nTriangle + 0] + 2]),
												 Wm5::Vector3f(pVertexData[3 * pVertexIndicies[3 * nTriangle + 1] + 0], pVertexData[3 * pVertexIndicies[3 * nTriangle + 1] + 1], pVertexData[3 * pVertexIndicies[3 * nTriangle + 1] + 2]),
												 Wm5::Vector3f(pVertexData[3 * pVertexIndicies[3 * nTriangle + 2] + 0], pVertexData[3 * pVertexIndicies[3 * nTriangle + 2] + 1], pVertexData[3 * pVertexIndicies[3 * nTriangle + 2] + 2]));
						bool DegenerateTriangle = IsTriangleDegenerate(Triangle);

						if (DegenerateTriangle) 
							continue;
					}

#define PREAPPLYMATRIX
					pEntireColorData[3 * 3 * nTriangleNumber + 0] = static_cast<uint8>(255.999 * effect->GetDiffuseColor().x);// + effect->GetAmbientColor().x - rand()%1000 * 0.0001f;//rand()%1000 * 0.001f;
					pEntireColorData[3 * 3 * nTriangleNumber + 1] = static_cast<uint8>(255.999 * effect->GetDiffuseColor().y);// + effect->GetAmbientColor().y - rand()%1000 * 0.0001f;//rand()%1000 * 0.001f;
					pEntireColorData[3 * 3 * nTriangleNumber + 2] = static_cast<uint8>(255.999 * effect->GetDiffuseColor().z);// + effect->GetAmbientColor().z - rand()%1000 * 0.0001f;//rand()%1000 * 0.001f;
#ifdef PREAPPLYMATRIX
					{Wm5::Vector4f oPoint(pNormalData[3 * pNormalIndicies[3 * nTriangle + 0] + 0], pNormalData[3 * pNormalIndicies[3 * nTriangle + 0] + 1], pNormalData[3 * pNormalIndicies[3 * nTriangle + 0] + 2], 0); oPoint = oPoint * oMatrix; oPoint.Normalize();
					pEntireNormalData[3 * 3 * nTriangleNumber + 0] = oPoint.X();
					pEntireNormalData[3 * 3 * nTriangleNumber + 1] = oPoint.Y();
					pEntireNormalData[3 * 3 * nTriangleNumber + 2] = oPoint.Z();}
					Wm5::Vector4f oPoint1(pVertexData[3 * pVertexIndicies[3 * nTriangle + 0] + 0], pVertexData[3 * pVertexIndicies[3 * nTriangle + 0] + 1], pVertexData[3 * pVertexIndicies[3 * nTriangle + 0] + 2], 1); oPoint1 = oPoint1 * oMatrix;
					pEntireVertexData[3 * 3 * nTriangleNumber + 0] = oPoint1.X();
					pEntireVertexData[3 * 3 * nTriangleNumber + 1] = oPoint1.Y();
					pEntireVertexData[3 * 3 * nTriangleNumber + 2] = oPoint1.Z();
#else
					pEntireNormalData[3 * 3 * nTriangleNumber + 0] = pNormalData[3 * pNormalIndicies[3 * nTriangle + 0] + 0];
					pEntireNormalData[3 * 3 * nTriangleNumber + 1] = pNormalData[3 * pNormalIndicies[3 * nTriangle + 0] + 1];
					pEntireNormalData[3 * 3 * nTriangleNumber + 2] = pNormalData[3 * pNormalIndicies[3 * nTriangle + 0] + 2];
					pEntireVertexData[3 * 3 * nTriangleNumber + 0] = pVertexData[3 * pVertexIndicies[3 * nTriangle + 0] + 0];
					pEntireVertexData[3 * 3 * nTriangleNumber + 1] = pVertexData[3 * pVertexIndicies[3 * nTriangle + 0] + 1];
					pEntireVertexData[3 * 3 * nTriangleNumber + 2] = pVertexData[3 * pVertexIndicies[3 * nTriangle + 0] + 2];
#endif
					pEntireColorData[3 * 3 * nTriangleNumber + 3] = static_cast<uint8>(255.999 * effect->GetDiffuseColor().x);// + effect->GetAmbientColor().x - rand()%1000 * 0.0001f;//rand()%1000 * 0.001f;
					pEntireColorData[3 * 3 * nTriangleNumber + 4] = static_cast<uint8>(255.999 * effect->GetDiffuseColor().y);// + effect->GetAmbientColor().y - rand()%1000 * 0.0001f;//rand()%1000 * 0.001f;
					pEntireColorData[3 * 3 * nTriangleNumber + 5] = static_cast<uint8>(255.999 * effect->GetDiffuseColor().z);// + effect->GetAmbientColor().z - rand()%1000 * 0.0001f;//rand()%1000 * 0.001f;
#ifdef PREAPPLYMATRIX
					{Wm5::Vector4f oPoint(pNormalData[3 * pNormalIndicies[3 * nTriangle + 1] + 0], pNormalData[3 * pNormalIndicies[3 * nTriangle + 1] + 1], pNormalData[3 * pNormalIndicies[3 * nTriangle + 1] + 2], 0); oPoint = oPoint * oMatrix; oPoint.Normalize();
					pEntireNormalData[3 * 3 * nTriangleNumber + 3] = oPoint.X();
					pEntireNormalData[3 * 3 * nTriangleNumber + 4] = oPoint.Y();
					pEntireNormalData[3 * 3 * nTriangleNumber + 5] = oPoint.Z();}
					Wm5::Vector4f oPoint2(pVertexData[3 * pVertexIndicies[3 * nTriangle + 1] + 0], pVertexData[3 * pVertexIndicies[3 * nTriangle + 1] + 1], pVertexData[3 * pVertexIndicies[3 * nTriangle + 1] + 2], 1); oPoint2 = oPoint2 * oMatrix;
					pEntireVertexData[3 * 3 * nTriangleNumber + 3] = oPoint2.X();
					pEntireVertexData[3 * 3 * nTriangleNumber + 4] = oPoint2.Y();
					pEntireVertexData[3 * 3 * nTriangleNumber + 5] = oPoint2.Z();
#else
					pEntireNormalData[3 * 3 * nTriangleNumber + 3] = pNormalData[3 * pNormalIndicies[3 * nTriangle + 1] + 0];
					pEntireNormalData[3 * 3 * nTriangleNumber + 4] = pNormalData[3 * pNormalIndicies[3 * nTriangle + 1] + 1];
					pEntireNormalData[3 * 3 * nTriangleNumber + 5] = pNormalData[3 * pNormalIndicies[3 * nTriangle + 1] + 2];
					pEntireVertexData[3 * 3 * nTriangleNumber + 3] = pVertexData[3 * pVertexIndicies[3 * nTriangle + 1] + 0];
					pEntireVertexData[3 * 3 * nTriangleNumber + 4] = pVertexData[3 * pVertexIndicies[3 * nTriangle + 1] + 1];
					pEntireVertexData[3 * 3 * nTriangleNumber + 5] = pVertexData[3 * pVertexIndicies[3 * nTriangle + 1] + 2];
#endif
					pEntireColorData[3 * 3 * nTriangleNumber + 6] = static_cast<uint8>(255.999 * effect->GetDiffuseColor().x);// + effect->GetAmbientColor().x - rand()%1000 * 0.0001f;//rand()%1000 * 0.001f;
					pEntireColorData[3 * 3 * nTriangleNumber + 7] = static_cast<uint8>(255.999 * effect->GetDiffuseColor().y);// + effect->GetAmbientColor().y - rand()%1000 * 0.0001f;//rand()%1000 * 0.001f;
					pEntireColorData[3 * 3 * nTriangleNumber + 8] = static_cast<uint8>(255.999 * effect->GetDiffuseColor().z);// + effect->GetAmbientColor().z - rand()%1000 * 0.0001f;//rand()%1000 * 0.001f;
#ifdef PREAPPLYMATRIX
					{Wm5::Vector4f oPoint(pNormalData[3 * pNormalIndicies[3 * nTriangle + 2] + 0], pNormalData[3 * pNormalIndicies[3 * nTriangle + 2] + 1], pNormalData[3 * pNormalIndicies[3 * nTriangle + 2] + 2], 0); oPoint = oPoint * oMatrix; oPoint.Normalize();
					pEntireNormalData[3 * 3 * nTriangleNumber + 6] = oPoint.X();
					pEntireNormalData[3 * 3 * nTriangleNumber + 7] = oPoint.Y();
					pEntireNormalData[3 * 3 * nTriangleNumber + 8] = oPoint.Z();}
					Wm5::Vector4f oPoint3(pVertexData[3 * pVertexIndicies[3 * nTriangle + 2] + 0], pVertexData[3 * pVertexIndicies[3 * nTriangle + 2] + 1], pVertexData[3 * pVertexIndicies[3 * nTriangle + 2] + 2], 1); oPoint3 = oPoint3 * oMatrix;
					pEntireVertexData[3 * 3 * nTriangleNumber + 6] = oPoint3.X();
					pEntireVertexData[3 * 3 * nTriangleNumber + 7] = oPoint3.Y();
					pEntireVertexData[3 * 3 * nTriangleNumber + 8] = oPoint3.Z();
#else
					pEntireNormalData[3 * 3 * nTriangleNumber + 6] = pNormalData[3 * pNormalIndicies[3 * nTriangle + 2] + 0];
					pEntireNormalData[3 * 3 * nTriangleNumber + 7] = pNormalData[3 * pNormalIndicies[3 * nTriangle + 2] + 1];
					pEntireNormalData[3 * 3 * nTriangleNumber + 8] = pNormalData[3 * pNormalIndicies[3 * nTriangle + 2] + 2];
					pEntireVertexData[3 * 3 * nTriangleNumber + 6] = pVertexData[3 * pVertexIndicies[3 * nTriangle + 2] + 0];
					pEntireVertexData[3 * 3 * nTriangleNumber + 7] = pVertexData[3 * pVertexIndicies[3 * nTriangle + 2] + 1];
					pEntireVertexData[3 * 3 * nTriangleNumber + 8] = pVertexData[3 * pVertexIndicies[3 * nTriangle + 2] + 2];
#endif

					++nTriangleNumber;
				}
			}
			else if (FCDGeometryPolygons::PrimitiveType::LINES == pMesh->GetPolygons(nPolygon)->GetPrimitiveType())
			{
				size_t nLineCount = pMesh->GetPolygons(nPolygon)->GetInput(0)->GetIndexCount() / 2;
				//float * pLineVertexData = pMesh->GetVertexSource(0)->GetData();
				float * pLineVertexData = pMesh->GetPolygons(nPolygon)->GetInput(0)->GetSource()->GetData();
				uint32 * pLineVertexIndicies = pMesh->GetPolygons(nPolygon)->GetInput(0)->GetIndices();

				Wm5::Matrix4f oMatrix(Wm5::Matrix4f::IDENTITY);
				if (fstring::npos != m_pDocument->GetAsset()->GetContributor(0)->GetAuthoringTool().find("Google SketchUp 8"))
					for (uint8 i = 0; i < 3; ++i)
						oMatrix[i][i] *= 0.4f;

				for (size_t nLine = 0; nLine < nLineCount; ++nLine)
				{
#ifdef PREAPPLYMATRIX
					{Wm5::Vector4f oPoint(pLineVertexData[3 * pLineVertexIndicies[2 * nLine + 0] + 0], pLineVertexData[3 * pLineVertexIndicies[2 * nLine + 0] + 1], pLineVertexData[3 * pLineVertexIndicies[2 * nLine + 0] + 2], 0); oPoint = oPoint * oMatrix;
					pEntireLineVertexData[2 * 3 * nLineNumber + 0] = oPoint.X();
					pEntireLineVertexData[2 * 3 * nLineNumber + 1] = oPoint.Y();
					pEntireLineVertexData[2 * 3 * nLineNumber + 2] = oPoint.Z();}

					{Wm5::Vector4f oPoint(pLineVertexData[3 * pLineVertexIndicies[2 * nLine + 1] + 0], pLineVertexData[3 * pLineVertexIndicies[2 * nLine + 1] + 1], pLineVertexData[3 * pLineVertexIndicies[2 * nLine + 1] + 2], 0); oPoint = oPoint * oMatrix;
					pEntireLineVertexData[2 * 3 * nLineNumber + 3] = oPoint.X();
					pEntireLineVertexData[2 * 3 * nLineNumber + 4] = oPoint.Y();
					pEntireLineVertexData[2 * 3 * nLineNumber + 5] = oPoint.Z();}
#else
					pEntireLineVertexData[2 * 3 * nLineNumber + 0] = pLineVertexData[3 * pLineVertexIndicies[2 * nLine + 0] + 0];
					pEntireLineVertexData[2 * 3 * nLineNumber + 1] = pLineVertexData[3 * pLineVertexIndicies[2 * nLine + 0] + 1];
					pEntireLineVertexData[2 * 3 * nLineNumber + 2] = pLineVertexData[3 * pLineVertexIndicies[2 * nLine + 0] + 2];

					pEntireLineVertexData[2 * 3 * nLineNumber + 3] = pLineVertexData[3 * pLineVertexIndicies[2 * nLine + 1] + 0];
					pEntireLineVertexData[2 * 3 * nLineNumber + 4] = pLineVertexData[3 * pLineVertexIndicies[2 * nLine + 1] + 1];
					pEntireLineVertexData[2 * 3 * nLineNumber + 5] = pLineVertexData[3 * pLineVertexIndicies[2 * nLine + 1] + 2];
#endif

					++nLineNumber;
				}
			}
		}
	}

	// Populate Object
	float * pVertexData, * pNormalData, * pTextureCoordData, * pLineVertexData;
	uint8 * pColorData;
	Scene.PopulateObjectPointers(pVertexData, pNormalData, pColorData, pTextureCoordData, pLineVertexData);
	memcpy(pVertexData, pEntireVertexData, 3 * 3 * m_TriangleCount * sizeof(*pEntireVertexData));
	memcpy(pNormalData, pEntireNormalData, 3 * 3 * m_TriangleCount * sizeof(*pEntireNormalData));
	memcpy(pColorData, pEntireColorData, 3 * 3 * m_TriangleCount * sizeof(*pEntireColorData));
	memset(pTextureCoordData, 0, 2 * 3 * m_TriangleCount * sizeof(*pTextureCoordData));
	memcpy(pLineVertexData, pEntireLineVertexData, 2 * 3 * m_LineCount * sizeof(*pEntireLineVertexData));
	Scene.PopulatedObject(m_TriangleCount, m_LineCount);

	delete[] pEntireVertexData;
	delete[] pEntireNormalData;
	delete[] pEntireColorData;
	delete[] pEntireLineVertexData;
}
Ejemplo n.º 5
0
Point2i C_CoordinateTransform::GetCoordinate( Point2f A_rPoint )
{

	Point2i oPoint((long)A_rPoint.x, (long)A_rPoint.y);
	return p->m_oTransformationMatrix.get_element(oPoint.x, oPoint.y);
}
Ejemplo n.º 6
0
// draw current page
void 
BF_GUI_Text::DrawPage()
{
	BRect	oRect;
	BPoint	oPoint(3,poSysSetup->oFontNode.fHeight);
	int32	iCurLine;
	BString	*psLine;
	char	cBuffer[256];
	
	oRect = Bounds();
	
	SetHighColor(SYS_COLOR(BF_COLOR_NODE));
	SetLowColor(SYS_COLOR(BF_COLOR_BACK));
	for(iCurLine = 0;oPoint.y < oRect.bottom + poSysSetup->oFontNode.fHeight && iCurLine < ploString->CountItems();iCurLine++)
	{
		psLine = (BString *) ploString->ItemAt(iCurLine);

		ToUtf8(psLine->String(),cBuffer);

		BString oCurStr(cBuffer);
		oCurStr.ReplaceAll("\r","\x0");
		oCurStr.ReplaceAll("\n","\x0");
		oCurStr.ReplaceAll("\t","        ");
		if (bDrawSel && iMatchLine == iCurLine)
		{
			BString oBuffer;
			// draw first part of the string
			iStartSel = oCurStr.FindFirst(poMatch->String(),iStartSel);
			iStopSel = poMatch->CountChars();
			oCurStr.MoveInto(oBuffer,0,iStartSel);
			DrawString(oBuffer.String(),oPoint);
			// draw selected part of the string
			SetHighColor(SYS_COLOR(BF_COLOR_CURSOR_BACK));
			float fStartPoint = StringWidth(oBuffer.String());
			float fWidth = StringWidth(poMatch->String());
			BRect oRect(oPoint.x + fStartPoint,oPoint.y - poSysSetup->oFontNode.fHeight,oPoint.x + fStartPoint + fWidth,oPoint.y);
			FillRect(oRect);
			SetHighColor(0,0,0);
			SetLowColor(SYS_COLOR(BF_COLOR_CURSOR_BACK));
			oCurStr.MoveInto(oBuffer,0,iStopSel);
			DrawString(oBuffer.String());
			// draw rest part of the string
			SetHighColor(SYS_COLOR(BF_COLOR_NODE));
			SetLowColor(SYS_COLOR(BF_COLOR_BACK));
			DrawString(oCurStr.String());
		}
		else
		{
			// draw string without selection
			DrawString(oCurStr.String(),oPoint);
		};
		oPoint.y += poSysSetup->oFontNode.fHeight;
	};
//-------------------------------- change display position ----------------------------
/*
	BMessage *poMSG = new BMessage(BF_MSG_VIEWER_MOVE);
	float fPOS = oPoint.y / (poSysSetup->oFontNode.fHeight * ploString->CountItems());
	poMSG->AddFloat("Position",fPOS);
	BMessenger oMessenger(poStatus);
	oMessenger.SendMessage(poMSG);
*/
//------------------------------ TRUE if page is full ---------------------------------
	bFullPage = (oPoint.y < oRect.bottom + poSysSetup->oFontNode.fHeight) ? false : true;
};
void CStdUtilsTestDlg::OnTestMarkup() 
{
	CStdXml oXml, oXml2;
	CStdString strVal;
	int iVal=0;
	long lVal=0;
	float fltVal=0;
	double dblVal=0;
	bool bVal=false;

try
{
	strVal = "This is a string";
	lVal = 55433;
	iVal = 43;
	dblVal = 34.224432;
	fltVal = (float) 34.22;
	bVal = true;

	//Testing the Add functions
	oXml.AddElement("World");
	oXml.AddChildElement("string", strVal);
	oXml.AddChildElement("long", lVal);
	oXml.AddChildElement("int", iVal);
	oXml.AddChildElement("double", dblVal);
	oXml.AddChildElement("float", fltVal);
	oXml.AddChildElement("bool", bVal);

	oXml.AddChildElement("Robots");
	oXml.IntoChildElement("Robots");

	CStdIPoint oPoint(1,2,3), oPoint2;
	CStdFPoint oFPoint;
	Std_SavePoint(oXml, "Point", oPoint);
	Std_LoadPoint(oXml, "Point", oPoint2);
	Std_LoadPoint(oXml, "Point", oFPoint);

	oXml.SetAttrib("DoubleVal", dblVal);
	oXml.AddChildElement("Robot");
	oXml.IntoChildElement("Robot");
	oXml.AddChildElement("bool", bVal);
	oXml.SetChildAttrib("lVal", lVal);
	oXml.AddChildCData("Description", "n<6");
	oXml.OutOfElem();

	oXml.OutOfElem();
	oXml.Save("C:\\Biomechs\\Libraries\\StdUtils\\Test.xml");
	
	// Testing the get functions
//	oXml.Load("C:\\Biomechs\\Darwins Playground\\Projects\\InsectSimulator\\Scripts\\Final_Insect.xml");
/*
	oXml.FindElement("Test");
	strVal = oXml.GetChildString("string");

	iVal = oXml.GetChildInt("int");
	iVal = oXml.GetChildInt("float", -1);
	iVal = oXml.GetChildInt("string", -1);

	lVal = oXml.GetChildLong("long");
	lVal = oXml.GetChildLong("float", -1);
	lVal = oXml.GetChildLong("string", -1);

	fltVal = oXml.GetChildFloat("float");
	fltVal = oXml.GetChildFloat("int");
	fltVal = oXml.GetChildFloat("string", (float) 0.2);

	dblVal = oXml.GetChildDouble("double");
	dblVal = oXml.GetChildDouble("int");
	dblVal = oXml.GetChildDouble("string", 0.3455);

	bVal = oXml.GetChildBool("bool");
	bVal = oXml.GetChildBool("bool2");
	bVal = oXml.GetChildBool("bool3");
	bVal = oXml.GetChildBool("bool4");
	bVal = oXml.GetChildBool("string", false);
	
	//Errors
	//iVal = oXml.GetChildInt("string");
	//iVal = oXml.GetChildInt("float");
	//lVal = oXml.GetChildLong("string");
	//lVal = oXml.GetChildLong("float");
	//fltVal = oXml.GetChildFloat("string");
	//dblVal = oXml.GetChildDouble("string");
	//bVal = oXml.GetChildBool("string");
	*/
}
catch(CStdErrorInfo oError)
{
	AfxMessageBox(oError.m_strError);
}
catch(...)
{
	AfxMessageBox("Unidentified Error");
}
}