Exemplo n.º 1
0
void ccHObject::drawNameIn3D(CC_DRAW_CONTEXT& context)
{
	if (!context.display)
		return;

	//we display it in the 2D layer in fact!
	ccBBox bBox = getOwnBB();
	if (!bBox.isValid())
		return;
	
	ccGLMatrix trans;
	getAbsoluteGLTransformation(trans);

	ccGLCameraParameters camera;
	context.display->getGLCameraParameters(camera);

	CCVector3 C = bBox.getCenter();
	CCVector3d Q2D;
	camera.project(C, Q2D);

	QFont font = context.display->getTextDisplayFont(); //takes rendering zoom into account!
	context.display->displayText(	getName(),
									static_cast<int>(Q2D.x),
									static_cast<int>(Q2D.y),
									ccGenericGLDisplay::ALIGN_HMIDDLE | ccGenericGLDisplay::ALIGN_VMIDDLE,
									0.75f,
									0,
									&font);
}
Exemplo n.º 2
0
ccBBox ccHObject::getDisplayBB_recursive(bool relative, const ccGenericGLDisplay* display/*=0*/)
{
	ccBBox box;

	if (!display || display == m_currentDisplay)
		box = getOwnBB(true);

	for (Container::iterator it = m_children.begin(); it != m_children.end(); ++it)
	{
		if ((*it)->isEnabled())
		{
			ccBBox childBox = (*it)->getDisplayBB_recursive(true, display);
			if ((*it)->isGLTransEnabled())
			{
				childBox = childBox * (*it)->getGLTransformation();
			}
			box += childBox;
		}
	}

	if (!relative && box.isValid())
	{
		//get absolute bounding-box?
		ccGLMatrix trans;
		getAbsoluteGLTransformation(trans);
		box = box * trans;
	}

	return box;
}
Exemplo n.º 3
0
//====================================================drawNameIn3D======================================//
void ccHObject::drawNameIn3D(CC_DRAW_CONTEXT& context)
{
	//绘制窗口
	if (!context._win)return;

	//we display it in the 2D layer in fact!
	ccBBox bBox = getOwnBB();
	if (bBox.isValid()){

		ccGLMatrix trans;
		getAbsoluteGLTransformation(trans); //得到由祖先到当前物体的变换矩阵

		const double* MM = context._win->getModelViewMatd(); //viewMat   //模型视图矩阵
		const double* MP = context._win->getProjectionMatd(); //projMat  //投影矩阵
		int VP[4];
		context._win->getViewportArray(VP); //视口参数

		GLdouble xp,yp,zp;
		CCVector3 C = bBox.getCenter(); //BB的中心为之
		trans.apply(C); //实际的位置和显示的位置不同,将变换矩阵作用到中心位置上
		gluProject(C.x,C.y,C.z,MM,MP,VP,&xp,&yp,&zp); //根据视图矩阵,投影矩阵和视口参数对BB中心点进行投影

		QFont font = context._win->getTextDisplayFont(); //takes rendering zoom into account! //获取字体

		//在2D屏幕上显示文本
		context._win->displayText(	getName(),
									static_cast<int>(xp),
									static_cast<int>(yp),
									ccGenericGLDisplay::ALIGN_HMIDDLE | ccGenericGLDisplay::ALIGN_VMIDDLE,
									0.75f,
									0,
									&font);
	}
}
Exemplo n.º 4
0
bool ccShiftedObject::getGlobalBB(CCVector3d& minCorner, CCVector3d& maxCorner)
{
	ccBBox box = getOwnBB(false);
	minCorner = toGlobal3d(box.minCorner());
	maxCorner = toGlobal3d(box.maxCorner());
	return box.isValid();
}
Exemplo n.º 5
0
ccBBox ccHObject::getBB_recursive(bool withGLFeatures/*=false*/, bool onlyEnabledChildren/*=true*/)
{
	ccBBox box = getOwnBB(withGLFeatures);

	for (Container::iterator it = m_children.begin(); it != m_children.end(); ++it){
		if (!onlyEnabledChildren || (*it)->isEnabled())
			box += (*it)->getBB_recursive(withGLFeatures,onlyEnabledChildren);
	}

	return box;
}