Пример #1
0
	void Joystick::openController() {
		closeController();
		if (!SDL_IsGameController(m_deviceIndex)) {
			return;
		}

		m_controllerHandle = SDL_GameControllerOpen(m_deviceIndex);
	}
	//---------------------------------------------------------------
	void ControllerExporter::exportController( ExportNode* exportNode, Controller* controller, const String& controllerId, const String& controllerSource )
	{
		if ( controller->getControllerType() == Controller::SKIN )
			exportSkinController(exportNode, (SkinController*)controller, controllerId, controllerSource);
		else if ( controller->getControllerType() == Controller::MORPH )
			exportMorphController(exportNode, (MorphController*)controller, controllerId, controllerSource);

		closeController();
	}
Пример #3
0
	void Joystick::close() {
		closeController();
		if (m_joystickHandle) {
			SDL_JoystickClose(m_joystickHandle);
			m_joystickHandle = NULL;
		}
		m_instanceId = -1;
		m_deviceIndex = -1;
	}
Пример #4
0
        bool reopenJoystick(int j) {
#ifdef CURRENT_PLATFORM
            closeController();
            cid = j;
            return openController();
#else
            cid = j;
            return true;
#endif
        }
Пример #5
0
// ob should be of type OB_MESH
// both args are required
void ArmatureExporter::export_controller(Object* ob, Object *ob_arm)
{
	// joint names
	// joint inverse bind matrices
	// vertex weights

	// input:
	// joint names: ob -> vertex group names
	// vertex group weights: me->dvert -> groups -> index, weight

	/*
	me->dvert:

	typedef struct MDeformVert {
		struct MDeformWeight *dw;
		int totweight;
		int flag;	// flag only in use for weightpaint now
	} MDeformVert;

	typedef struct MDeformWeight {
		int				def_nr;
		float			weight;
	} MDeformWeight;
	*/

	Mesh *me = (Mesh*)ob->data;
	if (!me->dvert) return;

	std::string controller_name = id_name(ob_arm);
	std::string controller_id = get_controller_id(ob_arm, ob);

	openSkin(controller_id, controller_name,
			 COLLADABU::URI(COLLADABU::Utils::EMPTY_STRING, get_geometry_id(ob)));

	add_bind_shape_mat(ob);

	std::string joints_source_id = add_joints_source(ob_arm, &ob->defbase, controller_id);
	std::string inv_bind_mat_source_id = add_inv_bind_mats_source(ob_arm, &ob->defbase, controller_id);
	std::string weights_source_id = add_weights_source(me, controller_id);

	add_joints_element(&ob->defbase, joints_source_id, inv_bind_mat_source_id);
	add_vertex_weights_element(weights_source_id, joints_source_id, me, ob_arm, &ob->defbase);

	closeSkin();
	closeController();
}
void ControllerExporter::export_morph_controller(Object *ob, Key *key)
{
	bool use_instantiation = this->export_settings->use_object_instantiation;
	Mesh *me;

	me = bc_get_mesh_copy(scene,
				ob,
				this->export_settings->export_mesh_type,
				this->export_settings->apply_modifiers,
				this->export_settings->triangulate);

	std::string controller_name = id_name(ob) + "-morph";
	std::string controller_id = get_controller_id(key, ob);

	openMorph(controller_id, controller_name,
	         COLLADABU::URI(COLLADABU::Utils::EMPTY_STRING, get_geometry_id(ob, use_instantiation)));

	std::string targets_id = add_morph_targets(key, ob);
	std::string morph_weights_id = add_morph_weights(key, ob);
	
	COLLADASW::TargetsElement targets(mSW);

	COLLADASW::InputList &input = targets.getInputList();

	input.push_back(COLLADASW::Input(COLLADASW::InputSemantic::MORPH_TARGET, // constant declared in COLLADASWInputList.h
	                                 COLLADASW::URI(COLLADABU::Utils::EMPTY_STRING, targets_id)));
	input.push_back(COLLADASW::Input(COLLADASW::InputSemantic::MORPH_WEIGHT,
	                                 COLLADASW::URI(COLLADABU::Utils::EMPTY_STRING, morph_weights_id)));
	targets.add();

	BKE_libblock_free_us(G.main, me);


	//support for animations
	//can also try the base element and param alternative
	add_weight_extras(key);
	closeMorph();
	closeController();
}
Пример #7
0
void DlgPrefController::disableDevice() {
    emit(closeController(m_pController));
    //TODO: Should probably check if close() actually succeeded.
}