int main( void) { HAB hab = 0; HMQ hmq = 0; HWND hwnd = 0; int nRtn = 8; QMSG qmsg; do { Morph(); hab = WinInitialize( 0); if (!hab) break; hmq = WinCreateMsgQueue( hab, 0); if (!hmq) break; // avoid compatibility problems // RWSFULLVERSION for RwsTest v0.80 is 0x08000100 if (RwsQueryVersion( 0) < RWSFULLVERSION) { WinMessageBox( HWND_DESKTOP, 0, "Please use a newer version of the RWS08 dlls", "FPos", 1, MB_OK | MB_ERROR | MB_MOVEABLE); break; } hwnd = WinLoadDlg( HWND_DESKTOP, // parent-window NULLHANDLE, // owner-window MainWndProc, // dialog proc NULLHANDLE, // EXE module handle IDD_MAIN, // dialog id NULL); // pointer to create params if (!hwnd) break; while (WinGetMsg( hab, &qmsg, NULLHANDLE, 0, 0)) WinDispatchMsg( hab, &qmsg); nRtn = 0; } while (fFalse); if (nRtn) DosBeep( 440, 150); if (hwnd) WinDestroyWindow( hwnd); if (hmq) WinDestroyMsgQueue( hmq); if (hab) WinTerminate( hab); return (nRtn); }
void Bird::HandleUpdate(StringHash eventType, VariantMap &eventData) { if (dead_ && GetPosition().y_ < -5.0f) Disable(); float timeStep = eventData[SceneUpdate::P_TIMESTEP].GetFloat(); if (sinceSpeciesSet_ < morphTime_){ Morph(); } sinceSpeciesSet_ += timeStep; if (sinceStateChange_ > stateDuration_){ switch (state_) { case BirdState::Flying: { SetState(BirdState::Landing); } break; case BirdState::Standing: { SetState(BirdState::Flying); } break; default: break; } } if(!(first_ && state_ == BirdState::Standing)) sinceStateChange_ += timeStep; switch (state_) { case BirdState::Flying: { Fly(timeStep); } break; case BirdState::Landing: { Land(timeStep); } break; case BirdState::Standing: { Stand(timeStep); } break; default: break; } //Move bird rootNode_->Translate(velocity_*timeStep, TS_WORLD); //Update rotation in accordance with the birds movement. if (velocity_.Length() > 0.01f){ Quaternion rotation = rootNode_->GetWorldRotation(); Quaternion aimRotation = rotation; aimRotation.FromLookRotation(velocity_); rootNode_->SetRotation(rotation.Slerp(aimRotation, 2.0f * timeStep * velocity_.Length())); } }
mxArray * imorph(const mxArray *msrc, const mxArray *mmask) { int dest_nrows, dest_ncols, mask_nrows,mask_ncols; int src_nrows, src_ncols; mxArray *mdest; double *src, *dest, *mask; int band_offset, row_offset, col_offset; int src_band, src_row, src_col, dest_band, dest_row, dest_col, i, j, k; src_nrows = mxGetM(msrc); src_ncols = mxGetN(msrc); mask_nrows = mxGetM(mmask); mask_ncols = mxGetN(mmask); /* Determine what dimensions the destination image should have: o if the pad method is Trim, the destination image will have smaller dimensions than the source image (by an amount corresponding to the mask size); otherwise it will have the same dimensions. */ dest_nrows = src_nrows; dest_ncols = src_ncols; if (pad_method == PadTrim) { dest_nrows -= (mask_nrows - 1); dest_ncols -= (mask_ncols - 1); if (dest_nrows <= 0 || dest_ncols <= 0) mexErrMsgTxt("Image is smaller than mask"); } /* Locate the destination. Since the operation cannot be carried out in place, we create a temporary work image to serve as the destination if dest == src or dest == mask: */ mdest = mxCreateDoubleMatrix(dest_nrows, dest_ncols, mxREAL); src = mxGetPr(msrc); dest = mxGetPr(mdest); mask = mxGetPr(mmask); /* Determine the mapping from destination coordinates + mask coordinates to source coordinates: */ if (pad_method == PadTrim) row_offset = col_offset = 0; else { row_offset = - (mask_nrows / 2); col_offset = - (mask_ncols / 2); } /* Perform the convolution over all destination rows, columns: */ switch (oper) { case OpMin: Morph(min, L1); break; case OpMax: Morph(max, L2); break; case OpDiff: Morph(max-min, L3); break; case OpPlusMin: MorphPlusMin(L4); break; } return mdest; }