Esempio n. 1
0
// virtual
void Transform::DrawGlobalLights(X3DDrawContext* pDC)
{
	D3DXMATRIX transform = GetTransform();
	pDC->m_renderContext->PushModelView(transform * pDC->m_renderContext->modelViewMatrix());

	DrawGlobalLightsChildren(pDC, getChildrenField());

	pDC->m_renderContext->PopMatrix();

#if 0
	pDC->m_pGraphics3D->PushMatrix();

// P' = T * C * R * SR * S * -SR * -C * P

		pDC->m_pGraphics3D->TranslateTransform(m_T->m_value);
		pDC->m_pGraphics3D->TranslateTransform(m_C->m_value);
		pDC->m_pGraphics3D->RotateTransform(gmDegrees(m_R->m_value.m_angle), m_R->m_value.m_axis);
		pDC->m_pGraphics3D->RotateTransform(gmDegrees(m_SR->m_value.m_angle), m_SR->m_value.m_axis);
		pDC->m_pGraphics3D->ScaleTransform(m_S->m_value);
		pDC->m_pGraphics3D->RotateTransform(gmDegrees(m_SR->m_value.m_angle), -m_SR->m_value.m_axis);
		pDC->m_pGraphics3D->TranslateTransform(-m_C->m_value);

	DrawGlobalLightsChildren(pDC, get_children());

	pDC->m_pGraphics3D->PopMatrix();
#endif
}
Esempio n. 2
0
void Anchor::DrawOverlay(X3DDrawContext* pDC)
{
	MFNode* children = static_cast<MFNode*>(getChildrenField());

	int nLight = pDC->m_renderContext->m_nLight;

	for (size_t i = 0; i < getChildrenField()->m_items.GetSize(); ++i)
	{
		X3DNode* node = getChildrenField()->m_items[i];

		if (node)
		{
			RenderImplImpl* render = dynamic_cast<RenderImplImpl*>(node->GetNode());
			if (render)
			{
				render->PreDraw(pDC);
			}
		}
	}

	for (size_t i = 0; i < getChildrenField()->m_items.GetSize(); ++i)
	{
		X3DNode* node = getChildrenField()->m_items[i];

		if (node)
		{
			RenderImplImpl* render = dynamic_cast<RenderImplImpl*>(node->GetNode());
			if (render)
			{
				render->DrawOverlay(pDC);
			}
		}
	}

	for (int i = pDC->m_renderContext->m_nLight; i >= nLight; i--)
	{
	//	pDC->m_pGraphics3D->Disable(GL_LIGHT0+i);
	}
	pDC->m_renderContext->m_nLight = nLight;
}
Esempio n. 3
0
void Transform::DrawOverlay(X3DDrawContext* pDC)
{
	Vec3f S = getScale();

	if (S[0] == 0 && S[1] == 0 && S[2] == 0)
		return;

	D3DXMATRIX transform = GetTransform();
	pDC->m_renderContext->PushModelView(transform * pDC->m_renderContext->modelViewMatrix());

	// TODO: not here
	if (m_selected)
	{
	//	pDC->m_renderContext->PushModelView(pDC->m_renderContext->modelViewMatrix() * MatrixTranslation(getLocation()));

		D3DXMATRIX m = pDC->m_renderContext->modelViewMatrix();
		DrawBoundingBox(pDC, CalculateBoundingBox(*(gm::matrix4f*)&m));

		DrawAxis(pDC);

	//	pDC->m_renderContext->PopMatrix();
	//	pDC->m_renderContext->GetRT()->m_d3d10->m_device->OMSetDepthStencilState(depthStencilState, stencilRef);
	}

	DrawOverlayChildren(pDC, getChildrenField());

	pDC->m_renderContext->PopMatrix();

#if 0
	/*
	SFVec3f*		C = static_cast<SFVec3f*>(m_C);
	SFRotation*	R = static_cast<SFRotation*>(m_R);
	SFVec3f*		S = static_cast<SFVec3f*>(m_S);
	SFVec3f*		SR = static_cast<SFVec3f*>(m_SR);
	SFVec3f*		T = static_cast<SFVec3f*>(m_T);
	MFNode*		children = static_cast<MFNode*>(m_children);
	*/

	pDC->m_pGraphics3D->glPushMatrix();

		pDC->m_pGraphics3D->glTranslate(m_T->m_value);
		pDC->m_pGraphics3D->glTranslate(m_C->m_value);
		pDC->m_pGraphics3D->glRotate(gmDegrees(m_R->m_value.m_angle), m_R->m_value.m_axis);
		pDC->m_pGraphics3D->glRotate(gmDegrees(m_SR->m_value.m_angle), m_SR->m_value.m_axis);
		pDC->m_pGraphics3D->glScale(m_S->m_value);
		pDC->m_pGraphics3D->glRotate(gmDegrees(m_SR->m_value.m_angle), -m_SR->m_value.m_axis);
		pDC->m_pGraphics3D->glTranslate(-m_C->m_value);

		// Draw axes
	{
		//DrawBoundBox();

		pDC->m_pGraphics3D->glPushAttrib(GL_ENABLE_BIT);

		float len = 4;

		pDC->m_pGraphics3D->glDisable(GL_LIGHTING);

		pDC->m_pGraphics3D->glBegin(GL_LINES);

		pDC->m_pGraphics3D->glColorf(1.0, 0, 0);	// red
		pDC->m_pGraphics3D->glVertexf(0, 0, 0);
		pDC->m_pGraphics3D->glVertexf(1*len, 0, 0);

		pDC->m_pGraphics3D->glColorf(0.0, 1.0, 0);	// blue
		pDC->m_pGraphics3D->glVertexf(0, 0, 0);
		pDC->m_pGraphics3D->glVertexf(0, 1*len, 0);

		pDC->m_pGraphics3D->glColorf(0, 0, 1.0);	// green
		pDC->m_pGraphics3D->glVertexf(0, 0, 0);
		pDC->m_pGraphics3D->glVertexf(0, 0, 1*len);

		pDC->m_pGraphics3D->glEnd();

		pDC->m_pGraphics3D->glColorf(1,1,1);	// white
	//	GLUquadricObj* q = gluNewQuadric();
		LDraw::gluSphere(pDC->m_pGraphics3D, 0.1, 8, 8);
	//	gluDeleteQuadric(q);

		pDC->m_pGraphics3D->glPopAttrib();
	}

	int nLight = pDC->m_nLight;

	int i;

	for (i = 0; i < m_children->m_items.GetSize(); i++)
	{
		if (m_children->m_items[i])
		{
			CLRenderImplImpl* render = dynamic_cast<CLRenderImplImpl*>(m_children->m_items[i]->GetNode());
			if (render)
			{
				render->PreDraw(pDC);
			}
		}
	}

	for (i = 0; i < m_children->m_items.GetSize(); i++)
	{
		if (m_children->m_items[i])
		{
			CLRenderImplImpl* render = dynamic_cast<CLRenderImplImpl*>(m_children->m_items[i]->GetNode());
			if (render)
			{
				render->DrawOverlay(pDC);
			}
		}
	}

	for (i = pDC->m_nLight; i >= nLight; i--)
	{
		pDC->m_pGraphics3D->glDisable(GL_LIGHT0+i);
	}
	pDC->m_nLight = nLight;

	pDC->m_pGraphics3D->glPopMatrix();
#endif
}
Esempio n. 4
0
// virtual
void Transform::Draw(X3DDrawContext* pDC)
{
	Vec3f S = getScale();

	if (S[0] == 0 && S[1] == 0 && S[2] == 0)
		return;

	D3DXMATRIX transform = GetTransform();

	pDC->m_renderContext->PushModelView(transform * pDC->m_renderContext->modelViewMatrix());

#if 0	// Had this
	pDC->m_pGraphics3D->PushMatrix();

// P' = T * C * R * SR * S * -SR * -C * P

		pDC->m_pGraphics3D->TranslateTransform(m_T->m_value);
		pDC->m_pGraphics3D->TranslateTransform(m_C->m_value);
		if (m_R->m_value.m_angle) pDC->m_pGraphics3D->RotateTransform(gmDegrees(m_R->m_value.m_angle), m_R->m_value.m_axis);
		if (m_SR->m_value.m_angle) pDC->m_pGraphics3D->RotateTransform(gmDegrees(m_SR->m_value.m_angle), m_SR->m_value.m_axis);
		pDC->m_pGraphics3D->ScaleTransform(m_S->m_value);
		if (m_SR->m_value.m_angle) pDC->m_pGraphics3D->RotateTransform(gmDegrees(m_SR->m_value.m_angle), -m_SR->m_value.m_axis);
		pDC->m_pGraphics3D->TranslateTransform(-m_C->m_value);
#endif
	// Draw axes
#if 0
	if (FALSE)
	{
		pDC->m_pGraphics3D->glPushAttrib(GL_ENABLE_BIT);

		float len = 4;

		pDC->m_pGraphics3D->glDisable(GL_LIGHTING);

		pDC->m_pGraphics3D->glBegin(GL_LINES);

		pDC->m_pGraphics3D->glColor3f(1.0, 0, 0);	// red
		pDC->m_pGraphics3D->glVertex3f(0, 0, 0);
		pDC->m_pGraphics3D->glVertex3f(1*len, 0, 0);

		pDC->m_pGraphics3D->glColor3f(0.0, 1.0, 0);	// blue
		pDC->m_pGraphics3D->glVertex3f(0, 0, 0);
		pDC->m_pGraphics3D->glVertex3f(0, 1*len, 0);

		glColor3f(0, 0, 1.0);	// green
		glVertex3f(0, 0, 0);
		glVertex3f(0, 0, 1*len);

		glEnd();

		glPopAttrib();
	}
#endif

	DrawChildren(pDC, getChildrenField());

	/*
	int nLight = pDC->m_nLight;
	int nNames = pDC->m_namedNodes.GetSize();

	int i;

	for (i = 0; i < m_children->m_items.GetSize(); i++)
	{
		if (m_children->m_items[i])
		{
			RenderImplImpl* render = dynamic_cast<RenderImplImpl*>(m_children->m_items[i]->GetNode());
			if (render)
			{
				render->PreDraw(pDC);
			}
		}
	}

	for (i = 0; i < m_children->m_items.GetSize(); i++)
	{
		if (m_children->m_items[i])
		{
			RenderImplImpl* render = dynamic_cast<RenderImplImpl*>(m_children->m_items[i]->GetNode());
			if (render)
			{
				render->Draw(pDC);
			}
		}
	}

	for (i = pDC->m_namedNodes.GetSize(); i >= nNames; i--)
	{
//		glPopName();
	}
	for (i = pDC->m_nLight; i >= nLight; i--)
	{
		pDC->m_pGraphics3D->glDisable(GL_LIGHT0+i);
	}
	pDC->m_nLight = nLight;
	*/

	pDC->m_renderContext->PopMatrix();
	//pDC->m_transformStack.pop();
#if 0
	pDC->m_pGraphics3D->PopMatrix();
#endif
}
Esempio n. 5
0
// virtual
void Layer2D::Draw(X3DDrawContext* pDC)
{
	DrawChildren(pDC, getChildrenField());
}