void UIWidget::copyProperties(UIWidget *widget) { setEnabled(widget->isEnabled()); setVisible(widget->isVisible()); setBright(widget->isBright()); setTouchEnabled(widget->isTouchEnabled()); m_bTouchPassedEnabled = false; setZOrder(widget->getZOrder()); setUpdateEnabled(widget->isUpdateEnabled()); setTag(widget->getTag()); setName(widget->getName()); setActionTag(widget->getActionTag()); m_bIgnoreSize = widget->m_bIgnoreSize; m_tSize = widget->m_tSize; m_tCustomSize = widget->m_tCustomSize; copySpecialProperties(widget); m_eSizeType = widget->getSizeType(); m_tSizePercent = widget->m_tSizePercent; m_ePositionType = widget->m_ePositionType; m_tPositionPercent = widget->m_tPositionPercent; setPosition(widget->getPosition()); setAnchorPoint(widget->getAnchorPoint()); setScaleX(widget->getScaleX()); setScaleY(widget->getScaleY()); setRotation(widget->getRotation()); setRotationX(widget->getRotationX()); setRotationY(widget->getRotationY()); setFlipX(widget->isFlipX()); setFlipY(widget->isFlipY()); setColor(widget->getColor()); setOpacity(widget->getOpacity()); setCascadeOpacityEnabled(widget->isCascadeOpacityEnabled()); setCascadeColorEnabled(widget->isCascadeColorEnabled()); onSizeChanged(); }
void Widget::copyProperties(Widget *widget) { setEnabled(widget->isEnabled()); setVisible(widget->isVisible()); setBright(widget->isBright()); setTouchEnabled(widget->isTouchEnabled()); _touchPassedEnabled = false; setLocalZOrder(widget->getLocalZOrder()); setTag(widget->getTag()); setName(widget->getName()); setActionTag(widget->getActionTag()); _ignoreSize = widget->_ignoreSize; _size = widget->_size; _customSize = widget->_customSize; copySpecialProperties(widget); _sizeType = widget->getSizeType(); _sizePercent = widget->_sizePercent; _positionType = widget->_positionType; _positionPercent = widget->_positionPercent; setPosition(widget->getPosition()); setAnchorPoint(widget->getAnchorPoint()); setScaleX(widget->getScaleX()); setScaleY(widget->getScaleY()); setRotation(widget->getRotation()); setRotationX(widget->getRotationX()); setRotationY(widget->getRotationY()); setFlipX(widget->isFlipX()); setFlipY(widget->isFlipY()); setColor(widget->getColor()); setOpacity(widget->getOpacity()); setCascadeOpacityEnabled(widget->isCascadeOpacityEnabled()); setCascadeColorEnabled(widget->isCascadeColorEnabled()); onSizeChanged(); }
//YXZ euler angles void Matrix4x4::setRotation(float x,float y, float z) { setRotationY(y); Matrix4x4 temp; temp.setRotationX(x); *this *= temp; temp.setRotationZ(z); *this *= temp; }
void PPropertyTransform::setQuaternion(pfloat32 x, pfloat32 y, pfloat32 z, pfloat32 w) { pfloat32 q[] = { x, y, z, w }; pfloat32 rx, ry, rz; pQuaternionGetRotation(q, rx, ry, rz); setRotationX(rx); setRotationY(ry); setRotationZ(rz); }
void Object3D::lookAt(Vector3D& target, Vector3D& upAxis) { if (m_transformDirty) updateTransform(); Vector3D zAxis(target.m_x - m_position.m_x, target.m_y - m_position.m_y, target.m_z - m_position.m_z); zAxis.normalize(); Vector3D xAxis(upAxis.m_y * zAxis.m_z - upAxis.m_z * zAxis.m_y, upAxis.m_z * zAxis.m_x - upAxis.m_x * zAxis.m_z, upAxis.m_x * zAxis.m_y - upAxis.m_y * zAxis.m_x); xAxis.normalize(); if (xAxis.getLength() < .05f) { xAxis.m_x = upAxis.m_y; xAxis.m_y = upAxis.m_x; xAxis.m_z = 0; xAxis.normalize(); } Vector3D yAxis(zAxis.m_y * xAxis.m_z - zAxis.m_z * xAxis.m_y, zAxis.m_z * xAxis.m_x - zAxis.m_x * xAxis.m_z, zAxis.m_x * xAxis.m_y - zAxis.m_y * xAxis.m_x); float (&raw)[16] = m_transform.m_rawData; raw[0] = m_scaling.m_x * xAxis.m_x; raw[1] = m_scaling.m_x * xAxis.m_y; raw[2] = m_scaling.m_x * xAxis.m_z; raw[4] = m_scaling.m_y * yAxis.m_x; raw[5] = m_scaling.m_y * yAxis.m_y; raw[6] = m_scaling.m_y * yAxis.m_z; raw[8] = m_scaling.m_z * zAxis.m_x; raw[9] = m_scaling.m_z * zAxis.m_y; raw[10] = m_scaling.m_z * zAxis.m_z; raw[12] = m_position.m_x; raw[13] = m_position.m_y; raw[14] = m_position.m_z; raw[3] = raw[7] = raw[11] = 0; raw[15] = 1; setTransform(m_transform); if (zAxis.m_z < 0) { setRotationY(180 - getRotationY()); setRotationX(getRotationX() - 180); setRotationZ(getRotationZ() - 180); } }
void CCCameraBase::incrementRotationY(const float increment) { rotation.y += increment; setRotationY( rotation.y ); }
void ModelDataModel::setRotation(const Vector3f &rotation) { setRotationX(rotation[0]*RAD_TO_DEG); setRotationY(rotation[1]*RAD_TO_DEG); setRotationZ(rotation[2]*RAD_TO_DEG); }
int main( int argc, char *argv[] ) { unsigned int frames = 0; int res; Mat4 projection_matrix; Mat4 viewMat; Mat4 rotMat; Mat4 modelMat; float aspect; float dw, dh; int debug_flag = 0; bcm_host_init(); res = WinCreate( &g_sc ); if( !res ) { printf( "Create window error!\n" ); return 0; } res = SurfaceCreate(&g_sc); if( !res ) { printf( "Create surface error!\n" ); return 0; } makeUnit(&viewMat); aspect = (float)g_sc.width / (float)g_sc.height; //makeProjectionMatrix(&g_sp.VpMatrix, 1, 65536, 53, aspect); //setPosition(&viewMat, 0, -4, -24 ); dw = 0.5f * aspect; dh = 0.5f; perspectiveMatrix( -dw, +dw, -dh, +dh, 1, 160, &g_sp.VpMatrix ); setPosition(&viewMat, 0, -12, -32 ); //print_mat4( &g_sp.VpMatrix ); mulMatrix(&g_sp.VpMatrix, &g_sp.VpMatrix, &viewMat); makeUnit(&modelMat); mulMatrix( &projection_matrix, &modelMat, &g_sp.VpMatrix ); makeUnit(&rotMat); setRotationY(&rotMat, 0.5); /* 30 degree/sec */ pmd_file = NULL; vmd_file = NULL; if( argc < 2 ) { printf( "File Error!\n" ); printf( "Argment1 : Pmd or Pmx file.\n" ); printf( "Argment2 : Vmd file.\n" ); return 0; } if( argc > 1 ) pmd_file = argv[ 1 ]; if( argc > 2 ) vmd_file = argv[ 2 ]; init(); if( argc > 3 && argv[ 3 ] ) { if( strncmp( argv[ 3 ], "-D", 2 ) == 0 ) debug_flag = 1; } //print_mat4( &projection_matrix ); glEnable(GL_DEPTH_TEST); glClearColor( 0.0f, 0.0f, 0.0f, 1.0f ); Mat4 delta_mat; makeUnit( &delta_mat ); if( argc > 4 ) { int i, j; char cmd_string[ 255 ] = { 0 }; for( i = 3; i < argc; i ++ ) { int length = 0; strcpy( cmd_string, argv[ i ] ); puts( cmd_string ); length = strlen( cmd_string ); cmd_string[ length ] = ' '; cmd_string[ length + 1 ] = '&'; cmd_string[ length + 2 ] = '\0'; system( cmd_string ); } } fps = new Fps(); fps->set_fps( _fps_ ); /* 1200frame / 60fps = 20sec */ //while( frames < 1200 ) while( !p->get_vmd( 0 )->is_end() || ( !vmd_file && frames < 160 ) ) //while( 1 ) { Mat4 pl_matrix; glViewport(0, 0, g_sc.width, g_sc.height); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); /* X Rotation */ mulMatrix( &pl_matrix, &projection_matrix, &delta_mat ); //glUniformMatrix4fv(g_sp.uModelMatrix, 1, GL_FALSE, modelMat.m); p->set_projection_matrix( pl_matrix.m ); draw(); /* char c = get_keyboard(); makeUnit( &delta_mat ); switch( c ) { case 'w': setPosition( &delta_mat, 0, 0, +4 ); break; case 's': setPosition( &delta_mat, 0, 0, -4 ); break; case 'a': setRotationY( &delta_mat, +0.5 ); break; case 'd': setRotationY( &delta_mat, -0.5 ); break; } */ eglSwapBuffers(g_sc.display, g_sc.surface); frames ++; //glutTimerFunc( fps->get_wait_time() * 1000.0f, timer, 0 ); usleep( 1600 ); if( debug_flag ) fps->draw(); } printf( "Ending process!\n" ); end(); return 0; }
//-------------------------------------------------------------- void LayerTransform::processOscCommand(const string& command, const ofxOscMessage& m) { if(isMatch(command,"position") || isMatch(command,"p")) { if(validateOscSignature("([if][if]?[if]?)|([s][if])", m)) { if(m.getArgType(0) == OFXOSC_TYPE_STRING) { char c = tolower(getArgAsStringUnchecked(m,0)[0]); if(c == 'x') { setPositionX(getArgAsFloatUnchecked(m,1)); } else if(c == 'y') { setPositionY(getArgAsFloatUnchecked(m,1)); } else if(c == 'z') { setPositionZ(getArgAsFloatUnchecked(m,1)); } else if(c == 'n') { setPositionNormalized(getArgAsBoolUnchecked(m,1)); } else { ofLogError("LayerTransform") << "invalid arg type: " << c << " " << command << "."; } } else { setPositionX(getArgAsFloatUnchecked(m,0)); if(m.getNumArgs() > 1) { setPositionY(getArgAsFloatUnchecked(m,1)); if(m.getNumArgs() > 2) { setPositionZ(getArgAsFloatUnchecked(m,2)); } } } } } else if(isMatch(command,"anchorpoint") || isMatch(command,"a")) { if(validateOscSignature("([if][if]?[if]?)|([s][if])", m)) { if(m.getArgType(0) == OFXOSC_TYPE_STRING) { char c = tolower(getArgAsStringUnchecked(m,0)[0]); if(c == 'x') { setAnchorPointX(getArgAsFloatUnchecked(m,1)); } else if(c == 'y') { setAnchorPointY(getArgAsFloatUnchecked(m,1)); } else if(c == 'z') { setAnchorPointZ(getArgAsFloatUnchecked(m,1)); } else if(c == 'n') { setAnchorPointNormalized(getArgAsBoolUnchecked(m,1)); } else { ofLog(OF_LOG_ERROR, "LayerTransform: invalid arg type: " + ofToString(c) + " " + command); } } else { setAnchorPointX(getArgAsFloatUnchecked(m,0)); if(m.getNumArgs() > 1) { setAnchorPointY(getArgAsFloatUnchecked(m,1)); if(m.getNumArgs() > 2) { setAnchorPointZ(getArgAsFloatUnchecked(m,2)); } } } } } else if(isMatch(command,"rotate") || isMatch(command,"r")) { if(validateOscSignature("([if][if]?[if]?)|([s][if][if]?[if]?)", m)) { if(m.getArgType(0) == OFXOSC_TYPE_STRING) { char c = tolower(getArgAsStringUnchecked(m,0)[0]); if(c == 'x') { setRotationX(getArgAsFloatUnchecked(m,1)); } else if(c == 'y') { setRotationY(getArgAsFloatUnchecked(m,1)); } else if(c == 'z') { setRotationZ(getArgAsFloatUnchecked(m,1)); } else if(c == 'd') { setRotation(getArgsAsPoint(m, 1)); } else if(c == 'n') { setRotationNormalized(getArgAsBoolUnchecked(m,1)); } else { ofLog(OF_LOG_ERROR, "LayerTransform: invalid arg type: " + ofToString(c) + " " + command); } } else { setRotationX(getArgAsFloatUnchecked(m,0)); if(m.getNumArgs() > 1) { setRotationY(getArgAsFloatUnchecked(m,1)); if(m.getNumArgs() > 2) { setRotationZ(getArgAsFloatUnchecked(m,2)); } } } } } else if(isMatch(command,"scale") || isMatch(command,"s")) { if(validateOscSignature("([f][f]?[f]?)|([s][f])", m)) { if(m.getArgType(0) == OFXOSC_TYPE_STRING) { char c = tolower(getArgAsStringUnchecked(m,0)[0]); float val = getArgAsFloatUnchecked(m,1); if(c == 'x') { setScaleX(val); } else if(c == 'y') { setScaleY(val); } else if(c == 'z') { setScaleZ(val); } else { ofLog(OF_LOG_ERROR, "LayerTransform: invalid arg type: " + ofToString(c) + " " + command); } } else { setScaleX(getArgAsFloatUnchecked(m,0)); if(m.getNumArgs() > 1) { setScaleY(getArgAsFloatUnchecked(m,1)); if(m.getNumArgs() > 2) { setScaleZ(getArgAsFloatUnchecked(m,2)); } } } } } else if(isMatch(command,"opacity") || isMatch(command,"o")) { if(validateOscSignature("[if]", m)) { setOpacity(getArgAsFloatUnchecked(m,0)); } } else if(isMatch(command,"opacityn") || isMatch(command,"on")) { if(validateOscSignature("[if]", m)) { setOpacityNormalized(getArgAsFloatUnchecked(m,0)); } } else if(isMatch(command,"size") || isMatch(command, "sz")) { if(validateOscSignature("[if][if]", m)) { setSize(getArgAsFloatUnchecked(m,0),getArgAsFloatUnchecked(m,1)); } } else if(isMatch(command,"width") || isMatch(command, "w")) { if(validateOscSignature("[if]", m)) { setWidth(getArgAsFloatUnchecked(m,0)); } } else if(isMatch(command,"height") || isMatch(command, "h")) { if(validateOscSignature("[if]", m)) { setHeight(getArgAsFloatUnchecked(m,0)); } } }