Exemplo n.º 1
0
Transform::Transform(const glm::vec3 &translation,
                     const glm::vec3 &rotation,
                     const glm::vec3 &scale)
    : _translation(translation),
      _rotation(rotation),
      _scale(scale) {
  calculateMatrices();
}
Exemplo n.º 2
0
void Transform::setTransform(
    const glm::vec3 &translation,
    const glm::vec3 &rotation,
    const glm::vec3 &scale) {
  _translation = translation;
  _rotation = rotation;
  _scale = scale;
  calculateMatrices();
}
Exemplo n.º 3
0
bool Light::fromXml(PropertyBag &xml)
{
	destroy();

	xml.get("constantAttenuation", constantAttenuation);
	xml.get("linearAttenuation", linearAttenuation);
	xml.get("quadraticAttenuation", quadraticAttenuation);
	xml.get("lightPosition", lightPosition);;
	xml.get("pointLight", pointLight);
	xml.get("lightDirection", lightDirection);
	xml.get("spotAngle", spotAngle);
	xml.get("spotExponent", spotExponent);
	xml.get("enable", enable);

	calculateMatrices();

    return true;
}
Exemplo n.º 4
0
void Shadow::update(const ActorSet &zoneActors, float deltaTime)
{
	if(light!=0 && zoneActors.isMember(actorID))
	{
		const Actor &actor = zoneActors.get(actorID);

		// Update the shadow when something has changed
		needsUpdate |= (actor.hasAnimated || actor.hasMoved);

		// Update when necessary or requested
		if(needsUpdate)
		{
			float lx=0, ly=0;

			calculateAngularSpread(actor, lightViewMatrix, lx, ly);

			calculateMatrices(*light, actor, shadowMapSize, lightProjectionMatrix, lightViewMatrix, textureMatrix, lx, ly);

			frustum = calculateFrustum(lightProjectionMatrix, lightViewMatrix);

			if(g_Application.displayDebugData)
			{
				calculateFrustumVertices(*light, actor, lx, ly, ntl, ntr, nbl, nbr, ftl, ftr, fbl, fbr);
			}

			renderToShadow(shadowMapTexture, shadowMapSize, actor, lightProjectionMatrix, lightViewMatrix);

			needsUpdate=false;
		}

		// Periodically take some time to determine the actors that be receiving this shadow
		periodicTimer-=deltaTime;
		if(periodicTimer<0)
		{
			periodicTimer = 250.0f + FRAND_RANGE(100.0f, 250.0f); // stagger
			receivers = calculateReceivers(zoneActors, lightProjectionMatrix, lightViewMatrix);
		}
	}
}
Exemplo n.º 5
0
void Transform::setScale(const glm::vec3 &scale) {
  _scale = scale;
  calculateMatrices();
}
Exemplo n.º 6
0
void Transform::setRotation(const glm::vec3 &rotation) {
  _rotation = rotation;
  calculateMatrices();
}
Exemplo n.º 7
0
void Transform::setTranslation(const glm::vec3 &translation) {
  _translation = translation;
  calculateMatrices();
}
Exemplo n.º 8
0
static
void
paralellJacobi(struct calculation_arguments const* arguments, struct calculation_results *results, struct options const* options)
{
    int rank, num_procs;
    MPI_Status status;
    
    
    MPI_Init(arguments->argc, arguments->argv);
    MPI_Comm_rank(MPI_COMM_WORLD, &rank);
    MPI_Comm_size(MPI_COMM_WORLD, &num_procs);
    
    if(rank == 0)
        calculateMatrices(arguments, num_procs);
    
    int i, j;                                   /* local variables for loops  */
    int m1, m2;                                 /* used as indices for old and new matrices       */
    double star;                                /* four times center value minus 4 neigh.b values */
    double residuum;                            /* residuum of current iteration                  */
    double maxresiduum;                         /* maximum residuum value of a slave in iteration */
    
    int const N = arguments->N;
    double const h = arguments->h;
    
    double pih = 0.0;
    double fpisin = 0.0;
    
    int term_iteration = options->term_iteration;
    
    int sendRec_before = (rank - 1) % num_procs;
    int sendRec_after = rank + 1 % num_procs;
    m1 = 0;
    m2 = 1;
    
    
    if (options->inf_func == FUNC_FPISIN)
    {
        pih = PI * h;
        fpisin = 0.25 * TWO_PI_SQUARE * h * h;
    }
    
    while (term_iteration > 0)
    {
        double** Matrix_Out = getMyMatrix(arguments->start[rank], arguments->moveSize[rank], m1, arguments);
        double** Matrix_In  = getMyMatrix(arguments->start[rank], arguments->moveSize[rank], m2, arguments);
        
        maxresiduum = 0;
        
        
        if ((rank % 2) == 0)
        {
            if (rank == 0)
            {
                /*TODO: Sendplätze überprüfen, Sendetypen überprüfen */
                MPI_Send(&Matrix_In[arguments->moveSize[rank] - 1], 1, MPI_DOUBLE, sendRec_after, TAG_SEND, MPI_COMM_WORLD);
                MPI_Recv(&Matrix_In[arguments->moveSize[rank]], 1, MPI_DOUBLE,sendRec_after, TAG_RECV, MPI_COMM_WORLD, NULL);
                
            }
            else if (rank == num_procs -1)
            {
                MPI_Send(&Matrix_In[arguments->moveSize[rank] - 1], 1, MPI_DOUBLE, sendRec_before, TAG_SEND, MPI_COMM_WORLD);
                MPI_Recv(&Matrix_In[0], 1, MPI_DOUBLE,  sendRec_before, TAG_RECV, MPI_COMM_WORLD, NULL);
            }
            else
            {
                MPI_Send(&Matrix_In[1], 1, MPI_DOUBLE, sendRec_before, TAG_SEND, MPI_COMM_WORLD);
                MPI_Send(&Matrix_In[arguments->moveSize[rank] - 1], 1, MPI_DOUBLE, sendRec_after, TAG_SEND, MPI_COMM_WORLD);
                MPI_Recv(&Matrix_In[0], 1, MPI_DOUBLE,  sendRec_after, TAG_RECV, MPI_COMM_WORLD, NULL);
                MPI_Recv(&Matrix_In[arguments->moveSize[rank]], 1, MPI_DOUBLE,  sendRec_before, TAG_RECV, MPI_COMM_WORLD, NULL);
            }
        }
        else
        {
            if (rank == num_procs - 1)
            {
                MPI_Recv(&Matrix_In[0], 1, MPI_DOUBLE,  sendRec_before, TAG_RECV, MPI_COMM_WORLD, NULL);
                MPI_Send(&Matrix_In[arguments->moveSize[rank] - 1], 1, MPI_DOUBLE, sendRec_before, TAG_SEND, MPI_COMM_WORLD);
            }
            else
            {
                MPI_Recv(&Matrix_In[0], 1, MPI_DOUBLE,  sendRec_after, TAG_RECV, MPI_COMM_WORLD, NULL);
                MPI_Recv(&Matrix_In[arguments->moveSize[rank]], 1, MPI_DOUBLE,  sendRec_before, TAG_RECV, MPI_COMM_WORLD, NULL);
                MPI_Send(&Matrix_In[1], 1, MPI_DOUBLE, sendRec_before, TAG_SEND, MPI_COMM_WORLD);
                MPI_Send(&Matrix_In[arguments->moveSize[rank] - 1], 1, MPI_DOUBLE, sendRec_after, TAG_SEND, MPI_COMM_WORLD);
            }
        }
        
        
        
        /* over all rows */
        for (i = 1; i < arguments->moveSize[rank]; i++)
        {
            double fpisin_i = 0.0;
            
            if (options->inf_func == FUNC_FPISIN)
            {
                fpisin_i = fpisin * sin(pih * (double)i);
            }
            
            /* over all columns */
            for (j = 1; j < N; j++)
            {
                star = 0.25 * (Matrix_In[i-1][j] + Matrix_In[i][j-1] + Matrix_In[i][j+1] + Matrix_In[i+1][j]);
                
                if (options->inf_func == FUNC_FPISIN)
                {
                    star += fpisin_i * sin(pih * (double)j);
                }
                
                if (options->termination == TERM_PREC || term_iteration == 1)
                {
                    residuum = Matrix_In[i][j] - star;
                    residuum = (residuum < 0) ? -residuum : residuum;
                    maxresiduum = (residuum < maxresiduum) ? maxresiduum : residuum;
                }
                
                Matrix_Out[i][j] = star;
            }
        }
        
        results->stat_iteration++;
        results->stat_precision = maxresiduum;
        
        
        /* exchange m1 and m2 */
        i = m1;
        m1 = m2;
        m2 = i;
        
        
        
        /* check for stopping calculation, depending on termination method */
        if (options->termination == TERM_PREC)
        {
            if (maxresiduum < options->term_precision)
            {
                term_iteration = 0;
            }
        }
        else if (options->termination == TERM_ITER)
        {
            term_iteration--;
        }
    }
    
    DisplayMatrixMPI(arguments, results, options, rank, num_procs, arguments->start[rank], (arguments->moveSize[rank] + arguments->start[rank]));
    
    results->m = m2;
}