Example #1
0
void max_jit_kinect2_outputmatrix(t_max_jit_kinect2 *x)
{
    long outputmode = max_jit_mop_getoutputmode(x);
    void *mop = max_jit_obex_adornment_get(x,_jit_sym_jit_mop);
    t_jit_err err;

    
    if (outputmode && mop)
    {
        //always output unless output mode is none
        if (outputmode==2) // pass input case, but since jit.kinect2 has no input then this means no output
        {
            return;
        }
        
        if (outputmode==1)
        {
            if ((err = (t_jit_err)jit_object_method(max_jit_obex_jitob_get(x), _jit_sym_matrix_calc,
                                                   jit_object_method(mop,_jit_sym_getinputlist),
                                                   jit_object_method(mop,_jit_sym_getoutputlist))))
            {
                if (err != JIT_ERR_HW_UNAVAILABLE) jit_error_code(x,err);
                return;
            }
        }
        max_jit_mop_outputmatrix(x);
    }
}
Example #2
0
void max_jit_leap_outputmatrix(t_max_jit_leap *x)
{
	long outputmode = max_jit_mop_getoutputmode(x);
	void *mop = max_jit_obex_adornment_get(x,_jit_sym_jit_mop);
	t_jit_err err;	
	
	if (outputmode && mop) //always output unless output mode is none
	{
		if (outputmode == 1)
		{
			if ((err=(t_jit_err)jit_object_method(max_jit_obex_jitob_get(x),	_jit_sym_matrix_calc, jit_object_method(mop,_jit_sym_getinputlist), jit_object_method(mop,_jit_sym_getoutputlist))))
			{
				jit_error_code(x,err); 
			}
			else
			{
				max_jit_mop_outputmatrix(x);
			}
		}
		else
		{
			max_jit_mop_outputmatrix(x);
		}
	}	
}
void max_jit_realsense_grab_outputmatrix(t_max_jit_realsense_grab *x)
{
//	post("%s", __FUNCTION__);
	t_atom a;
	long outputmode = max_jit_mop_getoutputmode(x);
	void *mop = max_jit_obex_adornment_get(x, _jit_sym_jit_mop);
	t_jit_err err;

	if (outputmode&&mop)
	{ //always output unless output mode is none
		if (outputmode == 1)
		{
			if (err = (t_jit_err)jit_object_method(
				max_jit_obex_jitob_get(x),
				_jit_sym_matrix_calc,
				jit_object_method(mop, _jit_sym_getinputlist),
				jit_object_method(mop, _jit_sym_getoutputlist)))
			{
				jit_error_code(x, err);
			}
			else {
				max_jit_mop_outputmatrix(x);
			}
		}
		else {
			max_jit_mop_outputmatrix(x);
		}
	}
}
Example #4
0
void
PenizeBang(
	msobPenize* me)
	
	{
	
	if (max_jit_mop_getoutputmode(me) != 0) {
		jcobPenize* jitOb = (jcobPenize*) max_jit_obex_jitob_get(me);
		
		SendDataToOutlet(jitOb, gSymGetDiffs, me->coreObject.o_outlet);
		}

	}
Example #5
0
void max_jit_3m_bang(t_max_jit_3m *x)
{
	long ac;
	void *o;
	
	if (max_jit_mop_getoutputmode(x)&&x->av) {
		o=max_jit_obex_jitob_get(x);
		//passing in memory to attr function. be sure object knows how to handle this
		ac=JIT_MATRIX_MAX_PLANECOUNT;
		jit_object_method(o,ps_getmax,&ac,&(x->av));
		if (ac>1)
			outlet_anything(x->maxout,_jit_sym_list,ac,x->av);
		else {
			if (x->av->a_type==A_FLOAT)
				outlet_float(x->maxout,jit_atom_getfloat(x->av));
			else 
				outlet_int(x->maxout,jit_atom_getlong(x->av));
		}
		ac=JIT_MATRIX_MAX_PLANECOUNT;
		jit_object_method(o,ps_getmean,&ac,&(x->av));
		if (ac>1)
			outlet_anything(x->meanout,_jit_sym_list,ac,x->av);
		else {
			if (x->av->a_type==A_FLOAT)
				outlet_float(x->meanout,jit_atom_getfloat(x->av));
			else 
				outlet_int(x->meanout,jit_atom_getlong(x->av));
		}
		ac=JIT_MATRIX_MAX_PLANECOUNT;
		jit_object_method(o,ps_getmin,&ac,&(x->av));
		if (ac>1)
			outlet_anything(x->minout,_jit_sym_list,ac,x->av);
		else {
			if (x->av->a_type==A_FLOAT)
				outlet_float(x->minout,jit_atom_getfloat(x->av));
			else 
				outlet_int(x->minout,jit_atom_getlong(x->av));
		}
	}
}
void max_jit_SDIF_buffer_outputmatrix(t_max_jit_SDIF_buffer *x){
	t_atom a;
	long outputmode=max_jit_mop_getoutputmode(x);
	void *mop=max_jit_obex_adornment_get(x,_jit_sym_jit_mop);
	t_jit_err err;	
	
	if (outputmode&&mop) { //always output unless output mode is none
		if (outputmode==1) {
			if (err=(t_jit_err)jit_object_method(
				max_jit_obex_jitob_get(x), 
				_jit_sym_matrix_calc,
				jit_object_method(mop,_jit_sym_getinputlist),
				jit_object_method(mop,_jit_sym_getoutputlist),
				x->t_matrix))
			{
				jit_error_code(x,err); 
			} else {
				max_jit_mop_outputmatrix(x);
			}
		}
	}	
}
Example #7
0
void max_jit_openni_outputmatrix(t_max_jit_openni *x)
{
	long outputmode = max_jit_mop_getoutputmode(x);
	void *mop = max_jit_obex_adornment_get(x,_jit_sym_jit_mop);
	t_jit_openni *pJit_OpenNI = (t_jit_openni *)max_jit_obex_jitob_get(x);
	t_jit_err err;	
	t_atom osc_argv[16];			// max number of atoms/values after the message selector
	char osc_string[MAX_LENGTH_STR_JOINT_NAME + 10];	// max joint string + 9 for "/skel/xx/" + terminating null
	char *msg_selector_string;
	int i, j, k;
	const char strSkelFormatOutput[3][12] = { "/skel/%u/%s", "skel", "/joint" };		// switchable skeleton output format selectors
	// the [2] format string below should be an unsigned %u, however OSCeleton codebase incorrectly uses %d so I also use it here for compatibility
	const char strUserCoMFormatOutput[3][9] = { "/user/%u", "user", "/user/%d" };		// switchable user CoM output format selectors
	const char strFloorFormatOutput[3][7] = { "/floor", "floor", "/floor" };			// switchable floor output format selectors
		
	LOG_DEBUG("starting custom outputmatrix()");
	if (outputmode && mop)
	{
		//always output unless output mode is none
		if (outputmode==2) // pass input case, but since jit.openni has no input then this means no output
		{
			LOG_DEBUG("bypassing matrix_calc(), bypassing outputmatrix()");
			return;
		}

		if (outputmode==1)
		{
			LOG_DEBUG("about to call matrix_calc from custom outputmatrix");
			if (err = (t_jit_err)jit_object_method(max_jit_obex_jitob_get(x), _jit_sym_matrix_calc,
				  jit_object_method(mop,_jit_sym_getinputlist),
				  jit_object_method(mop,_jit_sym_getoutputlist)))
			{
				if (err != JIT_ERR_HW_UNAVAILABLE) jit_error_code(x,err);
				return;
			}
		}

		// output floor from scene generator
		if (pJit_OpenNI->hProductionNode[SCENE_GEN_INDEX] && pJit_OpenNI->bOutputSceneFloor)
		{
			msg_selector_string = (char *)strFloorFormatOutput[x->chrSkeletonOutputFormat];
			atom_setfloat(&(osc_argv[0]), pJit_OpenNI->planeFloor.ptPoint.X);
			atom_setfloat(&(osc_argv[1]), pJit_OpenNI->planeFloor.ptPoint.Y);
			atom_setfloat(&(osc_argv[2]), pJit_OpenNI->planeFloor.ptPoint.Z);
			atom_setfloat(&(osc_argv[3]), pJit_OpenNI->planeFloor.vNormal.X);
			atom_setfloat(&(osc_argv[4]), pJit_OpenNI->planeFloor.vNormal.Y);
			atom_setfloat(&(osc_argv[5]), pJit_OpenNI->planeFloor.vNormal.Z);
			outlet_anything(x->osc_outlet, gensym(msg_selector_string), 6, osc_argv);
		}

		// output seen users' centers of mass and skeletons
		for (i=0; i<pJit_OpenNI->iNumUsersSeen; i++)
		{
			short iNumAtoms = 0;
			
			// output user center of mass
			switch (x->chrSkeletonOutputFormat)
			{
			case 0:	// default jit.openni skeleton OSC output format
			case 2: // legacy OSCeleton format
				snprintf_zero(osc_string, sizeof(osc_string), strUserCoMFormatOutput[x->chrSkeletonOutputFormat], pJit_OpenNI->pUserSkeletonJoints[i].userID);
				msg_selector_string = osc_string;
				break;
			case 1: // native max route compatible format
				msg_selector_string = (char *)strUserCoMFormatOutput[1];
				atom_setlong(osc_argv + (iNumAtoms++), pJit_OpenNI->pUserSkeletonJoints[i].userID);
				break;
			}
			atom_setfloat(osc_argv + (iNumAtoms++), pJit_OpenNI->pUserSkeletonJoints[i].userCoM.X);
			atom_setfloat(osc_argv + (iNumAtoms++), pJit_OpenNI->pUserSkeletonJoints[i].userCoM.Y);
			atom_setfloat(osc_argv + (iNumAtoms++), pJit_OpenNI->pUserSkeletonJoints[i].userCoM.Z);
			outlet_anything(x->osc_outlet, gensym(msg_selector_string), iNumAtoms, osc_argv);

			// output skeletons
			if (pJit_OpenNI->pUserSkeletonJoints[i].bUserSkeletonTracked)
			{
				for (j=1; j<= NUM_OF_SKELETON_JOINT_TYPES; j++)
				{
					if (pJit_OpenNI->pUserSkeletonJoints[i].jointTransform[j].position.fConfidence >= pJit_OpenNI->fPositionConfidenceFilter &&
							( pJit_OpenNI->bOutputSkeletonOrientation ?
							(pJit_OpenNI->pUserSkeletonJoints[i].jointTransform[j].orientation.fConfidence >= pJit_OpenNI->fOrientConfidenceFilter) : true))
					{
						iNumAtoms = 0;

						switch (x->chrSkeletonOutputFormat)
						{
						case 0:	// default jit.openni skeleton output format "/skel/%u/%s"
							snprintf_zero(osc_string, sizeof(osc_string), strSkelFormatOutput[0], pJit_OpenNI->pUserSkeletonJoints[i].userID, strJointNames[j]);
							msg_selector_string = osc_string;
							break;
						case 1: // skeleton output "skel %u %s" to easily use with standard max route object
							msg_selector_string = (char *)strSkelFormatOutput[1];
							atom_setlong(osc_argv + (iNumAtoms++), pJit_OpenNI->pUserSkeletonJoints[i].userID);
							atom_setsym(osc_argv + (iNumAtoms++), gensym(strJointNames[j]));
							break;
						case 2: // skeleton output "/joint %s %u" same format as OSCeleton's default output with no orientation and no OSCeleton's legacy "normalized" values
							msg_selector_string = (char *)strSkelFormatOutput[2];
							atom_setsym(osc_argv + (iNumAtoms++), gensym(strJointNames[j]));
							atom_setlong(osc_argv + (iNumAtoms++), pJit_OpenNI->pUserSkeletonJoints[i].userID);
							break;
						}
						atom_setfloat(osc_argv + (iNumAtoms++), pJit_OpenNI->pUserSkeletonJoints[i].jointTransform[j].position.position.X);
						atom_setfloat(osc_argv + (iNumAtoms++), pJit_OpenNI->pUserSkeletonJoints[i].jointTransform[j].position.position.Y);
						atom_setfloat(osc_argv + (iNumAtoms++), pJit_OpenNI->pUserSkeletonJoints[i].jointTransform[j].position.position.Z);

						if (x->chrSkeletonOutputFormat != 2)
						{						
							atom_setfloat(osc_argv + (iNumAtoms++), pJit_OpenNI->pUserSkeletonJoints[i].jointTransform[j].position.fConfidence);
						}

						if (pJit_OpenNI->bOutputSkeletonOrientation && (x->chrSkeletonOutputFormat != 2))
						{
							// General belief and https://groups.google.com/forum/#!topic/openni-dev/-ib1yX-o0lk say that OpenNI stores the
							// orientation matrix in row-major order.
							// X axis = (elements[0], elements[3], elements[6])
							// Y axis = (elements[1], elements[4], elements[7])
							// Z axis = (elements[2], elements[5], elements[8])
							// Just in case, column major order is easy to substitute with: for (k=0; k<9; k++) atom_setfloat(osc_argv + iAtomOffset + 4 + k, pJit_OpenNI->pUserSkeletonJoints[i].jointTransform[j].orientation.orientation.elements[k]);
							for (k=0; k<3; k++)
							{
								atom_setfloat(osc_argv + (iNumAtoms++), pJit_OpenNI->pUserSkeletonJoints[i].jointTransform[j].orientation.orientation.elements[k]);
								atom_setfloat(osc_argv + (iNumAtoms++), pJit_OpenNI->pUserSkeletonJoints[i].jointTransform[j].orientation.orientation.elements[k+3]);
								atom_setfloat(osc_argv + (iNumAtoms++), pJit_OpenNI->pUserSkeletonJoints[i].jointTransform[j].orientation.orientation.elements[k+6]);
							}
							if (x->chrSkeletonOutputFormat != 2)
							{
								atom_setfloat(osc_argv + (iNumAtoms++), pJit_OpenNI->pUserSkeletonJoints[i].jointTransform[j].orientation.fConfidence);
							}
						}
						outlet_anything(x->osc_outlet, gensym(msg_selector_string), iNumAtoms, osc_argv);
					}
				}
			}
		}

		LOG_DEBUG("now calling outputmatrix()");
		max_jit_mop_outputmatrix(x);
		LOG_DEBUG("called outputmatrix()");
	}	
}