D3D12_STATIC_SAMPLER_DESC ConvertToStaticSampler(const D3D12_SAMPLER_DESC& samplerDesc, uint32 shaderRegister,
                                                 uint32 registerSpace, D3D12_SHADER_VISIBILITY visibility)
{
    D3D12_STATIC_SAMPLER_DESC staticDesc = { };
    staticDesc.Filter = samplerDesc.Filter;
    staticDesc.AddressU = samplerDesc.AddressU;
    staticDesc.AddressV = samplerDesc.AddressV;
    staticDesc.AddressW = samplerDesc.AddressW;
    staticDesc.MipLODBias = samplerDesc.MipLODBias;
    staticDesc.MaxAnisotropy = samplerDesc.MaxAnisotropy;
    staticDesc.ComparisonFunc = samplerDesc.ComparisonFunc;
    staticDesc.MinLOD = samplerDesc.MinLOD;
    staticDesc.MaxLOD = samplerDesc.MaxLOD;
    staticDesc.ShaderRegister = shaderRegister;
    staticDesc.RegisterSpace = registerSpace;
    staticDesc.ShaderVisibility = visibility;

    Float4 borderColor = Float4(samplerDesc.BorderColor[0], samplerDesc.BorderColor[1], samplerDesc.BorderColor[2], samplerDesc.BorderColor[3]);
    if(borderColor == Float4(1.0f, 1.0f, 1.0f, 1.0f))
        staticDesc.BorderColor = D3D12_STATIC_BORDER_COLOR_OPAQUE_WHITE;
    else if(borderColor == Float4(0.0f, 0.0f, 0.0f, 1.0f))
        staticDesc.BorderColor = D3D12_STATIC_BORDER_COLOR_OPAQUE_BLACK;
    else
        staticDesc.BorderColor =  D3D12_STATIC_BORDER_COLOR_TRANSPARENT_BLACK;

    return staticDesc;
}
Beispiel #2
0
//----------------------------------------------------------------------------
void Delaunay3D::DoSearch ()
{
    // Make all tetra wireframe.
    const int numSimplices = mDelaunay->GetNumSimplices();
    Float4 lightGray(0.75f, 0.75f, 0.75f, 1.0f);
    int i;
    for (i = 0; i < numSimplices; ++i)
    {
        ChangeTetraStatus(i, lightGray, true);
    }

    // Generate random point in AABB of data set.
    Vector3f random;
    random.X() = Mathf::IntervalRandom(mMin.X(), mMax.X());
    random.Y() = Mathf::IntervalRandom(mMin.Y(), mMax.Y());
    random.Z() = Mathf::IntervalRandom(mMin.Z(), mMax.Z());

    // Move sphere to this location.
    Spatial* sphere = mScene->GetChild(0);
    sphere->Culling = Spatial::CULL_DYNAMIC;
    sphere->LocalTransform.SetTranslate(random);
    sphere->Update();

    if (mDelaunay->GetContainingTetrahedron(random) >= 0)
    {
        // Make all tetra on the path solid.
        const int pathLast = mDelaunay->GetPathLast();
        for (i = 0; i <= pathLast; ++i)
        {
            int index = mDelaunay->GetPath()[i];
            float red, blue;
            if (pathLast > 0)
            {
                red = i/(float)pathLast;
                blue = 1.0f - red;
            }
            else
            {
                red = 1.0f;
                blue = 0.0f;
            }
            ChangeTetraStatus(index, Float4(red, 0.0f, blue, 0.5f), false);
        }
    }
    else
    {
        // The point is outside the convex hull.  Change the wireframe
        // color for the last visited face in the search path.
        int index = mDelaunay->GetPath()[mDelaunay->GetPathLast()];
        int v0, v1, v2, v3;
        int vOpposite = mDelaunay->GetLastFace(v0, v1, v2, v3);
        ChangeLastTetraStatus(index, vOpposite,
            Float4(0.0f, 1.0f, 0.0f, 0.5f),
            Float4(0.0f, 0.25f, 0.0f, 0.5f));
    }

    mCuller.ComputeVisibleSet(mScene);
}
LightDescPoint::LightDescPoint()
{
	ambient		= Float4(0.0f, 0.0f, 0.0f, 0.0f);
	diffuse		= Float4(0.0f, 0.0f, 0.0f, 0.0f);
	specular	= Float4(0.0f, 0.0f, 0.0f, 0.0f);

	range		= 0.0f;
	attenuation	= Float3(0.0f, 0.0f, 0.0f);
}
Beispiel #4
0
void GrassModule::OnGrassClick(const MGUI::MouseEvent * e)
{
	if (mImageBox_Selected)
		mImageBox_Selected->SetColor(Float4(1.0f, 1.0f, 1.0f));

	mImageBox_Selected = (MGUI::ImageBox *)e->sender;

	if (mImageBox_Selected)
		mImageBox_Selected->SetColor(Float4(0.7f, 0.7f, 1.0f));
}
Beispiel #5
0
 Point lerp3d(const Point& px0y0z0, const Point& px1y0z0, const Point& px0y1z0, const Point& px1y1z0,
     const Point& px0y0z1, const Point& px1y0z1, const Point& px0y1z1, const Point& px1y1z1,
     float xPoint, float yPoint, float zPoint) {
         return Point(lerp3d(Float4(px0y0z0), Float4(px1y0z0), Float4(px0y1z0), Float4(px1y1z0), 
             Float4(px0y0z1), Float4(px1y0z1), Float4(px0y1z1), Float4(px1y1z1), 
             xPoint, yPoint, zPoint));
 }
Beispiel #6
0
Float4 Quaternion::getAxisAndAngle() const
{
    float ha = std::acos(w);
    float sha = std::sin(ha);

    return Float4(x / sha, y / sha, z / sha, ha*2.0f);
}
Beispiel #7
0
void GrassModule::OnRender()
{
	if (!mLayout->IsVisible() || mImageBox_Selected == NULL || !Terrain::Instance()->IsValid())
		return ;

	Aabb aabb;
	aabb.minimum = mBrushPosition - Float3(mBrushSize * 0.5f, 1, mBrushSize * 0.5f);
	aabb.maximum = mBrushPosition + Float3(mBrushSize * 0.5f, 1, mBrushSize * 0.5f);

	RenderSystem::Instance()->SetWorldTM(Mat4::Identity);

	for (int y = 0; y < Terrain::Instance()->GetInfo()->BlockCount.x; ++y)
	{
		for (int x = 0; x < Terrain::Instance()->GetInfo()->BlockCount.y; ++x)
		{
			TerrainMesh * mesh = Terrain::Instance()->_getBlock(x, y);
			const Aabb & bound = mesh->GetWorldAabb();

			float x0 = Max(aabb.minimum.x, bound.minimum.x);
			float z0 = Max(aabb.minimum.z, bound.minimum.z);

			float x1 = Min(aabb.maximum.x, bound.maximum.x);
			float z1 = Min(aabb.maximum.z, bound.maximum.z);

			if (x0 <= x1 && z0 <= z1)
			{
				mShaderFX_Brush->GetPass(0)->SetConst("u_MinInvSize", Float4(aabb.minimum.x, aabb.minimum.z, 1 / mBrushSize, 1 / mBrushSize));
				mShaderFX_Brush->GetPass(0)->SetConst("u_XZTransform", mesh->GetXZTransform());

				RenderSystem::Instance()->SetTexture(0, MGUI::Helper::Instance()->GetWhiteTexture().c_ptr());
				RenderSystem::Instance()->Render(mShaderFX_Brush, mesh->GetRenderOp());
			}
		}
	}
}
Beispiel #8
0
//----------------------------------------------------------------------------
Polysegments::Polysegments ()
    :
    WindowApplication3("SampleGraphics/Polysegments", 0, 0, 640, 480,
        Float4(0.75f, 0.75f, 0.75f, 1.0f)),
        mTextColor(1.0f, 1.0f, 1.0f, 1.0f)
{
}
//----------------------------------------------------------------------------
BSplineSurfaceFitter::BSplineSurfaceFitter ()
	:
	WindowApplication3("SampleMathematics/BSplineSurfaceFitter", 0, 0, 640,
	                   480, Float4(0.0f, 0.5f, 0.75f, 1.0f)),
	mTextColor(0.0f, 0.0f, 0.0f, 1.0f)
{
}
//----------------------------------------------------------------------------
PolyhedronDistance::PolyhedronDistance ()
    :
    WindowApplication3("SamplePhysics/PolyhedronDistance", 0, 0, 640, 480,
        Float4(0.5f, 0.0f, 1.0f, 1.0f)),
        mTextColor(1.0f, 1.0f, 1.0f, 1.0f)
{
}
//----------------------------------------------------------------------------
FoucaultPendulum::FoucaultPendulum ()
    :
    WindowApplication3("SamplePhysics/FoucaultPendulum", 0, 0, 640, 480,
        Float4(0.819607f, 0.909803f, 0.713725f, 1.0f)),
        mTextColor(1.0f, 1.0f, 1.0f, 1.0f)
{
}
Beispiel #12
0
//----------------------------------------------------------------------------
RoughPlaneThinRod2::RoughPlaneThinRod2 ()
	:
	WindowApplication2("SamplePhysics/RoughPlaneThinRod2", 0, 0, 256, 256,
	                   Float4(1.0f, 1.0f, 1.0f, 1.0f))
{
	mSize = GetWidth();
}
Beispiel #13
0
//----------------------------------------------------------------------------
MaterialTextures::MaterialTextures ()
    :
    WindowApplication3("SampleGraphics/MaterialTextures", 0, 0, 640, 480,
                      Float4(1.0f, 1.0f, 1.0f, 1.0f)),
    mTextColor(0.0f, 0.0f, 0.0f, 1.0f)
{
}
Beispiel #14
0
//----------------------------------------------------------------------------
BillboardNodes::BillboardNodes ()
    :
    WindowApplication3("SampleGraphics/BillboardNodes",0, 0, 640, 480,
        Float4(0.9f, 0.9f, 0.9f, 1.0f)),
        mTextColor(1.0f, 1.0f, 1.0f, 1.0f)
{
}
//----------------------------------------------------------------------------
ClodMeshes::ClodMeshes ()
    :
    WindowApplication3("SampleGraphics/ClodMeshes", 0, 0, 640, 480,
        Float4(0.9f, 0.9f, 0.9f, 1.0f)),
        mTextColor(0.0f, 0.0f, 0.0f, 1.0f)
{
}
Beispiel #16
0
			const Ray operator * ( const Ray& lhs, const Matrix4x4& world )
			{
				const Float3 origin = lhs.origin * world;
				const Float3 direction = ( Float4( lhs.direction, 0 ) * world );
				Ray result( origin, direction );
				return result;
			}
Beispiel #17
0
//----------------------------------------------------------------------------
NonuniformScale::NonuniformScale ()
    :
    WindowApplication3("SampleGraphics/NonuniformScale", 0, 0, 640, 480,
        Float4(0.5f, 0.0f, 1.0f, 1.0f)),
        mTextColor(1.0f, 1.0f, 1.0f, 1.0f)
{
}
Beispiel #18
0
//----------------------------------------------------------------------------
ParticleSystems::ParticleSystems ()
    :
    WindowApplication3("SampleGraphics/ParticleSystems", 0, 0, 640, 480,
        Float4(0.5f, 0.0f, 1.0f, 1.0f)),
        mTextColor(1.0f, 1.0f, 1.0f, 1.0f)
{
}
Beispiel #19
0
//----------------------------------------------------------------------------
BlendedAnimations::BlendedAnimations ()
	:
	WindowApplication3("SampleGraphics/BlendedAnimations", 0, 0, 768, 768,
	                   Float4(0.5f, 0.0f, 1.0f, 1.0f)),
	mTextColor(1.0f, 1.0f, 1.0f, 1.0f),
	mManager(ThePath + "Data/", "Biped"),
	mAnimTime(0.0),
	mUpArrowPressed(false),
	mShiftPressed(false)
{
	// Set animation information.  The counts differ in debug and release
	// builds because of the differing frame rates of those builds.
#ifdef _DEBUG
	int idleWalkCount = 100;
	int walkCount = 10;
	int walkRunCount = 100;
	mAnimTimeDelta = 0.01;
#else
	int idleWalkCount = 1000;
	int walkCount = 100;
	int walkRunCount = 1000;
	mAnimTimeDelta = 0.001;
#endif

	// The idle head turning occurs too frequently (frequency = 1 in the
	// original model).  Reduce the turning by half.
	mManager.SetIdle(0.5, 0.0);

	// The walk and run cycles must be aligned properly for blending.  A
	// phase of 0.2 for the run cycle aligns the biped feet.
	mManager.SetRun(1.0, 0.2);

	// The initial state is 'idle'.
	mManager.Initialize(idleWalkCount, walkCount, walkRunCount);
}
//----------------------------------------------------------------------------
ClipMesh::ClipMesh ()
    :
    WindowApplication3("SampleMathematics/ClipMesh", 0, 0, 640, 480,
        Float4(0.75f, 0.75f, 0.75f, 1.0f)),
        mTextColor(1.0f, 1.0f, 1.0f, 1.0f)
{
}
Beispiel #21
0
//----------------------------------------------------------------------------
PolygonDistance::PolygonDistance ()
	:
	WindowApplication2("SamplePhysics/PolygonDistance", 0, 0, 512, 512,
	                   Float4(1.0f, 1.0f, 1.0f, 1.0f))
{
	mSize = GetWidth();
}
Beispiel #22
0
	virtual void OnInit()
	{
		MGUI::FontManager::Instance()->Load("Sample.font");
		MGUI::InputManager::Instance()->E_MouseUp += new ncListener1<const MGUI::MouseEvent *>(OnPick);
		MGUI::InputManager::Instance()->E_TouchUp += new ncListener1<const MGUI::TouchEvent *>(OnPickTE);

		World::Instance()->MainRenderContext()->SetColorClear(eClearMode::ALL, Float4(0.15f, 0.15f, 0.15f));
		World::Instance()->MainCamera()->SetPosition(Float3(0, 5, -10));
		World::Instance()->MainCamera()->SetDirection(Float3(0, -5, 10));
		World::Instance()->MainLight()->SetDirection(Float3(0, -0.5f, 1));

		gMeshFloor = MeshManager::Instance()->NewPlane(Plane(0, 1, 0, 0), 10, 10);
		gMeshFloor->GetSubMesh(0)->GetMaterial()->ambient = Float3(0.3f, 0.0f, 0.3f);
		gMeshFloor->GetSubMesh(0)->GetMaterial()->diffuse = Float3(0.0f, 0.0f, 0.0f);

		gMeshBox = MeshManager::Instance()->NewBox(1, 1, 1);
		gMeshBox->GetSubMesh(0)->GetMaterial()->ambient = Float3(0.1f, 0.1f, 0.1f);
		gMeshBox->GetSubMesh(0)->GetMaterial()->diffuse = Float3(0.0f, 0.5f, 0.0f);
		gMeshBox->SetPosition(Float3(0, 3, 0));

		PhyWorld::Instance()->SetWorldGravity(0, -9.8f, 0);
		PhyWorld::Instance()->SetWorldContactSurfaceLayer(0.01f);

		gPhyEntityFloor = new PhyPlane;
		gPhyEntityFloor->SetCollisionFlag(FLAG_FLOOR);

		gPhyEntityBox = new PhyBox(PhyEntity::RIGID_BODY);
		gPhyEntityBox->SetBodyAutoDisable(false);
		gPhyEntityBox->SetLength(1, 1, 1);
		gPhyEntityBox->SetMass(5, 1, 1, 1);
		gPhyEntityBox->SetPosition(Float3(0, 3, 0));
		gPhyEntityBox->SetBounceParam(1.0f, 1.0f);
		gPhyEntityBox->SetCollisionFlag(FLAG_BOX);
		gPhyEntityBox->SetAngularVel(Float3(2, 2, 2));
	}
Beispiel #23
0
//----------------------------------------------------------------------------
PolygonOffsets::PolygonOffsets ()
    :
    WindowApplication3("SampleGraphics/PolygonOffsets", 0, 0, 640, 480,
        Float4(0.5f, 0.0f, 1.0f, 1.0f)),
        mTextColor(1.0f, 1.0f, 1.0f, 1.0f)
{
}
Beispiel #24
0
//----------------------------------------------------------------------------
SwitchNodes::SwitchNodes ()
    :
    WindowApplication3("SampleGraphics/SwitchNodes", 0, 0, 640, 480,
        Float4(0.5f, 0.0f, 1.0f, 1.0f)),
        mTextColor(1.0f, 1.0f, 1.0f, 1.0f)
{
}
void ExplosionSpherePhysicsObject::onUpdate(float delta)
{
	//--------------------------------------------------------------------------------------
	// Update scaling. Expand explosion sphere according to mutator settings retrieved in "subClassSpecificInitHook()"
	//--------------------------------------------------------------------------------------
	std::vector<int> explosionSphereEntityId = itrPhysics.ownerAt(attributeIndex_)->getAttributes(ATTRIBUTE_EXPLOSIONSPHERE);
	for(unsigned int i = 0; i < explosionSphereEntityId.size(); i++)
	{
		AttributePtr<Attribute_ExplosionSphere> ptr_explosionSphere = itrExplosionSphere.at(explosionSphereEntityId.at(i));
		ptr_explosionSphere->currentRadius += explosionSphereExpansionRate_*delta;
		if(ptr_explosionSphere->currentRadius >= explosionSphereFinalRadius_)
		{
			ptr_explosionSphere->currentRadius = explosionSphereFinalRadius_;
		}
		itrPhysics.at(attributeIndex_)->ptr_spatial->scale = Float3(ptr_explosionSphere->currentRadius,ptr_explosionSphere->currentRadius,ptr_explosionSphere->currentRadius);
		localCollisionShape_->setLocalScaling(btVector3(ptr_explosionSphere->currentRadius, ptr_explosionSphere->currentRadius, ptr_explosionSphere->currentRadius));
	}

	//--------------------------------------------------------------------------------------
	// Update rotation
	//--------------------------------------------------------------------------------------
	btQuaternion randomRotationQuaternion (randomRotation_.x()*delta,randomRotation_.y()*delta,randomRotation_.z()*delta);
	btQuaternion rotateWithRandomRotationQuaternion = randomRotationQuaternion*getWorldTransform().getRotation();
	getWorldTransform().setRotation(rotateWithRandomRotationQuaternion);
	itrPhysics.at(attributeIndex_)->ptr_spatial->rotation = Float4(rotateWithRandomRotationQuaternion.x(),rotateWithRandomRotationQuaternion.y(),rotateWithRandomRotationQuaternion.z(),rotateWithRandomRotationQuaternion.w());
}
Beispiel #26
0
//----------------------------------------------------------------------------
Castle::Castle ()
    :
    WindowApplication3("SampleGraphics/Castle", 0, 0, 800, 600,
        Float4(0.6f, 0.851f, 0.918f, 1.0f)),
    mTextColor(1.0f, 1.0f, 1.0f, 1.0f)
{
    Environment::InsertDirectory(ThePath + "Geometry/");
    Environment::InsertDirectory(ThePath + "Shaders/");
    Environment::InsertDirectory(ThePath + "Textures/");

    mPickMessage[0] = 0;
    mVerticalDistance = 5.0f;

    // Generate pick ray information.
    mNumRays = 5;
    mHalfAngle = 0.25f*Mathf::PI;
    mCos = new1<float>(mNumRays);
    mSin = new1<float>(mNumRays);
    mTolerance = new1<float>(mNumRays);
    float mult = 1.0f/(mNumRays/2);
    for (int i = 0; i < mNumRays; ++i)
    {
        float unit = i*mult - 1.0f;  // in [-1,1]
        float angle = Mathf::HALF_PI + mHalfAngle*unit;
        mCos[i] = Mathf::Cos(angle);
        mSin[i] = Mathf::Sin(angle);
        mTolerance[i] = 2.0f - 1.5f*Mathf::FAbs(unit);  // in [1/2,1]
    }
}
//----------------------------------------------------------------------------
IntersectConvexPolyhedra::IntersectConvexPolyhedra ()
    :
    WindowApplication3("SampleMathematics/IntersectConvexPolyhedra", 0, 0,
        640, 480, Float4(0.75f, 0.75f, 0.75f, 1.0f)),
        mTextColor(1.0f, 1.0f, 1.0f, 1.0f)
{
}
//----------------------------------------------------------------------------
BSplineCurveExamples::BSplineCurveExamples ()
    :
    WindowApplication2("SamplePhysics/BSplineCurveExamples", 0, 0, 128, 128,
        Float4(1.0f, 1.0f, 1.0f, 1.0f))
{
    mSpline = 0;
    mCtrlPoint = 0;
    mKnot = 0;
    mCurveType = 0;
    mModified = false;

    mLocCtrlMin[0] = 1.0f/3.0f;
    mLocCtrlMax[0] = 5.0f/6.0f;
    mLocCtrlMin[1] = 1.0f/5.0f;
    mLocCtrlMax[1] = 4.0f/5.0f;
    mLocCtrlMin[2] = 1.0f/3.0f;
    mLocCtrlMax[2] = 5.0f/6.0f;
    mLocCtrlMin[3] = 2.0f/7.0f;
    mLocCtrlMax[3] = 5.0f/7.0f;
    mLocCtrlMin[4] = 1.0f/5.0f;
    mLocCtrlMax[4] = 4.0f/5.0f;
    mLocCtrlMin[5] = 1.0f/4.0f;
    mLocCtrlMax[5] = 5.0f/8.0f;

    mSize = GetWidth();
    mV0 = mSize/16.0f;
    mV1 = 0.5f*mSize;
    mV2 = 15.0f*mSize/16.0f;
}
Beispiel #29
0
//----------------------------------------------------------------------------
Delaunay3D::Delaunay3D ()
    :
    WindowApplication3("SampleMathematics/Delaunay3D", 0, 0, 640, 480,
        Float4(1.0f, 1.0f, 1.0f, 1.0f))
{
    mDelaunay = 0;
}
//----------------------------------------------------------------------------
ReflectionsAndShadows::ReflectionsAndShadows ()
    :
    WindowApplication3("SampleGraphics/ReflectionsAndShadows", 0, 0, 640, 480,
        Float4(0.5f, 0.0f, 1.0f, 1.0f)),
        mTextColor(0.0f, 0.0f, 0.0f, 1.0f)
{
    mUpdateTime = 0.0;
}