示例#1
0
 void move( float x, float z )
 {
   btVector3 temp = btVector3( x*getDT(), 0.0, z*getDT() );
   
   //rigidbody->translate( temp );
   
   rigidbody->applyForce(temp, btVector3(0.0, 0.0, 0.0));
 }
VarMatrixExprReturnSP LitMatrixExprReturn::convertToVarMatrixExprReturn( void ) {
	VarMatrixExprReturn::Sequence sequence;

	if ( !getSequence().empty() ) {
		SFC::DT dt = SFCTypesManager::getSingleton().getBaseDT( getDT() );
		for( Sequence::iterator sqnItr = getSequence().begin() ; sqnItr != getSequence().end() ; (void)++sqnItr ) {
			Exprs exprs = DE( *sqnItr );
			sequence.push_back(  VarExprReturn::create( getBlock(), exprs, ExprsProxyVector(), dt )  );
		}
	}

	return VarMatrixExprReturn::create( getBlock(), getDT(), sequence );
}
VarExprReturnSP LitMatrixExprReturn::convertToVarExprReturn( VarExprReturn &varExprReturn ) {
	SFC::DT dt = getDT();
//	assert( dt == varExprReturn.getDT() );

	SFCTypesManager::DimensionVector dimensionVector = SFCTypesManager::getDimensions( dt );

	if ( dimensionVector.empty() ) {
		Exprs exprs = DE( getSequence().front() );
		VarExprReturnSP varExprReturnSP = VarExprReturn::create(  getBlock(), exprs, ExprsProxyVector(), SFCTypesManager::getSingleton().getBasicType( "double" )  );
		varExprReturn.combine( "=", varExprReturnSP )->collapse();
		return VarExprReturn::create( varExprReturn );
	}

	SFCTypesManager::DimensionVector countVector( dimensionVector.size(), 0 );

	for( Sequence::iterator sqnItr = getSequence().begin() ; sqnItr != getSequence().end() ; ++sqnItr ) {

		for( unsigned int ix = 0 ; ix < (unsigned int) dimensionVector.size() ; ++ix ) {
			varExprReturn.getExprsProxyVector()[ ix ].setExprs(  IE( countVector[ ix ] )  );
		}

		Exprs exprs = BE(  varExprReturn.getExprs(), "=", DE( *sqnItr )  );
		exprs.buildUdm( getBlock(), SFC::CompoundStatement::meta_stmnt );

		for( int ix = dimensionVector.size() ; --ix >= 0 ;) {
			if ( ++countVector[ix] < dimensionVector[ix] ) break;
			countVector[ix] = 0;
		}

	}
	
	return VarExprReturn::create( varExprReturn );
}
示例#4
0
void update()
{
    //total time
    static float angle = 0.0;
    float dt = getDT();// if you have anything moving, use dt.

    // check for reverse direction
    if( rotateFlag == true )
    {
      // reverse angle
      angle = angle - (dt * M_PI/2); //move through -90 degrees a second

      // move in a circle
      model = glm::translate( glm::mat4(1.0f), glm::vec3(4.0 * sin(angle), 0.0, 4.0 * cos(angle)));
      // rotate around y axis
      model = glm::rotate(model,angle,glm::vec3(0.0f,1.0f,0.0f));
    }
    else 
    {
      // update angle
      angle += dt * M_PI/2; //move through 90 degrees a second

      // move in a circle
      model = glm::translate( glm::mat4(1.0f), glm::vec3(4.0 * sin(angle), 0.0, 4.0 * cos(angle)));
      // rotate around y axis
      model = glm::rotate(model,angle,glm::vec3(0.0f,1.0f,0.0f));
    }

    // update the state of the scene
    glutPostRedisplay();//call the display callback
}
示例#5
0
void update()
{
    //rough fps handling
    frame++;
    t4 = std::chrono::high_resolution_clock::now();

    int ret = std::chrono::duration_cast< std::chrono::duration<float> >(t4-t3).count();

    if(ret >= 1)
    {
        simConfig.lastFPS = frame;
        frame = 0;
        t3 = std::chrono::high_resolution_clock::now();
    }

    if(frame % 3 == 0 || frame != 0)
    {
        //time passed gets calculated
        float dt = getDT() * timeRate;

        //if we just exited a pause, just make the dt zero so no jerking when unpausing
        if(recentlyPaused)
        {
            dt = 0;
            recentlyPaused = false;
        }

        simEntities.tick(dt);

        simConfig.tick(dt);
    }

    // Update the state of the scene
    glutPostRedisplay();//call the display callback
}
示例#6
0
void update()
{
    //total time
    static float angle = 0.0;
    static float rotate = 0.0;
    static float MoonAngle = 0.0;
    static float MoonRotate = 0.0;

    float dt = getDT();// if you have anything moving, use dt.

    angle += (dt * M_PI/5)*(Spin); //move through 90 degrees a second
    rotate += dt * M_PI * (Rotation);
    MoonAngle += (dt * M_PI/2)*(MoonSpin);
    MoonRotate += dt * M_PI * (MoonRotation);

    model = glm::translate( glm::mat4(1.0f), glm::vec3(6.5 * sin(angle), 0.0, 6.5 * cos(angle)));
    Moon = glm::translate( model, glm::vec3(5.5 * sin(MoonAngle), 0.0, 5.5 * cos(MoonAngle)));
    model = glm::rotate( model, rotate, glm::vec3(0.0, 1.0, 0.0) );
    Moon = glm::rotate( Moon, MoonRotate, glm::vec3(0.0, 1.0, 0.2) );

    Moon = glm::scale(Moon, glm::vec3(0.75, 0.75, 0.75));
    model = glm::scale(model, glm::vec3(1.25, 1.25, 1.25));



    // Update the state of the scene
    glutPostRedisplay();//call the display callback
}
示例#7
0
文件: main.cpp 项目: csorkin09/CS-480
void update(){
     //total timeshader_stat
    	static float angle = 0.0;
	static float spin = 0.0;
    	float dt = getDT();// if you have anything moving, use dt.

     angle += dt * M_PI/2; //move through 90 degrees a second which is in radians
   
     model = glm::translate( glm::mat4(1.0f), glm::vec3(4.0 * sin(angle), 0.0, 4.0 * cos(angle)) );
	//model = glm::scale( model, glm::vec3(50.0f, 50.0f, 50.0f));
     // model is our cube
     // rotate is a function that will do matrix math with rotation matrix
     // mat4(1.0f) is our that converts result to 4x4 matrix
     // angle*100 is our alpha angle this is in degrees 
     // 3d vector to change matrix so it rotates along y
     // spins clockwise
	if (canSpin){    
     	//converts rad to angles then multiply by direction and speed of spin
          spin += speed * dir * dt * 90;   
	}
	model = model * glm::rotate(glm::mat4(1.0f), spin, glm::vec3(0.0f,1.0f, 1.0f));  
 
     // Update the state of the scene
     glutPostRedisplay();//call the dishader_statsplay callback
}
MatrixExprReturnSP LitMatrixExprReturn::appendColumns( LitMatrixExprReturn &litMatrixExprReturn ) {
	__int64 thisRows, thisColumns;
	getRowsAndColumns( thisRows, thisColumns );
	if ( thisRows == 0 ) return LitMatrixExprReturn::create( litMatrixExprReturn );

	__int64 rhsRows, rhsColumns;
	litMatrixExprReturn.getRowsAndColumns( rhsRows, rhsColumns );
	if ( rhsRows == 0 ) return LitMatrixExprReturn::create( *this );

	assert( thisRows == rhsRows );

	Sequence sequence;
	Sequence::iterator sqnItr1 = getSequence().begin();
	Sequence::iterator sqnItr2 = litMatrixExprReturn.getSequence().begin();
	for( int ix = 0 ; ix < thisRows ; (void)++ix ) {
		for ( int jx = 0 ; jx < thisColumns ; (void)++jx ) {
			sequence.push_back( *sqnItr1 );
			(void)++sqnItr1;
		}
		for ( int jx = 0 ; jx < rhsColumns ; (void)++jx ) {
			sequence.push_back( *sqnItr2 );
			(void)++sqnItr2;
		}
	}

	SFC::DT dominantDT = SFCTypesManager::getDominantType( getDT(), litMatrixExprReturn.getDT() );
	return create( getBlock(), (int) thisRows, (int) thisColumns + rhsColumns, dominantDT, sequence );
}
示例#9
0
文件: main.cpp 项目: WendyHanzer/2
void update(){
     //total time
    	static float angle = 0.0;
	static float spin = 0.0;
	static float moonspin = 0.0;
    	float dt = getDT();// if you have anything moving, use dt.

     angle += dt * M_PI/2; //move through 90 degrees a second which is in radians
   	
	//yearly rotation of planet
     model[0] = glm::translate( glm::mat4(1.0f), glm::vec3(4.0 * sin(angle), 0.0, 4.0 * cos(angle)) );
	
	//monthly orbit of the moon
	model[1] = glm::translate( model[0], glm::vec3(5.0 * sin(angle), 0.0, 5.0 * cos(angle)) );
	//the moon is 1/3 for easy identification	
	model[1] = glm::scale( model[1], glm::vec3(.3f, .3f, .3f));
	
     // model is our cube
     // rotate is a function that will do matrix math with rotation matrix
     // mat4(1.0f) is our that converts result to 4x4 matrix
     // angle*100 is our alpha angle this is in degrees 
     // 3d vector to change matrix so it rotates along y
     // spins clockwise
	if (canSpin){    
     	//converts rad to angles then multiply by direction and speed of spin
          spin += speed * dir * dt * 90;   
	}
	//moon rotation speed
	moonspin += 3 * speed * dt * 90;
	model[0] = model[0] * glm::rotate( glm::mat4(1.0f), spin, glm::vec3(0.0f,1.0f, 0.0f)); 
	//controls day and night phases of the moon
	model[1] = glm::rotate( model[1], moonspin, glm::vec3(0.0f,1.0f, 1.0f));
     // Update the state of the scene
     glutPostRedisplay();//call the display callback
}
ExprReturnSP LitMatrixExprReturn::multiply( LitMatrixExprReturn &litMatrixExprReturn ) {

	__int64 rows1, columns1;
	getRowsAndColumns( rows1, columns1 );

	__int64 rows2, columns2;
	litMatrixExprReturn.getRowsAndColumns( rows2, columns2 );

	if ( rows1 == 1 && columns1 == 1 ) {
		double multiplier = getSequence()[0];
		Sequence sequence = litMatrixExprReturn.getSequence();
		for( Sequence::iterator sqnItr = sequence.begin() ; sqnItr != sequence.end() ; (void)++sqnItr ) {
			*sqnItr *= multiplier;
		}
		return create( getBlock(), litMatrixExprReturn.getDT(), sequence );
	}

	if ( rows2 == 1 && columns2 == 1 ) {
		double multiplier = litMatrixExprReturn.getSequence()[0];
		Sequence sequence = getSequence();
		for( Sequence::iterator sqnItr = sequence.begin() ; sqnItr != sequence.end() ; (void)++sqnItr ) {
			*sqnItr *= multiplier;
		}
		return create( getBlock(), getDT(), sequence );
	}

	if ( columns1 != rows2 ) {
		if (  ( rows1 == 1 || columns1 == 1 ) && rows1 == rows2  ) std::swap( rows1, columns1 );
		else if (  ( rows2 == 1 || columns2 == 1 ) && columns1 == columns2  ) std::swap( rows2, columns2 ); 
		else { /* THROW ERROR */ }
	}

	Sequence sequence;
	Sequence &rhsSequence = litMatrixExprReturn.getSequence();
	for( long long ix = 0 ; ix < rows1 ; (void)++ix ) {
		for( long long jx = 0 ; jx < columns2 ; (void)++jx ) {
			double sum = 0;
			for( long long kx = 0 ; kx < columns1 ; (void)++kx ) {
				sum += getSequence()[ ix*rows1 + kx ] * rhsSequence[ kx*rows2 + jx ];
			}
			sequence.push_back( sum );
		}
	}

	SFC::DT dominantDT = SFCTypesManager::getDominantType( getDT(), litMatrixExprReturn.getDT() );
	return create( getBlock(), (int) rows1, (int) columns2, dominantDT, sequence );
}
示例#11
0
void update()
{
    //total time
    static float angle = 0.0, spinAngle = 0.0;
    float dt = getDT();// if you have anything moving, use dt.

    angle += dt * M_PI/2; //move through 90 degrees a second
    spinAngle = 4 * angle * 180.0/M_PI; // rotate 4 times in the 4 second circumfrance
    model = glm::translate( glm::mat4(1.0f), glm::vec3(4.0 * sin(angle), 0.0, 4.0 * cos(angle)));
    model = glm::rotate(model, spinAngle, glm::vec3(0.0f,1.0f,0.0f));
}
VarExprReturnSP LitMatrixExprReturn::convertToVarExprReturn( SFC::ArgDeclBase argDeclBase ) {

	// IF TYPE ISN'T ARRAY, THEN IT MUST BE BASIC
	if ( getDT().type() != SFC::Array::meta ) {
		double value = getSequence().front();
		// SEE IF value IS CAN BE ACCURATELY REPRESENTED AS AN INTEGER
		Exprs exprs;
		if ( int(value) <= INT_MAX && int( value ) == value ) exprs = IE( (int) value );
		else                                             exprs = DE( value );
		return VarExprReturn::create( getBlock(), exprs, ExprsProxyVector(), getDT() );
	}

	if ( argDeclBase == Udm::null ) {
		argDeclBase = SFCManager::createUniqueLocalVar( getBlock(), "result" );
		argDeclBase.dt() = getDT();
	}

	VarExprReturnSP varExprReturnSP = VarExprReturn::create( getBlock(), argDeclBase, getDT() );
	return convertToVarExprReturn( *varExprReturnSP );
}
	/* BUILDUDM */
	virtual void buildUdm(
	 SFC::CompoundStatement block, const Uml::CompositionChildRole &childRole = SFC::CompoundStatement::meta_stmnt
	) {
		if ( getDT().type() != SFC::Array::meta ) {
			getSequence().front()->buildUdm( block, childRole );
			return;
		}

		ExprReturnSP exprReturnSP = collapseLogical();
		exprReturnSP->buildUdm( block );
	}
ExprReturnSP LitMatrixExprReturn::collapseLogical() {
	if ( getDT().type() != SFC::Array::meta ) return create( *this );

	Sequence::iterator sqnItr = getSequence().begin();

	SFC::LocalVar localVar = SFCManager::createUniqueLocalVar( getBlock(), "test" );
	bool value = *sqnItr != 0;

	while( ++sqnItr != getSequence().end() ) value = value && ( *sqnItr != 0 );

	return create( getBlock(), value );
}
示例#15
0
void update()
{

    glm::vec3 tempPlayerOne = glm::vec3(objectsDataList.getModelMatrix(1)[3][0], objectsDataList.getModelMatrix(1)[3][1], objectsDataList.getModelMatrix(1)[3][2]);

    //glm::vec3 tempPlayerTwo = glm::vec3(objectsDataList.getModelMatrix(2)[3][0], objectsDataList.getModelMatrix(2)[3][1], objectsDataList.getModelMatrix(2)[3][2]);

    //glm::vec3 puckLoc = glm::vec3(objectsDataList.getModelMatrix(3)[3][0], objectsDataList.getModelMatrix(3)[3][1], objectsDataList.getModelMatrix(3)[3][2]);

    //cout << "Makes it to update!" << endl;
    float dt = getDT();
    int counter; 

    // pass dt to all objects and let them update themselves based on their
    // current flags/status
    if(!pauseBool)
    {
        dynamicsWorld->setGravity(btVector3(gravityX, -10, gravityZ)); 
        dynamicsWorld->stepSimulation(dt, 10.0f);

        for (counter = 0; counter < globalObjCount; counter++)
        {
            objectsDataList.updateObject(counter);
        }
    }

    switch(viewNum)
        {
            case 0:
                 view = glm::lookAt( glm::vec3(camX, camY, camZ), //Eye Position
                                glm::vec3(0, 0.0, 0.0), //Focus point
                                glm::vec3(0.0, 0.0, 1.0)); //Positive Y is up
                break;

            case 1:
                view = glm::lookAt( glm::vec3(tempPlayerOne.x + camX + offsetX, 30.0 + offsetY, tempPlayerOne.z + camZ + offsetZ), //Eye Position
                        glm::vec3(tempPlayerOne.x + offsetX, tempPlayerOne.y + offsetY, tempPlayerOne.z + offsetZ), //Focus point
                        glm::vec3(0.0, 0.0, 1.0)); //Positive Y is up
                break;

            case 2:
                //view = glm::lookAt( glm::vec3(tempPlayerTwo.x, 40.0, tempPlayerTwo.z), //Eye Position
                        //glm::vec3(tempPlayerTwo.x, tempPlayerTwo.y, tempPlayerTwo.z), //Focus point
                        //glm::vec3(0.0, 0.0, 1.0)); //Positive Y is up
                break;

        }

    //checkGoal();
   
    // Update the state of the scene
    glutPostRedisplay();//call the display callback    
}
示例#16
0
int main(){
  
  
  
  UsbController myCont(NORMAL);
  ttcVi *myTTC = new ttcVi(&myCont);
  scaler *s = new scaler(&myCont,0xCCCC00);
  
  myTTC->changeChannel(-1);
  myTTC->changeRandomFrequency(1);

  myTTC->resetCounter(); 
  cout<<"Starting..."<<endl;
  cout<<"Testing communication speed..."<<endl;
  for (int i=0; i<5; i++){
      struct timeval start,stop;
      gettimeofday(&start,NULL);
      for (int j=0; j<5000; j++){myTTC->getEventNumber();}
      gettimeofday(&stop,NULL);
      long int dT = getDT(start,stop);
      cout<< "Time to read 5000 values = "<<dT<<"ms "<<"rate = "<<5000./(1.*dT)<<"kHz"<<endl;
  }
  cout<<"done !"<<endl;

  cout<<"Testing random frequencies"<<endl;

  for (int i=0; i<5; i++){
      struct timeval start,stop;
      myTTC->changeRandomFrequency(i);
      int nStart = myTTC->getEventNumber();
      gettimeofday(&start,NULL);

      sleep(30);
      int nStop = myTTC->getEventNumber();
      gettimeofday(&stop,NULL);
      long int dT = getDT(start,stop);
      cout<< "Trig setting = "<<i<<"Ntrig ="<<nStop-nStart<<"    Time = "<<dT<<"ms "<<"    -> rate = "<<(nStop-nStart)/(1.*dT)<<"kHz"<<endl;
  }
}
示例#17
0
void update()
{
    //total time
    static float angle = 0.0;
    float dt = getDT();// if you have anything moving, use dt.

    angle += dt * M_PI/2; //move through 90 degrees a second
    model = glm::translate( glm::mat4(1.0f), glm::vec3(4.0 * sin(angle), 0.0, 4.0 * cos(angle)));

    // rotate cube
    model = glm::rotate( model, angle, glm::vec3(0,1,0) );
    // Update the state of the scene
    glutPostRedisplay();//call the display callback
}
示例#18
0
文件: Transient.C 项目: laizy/moose
void
Transient::init()
{
  if (!_time_stepper.get())
  {
    InputParameters pars = _app.getFactory().getValidParams("ConstantDT");
    pars.set<FEProblem *>("_fe_problem") = &_problem;
    pars.set<Transient *>("_executioner") = this;

    /**
     * We have a default "dt" set in the Transient parameters but it's possible for users to set other
     * parameters explicitly that could provide a better calculated "dt". Rather than provide difficult
     * to understand behavior using the default "dt" in this case, we'll calculate "dt" properly.
     */
    if (!_pars.isParamSetByAddParam("end_time") && !_pars.isParamSetByAddParam("num_steps") && _pars.isParamSetByAddParam("dt"))
      pars.set<Real>("dt") = (getParam<Real>("end_time") - getParam<Real>("start_time")) / static_cast<Real>(getParam<unsigned int>("num_steps"));
    else
      pars.set<Real>("dt") = getParam<Real>("dt");

    pars.set<bool>("reset_dt") = getParam<bool>("reset_dt");
    _time_stepper = MooseSharedNamespace::static_pointer_cast<TimeStepper>(_app.getFactory().create("ConstantDT", "TimeStepper", pars));
  }

  _problem.initialSetup();
  _time_stepper->init();

  if (_app.isRestarting())
    _time_old = _time;

  Moose::setup_perf_log.push("Output Initial Condition","Setup");
  _problem.outputStep(EXEC_INITIAL);
  Moose::setup_perf_log.pop("Output Initial Condition","Setup");

  // If this is the first step
  if (_t_step == 0)
    _t_step = 1;

  if (_t_step > 1) //Recover case
    _dt_old = _dt;

  else
  {
    computeDT();
//  _dt = computeConstrainedDT();
    _dt = getDT();
  }


}
示例#19
0
文件: main.cpp 项目: WendyHanzer/4y
void update()
{
    //total time
    static float transAngle = 0.0;
    static float rotAngle = 0.0;    
    float dt = getDT();// if you have anything moving, use dt.
    
    rotAngle += dt * 180/M_PI;
    transAngle += dt * M_PI/2; //move through 90 degrees a second

    rotate = glm::rotate (glm::mat4(1.0f), rotAngle, glm::vec3(0.0f,1.0f,0.0f));
    translate = glm::translate( glm::mat4(1.0f), glm::vec3(4.0 * sin(transAngle), 0.0, 4.0 * cos(transAngle)));
    model = rotate * translate;
    // Update the state of the scene
    glutPostRedisplay();//call the display callback
}
ExprReturnSP LitMatrixExprReturn::applyUnaryOp( const std::string &op ) {
	UnaryFunction unaryFunction = getUnaryFunction( op );
	if ( unaryFunction == 0 ) {
		std::cerr << "WARNING: operation \"" << op << "\" not supported on literals." << std::endl;
		VarExprReturnSP varExprReturnSP = convertToVarExprReturn();
		return varExprReturnSP->applyUnaryOp( op );
	}

	Sequence sequence;

	for( Sequence::iterator sqnItr = getSequence().begin() ; sqnItr != getSequence().end() ; (void)++sqnItr ) {
		sequence.push_back(  unaryFunction( *sqnItr )  );
	}

	return create( getBlock(), getDT(), sequence );
}
ExprReturnSP LitMatrixExprReturn::divide( LitMatrixExprReturn &litMatrixExprReturn ) {

	__int64 rows1, columns1;
	getRowsAndColumns( rows1, columns1 );
	

	__int64 rows2, columns2;
	litMatrixExprReturn.getRowsAndColumns( rows2, columns2 );
	if ( rows2 != columns2 ) {
		std::cerr << "Division not supported for non-square matrix divisor." << std::endl;
		return create( *this );
	}

	Sequence sequence;
	for( int ix = 0 ; ix < rows2 ; (void)++ix ) {
		for( int jx = 0 ; jx < rows2 ; (void)++jx ) {
			sequence.push_back( ix == jx );
		}
	}

	Sequence rhsSequence = litMatrixExprReturn.getSequence();
	for( int ix = 0 ; ix < rows2 ; (void)++ix ) {
		double num = rhsSequence[ ix * rows2 + ix ];
		if ( num == 0 ) {
			std::cerr << "Zero along diagonal detected: please fix code to deal with this" << std::endl;
			return create( *this );
		}
		for( int jx = ix ; jx < rows2 ; (void)++jx ) {
			rhsSequence[ ix * rows2 + jx ] /= num;
			sequence[ ix * rows2 + jx ] /= num;
		}
		for( int kx = 0 ; kx < rows2 ; (void)++kx ) {
			if ( kx == ix ) continue;
			double mul = rhsSequence[ kx * rows2 + ix ];
			for( int jx = ix ; jx < rows2 ; (void)++jx ) {
				rhsSequence[ kx * rows2 + jx ] -= rhsSequence[ ix * rows2 + jx ] * mul;
			}
			for( int jx = ix ; jx < rows2 ; (void)++jx ) {
				sequence[ kx * rows2 + jx ] -= sequence[ ix * rows2 + jx ] * mul;
			}
		}
	}

	SFC::DT dominantDT = SFCTypesManager::getDominantType( getDT(), litMatrixExprReturn.getDT() );
	return multiply(  create( getBlock(), (int) rows2, (int) rows2, dominantDT, sequence )  );
}
示例#22
0
文件: main.cpp 项目: Landrito/School
void update()
{
    //total time
    static float angle = 0.0;
    static float spin = 0.0;
    float dt = getDT();// if you have anything moving, use dt.

    

    angle += dt * M_PI/2 * rotationDirection * rotationSpeed; //move through 90 degrees a second
    spin += dt * M_PI * spinCube;
   
    model = glm::translate( glm::mat4(1.0f), glm::vec3(4.0 * sin(angle), 0.0, 4.0 * cos(angle)));
    model *= glm::rotate( glm::mat4(1.0f), spin, glm::vec3(0.0, 1.0, 0.0) );
    // Update the state of the scene
    glutPostRedisplay();//call the display callback
}
示例#23
0
void update()
{
    //total time
    static float rotationAngle = 0.0;
    static float orbitAngle = 0.0;
    float dt = getDT();// if you have anything moving, use dt.

    orbitAngle += dt * M_PI/2; //move through 90 degrees a second

    rotationAngle += dt * M_PI/2; //move through 90 degrees a second


    // added for the rotation of cube around itself
    model = glm::rotate( glm::mat4(1.0f), rotationAngle, glm::vec3(0.0, 1.0, 0.0));

    // Update the state of the scene
    glutPostRedisplay();//call the display callback
}
示例#24
0
void update()
{
    //total time
    static float angle = 0.0;
    float dt = getDT();// if you have anything moving, use dt.

    angle += dt * 90.0; //move through 90 degrees a second
	//because the model is not upright and it is too big to easily fix with blender
    glm::mat4 orientModel = glm::rotate( glm::mat4(1.0f), 100.0f, glm::vec3(1.0f,0.0f,0.0f));
	//spin model
    glm::mat4 rotateModel = glm::rotate( glm::mat4(1.0f), angle, glm::vec3(0.0f,1.0f,0.0f));

	//set model matrix
	model = rotateModel*orientModel;

    // Update the state of the scene
    glutPostRedisplay();//call the display callback
}
示例#25
0
文件: Transient.C 项目: rtung/moose
void
Transient::init()
{
  if (_time_stepper == NULL)
  {
    InputParameters pars = _app.getFactory().getValidParams("ConstantDT");
    pars.set<FEProblem *>("_fe_problem") = &_problem;
    pars.set<Transient *>("_executioner") = this;
    pars.set<Real>("dt") = getParam<Real>("dt");
    pars.set<bool>("reset_dt") = getParam<bool>("reset_dt");
    _time_stepper = static_cast<TimeStepper *>(_app.getFactory().create("ConstantDT", "TimeStepper", pars));
  }

  _problem.initialSetup();
  _time_stepper->init();

  Moose::setup_perf_log.push("Output Initial Condition","Setup");

  _output_warehouse.outputInitial();

  if (_output_initial)
  {
    _problem.output();
    _problem.outputPostprocessors();
    _problem.outputRestart();
  }
  Moose::setup_perf_log.pop("Output Initial Condition","Setup");

  // If this is the first step
  if (_t_step == 0)
    _t_step = 1;

  if (_t_step > 1) //Restart case
  {
    _dt_old = _dt;
  }
  else
  {
    computeDT();
//  _dt = computeConstrainedDT();
    _dt = getDT();
  }
}
MatrixExprReturnSP LitMatrixExprReturn::appendRows( LitMatrixExprReturn &litMatrixExprReturn ) {
	__int64 thisRows, thisColumns;
	getRowsAndColumns( thisRows, thisColumns );
	if ( thisRows == 0 ) return LitMatrixExprReturn::create( litMatrixExprReturn );

	__int64 rhsRows, rhsColumns;
	litMatrixExprReturn.getRowsAndColumns( rhsRows, rhsColumns );
	if ( rhsRows == 0 ) return LitMatrixExprReturn::create( *this );

	assert( thisColumns == rhsColumns );

	Sequence sequence = getSequence();
	sequence.insert(
	 sequence.end(), litMatrixExprReturn.getSequence().begin(), litMatrixExprReturn.getSequence().end()
	);

	SFC::DT dominantDT = SFCTypesManager::getDominantType( getDT(), litMatrixExprReturn.getDT() );
	return create( getBlock(), (int) thisRows + rhsRows, (int) thisColumns, dominantDT, sequence );
}
示例#27
0
文件: main.cpp 项目: csorkin09/CS-480
void update()
{
    //total time
    static float angle = 0.0;
    static float secondAngle = 0.0;

    float dt = getDT();// if you have anything moving, use dt.

    angle += dt * M_PI/2; //move through 90 degrees a second
    
    //change orbit direction
    if(flip == 1)
    {
      angle += dt * M_PI/2;
    }
    
    if(flip == 0)
    {
      angle += -2*(dt * M_PI/2);
    }

    model = glm::translate(glm::mat4(1.0f), glm::vec3(4.0 * sin(angle), 0.0, 4.0 * cos(angle)));

    moon = glm::translate(model, glm::vec3(10.0 * sin(angle), 0.0, 10.0 * cos(angle)));


    //rotate model
    if(stop == 1)
    {
      secondAngle += dt*M_PI/2;
    }

     if(reverse == 1 && stop == 1)
     {
      secondAngle += -2*(dt*M_PI/2);
     }

    model = glm::rotate(model, 50*secondAngle, glm::vec3(0,1,0));

    // Update the state of the scene
    glutPostRedisplay();//call the display callback
}
示例#28
0
int main(){
  
  
  
  UsbController myCont(NORMAL);
  ttcVi *myTTC = new ttcVi(&myCont);
  
  cout<<"Starting..."<<endl;

  for (int i=0; i<50; i++){
      struct timeval start,stop;
      int nStart = myTTC->getEventNumber();
      gettimeofday(&start,NULL);

      sleep(5);
      int nStop = myTTC->getEventNumber();
      gettimeofday(&stop,NULL);
      long int dT = getDT(start,stop);
      cout<<"Ntrig ="<<nStop-nStart<<"    Time = "<<dT<<"ms "<<"    -> rate = "<<1000*(nStop-nStart)/(1.*dT)<<"Hz"<<endl;
  }
}
void LitMatrixExprReturn::assignTo( VarExprReturnSPVector &varExprReturnSPVector ) {

	SFC::DT dt = SFCTypesManager::getSingleton().getBaseDT( getDT() );

	VarExprReturnSPVector::iterator vsvItr = varExprReturnSPVector.begin();

	for( Sequence::iterator sqnItr = getSequence().begin() ; sqnItr != getSequence().end() ; (void)++sqnItr ) {
		VarExprReturnSP varExprReturnSP = *vsvItr;
	
		if ( varExprReturnSP->getClassName() == ReferenceReturn::getName() ) {
			ReferenceReturnSP referenceReturnSP =
			 ExprReturn::static_pointer_cast< ReferenceReturn >( varExprReturnSP );
			referenceReturnSP->acquireType( dt );
		}

		Exprs exprs = BE(  varExprReturnSP->getExprs(), "=", DE( *sqnItr )  );
		exprs.buildUdm( getBlock(), SFC::CompoundStatement::meta_stmnt );

		(void)++vsvItr;
	}
}
示例#30
0
文件: main.cpp 项目: WendyHanzer/4y
void update() 
{
    //total time
    float dt = getDT();// if you have anything moving, use dt.

    //update board
    boardMesh.model=glm::rotate(glm::mat4(1.0f),float(DELTA_X_CHANGE*180/3.1415), glm::vec3(0,0,1));
    boardMesh.model=glm::rotate(boardMesh.model,float(DELTA_Y_CHANGE*180/3.1415), glm::vec3(1,0,0));


    //update sphere
    //check for collisions
    if(sphereMesh.holeTopFlag)
    {
        sphereMesh.checkBound(mazeHoles); //holes
    }
    else //if the ball is on a hole
    ballSetStart();

    if(paused == false) 
    {
        //update sphere based on collisions
        sphereMesh.updateBounds(dt); //update forces

        myPhysics.simulate(sphereMesh);
        btTransform trans;
        myPhysics.simulationBall->getMotionState()->getWorldTransform(trans);

        //update the x,y, and z
        sphereMesh.offset.x = trans.getOrigin().getX();
        sphereMesh.offset.y = trans.getOrigin().getY();
        sphereMesh.offset.z = trans.getOrigin().getZ();

        sphereMesh.model=glm::translate(glm::mat4(1.0f), glm::vec3(sphereMesh.offset.x, sphereMesh.offset.y, sphereMesh.offset.z));
        sphereMesh.model=glm::rotate(sphereMesh.model,float(DELTA_X_CHANGE*180*dt/3.1415), glm::vec3(0,0,1));
        sphereMesh.model=glm::rotate(sphereMesh.model,float(DELTA_Y_CHANGE*180*dt/3.1415), glm::vec3(1,0,0));
     }

    glutPostRedisplay();//call the display callback
}