void GLC_Mesh::copyBulkData(GLC_Mesh* pLodMesh, const QHash<GLuint, GLuint>& tagetToSourceIndexMap, int maxIndex)
{
	GLfloatVector tempFloatVector;
	int stride= 3;
	// Extract position bulk data
	Q_ASSERT(!m_MeshData.positionVectorHandle()->isEmpty());
	tempFloatVector.resize(stride * (maxIndex + 1));
	for (int i= 0; i < maxIndex + 1; ++i)
	{
		GLfloat* pTarget= &(tempFloatVector.data()[i * stride]);
		GLfloat* pSource= &(m_MeshData.positionVectorHandle()->data()[tagetToSourceIndexMap.value(i) * stride]);

		memcpy(pTarget, pSource, sizeof(GLfloat) * stride);
	}
	pLodMesh->addVertice(tempFloatVector);
	tempFloatVector.clear();

	// Extract normal bulk data
	Q_ASSERT(!m_MeshData.normalVectorHandle()->isEmpty());
	tempFloatVector.resize(stride * (maxIndex + 1));
	for (int i= 0; i < maxIndex + 1; ++i)
	{
		GLfloat* pTarget= &(tempFloatVector.data()[i * stride]);
		GLfloat* pSource= &(m_MeshData.normalVectorHandle()->data()[tagetToSourceIndexMap.value(i) * stride]);

		memcpy(pTarget, pSource, sizeof(GLfloat) * stride);
	}
	pLodMesh->addNormals(tempFloatVector);
	tempFloatVector.clear();

	if (!m_MeshData.texelVectorHandle()->isEmpty())
	{
		// Extract texel bulk data
		stride= 2;
		tempFloatVector.resize(stride * (maxIndex + 1));

		for (int i= 0; i < maxIndex + 1; ++i)
		{
			GLfloat* pTarget= &(tempFloatVector.data()[i * stride]);
			GLfloat* pSource= &(m_MeshData.texelVectorHandle()->data()[tagetToSourceIndexMap.value(i) * stride]);

			memcpy(pTarget, pSource, sizeof(GLfloat) * stride);
		}
		pLodMesh->addTexels(tempFloatVector);
		tempFloatVector.clear();
	}
}
void GLC_RepFlyMover::createRepresentation()
{
	// HUD creation
	GLC_Circle* pCircle= new GLC_Circle(m_Radius);
	pCircle->setWireColor(GLC_RepMover::m_MainColor);
	pCircle->setLineWidth(GLC_RepMover::m_Thickness);
	m_CenterCircle.addGeometry(pCircle);

	GLC_Polylines* pPolylines= new GLC_Polylines();
	GLfloatVector  points;
	const double hudx= m_HudOffset.getX();
	const double hudy= m_HudOffset.getY();
	points << -hudx << -hudy << 0.0;
	points << -hudx << hudy << 0.0;
	pPolylines->addPolyline(points);
	points.clear();
	points << hudx << -hudy << 0.0;
	points << hudx << hudy << 0.0;
	pPolylines->addPolyline(points);
	pPolylines->setWireColor(GLC_RepMover::m_MainColor);
	pPolylines->setLineWidth(GLC_RepMover::m_Thickness);
	m_Hud.addGeometry(pPolylines);

	// Plane creation
	pPolylines= new GLC_Polylines();
	points.clear();
	const double l1= m_Radius * 1.5;
	points << (-m_Radius - l1) << -m_Radius << 0.0;
	points << -m_Radius << -m_Radius << 0.0;
	points << 0.0 << 0.0 << 0.0;
	points << m_Radius << -m_Radius << 0.0;
	points << (m_Radius + l1) << -m_Radius << 0.0;
	pPolylines->addPolyline(points);
	pPolylines->setWireColor(GLC_RepMover::m_MainColor);
	pPolylines->setLineWidth(GLC_RepMover::m_Thickness);
	m_Plane.addGeometry(pPolylines);
}
Exemple #3
0
void GLC_Arrow::createWire()
{
	Q_ASSERT(m_WireData.isEmpty());
	GLfloatVector floatVector;
	floatVector.append(static_cast<float>(m_StartPoint.x()));
	floatVector.append(static_cast<float>(m_StartPoint.y()));
	floatVector.append(static_cast<float>(m_StartPoint.z()));
	floatVector.append(static_cast<float>(m_EndPoint.x()));
	floatVector.append(static_cast<float>(m_EndPoint.y()));
	floatVector.append(static_cast<float>(m_EndPoint.z()));

	GLC_Geometry::addVerticeGroup(floatVector);

	// Arrow Head
	GLC_Point3d headPoint1(-m_HeadLenght, m_HeadLenght * tan(m_HeadAngle / 2.0), 0.0);
	GLC_Point3d headPoint2(headPoint1.x(), -(headPoint1.y()), headPoint1.z());

	// Arrow frame
	GLC_Vector3d xArrow= (m_EndPoint - m_StartPoint).normalize();
	GLC_Vector3d yArrow= ((-m_ViewDir) ^ xArrow).normalize();
	GLC_Vector3d zArrow= (xArrow ^ yArrow).normalize();

	GLC_Matrix4x4 headMatrix;
	headMatrix.setColumn(0, xArrow);
	headMatrix.setColumn(1, yArrow);
	headMatrix.setColumn(2, zArrow);
	GLC_Matrix4x4 translate(m_EndPoint);
	headPoint1= translate * headMatrix * headPoint1;
	headPoint2= translate * headMatrix * headPoint2;

	// add head data
	floatVector.clear();
	floatVector.append(static_cast<float>(headPoint1.x()));
	floatVector.append(static_cast<float>(headPoint1.y()));
	floatVector.append(static_cast<float>(headPoint1.z()));

	floatVector.append(static_cast<float>(m_EndPoint.x()));
	floatVector.append(static_cast<float>(m_EndPoint.y()));
	floatVector.append(static_cast<float>(m_EndPoint.z()));

	floatVector.append(static_cast<float>(headPoint2.x()));
	floatVector.append(static_cast<float>(headPoint2.y()));
	floatVector.append(static_cast<float>(headPoint2.z()));

	GLC_Geometry::addVerticeGroup(floatVector);

}
// Create the wire of the mesh
void GLC_Box::createWire()
{
	Q_ASSERT(m_WireData.isEmpty());

	const GLfloat lgX= static_cast<const GLfloat>(m_dLgX / 2.0);
	const GLfloat lgY= static_cast<const GLfloat>(m_dLgY / 2.0);
	const GLfloat lgZ= static_cast<const GLfloat>(m_dLgZ / 2.0);

	// Float vector
	GLfloatVector floatVector;
	floatVector << lgX << lgY << lgZ;
	floatVector << lgX << lgY << -lgZ;
	floatVector << -lgX << lgY << -lgZ;
	floatVector << -lgX << lgY << lgZ;
	floatVector << lgX << lgY << lgZ;
	GLC_Geometry::addVerticeGroup(floatVector);
	floatVector.clear();

	floatVector << lgX << -lgY << lgZ;
	floatVector << lgX << -lgY << -lgZ;
	floatVector << -lgX << -lgY << -lgZ;
	floatVector << -lgX << -lgY << lgZ;
	floatVector << lgX << -lgY << lgZ;
	GLC_Geometry::addVerticeGroup(floatVector);
	floatVector.clear();

	floatVector << lgX << lgY << lgZ;
	floatVector << lgX << -lgY << lgZ;
	GLC_Geometry::addVerticeGroup(floatVector);
	floatVector.clear();

	floatVector << lgX << lgY << -lgZ;
	floatVector << lgX << -lgY << -lgZ;
	GLC_Geometry::addVerticeGroup(floatVector);
	floatVector.clear();

	floatVector << -lgX << lgY << -lgZ;
	floatVector << -lgX << -lgY << -lgZ;
	GLC_Geometry::addVerticeGroup(floatVector);
	floatVector.clear();

	floatVector << -lgX << lgY << lgZ;
	floatVector << -lgX << -lgY << lgZ;
	GLC_Geometry::addVerticeGroup(floatVector);
	floatVector.clear();
}