コード例 #1
0
/**
 * @brief Adds a point to the list of vertices
 *
 * Adds a point to the list of vertices and updates the data on the
 * OpenGL context.
 *
 * @param x The x-coordinate (in OpenGL normalized space)
 * @param y The y-coordinate (int OpenGL normalized space)
 */
void PolygonTool::AddPoint(float x, float y)
{
	pointsList.push_back(Point(x, y));
	++pointCount;
	UpdateVertexBuffer();
	UpdateIndexBuffer();
}
コード例 #2
0
//----------------------------------------------------------------------------
void Fluids3D::OnIdle ()
{
    MeasureTime();

#ifdef USE_PARTICLES
    bool particlesNeedUpdate = false;
#endif
    mIndexBufferNeedsUpdate = false;

    if (MoveCamera())
    {
#ifdef USE_PARTICLES
        particlesNeedUpdate = true;
#endif
        mIndexBufferNeedsUpdate = true;
    }

    if (MoveObject())
    {
#ifdef USE_PARTICLES
        particlesNeedUpdate = true;
#endif
        mIndexBufferNeedsUpdate = true;
        mScene->Update();
    }

#ifdef USE_PARTICLES
    if (particlesNeedUpdate)
    {
        mCube->GenerateParticles(mCamera);
    }
#endif

    if (mIndexBufferNeedsUpdate)
    {
        UpdateIndexBuffer();
        mIndexBufferNeedsUpdate = false;
    }

    if (!mSingleStep)
    {
        PhysicsTick();
    }

    GraphicsTick();

    UpdateFrameCount();
}
コード例 #3
0
  //************//
 //** EVENTS **//
//************//
	void ParticleMesh::do_UPDATE(Events::Event* pEvt)
	{
		PE::Events::Event_UPDATE *pRealEvt = (PE::Events::Event_UPDATE *)(pEvt);
		float frameTime = pRealEvt->m_frameTime;

		//we have to update ALL buffers since we will be writing to the GPU
		//if we don't keep their scaling proportional, we will get array axis
		//errors
		CameraSceneNode *pcam = CameraManager::Instance()->getActiveCamera()->getCamSceneNode();
		m_eyePos = pcam->m_worldTransform.getPos();

		UpdatePositionBuffer(m_eyePos, frameTime);
		UpdateTextCoordBuffer(frameTime);
		UpdateIndexBuffer(frameTime);
		UpdateNormalBuffers(frameTime);
	}
コード例 #4
0
ファイル: FRenderD3D11.cpp プロジェクト: JeongHwanYim/FEngine
void FRenderD3D11::RenderFrame()
{
	camera.CommitListener();
//	ProcessInCPU();

	float colorRGBA[4] = { 0.0f, 0.2f, 0.4f, 1.0f };
	// clear the back buffer to a deep blue
	m_pDeviceContext->ClearRenderTargetView(m_pBackbuffer, colorRGBA);

	UpdateVertexBuffer();
	UpdateIndexBuffer();
	UpdateConstantBuffer();

	// select which vertex buffer to display
	UINT stride = sizeof(VERTEX);
	UINT offset = 0;
	m_pDeviceContext->IASetVertexBuffers(0, 1, &m_pVertexBuffer, &stride, &offset);

	m_pDeviceContext->IASetIndexBuffer(m_pIndexBuffer, DXGI_FORMAT_R32_UINT, 0);

	m_pDeviceContext->VSSetConstantBuffers(0, 1, &m_pCBuffer);

	// select which primtive type we are using
	m_pDeviceContext->IASetPrimitiveTopology(D3D10_PRIMITIVE_TOPOLOGY_TRIANGLELIST);

	D3D11_RASTERIZER_DESC desc;
	ZeroMemory(&desc, sizeof(D3D11_RASTERIZER_DESC));
	desc.CullMode = D3D11_CULL_BACK;
	desc.FillMode = D3D11_FILL_WIREFRAME;
	desc.FrontCounterClockwise = false;
	desc.DepthClipEnable = true;

	ID3D11RasterizerState* pRasterizerState = NULL;
	m_pDevice->CreateRasterizerState(&desc, &pRasterizerState);

	m_pDeviceContext->RSSetState(pRasterizerState);

	// draw the vertex buffer to the back buffer
	m_pDeviceContext->DrawIndexed(triCorn.indices.size(), 0, 0);

	// switch the back buffer and the front buffer
	m_pSwapchain->Present(0, 0);
}
コード例 #5
0
//----------------------------------------------------------------------------
bool Fluids3D::OnInitialize ()
{
    if (!WindowApplication3::OnInitialize())
    {
        return false;
    }

    // Create the pseudocoloring for display.
    Vector3f key[9] =
    {
        Vector3f(  0.0f/255.0f,   0.0f/255.0f,   0.0f/255.0f),  // black
        Vector3f(128.0f/255.0f,  64.0f/255.0f,  64.0f/255.0f),  // brown
        Vector3f(128.0f/255.0f,   0.0f/255.0f, 255.0f/255.0f),  // violet
        Vector3f(  0.0f/255.0f,   0.0f/255.0f, 255.0f/255.0f),  // blue
        Vector3f(  0.0f/255.0f, 255.0f/255.0f,   0.0f/255.0f),  // green
        Vector3f(255.0f/255.0f, 255.0f/255.0f,   0.0f/255.0f),  // yellow
        Vector3f(255.0f/255.0f, 128.0f/255.0f,   0.0f/255.0f),  // orange
        Vector3f(255.0f/255.0f,   0.0f/255.0f,   0.0f/255.0f),  // red
        Vector3f(255.0f/255.0f, 255.0f/255.0f, 255.0f/255.0f)   // white
    };

    for (int i = 0, j = 0; i < 8; ++i)
    {
        for (int k = 0; k < 32; ++k, ++j)
        {
            float t = k/32.0f;
            float omt = 1.0f - t;
            mColor[j][0] = omt*key[i][0] + t*key[i+1][0];
            mColor[j][1] = omt*key[i][1] + t*key[i+1][1];
            mColor[j][2] = omt*key[i][2] + t*key[i+1][2];
        }
    }

    // Create the fluid solver.
    float x0 = -0.5f, y0 = -0.5f, z0 = -0.5f;
    float x1 = 0.5f, y1 = 0.5f, z1 = 0.5f;
    float dt = 0.001f;
    float denViscosity = 0.0001f, velViscosity = 0.0001f;
    int imax = 23, jmax = 23, kmax = 23;
    int numGaussSeidelIterations = 16;
    bool densityDirichlet = true;
    int numVortices = 8;
    mSmoke = new0 Smoke3D<float>(x0, y0, z0, x1, y1, z1, dt, denViscosity,
        velViscosity, imax, jmax, kmax, numGaussSeidelIterations,
        densityDirichlet, numVortices);

    mSmoke->Initialize();

    // Set up the camera.
    mCamera->SetFrustum(60.0f, GetAspectRatio(), 0.1f, 100.0f);
    APoint camPosition(1.0f, 0.0f, 0.0f);
    AVector camDVector(-1.0f, 0.0f, 0.0f);
    AVector camUVector(0.0f, 0.0f, 1.0f);
    AVector camRVector = camDVector.Cross(camUVector);
    mCamera->SetFrame(camPosition, camDVector, camUVector, camRVector);

    // Create the scene.
    CreateScene();
    mScene->Update();
#ifdef USE_PARTICLES
    mCube->GenerateParticles(mCamera);
#endif
    UpdateVertexBuffer();
    UpdateIndexBuffer();

    // The scene is controlled by a virtual trackball.
    InitializeCameraMotion(0.01f, 0.01f);
    InitializeObjectMotion(mScene);
    return true;
}
コード例 #6
0
//----------------------------------------------------------------------------
void Fluids3D::PhysicsTick ()
{
    mSmoke->DoSimulationStep();
    UpdateVertexBuffer();
    UpdateIndexBuffer();
}