void UniversalJoint::drawObject(const VisualizationParameterSet& visParams)
{
  if(visParams.surfaceStyle == VisualizationParameterSet::PHYSICS_WIREFRAME ||
     visParams.surfaceStyle == VisualizationParameterSet::PHYSICS_FLAT ||
     visParams.surfaceStyle == VisualizationParameterSet::PHYSICS_SMOOTH ||
     visParams.surfaceStyle == VisualizationParameterSet::MIXED_APPEARANCE ||
     visParams.surfaceStyle == VisualizationParameterSet::MIXED_PHYSICS)
  {
    dVector3 tempA;
    dJointGetUniversalAnchor(physicalJoint, tempA);
    Vector3d tempAnchor(tempA[0],tempA[1], tempA[2]);

    dJointGetUniversalAxis1(physicalJoint, tempA);
    Vector3d tempAxis1(tempA[0], tempA[1], tempA[2]);
    tempAxis1 *= 0.1;
    dJointGetUniversalAxis2(physicalJoint, tempA);
    Vector3d tempAxis2(tempA[0], tempA[1], tempA[2]);
    tempAxis2 *= 0.1;

    if(visParams.surfaceStyle == VisualizationParameterSet::MIXED_APPEARANCE)
    {
      glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
      glShadeModel(GL_FLAT);
      GLHelper::getGLH()->drawUniversalJoint(tempAnchor, tempAxis1, tempAxis2, true);
      glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
      glShadeModel(GL_SMOOTH);
    }
    else
    {
      GLHelper::getGLH()->drawUniversalJoint(tempAnchor, tempAxis1, tempAxis2, false);
    }
  }
}
void CUniversalJoint::RenderDebug()
{
	if (IsAttached())
	{
		matrix44 Tfm;
		dVector3 CurrAnchor;
		dJointGetUniversalAnchor(ODEJointID, CurrAnchor);
		Tfm.scale(vector3(0.1f, 0.1f, 0.1f));
		Tfm.translate(vector3(CurrAnchor[0], CurrAnchor[1], CurrAnchor[2]));
		nGfxServer2::Instance()->DrawShape(nGfxServer2::Sphere, Tfm, GetDebugVisualizationColor());
	}
}
Exemple #3
0
static void get_phys_joint_anchor(dJointID j, float *v)
{
    dVector3 V = { 0, 0, 0 };

    switch (dJointGetType(j))
    {
    case dJointTypeBall:      dJointGetBallAnchor     (j, V); break;
    case dJointTypeHinge:     dJointGetHingeAnchor    (j, V); break;
    case dJointTypeHinge2:    dJointGetHinge2Anchor   (j, V); break;
    case dJointTypeUniversal: dJointGetUniversalAnchor(j, V); break;
    default: break;
    }

    v[0] = (float) V[0];
    v[1] = (float) V[1];
    v[2] = (float) V[2];
}
Exemple #4
0
void
dxJointUniversal::setRelativeValues()
{
    dVector3 anchor;
    dJointGetUniversalAnchor(this, anchor);
    setAnchors( this, anchor[0], anchor[1], anchor[2], anchor1, anchor2 );

    dVector3 ax1,ax2;
    dJointGetUniversalAxis1(this, ax1);
    dJointGetUniversalAxis2(this, ax2);

    if ( flags & dJOINT_REVERSE )
    {
        setAxes( this, ax1[0],ax1[1],ax1[2], NULL, axis2 );
        setAxes( this, ax2[0],ax2[1],ax2[2], axis1, NULL );
    }
    else
    {
        setAxes( this, ax1[0],ax1[1],ax1[2], axis1, NULL );
        setAxes( this, ax2[0],ax2[1],ax2[2], NULL, axis2 );
    }

    computeInitialRelativeRotations();
}
Exemple #5
0
soyatomsPosition* soy_joints_universal_get_anchor (soyjointsUniversal* self) {
	soyatomsPosition* result;
	dxVector3* _tmp0_;
	dxVector3* v;
	struct dxJoint* _tmp1_;
	dxVector3* _tmp2_;
	soyatomsPosition* _tmp3_;
	soyatomsPosition* _tmp4_;
	soyatomsPosition* value;
	gboolean _tmp5_ = FALSE;
	gboolean _tmp6_ = FALSE;
	gboolean _tmp7_ = FALSE;
	soyatomsPosition* _tmp8_;
	gboolean _tmp14_;
	gboolean _tmp20_;
	gboolean _tmp26_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = dvector3_new ();
	v = _tmp0_;
	_tmp1_ = ((soyjointsJoint*) self)->joint;
	_tmp2_ = v;
	dJointGetUniversalAnchor ((struct dxJoint*) _tmp1_, _tmp2_);
	_tmp3_ = self->priv->_anchor_obj;
	_tmp4_ = _g_object_ref0 (_tmp3_);
	value = _tmp4_;
	_tmp8_ = value;
	if (_tmp8_ == NULL) {
		_tmp7_ = TRUE;
	} else {
		dxVector3* _tmp9_;
		dReal _tmp10_;
		soyatomsPosition* _tmp11_;
		gfloat _tmp12_;
		gfloat _tmp13_;
		_tmp9_ = v;
		_tmp10_ = _tmp9_->x;
		_tmp11_ = value;
		_tmp12_ = soy_atoms_position_get_x (_tmp11_);
		_tmp13_ = _tmp12_;
		_tmp7_ = ((gfloat) _tmp10_) != _tmp13_;
	}
	_tmp14_ = _tmp7_;
	if (_tmp14_) {
		_tmp6_ = TRUE;
	} else {
		dxVector3* _tmp15_;
		dReal _tmp16_;
		soyatomsPosition* _tmp17_;
		gfloat _tmp18_;
		gfloat _tmp19_;
		_tmp15_ = v;
		_tmp16_ = _tmp15_->y;
		_tmp17_ = value;
		_tmp18_ = soy_atoms_position_get_y (_tmp17_);
		_tmp19_ = _tmp18_;
		_tmp6_ = ((gfloat) _tmp16_) != _tmp19_;
	}
	_tmp20_ = _tmp6_;
	if (_tmp20_) {
		_tmp5_ = TRUE;
	} else {
		dxVector3* _tmp21_;
		dReal _tmp22_;
		soyatomsPosition* _tmp23_;
		gfloat _tmp24_;
		gfloat _tmp25_;
		_tmp21_ = v;
		_tmp22_ = _tmp21_->z;
		_tmp23_ = value;
		_tmp24_ = soy_atoms_position_get_z (_tmp23_);
		_tmp25_ = _tmp24_;
		_tmp5_ = ((gfloat) _tmp22_) != _tmp25_;
	}
	_tmp26_ = _tmp5_;
	if (_tmp26_) {
		soyatomsPosition* _tmp27_;
		dxVector3* _tmp31_;
		dReal _tmp32_;
		dxVector3* _tmp33_;
		dReal _tmp34_;
		dxVector3* _tmp35_;
		dReal _tmp36_;
		soyatomsPosition* _tmp37_;
		soyatomsPosition* _tmp38_;
		soyatomsPosition* _tmp39_;
		soyatomsPosition* _tmp40_;
		_tmp27_ = value;
		if (_tmp27_ != NULL) {
			soyatomsPosition* _tmp28_;
			guint _tmp29_ = 0U;
			soyatomsPosition* _tmp30_;
			_tmp28_ = self->priv->_anchor_obj;
			g_signal_parse_name ("on-set", SOY_ATOMS_TYPE_POSITION, &_tmp29_, NULL, FALSE);
			g_signal_handlers_disconnect_matched (_tmp28_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp29_, 0, NULL, (GCallback) __soy_joints_universal_anchor_set_soy_atoms_position_on_set, self);
			_tmp30_ = self->priv->_anchor_obj;
			g_object_weak_unref ((GObject*) _tmp30_, __soy_joints_universal_anchor_weak_gweak_notify, self);
		}
		_tmp31_ = v;
		_tmp32_ = _tmp31_->x;
		_tmp33_ = v;
		_tmp34_ = _tmp33_->y;
		_tmp35_ = v;
		_tmp36_ = _tmp35_->z;
		_tmp37_ = soy_atoms_position_new ((gfloat) _tmp32_, (gfloat) _tmp34_, (gfloat) _tmp36_);
		_g_object_unref0 (value);
		value = _tmp37_;
		_tmp38_ = value;
		g_signal_connect_object (_tmp38_, "on-set", (GCallback) __soy_joints_universal_anchor_set_soy_atoms_position_on_set, self, 0);
		_tmp39_ = value;
		g_object_weak_ref ((GObject*) _tmp39_, __soy_joints_universal_anchor_weak_gweak_notify, self);
		_tmp40_ = value;
		self->priv->_anchor_obj = _tmp40_;
	}
	result = value;
	_dvector3_free0 (v);
	return result;
}