//---------------------------- bool CFlash::Update( void ) { UpdateRGB(); Draw(); return true; }
//---------------------------- // Update //---------------------------- bool COrientedParticle::Update() { // Game pausing can cause dumb time things to happen, so kill the effect in this instance if ( mTimeStart > theFxHelper.mTime ) { return false; } if (( mTimeStart < theFxHelper.mTime ) && UpdateOrigin() == false ) { // we are marked for death return false; } if ( !Cull()) { UpdateSize(); UpdateRGB(); UpdateAlpha(); UpdateRotation(); Draw(); } return true; }
void BenchmarkImages(const wxString& msg, wxDC& dc) { if ( !opts.testImages ) return; if ( opts.mapMode != 0 ) dc.SetMapMode((wxMappingMode)opts.mapMode); wxPrintf("Benchmarking %s: ", msg); fflush(stdout); wxImage image(wxSize(opts.width, opts.height), false /* don't clear */); wxStopWatch sw; for ( int n = 0; n < opts.numIters; n++ ) { UpdateRGB(image.GetData(), n); dc.DrawBitmap(image, 0, 0); } const long t = sw.Time(); wxPrintf("%ld images done in %ldms = %gus/image or %ld FPS\n", opts.numIters, t, (1000. * t)/opts.numIters, (1000*opts.numIters + t - 1)/t); }
bool FXBezier::Update( void ) { vec3_t new_origin; float ftime, time2; VectorMA( m_control1_velocity, cg.frametime * 0.001f, m_control1_acceleration, m_control1_velocity ); VectorMA( m_control2_velocity, cg.frametime * 0.001f, m_control2_acceleration, m_control2_velocity ); ftime = cg.frametime * 0.001f; time2 = ftime * ftime * 0.5f; for ( int i = 0 ; i < 3 ; i++ ) { new_origin[i] = m_control1[i] + ftime * m_control1_velocity[i] + time2 * m_control1_velocity[i]; } VectorCopy( new_origin, m_control1 ); for ( i = 0 ; i < 3 ; i++ ) { new_origin[i] = m_control2[i] + ftime * m_control2_velocity[i] + time2 * m_control2_velocity[i]; } VectorCopy( new_origin, m_control2 ); UpdateAlpha(); UpdateScale(); UpdateRGB(); return true; }
bool FXQuad::Update( void ) { UpdateRoll(); UpdateScale(); UpdateAlpha(); UpdateRGB(); return true; }
bool FXCylinder::Update( void ) { UpdateScale(); UpdateHeight(); UpdateAlpha(); UpdateRGB(); return true; }
bool FXPrimitive::Update( void ) { //Move the object UpdateOrigin(); UpdateScale(); UpdateAlpha(); UpdateRGB(); return true; }
bool FXTrail::Update( void ) { //Move the object UpdateOrigin(); UpdateTailPoint(); UpdateScale(); UpdateAlpha(); UpdateRGB(); return true; }
//---------------------------- bool CLine::Update() { // Game pausing can cause dumb time things to happen, so kill the effect in this instance if ( mTimeStart > theFxHelper.mTime ) { return false; } if ( mFlags & FX_RELATIVE ) { if ( mClientID < 0 || mClientID >= ENTITYNUM_WORLD ) { // we are somehow not bolted even though the flag is on? return false; } vec3_t dir, end; trace_t trace; // Get our current position and direction GetOrigin( mClientID, mOrigin1 ); GetDir( mClientID, dir ); if ( mFlags & FX_APPLY_PHYSICS ) { VectorMA( mOrigin1, 2048, dir, end ); theFxHelper.Trace( &trace, mOrigin1, NULL, NULL, end, mClientID, MASK_SHOT ); VectorCopy( trace.endpos, mOrigin2 ); if ( mImpactFxID > 0 ) { theFxScheduler.PlayEffect( mImpactFxID, trace.endpos, trace.plane.normal ); } } else { VectorMA( mOrigin1, mOrgOffset[0], dir, mOrigin2 ); } } UpdateSize(); UpdateRGB(); UpdateAlpha(); Draw(); return true; }
//-------------------------- // // Derived Light Class // //-------------------------- //---------------------------- // Update //---------------------------- bool CLight::Update() { // Game pausing can cause dumb time things to happen, so kill the effect in this instance if ( mTimeStart > theFxHelper.mTime ) { return false; } UpdateSize(); UpdateRGB(); Draw(); return true; }
bool FXSprite::Update( void ) { if (m_start_time > cg.time) {//i was created in the future, right after un-pausing return false; } //Move the object UpdateOrigin(); UpdateRoll(); UpdateScale(); UpdateAlpha(); UpdateRGB(); return true; }
void OnGLRender(wxPaintEvent& WXUNUSED(event)) { m_glContext->SetCurrent(*m_glCanvas); glEnable(GL_TEXTURE_2D); glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glClear(GL_COLOR_BUFFER_BIT); wxPrintf("Benchmarking %s: ", "OpenGL images"); fflush(stdout); wxStopWatch sw; for ( int n = 0; n < opts.numIters; n++ ) { UpdateRGB(g_image.GetData(), n); glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, opts.width, opts.height, GL_RGB, GL_UNSIGNED_BYTE, g_image.GetData()); glBegin(GL_QUADS); glTexCoord2f(0, 0); glVertex2f(-1.0, -1.0); glTexCoord2f(0, 1); glVertex2f(-1.0, 1.0); glTexCoord2f(1, 1); glVertex2f(1.0, 1.0); glTexCoord2f(1, 0); glVertex2f(1.0, -1.0); glEnd(); m_glCanvas->SwapBuffers(); } const long t = sw.Time(); wxPrintf("%ld images done in %ldms = %gus/image or %ld FPS\n", opts.numIters, t, (1000. * t)/opts.numIters, (1000*opts.numIters + t - 1)/t); wxTheApp->ExitMainLoop(); }
//---------------------------- // Update //---------------------------- bool CPoly::Update() { vec3_t mOldOrigin; // Game pausing can cause dumb time things to happen, so kill the effect in this instance if ( mTimeStart > theFxHelper.mTime ) { return false; } // If our timestamp hasn't exired yet, we won't even consider doing any kind of motion if ( theFxHelper.mTime > mTimeStamp ) { VectorCopy( mOrigin1, mOldOrigin ); if (( mTimeStart < theFxHelper.mTime ) && UpdateOrigin() == false ) { // we are marked for death return false; } } if ( !Cull() ) { // only rotate when our start timestamp has expired if ( theFxHelper.mTime > mTimeStamp ) { // Only rotate whilst moving if ( !VectorCompare( mOldOrigin, mOrigin1 )) { Rotate(); } } UpdateRGB(); UpdateAlpha(); Draw(); } return true; }
//---------------------------- bool CBezier::Update( void ) { float ftime, time2; ftime = cg.frametime * 0.001f; time2 = ftime * ftime * 0.5f; for ( int i = 0; i < 3; i++ ) { mControl1[i] = mControl1[i] + ftime * mControl1Vel[i] + time2 * mControl1Vel[i]; mControl2[i] = mControl2[i] + ftime * mControl2Vel[i] + time2 * mControl2Vel[i]; } UpdateSize(); UpdateRGB(); UpdateAlpha(); Draw(); return true; }
//---------------------------- bool CTail::Update() { // Game pausing can cause dumb time things to happen, so kill the effect in this instance if ( mTimeStart > theFxHelper.mTime ) { return false; } if ( !fx_freeze.integer ) { VectorCopy( mOrigin1, mOldOrigin ); } if ( mFlags & FX_RELATIVE ) { if ( mClientID < 0 || mClientID >= ENTITYNUM_WORLD ) { // the thing we are bolted to is no longer valid, so we may as well just die. return false; } vec3_t dir, org; // vec3_t right, up; vec3_t realVel, realAccel; // Get our current position and direction GetOrigin( mClientID, org ); GetDir( mClientID, dir ); vec3_t ang, ax[3]; vectoangles( dir, ang ); AngleVectors( ang, ax[0], ax[1], ax[2] ); VectorMA( org, mOrgOffset[0], ax[0], org ); VectorMA( org, mOrgOffset[1], ax[1], org ); VectorMA( org, mOrgOffset[2], ax[2], org ); // calc the real velocity and accel vectors // FIXME: if you want right and up movement in addition to the forward movement, you'll have to convert dir into a set of perp. axes and do some extra work VectorScale( ax[0], mVel[0], realVel ); VectorMA( realVel, mVel[1], ax[1], realVel ); VectorMA( realVel, mVel[2], ax[2], realVel ); VectorScale( ax[0], mAccel[0], realAccel ); VectorMA( realAccel, mAccel[1], ax[1], realAccel ); VectorMA( realAccel, mAccel[2], ax[2], realAccel ); // Get our real velocity at the current time, taking into account the effects of acceleration. NOTE: not sure if this is even 100% correct math-wise VectorMA( realVel, (theFxHelper.mTime - mTimeStart) * 0.001f, realAccel, realVel ); // Now move us to where we should be at the given time VectorMA( org, (theFxHelper.mTime - mTimeStart) * 0.001f, realVel, mOrigin1 ); // Just calc an old point some time in the past, doesn't really matter when VectorMA( org, ((theFxHelper.mTime - mTimeStart) - 3) * 0.001f, realVel, mOldOrigin ); } else if (( mTimeStart < theFxHelper.mTime ) && UpdateOrigin() == false ) { // we are marked for death return false; } if ( !Cull() ) { UpdateSize(); UpdateLength(); UpdateRGB(); UpdateAlpha(); CalcNewEndpoint(); Draw(); } return true; }
//---------------------------- // Update //---------------------------- bool CParticle::Update() { // Game pausing can cause dumb time things to happen, so kill the effect in this instance if ( mTimeStart > theFxHelper.mTime ) { return false; } if ( mFlags & FX_RELATIVE ) { if ( mClientID < 0 || mClientID >= ENTITYNUM_WORLD ) { // we are somehow not bolted even though the flag is on? return false; } vec3_t dir, org; vec3_t realVel, realAccel; float time = (theFxHelper.mTime - mTimeStart) * 0.001f; // Get our current position and direction GetOrigin( mClientID, org ); GetDir( mClientID, dir ); vec3_t ang, ax[3]; vectoangles( dir, ang ); AngleVectors( ang, ax[0], ax[1], ax[2] ); // VectorCopy( dir, ax[0] ); // CrossProduct( up, ax[0], ax[1] ); // VectorNormalize( ax[1] ); // CrossProduct( ax[0], ax[1], ax[2] ); VectorMA( org, mOrgOffset[0], ax[0], org ); VectorMA( org, mOrgOffset[1], ax[1], org ); VectorMA( org, mOrgOffset[2], ax[2], org ); // calc the real velocity and accel vectors VectorScale( ax[0], mVel[0], realVel ); VectorMA( realVel, mVel[1], ax[1], realVel ); VectorMA( realVel, mVel[2], ax[2], realVel ); realVel[2] += 0.5f * mGravity * time; VectorScale( ax[0], mAccel[0], realAccel ); VectorMA( realAccel, mAccel[1], ax[1], realAccel ); VectorMA( realAccel, mAccel[2], ax[2], realAccel ); // Get our real velocity at the current time, taking into account the effects of acceleartion. NOTE: not sure if this is even 100% correct math-wise VectorMA( realVel, time, realAccel, realVel ); // Now move us to where we should be at the given time VectorMA( org, time, realVel, mOrigin1 ); } else if (( mTimeStart < theFxHelper.mTime ) && UpdateOrigin() == false ) { // we are marked for death return false; } if ( !Cull()) { UpdateSize(); UpdateRGB(); UpdateAlpha(); UpdateRotation(); Draw(); } return true; }
/****************************************************************************** * * Test program * *****************************************************************************/ int main(void) { int ret; int servo; // lame TI compiler cant handle loop var declaration FPUStackingDisable(); /* Initialize the clock to run at 40 MHz */ SysCtlClockSet(SYSCTL_SYSDIV_5 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ | SYSCTL_OSC_MAIN); gSysClock = SysCtlClockGet(); /* Initialize the UART. */ SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); GPIOPinConfigure(GPIO_PA0_U0RX); GPIOPinConfigure(GPIO_PA1_U0TX); GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1); #ifdef STELLARISWARE UARTStdioInit(0); #else UARTStdioConfig(0, 115200, gSysClock); #endif UARTprintf("\n\nServoBoard-Test\n---------------\n"); /* Initialize the GPIO port for the RGB LED */ SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, RGB_PINS); GPIOPinWrite(GPIO_PORTF_BASE, RGB_PINS, 0); /* Initialize the battery monitor * Use zeroes for parameter so default calibration will be used */ Servo_BatteryInit(0, 0); /* Initialize servos for 20 msec */ ret = Servo_Init(gSysClock, 20000); if(ret) { UARTprintf("error calling ServoInit\n"); return 0; } /* Enter loop to initialize all the servos in the system */ for(servo = 0; servo < NUM_SERVOS; servo++) { /* Associate each servo ID with a hardware timer (and A or B half) */ hServo[servo] = Servo_Config(servoInfo[servo].timer, servoInfo[servo].half); if(hServo[servo] == 0) { UARTprintf("error config servo %d\n", servo); return 0; } /* Delay a bit before initting the next servo. This is done to * spread out the servo pulses so they do not all happen at the * same time and load down the power supply. * The delay value was determined experimentally. If the * system clock frequency is changed then the delay value needs to * be changed */ SysCtlDelay(22000); } /* Set each servo position to 0 to start, with 100 ms delay */ for(servo = 0; servo < NUM_SERVOS; servo++) { /* Set the servo motion rate */ Servo_SetMotionParameters(hServo[servo], 200); Servo_SetPosition(hServo[servo], 0); SysCtlDelay((gSysClock / 10) / 3); } // MoveAll(0xFFF, 0); /* In this loop we just move all the servos between +45 and * -45 deg (uncalibrated). There is a 100 ms delay between each * servo, so that if observed with a scope each servo does not have * the exact same timing. */ while(1) { /* Move all servos to -45 deg, with 100 ms between each servo */ for(servo = 0; servo < NUM_SERVOS; servo++) { UpdateRGB(); MoveOne(servo, -450); DelayMs(100); } /* Now move all servos to +45 deg, with 100 ms delay */ for(servo = 0; servo < NUM_SERVOS; servo++) { UpdateRGB(); MoveOne(servo, 450); DelayMs(100); } /* Read the battery voltage and print to the terminal */ uint32_t bat = Servo_ReadBatteryMv(); UARTprintf("%u.%02u V\n", bat / 1000, (bat % 1000) / 10); } #ifndef ccs // prevent warning from TI ccs compiler return(0); #endif }