コード例 #1
0
ファイル: chunk.cpp プロジェクト: Jojendersie/Monolith
	// ********************************************************************* //
	void ChunkBuilder::RecomputeVertexBuffer( Chunk& _chunk )
	{
		VoxelVertex* vertexBuffer = (VoxelVertex*)malloc(CHUNK_SIZE*CHUNK_SIZE*CHUNK_SIZE*sizeof(VoxelVertex));

		// If it is dirty update the subtree
		Model::ModelData::SVON* node = _chunk.m_modelData->Get( IVec3(_chunk.m_root), _chunk.m_root[3] );
		if( node->Data().IsDirty() )
		{
			node->Traverse( _chunk.m_root, UpdateInner() );
			node->TraverseEx( _chunk.m_root, UpdateMaterial(),
				_chunk.m_modelData->Get( IVec3(_chunk.m_root[0]-1, _chunk.m_root[1]  , _chunk.m_root[2]  ), _chunk.m_root[3] ),
				_chunk.m_modelData->Get( IVec3(_chunk.m_root[0]+1, _chunk.m_root[1]  , _chunk.m_root[2]  ), _chunk.m_root[3] ),
				_chunk.m_modelData->Get( IVec3(_chunk.m_root[0]  , _chunk.m_root[1]-1, _chunk.m_root[2]  ), _chunk.m_root[3] ),
				_chunk.m_modelData->Get( IVec3(_chunk.m_root[0]  , _chunk.m_root[1]+1, _chunk.m_root[2]  ), _chunk.m_root[3] ),
				_chunk.m_modelData->Get( IVec3(_chunk.m_root[0]  , _chunk.m_root[1]  , _chunk.m_root[2]-1), _chunk.m_root[3] ),
				_chunk.m_modelData->Get( IVec3(_chunk.m_root[0]  , _chunk.m_root[1]  , _chunk.m_root[2]+1), _chunk.m_root[3] ) );
		}

		// Newest method O(k): run over surface only
		FillBuffer FillP;
		FillP.appendBuffer = vertexBuffer;
		FillP.level = _chunk.m_root[3] - _chunk.m_depth;
		FillP.pmin = (IVec3(_chunk.m_root) << (_chunk.m_root[3] - FillP.level));
		// Using all neighbors == none creates at least the voxels at the chunk boundary.
		// These extra voxels solve a problem when deleting things in a neighbor chunk.
		// Without there would be noticeable holes due to not updating this chunk.
		node->Traverse( _chunk.m_root, FillP );
		int numVoxels = int(FillP.appendBuffer - vertexBuffer);

		if( numVoxels )
			_chunk.m_voxels.GetBuffer(0)->SetData((void*&)vertexBuffer, numVoxels * sizeof(VoxelVertex));
		else free(vertexBuffer);
	}
コード例 #2
0
ファイル: Drawable2D.cpp プロジェクト: reattiva/Urho3D
void Drawable2D::ApplyAttributes()
{
    if (materialUpdatePending_)
    {
        materialUpdatePending_ = false;
        UpdateMaterial();
    }
}
コード例 #3
0
	void SkyboxRenderObject::Initialize(AABBox3& box)
	{
		bbox = box;
		
		CreateRenderData();
		BuildSkybox();
		UpdateMaterial();
	}
コード例 #4
0
ファイル: Drawable2D.cpp プロジェクト: reattiva/Urho3D
void Drawable2D::SetBlendMode(BlendMode mode)
{
    if (mode == blendMode_)
        return;

    blendMode_ = mode;
    UpdateMaterial();
    MarkNetworkUpdate();
}
コード例 #5
0
ファイル: StaticSprite2D.cpp プロジェクト: boberfly/Urho3D
void StaticSprite2D::SetBlendMode(BlendMode blendMode)
{
    if (blendMode == blendMode_)
        return;

    blendMode_ = blendMode;

    UpdateMaterial();
    MarkNetworkUpdate();
}
コード例 #6
0
ファイル: StaticSprite2D.cpp プロジェクト: boberfly/Urho3D
void StaticSprite2D::SetSprite(Sprite2D* sprite)
{
    if (sprite == sprite_)
        return;

    sprite_ = sprite;
    UpdateMaterial();

    sourceBatchesDirty_ = true;
    MarkNetworkUpdate();
}
コード例 #7
0
ファイル: StaticSprite2D.cpp プロジェクト: boberfly/Urho3D
void StaticSprite2D::SetCustomMaterial(Material* customMaterial)
{
    if (customMaterial == customMaterial_)
        return;

    customMaterial_ = customMaterial;
    sourceBatchesDirty_ = true;

    UpdateMaterial();
    MarkNetworkUpdate();
}
コード例 #8
0
ファイル: Drawable2D.cpp プロジェクト: reattiva/Urho3D
void Drawable2D::SetSprite(Sprite2D* sprite)
{
    if (sprite == sprite_)
        return;

    sprite_ = sprite;
    verticesDirty_ = true;
    geometryDirty_ = true;
    UpdateMaterial();
    OnMarkedDirty(node_);
    MarkNetworkUpdate();
}
コード例 #9
0
ファイル: Drawable2D.cpp プロジェクト: reattiva/Urho3D
void Drawable2D::SetMaterial(Material* material)
{
    if (material == material_)
        return;

    material_ = material;
    // If a null material was specified, create one with defaults, otherwise clone the material so that
    // the diffuse texture can be changed according to the sprite being used
    if (!material_)
        CreateDefaultMaterial();
    else
        batches_[0].material_ = material_->Clone();
    UpdateMaterial();
    MarkNetworkUpdate();
}
コード例 #10
0
ファイル: Shader.cpp プロジェクト: AlexGreulich/HRTFVR
void Shader::Update(Transform *transform, Camera *camera, Material* mat)
{
	glm::mat4 M = transform->GetModel();
	glm::mat4 V = camera->getView();
	glm::mat4 P = camera->getProjection();

	glm::mat4 Normal = transform->getNormalMat(camera);

	glm::vec4 d = mat->getDiffuse();
	glm::vec4 a = mat->getAmbient();
	glm::vec4 s = mat->getSpecular();
	glm::vec4 e = mat->getEmissive();
	float shiny = mat->getShininess();
	
	UpdateMVP(M, V, P);
	UpdateMaterial(d, a, s, e, shiny);
	UpdateNormalMat(Normal);
	UpdateLightPosition(m_lightPosition);
	UpdateLightDirection(m_lightDirection);
}
コード例 #11
0
ファイル: feet.cpp プロジェクト: Skylion007/RifTop
void Feet::move(Ogre::Vector3 movement)
{
	if(movement.y >= 0.01f || movement.y <= -0.01f)
	{
		Ogre::Vector3 currentPosition = leftFoot->getPosition();
		if(currentPosition.x < -0.25)
		{
			currentPosition.x /=driftTogether;
		}
		else
		{
			currentPosition.x = -0.25;
		}

		currentPosition.z /=driftTogether;
		
		leftFoot->setPosition(currentPosition);

		currentPosition = rightFoot->getPosition();
		if(currentPosition.x > 0.25)
		{
			currentPosition.x /=driftTogether;
		}
		else
		{
			currentPosition.x = 0.25;
		}
		currentPosition.z /=driftTogether;
		rightFoot->setPosition(currentPosition);
	}
	else
	{
		movement.y = 0;

		moveRightFoot(movement);
		moveLeftFoot(movement);
	}

	UpdateMaterial();
}
コード例 #12
0
ファイル: plasticity_2d.cpp プロジェクト: KratosCSIC/trunk
void Plasticity2D::CalculateMaterialResponse( const Vector& StrainVector,
        const Matrix& DeformationGradient,
        Vector& StressVector,
        Matrix& AlgorithmicTangent,
        const ProcessInfo& CurrentProcessInfo,
        const Properties& props,
        const GeometryType& geom,
        const Vector& ShapeFunctionsValues,
        bool CalculateStresses,
        int CalculateTangent,
        bool SaveInternalVariables)

{
    UpdateMaterial(StrainVector, props, geom,ShapeFunctionsValues, CurrentProcessInfo);
    if (CalculateStresses==true)
    {
        CalculateStress(StrainVector, StressVector);
    }
    if(CalculateTangent==1)
    {
        CalculateStressAndTangentMatrix(StressVector,StrainVector, AlgorithmicTangent);
    }
}
コード例 #13
0
ファイル: feet.cpp プロジェクト: Skylion007/RifTop
void Feet::swapFeet()
{
	mLeftFootActive = !mLeftFootActive;
	UpdateMaterial();
}
コード例 #14
0
	void SkyboxRenderObject::SetTexture(const FilePath& texPath)
	{
		texturePath = texPath;
		UpdateMaterial();
	}
コード例 #15
0
void Isotropic_Rankine_Yield_Function::ReturnMapping(const Vector& StrainVector, const Vector& TrialStress, Vector& StressVector)
{

    if(mcurrent_Ft>0.00)
    {
        //const double& Young   = (*mprops)[YOUNG_MODULUS];
        //const double& Poisson = (*mprops)[POISSON_RATIO];
        //const double Gmodu    = Young/(2.00 * (1.00 + Poisson) );
        //const double Bulk     = Young/(3.00 * (1.00-2.00*Poisson));

        array_1d<double,3> PrincipalStress = ZeroVector(3);
        array_1d<double,3> Sigma = ZeroVector(3);
        array_1d<array_1d < double,3 > ,3> EigenVectors;
        array_1d<unsigned int,3> Order;
        //const double d3  = 0.3333333333333333333;

        const int dim =  TrialStress.size();
        Vector Stress(dim);
        Stress = ZeroVector(dim);
        /// computing the trial kirchooff strain
        SpectralDecomposition(TrialStress, PrincipalStress, EigenVectors);
        IdentifyMaximunAndMinumumPrincipalStres_CalculateOrder(PrincipalStress, Order);
        noalias(Sigma)  = PrincipalStress;
        noalias(Stress) = TrialStress;


        const bool check = CheckPlasticAdmisibility(PrincipalStress);
        if(check==true)
        {
            Vector delta_lamda;
            // return to main plane
            bool check = One_Vector_Return_Mapping_To_Main_Plane(PrincipalStress, delta_lamda,  Sigma);


            if(check==false)
            {
                //return to corner
                UpdateMaterial();
                check =  Two_Vector_Return_Mapping_To_Corner(PrincipalStress, delta_lamda, Sigma);
                if (check==false)
                {
                    //return to apex
                    UpdateMaterial();
                    Three_Vector_Return_Mapping_To_Apex (PrincipalStress, delta_lamda, Sigma);
                }
            }

            AssembleUpdateStressAndStrainTensor(Sigma,  EigenVectors,  Order, StrainVector, Stress);

            CalculatePlasticDamage(Sigma);
            Matrix PlasticTensor;
            PlasticTensor.resize(3,3,false);
            PlasticTensor = ZeroMatrix(3,3);
            /// Updating the  elastic plastic strain tensor
            for(unsigned int i=0; i<3; i++)
                noalias(PlasticTensor) +=  mPrincipalPlasticStrain_current[i] * Matrix(outer_prod(EigenVectors[Order[i]],  EigenVectors[Order[i]]));

            /// WARNING = Plane Strain
            mplastic_strain[0] = PlasticTensor(0,0);
            mplastic_strain[1] = PlasticTensor(1,1);
            mplastic_strain[2] = 2.00 * PlasticTensor(1,0);
            mplastic_strain[3] = PlasticTensor(2,2);

            //CalculatePlasticStrain(StrainVector, StressVector, mplastic_strain, Sigma[2]);
        }

        CalculateElasticStrain(Stress, mElastic_strain);

        /// WARNING = Plane Strain
        StressVector[0] = Stress[0];
        StressVector[1] = Stress[1];
        StressVector[2] = Stress[2];
        //KRATOS_WATCH("----------------------------")
    }
}
コード例 #16
0
ファイル: StaticSprite2D.cpp プロジェクト: 1vanK/Urho3D
void StaticSprite2D::OnSceneSet(Scene* scene)
{
    Drawable2D::OnSceneSet(scene);

    UpdateMaterial();
}