Quantcast
Channel: openFrameworks - Latest posts
Viewing all articles
Browse latest Browse all 40524

How to rotate and translate a ofxBullet body?

$
0
0

Hey @NickHardeman. cool! I made it work like you said; using the 009 branch and looking to the rotationExample:

            boxVector = pointTo - pointFrom;
            posBox = (pointTo + pointFrom) * 0.5;
            boxLength  = boxVector.length();
            
            boxVector.normalize();
            
            boxSizeY = boxLength - boxesMargin;
            
            boxes.push_back( new ofxBulletBox() );
            
            ofVec3f localBoxAxis( 0, 1, 0 );
//            ofVec3f localBoxAxis( 1, 0, 0 );
//            ofVec3f localBoxAxis( 0, 0, 1 );
            
            ofQuaternion rotation;
            rotation.makeRotate( localBoxAxis, boxVector );
            
            ((ofxBulletBox*)boxes[boxes.size()-1])->create( world.world, posBox, rotation, 0.5, boxSizeX, boxSizeY, boxSizeZ);
            
            boxes[boxes.size()-1]->add();

PS: Now, on this tree structure, I am trying to learn how to articulate it (with forces like wind) around nodes between boxes, like a tree / arm elbow / bones. I am using joints to try to limit the movements with the join constraints. I am using ofxBullet just for this, and I am not sure if there is another easier way... Anyway I'll open soon a new thread on the forum and I'll post the link here too! Thanks a lot for your help.


Viewing all articles
Browse latest Browse all 40524

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>