void CC3PODMeshNode::initAtIndex( GLint aPODIndex, CC3PODResource* aPODRez ) { init(); setPodIndex( aPODIndex ); SPODNode* pmn = (SPODNode*)getNodePODStructAtIndex( aPODIndex, aPODRez ); //LogRez(@"Creating %@ at index %i from: %@", [self class], aPODIndex, NSStringFromSPODNode(psn)); setName( pmn->pszName ); setPodContentIndex( pmn->nIdx ); setPodParentIndex( pmn->nIdxParent ); if ( pmn->pfAnimPosition ) setLocation( *(CC3Vector*)pmn->pfAnimPosition ); if ( pmn->pfAnimRotation ) setQuaternion( *(CC3Quaternion*)pmn->pfAnimRotation ); if ( pmn->pfAnimScale ) setScale( *(CC3Vector*)pmn->pfAnimScale ); if ( CC3PODNodeAnimation::sPODNodeDoesContainAnimation((PODStructPtr)pmn) ) setAnimation( CC3PODNodeAnimation::animationFromSPODNode( (PODStructPtr)pmn, aPODRez->getAnimationFrameCount() ) ); else if (aPODRez->shouldFreezeInanimateNodes()) setAnimation( CC3FrozenNodeAnimation::animationFromNodeState( this ) ); // If this node has a mesh, build it if (getPodContentIndex() >= 0) { setMesh( aPODRez->getMeshAtIndex( getPodContentIndex() ) ); } // If this node has a material, build it setPodMaterialIndex( pmn->nIdxMaterial ); if (getPodMaterialIndex() >= 0) setMaterial( (CC3PODMaterial*)aPODRez->getMaterialAtIndex( getPodMaterialIndex() ) ); }
void PhysicsBody::updateToODEState(void) { const dReal* pos(dBodyGetPosition(_BodyID)); const dReal* quat(dBodyGetQuaternion(_BodyID)); setPosition(Vec3f(pos[0], pos[1], pos[2])); Quaternion osgQuat; osgQuat.setValueAsQuat(quat[1], quat[2], quat[3], quat[0]); setQuaternion(osgQuat); }
void CC3PODLight::initAtIndex( GLint aPODIndex, CC3PODResource* aPODRez ) { init(); setPodIndex( aPODIndex ); SPODNode* psn = (SPODNode*)getNodePODStructAtIndex( aPODIndex, aPODRez ); //LogRez(@"Creating %@ at index %i from: %@", [self class], aPODIndex, NSStringFromSPODNode(psn)); setName( psn->pszName ); setPodContentIndex( psn->nIdx ); setPodParentIndex( psn->nIdxParent ); if ( psn->pfAnimPosition ) setLocation( *(CC3Vector*)psn->pfAnimPosition ); if ( psn->pfAnimRotation ) setQuaternion( *(CC3Quaternion*)psn->pfAnimRotation ); if ( psn->pfAnimScale ) setScale( *(CC3Vector*)psn->pfAnimScale ); if ( CC3PODNodeAnimation::sPODNodeDoesContainAnimation((PODStructPtr)psn) ) setAnimation( CC3PODNodeAnimation::animationFromSPODNode( (PODStructPtr)psn, aPODRez->getAnimationFrameCount() ) ); else if (aPODRez->shouldFreezeInanimateNodes()) setAnimation( CC3FrozenNodeAnimation::animationFromNodeState( this ) ); // Get the light content if (getPodContentIndex() >= 0) { SPODLight* psl = (SPODLight*)aPODRez->getLightPODStructAtIndex(getPodContentIndex()); //LogRez(@"Setting %@ parameters from %@", [self class], NSStringFromSPODLight(psl)); setPodTargetIndex( psl->nIdxTarget ); setAmbientColor( kCC3DefaultLightColorAmbient ); setDiffuseColor( ccc4f(psl->pfColour[0], psl->pfColour[1], psl->pfColour[2], 1.0) ); setSpecularColor( kCC3DefaultLightColorSpecular ); setAttenuation( CC3AttenuationCoefficientsMake(psl->fConstantAttenuation, psl->fLinearAttenuation, psl->fQuadraticAttenuation) ); switch (psl->eType) { case ePODDirectional: setIsDirectionalOnly( true ); break; case ePODPoint: setIsDirectionalOnly( false ); break; case ePODSpot: setIsDirectionalOnly( false ); setSpotCutoffAngle( CC3RadToDeg(psl->fFalloffAngle) ); setSpotExponent( psl->fFalloffExponent ); break; default: break; } } }
drawContext::drawContext(float fontFactor, bool retina) { GmshInitialize(); GmshSetOption("General", "Terminal", 1.0); onelabUtils::setFirstComputationFlag(false); for(int i = 0; i < 3; i++){ _translate[i] = 0.; _scale[i] = 1.; } setQuaternion(0., 0., 0., 1.); _fontFactor = fontFactor; _retina = retina; }
void GLWidget::handleExternalMode(){ freeCam.pos.set( 300., 0., 0.); //skele.isHidden = true; //stoma.isHidden = true; //model.isHidden = false; setQuaternion( 1); if( sun1.isOn == false){ sun1.isOn = sun2.isOn = true; emit sunStatusToggled(); } if( bulb.isOn == true){ bulb.isOn = false; emit bulbStatusToggled(); } }
void QuaternionProperty::load( const Config& config ) { float x, y, z, w; if( config.mapGetFloat( "X", &x ) && config.mapGetFloat( "Y", &y ) && config.mapGetFloat( "Z", &z ) && config.mapGetFloat( "W", &w )) { // Calling setQuaternion() once explicitly is better than letting // the Property class load the X, Y, Z, and W children // independently, which would result in at least 4 calls to // setQuaternion(). setQuaternion( Ogre::Quaternion( w, x, y, z )); } }
void GLWidget::handleInternalMode(){ freeCam.pos.set( -2.761694,14.281392,-52.381657); camT = -.082869; camP = -5.947087; //skele.isHidden = true; //stoma.isHidden = true; //model.isHidden = false; setQuaternion( 0); if( sun1.isOn == true){ sun1.isOn = sun2.isOn = false; emit sunStatusToggled(); } if( bulb.isOn == false){ bulb.isOn = true; emit bulbStatusToggled(); } }
bool QuaternionProperty::setValue( const QVariant& new_value ) { QStringList strings = new_value.toString().split( ';' ); if( strings.size() >= 4 ) { bool x_ok = true; float x = strings[ 0 ].toFloat( &x_ok ); bool y_ok = true; float y = strings[ 1 ].toFloat( &y_ok ); bool z_ok = true; float z = strings[ 2 ].toFloat( &z_ok ); bool w_ok = true; float w = strings[ 3 ].toFloat( &w_ok ); if( x_ok && y_ok && z_ok && w_ok ) { return setQuaternion( Ogre::Quaternion( w, x, y, z )); } } return false; }
void SParts::build(const Vector3d &ov, const Rotation &r, bool dynamics) { if (isBody()) { const dReal *q = r.q(); setPosition(ov); setQuaternion(q); } else { Vector3d v(m_pos.x(), m_pos.y(), m_pos.z()); v.rotate(r); v += ov; setPosition(v); Rotation rr(r); rr *= m_rot; setRotation(rr); } enableDynamics(dynamics); }
void CC3GLSLUniform::setQuaternion( const CC3Quaternion& value ) { setQuaternion( value, 0 ); }
void drawContext::eventHandler(int event, float x, float y) { int width = _width, height = _height; if(_retina){ // x,y for retina are still the same as for non-retina width /= 2; height /= 2; } _current.set(_scale, _translate, _right, _left, _bottom, _top, width, height, x, y); double xx[3] = {1.,0.,0.}; double yy[3] = {0.,1.,0.}; double q[4]; switch(event){ case 0: // finger(s) press the screen // in this case x and y represent the start point _start.set(_scale, _translate, _right, _left, _bottom, _top, width, height, x, y); _previous.set(_scale, _translate, _right, _left, _bottom, _top, width, height, x, y); break; case 1: // finger move (translate) // in this case x and y represent the current point _translate[0] += (_current.wnr[0] - _previous.wnr[0]); _translate[1] += (_current.wnr[1] - _previous.wnr[1]); _translate[2] = 0.; break; case 2: // fingers move (scale) // in this case we don't care about previous and current position, x // represent the scale _scale[0] = _scale[1] = _scale[2] = x; _start.recenter(_scale, _translate); break; case 3: // fingers move (rotate) addQuaternion((2. * _previous.win[0] - width) / width, (height - 2. * _previous.win[1]) / height, (2. * _current.win[0] - width) / width, (height - 2. * _current.win[1]) / height); break; case 4: // release the finger(s) // Do nothing ? break; case 5: // X view axis_to_quat(xx, M_PI/2, q); setQuaternion(q[0], q[1], q[2], q[3]); break; case 6: // Y view axis_to_quat(yy, M_PI/2, q); setQuaternion(q[0], q[1], q[2], q[3]); break; case 7: // Z view setQuaternion(0., 0., 0., 1.); break; default: // all other reset the position setQuaternion(0., 0., 0., 1.); for(int i = 0; i < 3; i++){ _translate[i] = 0.; _scale[i] = 1.; } break; } _previous.set(_scale, _translate, _right, _left, _bottom, _top, width, height, x, y); }
virtual void copy(Item* source, Item* destination, ItemDictionary ) { setQuaternion(destination, getQuaternion(source)); }
void PPropertyTransform::setRotation(pfloat32 angle, pfloat32 x, pfloat32 y, pfloat32 z) { pfloat32 q[4]; pQuaternionCreateRotation(angle, x, y, z, q); setQuaternion(q[0], q[1], q[2], q[3]); }
void GLWidget::initializeGL(){ //glewInit(); glEnable( GL_DEPTH_TEST); glFrontFace( GL_CCW); glShadeModel( GL_SMOOTH); glEnable( GL_NORMALIZE); setLighting( true); init3dEng(); setQuaternion( 1); //m_trackBalls = TrackBall(0.0f, QVector3D(0, 1, 0), TrackBall::Plane); m_trackBalls = TrackBall(0.0f, QVector3D(0, 1, 0), TrackBall::Sphere); //-- sun Light sun1.isOn = true; sun1.mat.ambi.set( .3, .3, .3, 1.); sun1.mat.diff.set( .7, .7, .7, 1.); sun1.pos.set( -.5, 1, .5, 0.); sun2.isOn = true; sun2.mat.ambi.set( .3, .3, .3, 1.); sun2.mat.diff.set( .7, .7, .7, 1.); sun2.pos.set( .5, -1, -.5, 0.); //-- bulb Light bulb.isOn = false; bulb.mat.ambi.set( .3, .3, .3, 1.); bulb.mat.diff.set( .7, .7, .7, 1.); bulb.mat.spec.set( 1., 1., 1., 1.); bulb.att.set( 1.0, .01, .0003); Texture2d *tex; GLubyte *textureImage; //added by sai tex = loadBMP( "lap.bmp"); //bool success = loadPngImage("lap.png",256,256,true,&textureImage); //tex = loadBMP( "tex3.bmp"); //stoma.Load3ds( "stomach.3ds"); stoma.LoadBIN("mesh.bin"); stoma.smooth = 1; stoma.bindTexture( tex); //stoma.bindTexture(&textureImage); //stoma.rotate( -90, 0, 0); //stoma.scale( Vector3f( .3, .3, .3)); //stoma.scale( Vector3f( .003, .003, .003)); stoma.col.set( .6, .6, .2); stoma.calcBoundingCube(); stoma.calcGraph(); //glTranslatef(0,-160.0,0.0); stoma.drawGraph(); skele.Load3ds( "skeleton.3ds"); skele.smooth = 1; skele.col.set( .7, .7, .7); skele.calcBoundingCube(); //stoma += -((skele.cubeBoundMin+skele.cubeBoundMax)/2.0); stoma += -((stoma.cubeBoundMin+stoma.cubeBoundMax)/2.0); skele += -((skele.cubeBoundMin+skele.cubeBoundMax)/2.0); skele.updateDisplayList(); stoma.lap(); stoma.saveBIN( "mappedmesh.bin"); //tex = loadBMP( "lapatlas.bmp"); //stoma.bindTexture( tex); stoma.updateDisplayList(); skele.isHidden = true; model.LoadBIN( "mesh.bin"); model.col.set( .8, .4, .4); model.scale( Vector3f(.1)); model.calcBoundingCube(); model += -((model.cubeBoundMin+model.cubeBoundMax)/2.0); model.updateDisplayList(); model.isHidden = true; m_mouseClick = 0; camS = 0.1; camM = 1.0; // camera zoom camT = 0.0; camP = 0.0; // camera theta and phi aspectRatio = 1.0; freeCam.pos.set( 45., 0., 0.); //freeCam.pos.set( 0., 0., -50.); freeCam.cnear = 0.01; freeCam.cfar = 2000.0; freeCam.ang = 45.0/camM; freeCam.eye.set( 0., 0., 0.); //freeCam.eye = freeCam.pos + Vector3f( sin(camP)*cos(camT), sin(camT), cos(camP)*cos(camT)); printf("Done\n"); }