Example #1
0
// ----------------------------------------------------------------------------
void Terrain::render()
{
    if (!m_visible) return;

    IVideoDriver* driver = SceneManager->getVideoDriver();

    driver->setMaterial(m_material);
    driver->setTransform(video::ETS_WORLD, IdentityMatrix);

    driver->drawVertexPrimitiveList(&m_mesh.vertices[0], m_mesh.vertex_count,
                                    &m_mesh.indices[0], m_mesh.quad_count * 2,
                                    video::EVT_2TCOORDS, EPT_TRIANGLES,
                                    video::EIT_16BIT);

    if (m_highlight_mesh.vertices && m_highlight_visible)
    {
        driver->setMaterial(m_highlight_material);
        driver->drawVertexPrimitiveList(&m_highlight_mesh.vertices[0],
                                         m_highlight_mesh.vertex_count,
                                         &m_highlight_mesh.indices[0],
                                         m_highlight_mesh.quad_count * 2,
                                         video::EVT_2TCOORDS, EPT_TRIANGLES,
                                         video::EIT_16BIT);
    }

} // render
Example #2
0
	void CSampleSceneNode::render()
	{
		u16 indices[] = { 0,2,3, 2,1,3, 1,0,3, 2,0,1 };
		IVideoDriver* driver = SceneManager->getVideoDriver();

		driver->setMaterial(Material);
		driver->setTransform(ETS_WORLD, AbsoluteTransformation);
		driver->drawVertexPrimitiveList(&Vertices[0], 4, &indices[0], 4, EVT_STANDARD, EPT_TRIANGLES, EIT_16BIT);
	}
Example #3
0
 void sq_dorender() const
 {
     vd->setMaterial(mat);
     vd->setTransform(ETS_WORLD, core::IdentityMatrix);
     vd->setTransform(ETS_VIEW, core::IdentityMatrix);
     vd->setTransform(ETS_PROJECTION, core::IdentityMatrix);
     vd->drawVertexPrimitiveList(vertices, 4, indices, 2, EVT_STANDARD,
                     scene::EPT_TRIANGLE_STRIP);
 }
	//! draws the element and its children
	void CGUIMeshViewer::draw()
	{
		if (!IsVisible)
			return;

		IGUISkin* skin = Environment->getSkin();
		IVideoDriver* driver = Environment->getVideoDriver();
		rect<SINT32> viewPort = AbsoluteRect;
		viewPort.LowerRightCorner.x -= 1;
		viewPort.LowerRightCorner.y -= 1;
		viewPort.UpperLeftCorner.x += 1;
		viewPort.UpperLeftCorner.y += 1;

		viewPort.clipAgainst(AbsoluteClippingRect);

		// draw the frame

		rect<SINT32> frameRect(AbsoluteRect);
		frameRect.LowerRightCorner.y = frameRect.UpperLeftCorner.y + 1;
		skin->draw2DRectangle(this, skin->getColor(EGDC_3D_SHADOW), frameRect, &AbsoluteClippingRect);

		frameRect.LowerRightCorner.y = AbsoluteRect.LowerRightCorner.y;
		frameRect.LowerRightCorner.x = frameRect.UpperLeftCorner.x + 1;
		skin->draw2DRectangle(this, skin->getColor(EGDC_3D_SHADOW), frameRect, &AbsoluteClippingRect);

		frameRect = AbsoluteRect;
		frameRect.UpperLeftCorner.x = frameRect.LowerRightCorner.x - 1;
		skin->draw2DRectangle(this, skin->getColor(EGDC_3D_HIGH_LIGHT), frameRect, &AbsoluteClippingRect);

		frameRect = AbsoluteRect;
		frameRect.UpperLeftCorner.y = AbsoluteRect.LowerRightCorner.y - 1;
		skin->draw2DRectangle(this, skin->getColor(EGDC_3D_HIGH_LIGHT), frameRect, &AbsoluteClippingRect);

		// draw the mesh

		if (Mesh)
		{
			//TODO: if outside of screen, dont draw.
			// - why is the absolute clipping rect not already the screen?

			rect<SINT32> oldViewPort = driver->getViewPort();

			driver->setViewPort(viewPort);

			Matrix4 mat;

			//CameraControl->calculateProjectionMatrix(mat);
			//driver->setTransform(TS_PROJECTION, mat);

			mat = Matrix4::IDENTITY;
			mat.setTrans(Vector3(0, 0, 0));
			//mat.setTranslation(Vector3(0, 0, 0));
			driver->setTransform(ETS_WORLD, mat);

			//CameraControl->calculateViewMatrix(mat);
			//driver->setTransform(TS_VIEW, mat);

			driver->setMaterial(Material);

			UINT32 frame = 0;
			if (Mesh->getFrameCount())
				frame = (Timer::getTime() / 20) % Mesh->getFrameCount();
			const IMesh* const m = Mesh->getMesh(frame);
			for (UINT32 i = 0; i<m->getMeshBufferCount(); ++i)
			{
				IMeshBuffer* mb = m->getMeshBuffer(i);
				driver->drawVertexPrimitiveList(mb->getVertices(),
					mb->getVertexCount(), mb->getIndices(),
					mb->getIndexCount() / 3, mb->getVertexType(),
					EPT_TRIANGLES, mb->getIndexType());
			}

			driver->setViewPort(oldViewPort);
		}

		IGUIElement::draw();
	}