Beispiel #1
0
void Camera::GenRight(const ork::fvec3& cam_pos, bool hud)
{
    ohmd_device_getf(hmd::gHMDDEV, OHMD_RIGHT_EYE_GL_PROJECTION_MATRIX, mMtxP.GetArray());
    ohmd_device_getf(hmd::gHMDDEV, OHMD_RIGHT_EYE_GL_MODELVIEW_MATRIX, mMtxHMDROT.GetArray() );
    mMtxV = hud ? mMtxHMDROT : (GenShipLookatMatrix()*mMtxHMDROT);
    mMtxVP = mMtxV*mMtxP;
    mCamPos = cam_pos;
    //mMtxHMDROT.dump("right");

    if( false == hud )
        Compute();
}
Beispiel #2
0
void Context::init()
{
    gHMDCTX = ohmd_ctx_create();
    int num_devices = ohmd_ctx_probe(gHMDCTX);
    if(num_devices < 0){
        printf("failed to probe devices: %s\n", ohmd_ctx_get_error(gHMDCTX));
        exit(-1);
    }

    if( num_devices==0 )
    {
        printf( "no HMD present!, goodbye!\n");
        exit(-1);
    }

    printf( "num_devices<%d>\n", num_devices );

    for( int i=0; i<num_devices; i++ )
    {
        auto vendor = GetDevString(i,OHMD_VENDOR);
        auto product = GetDevString(i,OHMD_PRODUCT);
        auto path = GetDevString(i,OHMD_PATH);
        printf("hmd<%d> vendor<%s>\n", i, vendor.c_str() );
        printf("hmd<%d> product<%s>\n", i, product.c_str() );
        printf("hmd<%d> path<%s>\n", i, path.c_str() );
    }

    static const int khmddevno = 0;

    auto vendor = GetDevString(khmddevno,OHMD_VENDOR);
    auto product = GetDevString(khmddevno,OHMD_PRODUCT);
    auto path = GetDevString(khmddevno,OHMD_PATH);

    printf("hmd vendor<%s>\n", vendor.c_str() );
    printf("hmd product<%s>\n", product.c_str() );
    printf("hmd path<%s>\n", path.c_str() );


    gHMDDEV = ohmd_list_open_device(gHMDCTX, khmddevno);
        
    if(!gHMDDEV){
        printf("failed to open device: %s\n", ohmd_ctx_get_error(gHMDCTX));
        exit(-1);
    }

    Resolution res = GetResolution();
    DistortionK dk = GetDistortionK();

    float lens_sep = GetFloat(OHMD_LENS_HORIZONTAL_SEPARATION);
    float lens_vctr = GetFloat(OHMD_LENS_VERTICAL_POSITION);
    float fov_l = GetFloat(OHMD_LEFT_EYE_FOV);
    float fov_r = GetFloat(OHMD_RIGHT_EYE_FOV);
    float asp_l = GetFloat(OHMD_LEFT_EYE_ASPECT_RATIO);
    float asp_r = GetFloat(OHMD_RIGHT_EYE_ASPECT_RATIO);

    printf("hmd resolution<%d %d>\n", res.x, res.y );
    printf("hmd lens separation<%f>\n", lens_sep );
    printf("hmd lens vcenter<%f>\n", lens_vctr );
    printf("hmd left FOV<%f>\n", fov_l );
    printf("hmd left ASPECT<%f>\n", asp_l );
    printf("hmd right FOV<%f>\n", fov_r );
    printf("hmd right ASPECT<%f>\n", asp_r );

    const auto&k = dk.k;


    printf("hmd distortion K<%f %f %f %f %f %f>\n", k[0], k[1], k[2], k[3], k[4], k[5] );

    ohmd_device_getf(gHMDDEV, OHMD_EYE_IPD, &gIPD);

    gIPD = 0.043f;
    printf( "IPD<%f>\n", gIPD );

}
Beispiel #3
0
RotQuat Context::GetRotQuat()
{
    RotQuat r;
    ohmd_device_getf(gHMDDEV, OHMD_ROTATION_QUAT, &r.q[0]); // this API call seems unsafe - no length passed in
    return r;
}
Beispiel #4
0
DistortionK GetDistortionK()
{
    DistortionK rval;
    ohmd_device_getf(gHMDDEV, OHMD_DISTORTION_K, &rval.k[0]); // this API call seems unsafe - no length passed in
    return rval;
}
Beispiel #5
0
static float GetFloat(ohmd_float_value ienum)
{
    float rval;
    ohmd_device_getf(gHMDDEV, ienum, &rval); // this API call seems unsafe - no length passed in
    return rval;
}
Beispiel #6
0
int main(int argc, char** argv)
{
	float fval; int ival;
	(void)argc; (void)argv;
	ohmd_context* ctx = ohmd_ctx_create();

	int num_devices = ohmd_ctx_probe(ctx);
	if(num_devices < 0){
		printf("failed to probe devices: %s\n", ohmd_ctx_get_error(ctx));
		return -1;
	}

	printf("num devices: %d\n", num_devices);

	for(int i = 0; i < num_devices; i++){
		printf("vendor: %s\n", ohmd_list_gets(ctx, i, OHMD_VENDOR));
		printf("product: %s\n", ohmd_list_gets(ctx, i, OHMD_PRODUCT));
		printf("path: %s\n", ohmd_list_gets(ctx, i, OHMD_PATH));
	}

	ohmd_device* hmd = ohmd_list_open_device(ctx, 0);

	ohmd_device_geti(hmd, OHMD_SCREEN_HORIZONTAL_RESOLUTION, &ival);
	printf("hres: %i\n", ival);
	ohmd_device_geti(hmd, OHMD_SCREEN_VERTICAL_RESOLUTION, &ival);
	printf("vres: %i\n", ival);

	ohmd_device_getf(hmd, OHMD_SCREEN_HORIZONTAL_SIZE, &fval);
	printf("hsize: %f\n", fval);
	ohmd_device_getf(hmd, OHMD_SCREEN_VERTICAL_SIZE, &fval);
	printf("vsize: %f\n", fval);

	ohmd_device_getf(hmd, OHMD_LENS_HORIZONTAL_SEPERATION, &fval);
	printf("lens seperation: %f\n", fval);
	ohmd_device_getf(hmd, OHMD_LENS_VERTICAL_POSITION, &fval);
	printf("lens vcenter: %f\n", fval);
	ohmd_device_getf(hmd, OHMD_LEFT_EYE_FOV, &fval);
	printf("fov: %f\n", fval);
	ohmd_device_getf(hmd, OHMD_LEFT_EYE_ASPECT_RATIO, &fval);
	printf("aspect: %f\n", fval);

	if(!hmd){
		printf("failed to open device: %s\n", ohmd_ctx_get_error(ctx));
		return -1;
	}

	for(int i = 0; i < 10000; i++){
		float q[4];

		ohmd_ctx_update(ctx);

		ohmd_device_getf(hmd, OHMD_ROTATION_QUAT, q);
		printf("quat: % 4.4f, % 4.4f, % 4.4f, % 4.4f\n", q[0], q[1], q[2], q[3]);

		ohmd_sleep(.01);
	}

	ohmd_ctx_destroy(ctx);
	
	return 0;
}
Beispiel #7
0
void hmd_prep_right()
{
    hmd_common_right();
    ohmd_device_getf(dev, OHMD_RIGHT_EYE_GL_PROJECTION_MATRIX, P);
    ohmd_device_getf(dev, OHMD_RIGHT_EYE_GL_MODELVIEW_MATRIX,  M);
}
Beispiel #8
0
void hmd_prep_left()
{
    hmd_common_left();
    ohmd_device_getf(dev, OHMD_LEFT_EYE_GL_PROJECTION_MATRIX, P);
    ohmd_device_getf(dev, OHMD_LEFT_EYE_GL_MODELVIEW_MATRIX,  M);
}