Beispiel #1
0
//----------------------------------------------------------------------------
void Skinning::OnIdle ()
{
    MeasureTime();

    UpdateConstants((float)GetTimeInSeconds());

    if (MoveCamera())
    {
        mCuller.ComputeVisibleSet(mScene);
    }

    if (MoveObject())
    {
        mScene->Update();
        mCuller.ComputeVisibleSet(mScene);
    }

    if (mRenderer->PreDraw())
    {
        mRenderer->ClearBuffers();
        mRenderer->Draw(mCuller.GetVisibleSet());
        DrawFrameRate(8, GetHeight()-8, mTextColor);
        mRenderer->PostDraw();
        mRenderer->DisplayColorBuffer();
    }

    UpdateFrameCount();
}
Beispiel #2
0
Fluids3DWindow::Fluids3DWindow(Parameters& parameters)
    :
    Window3(parameters),
    mFluid(mEngine, mProgramFactory, GRID_SIZE, GRID_SIZE, GRID_SIZE, 0.002f)
{
    if (!SetEnvironment() || !CreateNestedBoxes())
    {
        parameters.created = false;
        return;
    }

    // Use blending for the visualization.
    mAlphaState = std::make_shared<BlendState>();
    mAlphaState->target[0].enable = true;
    mAlphaState->target[0].srcColor = BlendState::BM_SRC_ALPHA;
    mAlphaState->target[0].dstColor = BlendState::BM_INV_SRC_ALPHA;
    mAlphaState->target[0].srcAlpha = BlendState::BM_SRC_ALPHA;
    mAlphaState->target[0].dstAlpha = BlendState::BM_INV_SRC_ALPHA;
    mEngine->SetBlendState(mAlphaState);

    // The alpha channel must be zero for the blending of density to work
    // correctly through the fluid region.
    mEngine->SetClearColor({ 1.0f, 1.0f, 1.0f, 0.0f });

    // The geometric proxies for volume rendering are concentric boxes.  They
    // are drawn from inside to outside for correctly sorted drawing, so depth
    // buffering is not needed.
    mNoDepthState = std::make_shared<DepthStencilState>();
    mNoDepthState->depthEnable = false;
    mEngine->SetDepthStencilState(mNoDepthState);

    mFluid.Initialize();
    InitializeCamera();
    UpdateConstants();
}
//----------------------------------------------------------------------------
void PerformanceAMDWindow::OnIdle()
{
    MeasureTime();

    MoveCamera();
    UpdateConstants();

    mEngine->ClearBuffers();

    mPerformance.Profile([this]()
    {
        mEngine->Execute(mGenerateTexture, mNumXGroups, mNumYGroups, 1);
        mEngine->Draw(mTriangles);
    });

    // Compute the average measurements.  GetAverage allows you to access
    // the measurements during application run time.  SaveAverage calls
    // GetAverage and writes the results to a spreadsheet.
    std::vector<std::vector<AMDPerformance::Measurement>> measurements;
    if (mPerformance.GetNumProfileCalls() == 16)
    {
        mPerformance.GetAverage(measurements);
        mPerformance.SaveAverage("ProfileResults.csv");
    }

    DrawFrameRate(8, mYSize - 8, mTextColor);
    mEngine->DisplayColorBuffer(0);

    UpdateFrameCount();
}
Beispiel #4
0
bool CVXS_Bond::DefineBond(BondType BondTypeIn, int Vox1SIndIn, int Vox2SIndIn, bool PermIn) //usually only called whenn creating bond...
{
	ThisBondType = BondTypeIn;
	Perm = PermIn; 
	if (!SetVoxels(Vox1SIndIn, Vox2SIndIn)) return false;
	if (!UpdateConstants()) return false;
	ResetBond(); //??

	return true;
}
bool CVXS_Bond::DefineBond(BondType BondTypeIn, int Vox1SIndIn, int Vox2SIndIn, bool PermIn) //usually only called whenn creating bond...
{
	// std::cout << "DEBUG MALLOC: GOT HERE -- BOND." <<  std::endl;
	ThisBondType = BondTypeIn;
	Perm = PermIn; 
	if (!SetVoxels(Vox1SIndIn, Vox2SIndIn)) return false;
	if (!UpdateConstants()) return false;
	ResetBond(); //??
	// std::cout << "DONE BOND." <<  std::endl;
	return true;
}
Beispiel #6
0
bool CVXS_Bond::SetVoxels(const int V1SIndIn, const int V2SIndIn)
{
	Vox1SInd=V1SIndIn;
	Vox2SInd=V2SIndIn;
	if (Vox1SInd == Vox2SInd) return true; //Equale voxel indices is a flag to disable a bond
	if (!UpdateVox1Ptr()){Vox1SInd=-1; return false;}
	if (!UpdateVox2Ptr()){Vox2SInd=-1; return false;}

	OrigDist = pVox2->GetOrigPos() - pVox1->GetOrigPos(); //original distance (world coords)
	HomogenousBond = (pVox1->GetMaterial() == pVox2->GetMaterial());

	if (OrigDist.x == 0 && OrigDist.y == 0) ThisBondDir = BD_Z;
	else if (OrigDist.x == 0 && OrigDist.z == 0) ThisBondDir = BD_Y;
	else if (OrigDist.y == 0 && OrigDist.z == 0) ThisBondDir = BD_X;
	else ThisBondDir = BD_ARB;

	vfloat E1 = pVox1->GetEMod(), E2 = pVox2->GetEMod();
	vfloat u1 = pVox1->GetPoisson(), u2 = pVox2->GetPoisson();
	vfloat CTE1 = pVox1->GetCTE(), CTE2 = pVox2->GetCTE();

	if (E1 == 0 || E2 == 0) {return false;}
	if (u1 < 0 || u1 > 0.5 || u2 < 0 || u2 > 0.5 ) {return false;} //bad poissons ratio;

	E = (E1*E2/(E1+E2))*2; //x2 derived from case of equal stiffness: E1*E1/(E1+E1) = 0.5*E1 
	if (u1==0 && u2==0) u=0;
	else u = (u1*u2/(u1+u2))*2; //Poissons ratio
	CTE = (CTE1/2+CTE2/2); //thermal expansion

	//for now we are only using the nominal size of the voxel, although we could change this later if needed
	//rotate the box dimensions into the correct refference frame of x being direction of bond
	switch (ThisBondType){
		case B_LINEAR:
		L = (pVox1->GetOrigSize() + pVox2->GetOrigSize())*0.5;
		ToXDirBond(&L); //in X direction, so L.X is beam length, L.y, L.z are transverse dimensions
		L = L.Abs(); //distances strictly positive!
		break;
		case B_LINEAR_CONTACT: //X direction of L is in line with the contact...
		default:		
			L.x = p_Sim->LocalVXC.GetLatticeDim();
			L.y = L.x;
			L.z = L.x;
		break;
	}

	if (!UpdateConstants()) return false;
	ResetBond();

	return true;
}
CVXS_Bond& CVXS_Bond::operator=(const CVXS_Bond& Bond)
{
	//Bond definition
	p_Sim = Bond.p_Sim;
	ThisBondType = Bond.ThisBondType;
	Perm = Bond.Perm;

	//State variables
	Force1 = Bond.Force1;
	Force2 = Bond.Force2;
	Moment1 = Bond.Moment1;
	Moment2 = Bond.Moment2;
	StrainEnergy = Bond.StrainEnergy;
	SmallAngle = Bond.SmallAngle;
	_Pos2=Bond._Pos2; 
	_Angle1=Bond._Angle1;
	_Angle2=Bond._Angle2;
	_LastPos2=Bond._LastPos2; 
	_LastAngle1=Bond._LastAngle1;
	_LastAngle2=Bond._LastAngle2; 
	CurStrain = Bond.CurStrain;
	CurStress = Bond.CurStress;
	MaxStrain = Bond.MaxStrain;
	Yielded = Bond.Yielded;
	Broken = Bond.Broken;
	RestDist = Bond.RestDist;

	Vox1SInd = Bond.Vox1SInd;
	Vox2SInd = Bond.Vox2SInd;
	if (!UpdateVox1Ptr()){Vox1SInd=-1;}
	if (!UpdateVox2Ptr()){Vox2SInd=-1;}
	OrigDist = Bond.OrigDist;
	HomogenousBond = Bond.HomogenousBond;
	ThisBondDir = Bond.ThisBondDir;
	L = Bond.L;
	E = Bond.E;
	u = Bond.u;
	CTE = Bond.CTE;

	UpdateConstants();

	return *this;
}
Beispiel #8
0
void Fluids3DWindow::OnIdle()
{
    mTimer.Measure();

    mCameraRig.Move();
    UpdateConstants();

    mFluid.DoSimulationStep();

    mEngine->ClearBuffers();
    for (auto visual : mVisible)
    {
        mEngine->Draw(visual);
    }
    mEngine->Draw(8, mYSize - 8, { 0.0f, 0.0f, 0.0f, 1.0f }, mTimer.GetFPS());
    mEngine->DisplayColorBuffer(1);

    mTimer.UpdateFrameCount();
}
Beispiel #9
0
void LightsWindow::OnIdle()
{
    mTimer.Measure();

    mCameraRig.Move();
    UpdateConstants();

    mEngine->ClearBuffers();
    mEngine->Draw(mPlane[0]);
    mEngine->Draw(mPlane[1]);
    mEngine->Draw(mSphere[0]);
    mEngine->Draw(mSphere[1]);
    Vector4<float> textColor{ 1.0f, 1.0f, 1.0f, 1.0f };
    mEngine->Draw(8, 16, textColor, mCaption[mType]);
    mEngine->Draw(8, mYSize - 8, textColor, mTimer.GetFPS());
    mEngine->DisplayColorBuffer(0);

    mTimer.UpdateFrameCount();
}
CVXS_Bond::CVXS_Bond(CVX_Sim* p_SimIn)
{
	p_Sim = p_SimIn;
	ThisBondType = B_LINEAR;
	Perm = false;

	ResetBond(); //Zeroes out all state variables

	//Set independent variables
	Vox1SInd = -1;
	Vox2SInd = -1;
	pVox1 = NULL;
	pVox2 = NULL;
	OrigDist = Vec3D<>(0,0,0);
	HomogenousBond = false;
	ThisBondDir = BD_X;
	E=0; u=0; CTE=0;
	L = Vec3D<>(0, 0, 0);
	
	UpdateConstants(); //updates all the dependent variables based on zeros above.
}
void GeometryShadersWindow::OnIdle()
{
    mTimer.Measure();

    mCameraRig.Move();
    UpdateConstants();

    mEngine->ClearBuffers();
    mEngine->Draw(mMesh);
    mEngine->Draw(8, mYSize - 8, { 0.0f, 0.0f, 0.0f, 1.0f }, mTimer.GetFPS());
    mEngine->DisplayColorBuffer(0);

#if defined(SAVE_RENDERING_TO_DISK)
    mEngine->Enable(mTarget);
    mEngine->ClearBuffers();
    mEngine->Draw(mMesh);
    mEngine->Disable(mTarget);
    mEngine->CopyGpuToCpu(mTarget->GetRTTexture(0));
    WICFileIO::SaveToPNG("GeometryShaders.png",
        mTarget->GetRTTexture(0).get());
#endif

    mTimer.UpdateFrameCount();
}