int test_config(void) { printf("\n\tTouch in the mouse\n\n"); unsigned long data, res; unsigned char a[3]; mouse_subscribe(); mouse_write(MOUSE_STATUS); mouse_read(&data); while (1) { mouse_read(&data); if ((BIT(7) & data) && (BIT(3) & res)) break; } a[0] = data; while (1) { mouse_read(&data); if (data <= 3) break; } a[1] = data; tickdelay(micros_to_ticks(DELAY_US)); if (mouse_read(&data) != 0) return -1; a[2] = data; printf("\n\tCONFIGURATION\n"); printf( "\tMode: %s\n\tEnable: %d\n\tScaling: %s\n\tLB: %d\n\tMB: %d\n\tRB: %d\n\tResolution: %d count/mm\n\tSample Rate: %d\n", MODE(a[0]) ? "Remote" : "Stream", ENABLE(a[0]), SCALING(a[0]) ? "1:1" : "2:1", LEFT(a[0]), MIDDLE(a[0]), RIGHT(a[0]), RESOLUTION(a[1]), RATE(a[2])); mouse_unsubscribe(); printf("\n\tpress ANY KEY to continue\n"); mouse_read(&res); /* clear out buffer */ }
void target::id_four_targets(report_vector * reports) { //all baskets on screen. //pick lowest for bottom, highest for top, furthest left for midleft, //and the last on is midright. report_vector::iterator chosen; double cmpval = 0.0; //further up than everything //find bottom for (report_vector::iterator i = reports->begin(); i < reports->end(); ++i) { if (i->center_mass_y > cmpval) { chosen = i; } } bottom_basket.update_data_with_report(*chosen); reports->erase(chosen); //find top cmpval = (double)RESOLUTION().Y(); //further down than everything for (report_vector::iterator i = reports->begin(); i < reports->end(); ++i) { if (i->center_mass_y < cmpval) { chosen = i; } } top_basket.update_data_with_report(*chosen); reports->erase(chosen); //find left cmpval = (double)RESOLUTION().X(); for (report_vector::iterator i = reports->begin(); i < reports->end(); ++i) { if (i->center_mass_x < cmpval) { chosen = i; } } midleft_basket.update_data_with_report(*chosen); reports->erase(chosen); //should only be one element left in vector //right midright_basket.update_data_with_report(*(reports->begin())); }
void target::update_data_with_report(const ParticleAnalysisReport & r) { m_valid = true; #ifdef VISION_ALT_HEURISTIC if (ALGORITHM == TRIGONOMETRIC) { m_distance = get_distance_TRIG(r, m_height); } else if (ALGORITHM == REGRESSION) { m_distance = vision_processing::get_distance_from_report(r); } #elif defined VISION_ALT_ADHOC m_distance = vision_processing::get_distance_from_report(r); m_height = vision_processing::get_height_offset_from_report(r, m_distance); #endif m_x_offset = r.center_mass_x - (RESOLUTION().X()/2); m_fresh = true; }
#include "CIndieLib_vc2008.h" #include "FunctionalityTests.h" static const float g_testingInterval = 500.f; static const float g_maxPointPixelRatio = 3.0f; struct RESOLUTION { public: int x, y; RESOLUTION(int newx, int newy): x(newx), y(newy) {} }; //Desktop/laptop platforms #if defined (PLATFORM_WIN32) || defined (PLATFORM_LINUX) || defined (PLATFORM_OSX) static const int g_numTestedRes = 8; static RESOLUTION g_possibleRes[g_numTestedRes] = {RESOLUTION(480, 320), RESOLUTION(640, 480), RESOLUTION(800, 600), RESOLUTION(960, 640), RESOLUTION(1024, 768), RESOLUTION(1440, 900), RESOLUTION(1280,960), RESOLUTION(1920, 1200)}; #endif void FunctionalityTests::performTests(float dt) { _keyTimer += dt; //if (_timer > g_testingInterval) { //Only perform 1 test _timer = 0.0f;
static void parse_setting (PinPointPoint *point, const char *setting) { /* C Preprocessor macros implemeting a mini language for interpreting * pinpoint key=value pairs */ #define START_PARSER if (0) { #define DEFAULT } else { #define END_PARSER } #define IF_PREFIX(prefix) } else if (g_str_has_prefix (setting, prefix)) { #define IF_EQUAL(string) } else if (g_str_equal (setting, string)) { #define STRING g_intern_string (strchr (setting, '=') + 1) #define INT atoi (strchr (setting, '=') + 1) #define FLOAT g_ascii_strtod (strchr (setting, '=') + 1, NULL) #define RESOLUTION(r) parse_resolution (&r, strchr (setting, '=') + 1) #define ENUM(r,t,s) \ do { \ int _i; \ EnumDescription *_d = t##_desc; \ r = _d[0].value; \ for (_i = 0; _d[_i].name; _i++) \ if (g_strcmp0 (_d[_i].name, s) == 0) \ r = _d[_i].value; \ } while (0) START_PARSER IF_PREFIX("stage-color=") point->stage_color = STRING; IF_PREFIX("font=") point->font = STRING; IF_PREFIX("text-color=") point->text_color = STRING; IF_PREFIX("text-align=") ENUM(point->text_align, PPTextAlign, STRING); IF_PREFIX("shading-color=") point->shading_color = STRING; IF_PREFIX("shading-opacity=") point->shading_opacity = FLOAT; IF_PREFIX("duration=") point->duration = FLOAT; IF_PREFIX("command=") point->command = STRING; IF_PREFIX("transition=") point->transition = STRING; IF_PREFIX("camera-framerate=") point->camera_framerate = INT; IF_PREFIX("camera-resolution=") RESOLUTION (point->camera_resolution); IF_EQUAL("fill") point->bg_scale = PP_BG_FILL; IF_EQUAL("fit") point->bg_scale = PP_BG_FIT; IF_EQUAL("stretch") point->bg_scale = PP_BG_STRETCH; IF_EQUAL("unscaled") point->bg_scale = PP_BG_UNSCALED; IF_EQUAL("center") point->position = CLUTTER_GRAVITY_CENTER; IF_EQUAL("top") point->position = CLUTTER_GRAVITY_NORTH; IF_EQUAL("bottom") point->position = CLUTTER_GRAVITY_SOUTH; IF_EQUAL("left") point->position = CLUTTER_GRAVITY_WEST; IF_EQUAL("right") point->position = CLUTTER_GRAVITY_EAST; IF_EQUAL("top-left") point->position = CLUTTER_GRAVITY_NORTH_WEST; IF_EQUAL("top-right") point->position = CLUTTER_GRAVITY_NORTH_EAST; IF_EQUAL("bottom-left") point->position = CLUTTER_GRAVITY_SOUTH_WEST; IF_EQUAL("bottom-right") point->position = CLUTTER_GRAVITY_SOUTH_EAST; IF_EQUAL("no-markup") point->use_markup = FALSE; IF_EQUAL("markup") point->use_markup = TRUE; DEFAULT point->bg = g_intern_string (setting); END_PARSER /* undefine the overrides, returning us to regular C */ #undef START_PARSER #undef END_PARSER #undef DEFAULT #undef IF_PREFIX #undef IF_EQUAL #undef FLOAT #undef STRING #undef INT #undef ENUM #undef RESOLUTION }
double get_distance_TRIG(const ParticleAnalysisReport& r, double height) { double theta = angle_offset(RESOLUTION().Y()/2 - r.center_mass_y, RESOLUTION().Y(), FOV().Y()); return (height/std::tan(theta)); }
OP_ERROR aaOceanSOP::cookMySop(OP_Context &context) { if (lockInputs(context) >= UT_ERROR_ABORT) return error(); duplicateSource(0, context); setVariableOrder(3, 2, 0, 1); setCurGdh(0, myGdpHandle); setupLocalVars(); // variable declarations float now = context.getTime(); // Flag the SOP as being time dependent (i.e. cook on time changes) flags().timeDep = 1; // start pulling in SOP inputs and send to aaOcean enableEigens = (ENABLEEIGENS() != 0); if(pOcean->isChoppy() && enableEigens) enableEigens = TRUE; now = now + TIMEOFFSET(now); pOcean->input( RESOLUTION(), SEED(), OCEANSCALE(now), OCEANDEPTH(now), SURFACETENSION(now), VELOCITY(now), CUTOFF(now), WINDDIR(now), WINDALIGN(), DAMP(now), WAVESPEED(now), WAVEHEIGHT(now), CHOP(now), now, LOOPTIME(now), enableEigens, FALSE); // get the user-specified attribute that holds uv-data getUVAttributeName(UvAttribute); if(UvAttribute.length() == 0) UvAttribute = "uv"; const char* UVAttribName = (const char *)UvAttribute; uvRef = gdp->findFloatTuple(GA_ATTRIB_POINT, UVAttribName, 3); if(uvRef.isValid() == TRUE) { uvAttribute = uvRef.getAttribute(); uvTuple = uvRef.getAIFTuple(); } else { // uv attribute not found char msg[256]; sprintf(msg, "[aaOcean] Specified UV attribute \'%s\' not found on geometry.\ \nUV's are required for aaOcean to cook", UVAttribName); std::cout<<msg; std::cout.flush(); addError(SOP_MESSAGE, msg); unlockInputs(); return error(); } // setup local variables to output Eigens if(enableEigens) { eVecPlusRef = gdp->addFloatTuple(GA_ATTRIB_POINT, eVecPlusName, 3); eVecMinusRef = gdp->addFloatTuple(GA_ATTRIB_POINT, eVecMinusName, 3); eValuesRef = gdp->addFloatTuple(GA_ATTRIB_POINT, eValuesName, 1); eVecPlusHandle = GA_RWHandleV3(eVecPlusRef.getAttribute()); eVecMinusHandle = GA_RWHandleV3(eVecMinusRef.getAttribute()); eValuesHandle = GA_RWHandleF(eValuesRef.getAttribute()); } // inputs validated. Begin writing ocean data to output handles int npts = gdp->getNumPoints(); #pragma omp parallel for for (int pt_offset = 0; pt_offset < npts; ++pt_offset) { UT_Vector3F pos = gdp->getPos3(pt_offset); UT_Vector3F UV; uvTuple->get(uvAttribute, pt_offset, UV.data(), 3); // Houdini V coord runs in opposite direction compared to Softimage/Maya // Conforming with other apps to make ocean shape consistent across apps float u = UV.x(); float v = 1.0f - (fmod(UV.y(), 1.0f)); pos.y() += pOcean->getOceanData(u, v, aaOcean::eHEIGHTFIELD); if(pOcean->isChoppy()) { pos.x() += pOcean->getOceanData(u, v, aaOcean::eCHOPX); pos.z() += pOcean->getOceanData(u, v, aaOcean::eCHOPZ); } gdp->setPos3(pt_offset, pos); if(enableEigens) { UT_Vector3F eigenVectorPlusValue; UT_Vector3F eigenVectorMinusValue; float eigenValue; eigenVectorPlusValue.x() = pOcean->getOceanData(u, v, aaOcean::eEIGENPLUSX); eigenVectorPlusValue.y() = 0.0f; eigenVectorPlusValue.z() = pOcean->getOceanData(u, v, aaOcean::eEIGENPLUSZ); eigenVectorMinusValue.x() = pOcean->getOceanData(u, v, aaOcean::eEIGENMINUSX); eigenVectorMinusValue.y() = 0.0f; eigenVectorMinusValue.z() = pOcean->getOceanData(u, v, aaOcean::eEIGENMINUSZ); eigenValue = pOcean->getOceanData(u, v, aaOcean::eFOAM); eVecPlusHandle.set(pt_offset,eigenVectorPlusValue); eVecMinusHandle.set(pt_offset,eigenVectorMinusValue); eValuesHandle.set(pt_offset,eigenValue); } } unlockInputs(); return error(); }