예제 #1
0
파일: sample_4.cpp 프로젝트: skramm/udgcd
//-------------------------------------------------------------------
int main(int, char*[])
{
	SHOW_INFO;

	graph_t g;

	add_edge(0, 1, g);
	add_edge(0, 2, g);

	add_edge(1, 2, g);
	//  add_edge(1, 6, g); // remove the initial cycle

//	add_edge(2, 15, g);
//	add_edge(2, 8, g);

	add_edge(2, 3, g);
	add_edge(3, 4, g);

	add_edge(3, 5, g);
//	add_edge(4, 5, g);

	add_edge(5, 4, g);
//	add_edge(5, 9, g);
//	add_edge(7, 9, g);

//	add_edge(5, 12, g);
	add_edge(5, 6, g);
//	add_edge(6, 11, g);

	RenderGraph( g );

	std::vector<std::vector<vertex_t>> cycles = udgcd::FindCycles<graph_t,vertex_t>( g );      // no cycles at first
	udgcd::PrintPaths( std::cout, cycles, "final-0" );

	add_edge( 1, 6, g );                                 // cycle !
	cycles = udgcd::FindCycles<graph_t,vertex_t>( g );
	RenderGraph( g );
	udgcd::PrintPaths( std::cout, cycles, "final-1" );

/*	add_edge( 13, 14, g );                              // another cycle !
	RenderGraph( g );
	cycles = udgcd::FindCycles<graph_t,vertex_t>( g );
	udgcd::PrintPaths( std::cout, cycles, "final-2" );
*/
/*	add_edge( 15, 8, g );                               // another cycle !
	RenderGraph( g );
	cycles = udgcd::FindCycles<graph_t,vertex_t>( g );
	udgcd::PrintPaths( std::cout, cycles, "final-3" );
*/

	return 0;
}
예제 #2
0
void SbWaxGraph::Render()
{
    // Apply the shader
    m_pShader->Apply();

    // Render the cube
    m_pWaxModel->Render();

    // Render the graph
    RenderGraph();

    MtMatrix4 m4Transform = m_pWaxModel->GetWorldTransform();
    MtVector3 v3Translate = m4Transform.GetTranslation();

    MtVector3 v3Pos( 0, 0, 1 );
    v3Pos = v3Pos * m4Transform;
    HlDraw::RenderLine( v3Translate, v3Pos, RsColour::GreenColour() );

    v3Pos = MtVector3( 1, 0, 0 );
    v3Pos = v3Pos * m4Transform;
    HlDraw::RenderLine( v3Translate, v3Pos, RsColour::RedColour() );

    v3Pos = MtVector3( 0, 1, 0 );
    v3Pos = v3Pos * m4Transform;
    HlDraw::RenderLine( v3Translate, v3Pos, RsColour::BlueColour() );
}
예제 #3
0
파일: sample_5.cpp 프로젝트: skramm/udgcd
//-------------------------------------------------------------------
int main(int, char*[])
{
	SHOW_INFO;

	graph_t g;

	add_edge(0, 1, g);
	add_edge(0, 3, g);
	add_edge(0, 6, g);
	add_edge(0, 8, g);

	add_edge(1, 2, g);
	add_edge(3, 2, g);

	add_edge(3, 4, g);
	add_edge(5, 4, g);
	add_edge(5, 6, g);

	add_edge(9, 8, g);
	add_edge(9, 7, g);
	add_edge(1, 7, g);

	add_edge(10, 5, g);
	add_edge(10, 11, g);
	add_edge(11, 9, g);

	RenderGraph( g );

	std::vector<std::vector<vertex_t>> cycles = udgcd::FindCycles<graph_t,vertex_t>( g );      // no cycles at first
	udgcd::PrintPaths( std::cout, cycles, "final-5" );
}
예제 #4
0
void BarGauge::Render() {
    glDisable(GL_TEXTURE_2D);
    //sr_ResetRenderState(0); //needs this because rFont has bugs i presume.. Ie I have problems as soon as rTextFirld is used
    // z-man: actually, it is needed because per-frame-tasks get called without rendering context, so it has to be set.

    const tValue::Base &val_s = m_data.GetVal();
    const tValue::Base &min_s = m_data.GetMin();
    const tValue::Base &max_s = m_data.GetMax();

    float min = min_s.GetFloat();
    float max = max_s.GetFloat();
    float val = val_s.GetFloat();

    if (val > max) val = max;
    if (val < min) val = min;
    if (min >= max) return;

    RenderGraph(min, max, val,m_reverse?-1.:1., val_s);

    RenderMinMax(min_s, max_s);
    RenderCaption();

    //if (!sr_glOut)
    //    return;

    //glColor3f(1,1,1);
}
예제 #5
0
BOOL CVMR9Graph::BuildAndRenderGraph(bool withSound)
{
	USES_CONVERSION;

  int nLayer = 0;
  HRESULT hr;

	// ENSURE that a valid graph builder is available
	if (m_pGraphBuilder == NULL) {
		BOOL bRet = BuildFilterGraph(withSound);
		if (!bRet) return bRet;
	}

  // ENSURE that the filter graph is in a stop state
	OAFilterState filterState;
	m_pMediaControl->GetState(500, &filterState);
	if (filterState != State_Stopped) {
		m_pMediaControl->Stop();
	}

  	// CHECK a source filter availaibility for the layer
	if (m_srcFilterArray[nLayer] == NULL) {
		char pszFilterName[10];
		sprintf(pszFilterName, "SRC%02d", nLayer);
		IBaseFilter* pBaseFilter = NULL;
		hr = m_pGraphBuilder->AddSourceFilter(A2W(m_pszFileName), A2W(pszFilterName), &pBaseFilter);
		if (FAILED(hr)) {
			ReportError("Could not find a source filter for this file", hr);
			return FALSE;
		}
		m_srcFilterArray[nLayer] = pBaseFilter;
	} else {
		// suppress the old src filter
		IBaseFilter* pBaseFilter = m_srcFilterArray[nLayer];
		RemoveFilterChain(pBaseFilter, m_pVMRBaseFilter);
		pBaseFilter->Release();
		m_srcFilterArray[nLayer] = NULL;
		// create a new src filter
		char pszFilterName[10];
		sprintf(pszFilterName, "SRC%02d", nLayer);
		hr = m_pGraphBuilder->AddSourceFilter(A2W(m_pszFileName), A2W(pszFilterName), &pBaseFilter);
		m_srcFilterArray[nLayer] = pBaseFilter;
		if (FAILED(hr)) {
			m_srcFilterArray[nLayer] = NULL;
			ReportError("Could not load the file", hr);
			return FALSE;
		}
	}

	// RENDER the graph
	BOOL bRet = RenderGraph();
	if (!bRet) return bRet;

  return TRUE;
}
void CDlgCreateSpecularTexture::OnPaint() 
{
	CPaintDC dc(this); // device context for painting

  if( m_iTimerID == -1)
  {
    m_iTimerID = (int) SetTimer( 1, 24, NULL);
  }

  if( !m_bCustomWindowsCreated)
  {
    // ---------------- Create window for graph
    // obtain frames area window
    CWnd *pwndGraph = GetDlgItem(IDC_GRAPH_FRAME);
    ASSERT(pwndGraph != NULL);
    CRect rectGraphWindow;
    pwndGraph->GetWindowRect(&rectGraphWindow);
    ScreenToClient(&rectGraphWindow);
    m_wndGraph.Create( NULL, NULL, WS_BORDER|WS_VISIBLE, rectGraphWindow,
                                 this, IDW_SPECULAR_GRAPH);
    // ---------------- Create window for preview
    CWnd *pWndPreview = GetDlgItem(IDC_PREVIEW_FRAME);
    ASSERT(pWndPreview != NULL);
    CRect rectPreview;
    pWndPreview->GetWindowRect(&rectPreview);
    ScreenToClient(&rectPreview);
    // create window for for animation testing
    m_wndPreview.Create( NULL, NULL, WS_BORDER|WS_VISIBLE, rectPreview,
                                   this, IDW_SPECULAR_PREVIEW);
    // mark that custom windows are created
    m_bCustomWindowsCreated = TRUE;
  }

  RenderGraph();
  RenderPreview();
}
예제 #7
0
void Display()
{
  long current_time = GetTimeMillis();
  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  glLoadIdentity();
  
    Camera::get()->update();
    
    if(!pre_defined_graph && current_time - m_last_update > DELAY)
    {
      NextAnimation(m_graph, m_animation);
      m_last_update = current_time;
    }
//    gluLookAt(300,300,300,
 // 	     -4000, -3000, 400,
//	     0.0, 1.0, 0.0);
    RenderGraph(m_graph);
    
  glColor3f(1.0,1.0,1.0);
  glutSwapBuffers();
  
  //glFlush();
  glutPostRedisplay();
}
예제 #8
0
void LineGraph::GenrateGraph(sint32     &infoXCount,
                             sint32     &infoYCount,
                             double ***  infoGraphData,
                             sint32      category)
{
	infoYCount = 0;
	infoXCount = 0;

	AUI_ERRCODE                     errcode     = AUI_ERRCODE_OK;
	std::auto_ptr<aui_StringTable>  stringTable (new aui_StringTable(&errcode, "InfoStrings"));

	SetXAxisName(stringTable->GetString(6));
	SetYAxisName("Power");

	double minRound = s_minRound;
	double curRound = g_turn->GetRound();
	double minPower = 0;
	double maxPower = 10;

	SetGraphBounds(minRound, curRound, minPower, maxPower);
	HasIndicator(false);

	sint32 i;
	for ( i = 0 ; i < k_MAX_PLAYERS ; i++ )
	{
		if (g_player[i] && (i != PLAYER_INDEX_VANDALS))
		{
			infoYCount++;
		}
	}

	sint32* color = new sint32[infoYCount + g_deadPlayer->GetCount()];

	infoYCount = 0;

	for ( i = 0 ; i < k_MAX_PLAYERS ; i++ )
	{
		if (g_player[i] && (i != PLAYER_INDEX_VANDALS))
		{
			color[infoYCount++] = g_colorSet->ComputePlayerColor(i);
		}
	}

	for
	(
	    PointerList<Player>::Walker walk(g_deadPlayer);
	    walk.IsValid();
	    walk.Next()
	)
	{
		color[infoYCount++] = g_colorSet->ComputePlayerColor(walk.GetObj()->GetOwner());
	}

	infoXCount = static_cast<sint32>(curRound) - static_cast<sint32>(minRound);
	if (infoXCount == 0)
	{
		RenderGraph();
		return;
	}

	infoXCount = std::max<sint32>(1, infoXCount);
	infoYCount = std::max<sint32>(1, infoYCount);

	Assert(!*infoGraphData);
	*infoGraphData = new double *[infoYCount];

	for (i = 0 ; i < infoYCount; i++)
	{
		(*infoGraphData)[i] = new double[infoXCount];
		std::fill((*infoGraphData)[i], (*infoGraphData)[i] + infoXCount, 0.0);
	}

	sint32 playerCount = 0;
	for ( i = 0 ; i < k_MAX_PLAYERS ; i++ )
	{
		if (g_player[i] && (i != PLAYER_INDEX_VANDALS))
		{
			for (sint32 round = 0 ; round < infoXCount ; ++round)
			{
				sint32 strValue = GetCombinedStrength(*g_player[i]->m_strengths, round, category);
				(*infoGraphData)[playerCount][round] = strValue;

				while (strValue > maxPower)
					maxPower += 10.0;
			}

			playerCount++;
		}
	}

	for
	(
	    PointerList<Player>::Walker walk2(g_deadPlayer);
	    walk2.IsValid();
	    walk2.Next()
	)
	{
		for (sint32 round = 0 ; round < infoXCount ; ++round)
		{
			sint32 strValue = GetCombinedStrength(*walk2.GetObj()->m_strengths, round, category);
			(*infoGraphData)[playerCount][round] = strValue;

			while (strValue > maxPower)
				maxPower += 10.0;
		}

		playerCount++;
	}

	Assert(playerCount == infoYCount);

	SetLineData(infoYCount, infoXCount, (*infoGraphData), color);
	SetGraphBounds(minRound, curRound, minPower, maxPower);
	RenderGraph();

	delete color;
}