Esempio n. 1
0
void RigidBody::processBodyRot_() {
	if(!body_) {
		return;
	}

	float rx = getRotX();
	float ry = getRotY();
	float rz = getRotZ();
	float ra = getRotAngle();

	// Stop setting invalid rotations that crash bullet...
	if(rx == 0.0 && ry == 0.0 && rz == 0.0) {
		rx = 1.0;
	}

	btTransform xform;
	xform = getBody().getWorldTransform();
	xform.setRotation(btQuaternion (btVector3(rx, ry, rz), ra*(PI/180)));
	//((btPairCachingGhostObject*)body_)->setWorldTransform (xform);
	body_->setWorldTransform (xform);
}
Esempio n. 2
0
//RIGHT HAND:: treat grab as a mouse click. 
void checkRCursor(int func, hand_h* rhand){
	
	if(isGrab()) {
		rhand->storeHand(getPalm());		//keep the hand movement history

		//first time grab gesture occurs for right hand
		if(!stateGrabR) {	
			//adjust with width and height of the screen
			float* cursor = getCursor();
			cursorX = cursor[0];
			cursorY = cursor[1];
			set_state(1); 
			stateGrabR = true;

		}
		//still in grab gesture
		else{
			//sculpt
			if(func == 1) {
				
				//select a mesh once
				//we don't need this for painting
				set_state(2);
				
				if(switchHand){
					commitScene(rhand->gettranslateX(), rhand->gettranslateY(), rhand->gettranslateZ());
					recalNormal();
				}
				else{
					
					//grab group of mesh
					if(sListContain(getSelection()) >= 0 ){
						shape = true;
						interpolate(getsList(), rhand->gettranslateX(), 
							rhand->gettranslateY(), rhand->gettranslateZ(), getRotX(), getRotY());
						recalNormal();
					}
					//grab one mesh
					else if(getSelection() >= 0 && getSelection() < getFaceListSize()){
						shape = true;
						interpolate(getSelection(), rhand->gettranslateX(), 
							rhand->gettranslateY(), rhand->gettranslateZ(), getRotX(), getRotY());
						recalNormal();
					}
				}
			}
			//paint
			else if(func ==2){
				if(switchHand){
					commitScene(rhand->gettranslateX(), rhand->gettranslateY(), rhand->gettranslateZ());
					recalNormal();
				}else{
					if(getSelection() >=0 && getSelection() < getFaceListSize()){
						//printf("selection ->%d\n", getSelection());
						paintMesh(getSelection(), getBrushColor());
					}
				}
			}

			//selection?
			else if(func ==3){
				
			}
		}
	}
	else{
		//just release
		if(stateGrabR){
			//selection list
			//if(selection && getSelection() > 0 && getSelection() < getFaceListSize()){
			//	store_selection(getSelection());
			//}

			stateGrabR = false; 
			rhand->clearHandList();
			setNullSelection(); //show no mesh response when hand released

			//undo
			if(func == 1 && shape) {
				copy_vmmodel(); 
				shape = false;
			}
		}
	}
	

}