void Graph::plot(QPainter& painter, int funcId) { if (!funcs.isValid(funcId)) return; QPen curvepen; QColor color = funcs.getColor(funcId); curvepen.setColor(color); if (funcs.isSelected(funcId)) curvepen.setWidth(4); else curvepen.setWidth(2); float xold = xmin; QPainterPath path; bool first = false; float yold = funcs.eval(funcId, xold); float xd, yd; const bool error = false; // isnan(yold); xform(xold, yold, xd, yd); if (error) first = true; else { path.moveTo(xd, yd); first = false; } float x_per_pixel = (xmax - xmin) / width(), y_per_pixel = (ymax - ymin) / height(); int plotted = 0; float xrate = x_per_pixel * 1; // fedisableexcept(FE_ALL_EXCEPT); while (xold < xmax) { bool disjoint = false; float x = xold + xrate; float y = funcs.eval(funcId, x); if (!error) { if (fabs(y - yold) > y_per_pixel * 100 && xrate > .1 * x_per_pixel) { xrate /= 2; continue; } if (fabs(y - yold) < y_per_pixel * 5 && xrate < x_per_pixel) { xrate *= 2; } float xd, yd; xform(x, y, xd, yd); if (first || y > ymax || y < ymin) { path.moveTo(xd, yd); disjoint = true; } else path.lineTo(xd, yd); } first = false; xold = x; yold = y; plotted++; } painter.strokePath(path, curvepen); // std::cerr<<"Plottted "<<plotted<<std::endl; }
bool Game::InitializeUniverse() { bool _ok = true; if (_ok) { delete racket_; racket_ = new Racket(GetResourceManager(), "racket", ui_manager_); AddContextObject(racket_, cure::kNetworkObjectLocalOnly, 0); _ok = (racket_ != 0); deb_assert(_ok); if (_ok) { racket_->SetInitialTransform(xform(quat(), vec3(0, 0, 0))); racket_->EnableRootShadow(false); racket_->StartLoading(); } } if (_ok) { delete ball_; ball_ = new Ball(GetResourceManager(), "ball", ui_manager_); AddContextObject(ball_, cure::kNetworkObjectLocalOnly, 0); _ok = (ball_ != 0); deb_assert(_ok); if (_ok) { ball_->SetInitialTransform(xform(quat(), vec3(0, 0, 0.4f))); ball_->EnableRootShadow(false); ball_->StartLoading(); } } return _ok; }
bool GcBaseView::twoFingersMove(const MgMotion& motion) { if (!_zoomEnabled) { return false; } if (motion.gestureState <= kMgGestureBegan) { _lastScale = xform()->getZoomValue(_lastCenter); } else if (motion.gestureState == kMgGestureMoved && motion.startPt != motion.startPt2 && motion.point != motion.point2) { // 双指变单指则忽略移动 Point2d at((motion.startPt + motion.startPt2) / 2); Point2d pt((motion.point + motion.point2) / 2); float d1 = motion.point.distanceTo(motion.point2); float d0 = motion.startPt.distanceTo(motion.startPt2); float scale = d1 / d0; xform()->zoom(_lastCenter, _lastScale); // 先恢复 xform()->zoomByFactor(scale - 1, &at); // 以起始点为中心放缩显示 xform()->zoomPan(pt.x - at.x, pt.y - at.y); // 平移到当前点 _zooming = true; cmdView()->regenAll(false); } else if (_zooming) { _zooming = false; cmdView()->regenAll(false); } return true; }
/* * Set the clipping rectangle in an output GIF file. */ int GIFsetClip(Metafile *mf, int num, Glimit *rect) { mf_cgmo *cgmo = mf->cgmo; GIFmetafile *meta = find_meta(cgmo); int x1,y1,x2,y2; xform(meta, rect->xmin, rect->ymin, &x1, &y1); xform(meta, rect->xmax, rect->ymax, &x2, &y2); gdSetClip(meta->image, x1,y1,x2,y2); return OK; }
void Graph::drawY(QPainter& painter, int power, bool label) { QString format("%1"); float delta = pow(logBase, power - 1) / divs; float yline = ceil(ymin / delta) * delta; for (; yline < ymax; yline += delta) { float x1, x2, y1, y2; xform(xmin, yline, x1, y1); xform(xmax, yline, x2, y2); if (label) { painter.drawText(QPoint(x1 + 3, y1 - 4), format.arg(yline)); } else { painter.drawLine(x1, y1, x2, y2); } } }
void Polyhedron::transform(const T &xform) { for (size_t i = 0; i < vertices.size(); i++) { vertices[i].v = xform(vertices[i].v); } faceRecalc(); init(); }
void Projectile::interpolateTick(F32 delta) { Parent::interpolateTick(delta); if( mHasExploded ) return; Point3F interpPos = mCurrDeltaBase + mCurrBackDelta * delta; Point3F dir = mCurrVelocity; if(dir.isZero()) dir.set(0,0,1); else dir.normalize(); MatrixF xform(true); xform = MathUtils::createOrientFromDir(dir); xform.setPosition(interpPos); setRenderTransform(xform); // fade out the projectile image S32 time = (S32)(mCurrTick - delta); if(time > mDataBlock->fadeDelay) { F32 fade = F32(time - mDataBlock->fadeDelay); mFadeValue = 1.0 - (fade / F32(mDataBlock->lifetime)); } else mFadeValue = 1.0; updateSound(); }
void CacheDrivenTask::process( PageInfo const& page_info, AbstractFilterDataCollector* collector) { QRectF const initial_rect(QPointF(0.0, 0.0), page_info.metadata().size()); ImageTransformation xform(initial_rect, page_info.metadata().dpi()); xform.setPreRotation(m_ptrSettings->getRotationFor(page_info.imageId())); if (PageOrientationCollector* col = dynamic_cast<PageOrientationCollector*>(collector)) { col->process(xform.preRotation()); } if (m_ptrNextTask) { m_ptrNextTask->process(page_info, collector, xform); return; } if (ThumbnailCollector* thumb_col = dynamic_cast<ThumbnailCollector*>(collector)) { thumb_col->processThumbnail( std::auto_ptr<QGraphicsItem>( new ThumbnailBase( thumb_col->thumbnailCache(), thumb_col->maxLogicalThumbSize(), page_info.imageId(), xform ) ) ); } }
/* ****************************************************************************** * Function Name : instanceCube() * * Description : * * Input Arguments : GU_Detail *inst_gdp, GU_Detail *mb_gdp * * Return Value : int * ***************************************************************************** */ int VRAY_clusterThis::instanceCube(GU_Detail * inst_gdp, GU_Detail * mb_gdp) { #ifdef DEBUG std::cout << "VRAY_clusterThis::instanceCube()" << std::endl; #endif GEO_Primitive * myCube; GEO_Point * ppt; UT_Matrix4 xform(1.0); // UT_XformOrder xformOrder(UT_XformOrder::TRS, UT_XformOrder::XYZ); UT_Matrix3 rot_xform(1.0); // UT_Vector3 myDir = myPointAttributes.N; UT_Vector3 myUp = UT_Vector3(0,1,0); rot_xform.orient(myPointAttributes.N, myUp); xform = rot_xform; myCube = (GEO_Primitive *) inst_gdp->cube( myPointAttributes.myNewPos[0] - ((mySize[0] * myPointAttributes.pscale) / 2), myPointAttributes.myNewPos[0] + ((mySize[0] * myPointAttributes.pscale) / 2), myPointAttributes.myNewPos[1] - ((mySize[1] * myPointAttributes.pscale) / 2), myPointAttributes.myNewPos[1] + ((mySize[1] * myPointAttributes.pscale) / 2), myPointAttributes.myNewPos[2] - ((mySize[2] * myPointAttributes.pscale) / 2), myPointAttributes.myNewPos[2] + ((mySize[2] * myPointAttributes.pscale) / 2)); for(int i=0; i < myCube->getVertexCount(); i++) { ppt = myCube->getVertexElement(i).getPt(); UT_Vector4 P = ppt->getPos(); P *= xform; ppt->setPos(P); } VRAY_clusterThis::setInstanceAttributes(myCube); if(myDoMotionBlur == CLUSTER_MB_DEFORMATION) { myCube = (GEO_Primitive *) mb_gdp->cube(myPointAttributes.myMBPos[0] - ((mySize[0] * myPointAttributes.pscale) / 2), myPointAttributes.myMBPos[0] + ((mySize[0] * myPointAttributes.pscale) / 2), myPointAttributes.myMBPos[1] - ((mySize[1] * myPointAttributes.pscale) / 2), myPointAttributes.myMBPos[1] + ((mySize[1] * myPointAttributes.pscale) / 2), myPointAttributes.myMBPos[2] - ((mySize[2] * myPointAttributes.pscale) / 2), myPointAttributes.myMBPos[2] + ((mySize[2] * myPointAttributes.pscale) / 2)); for(int i=0; i < myCube->getVertexCount(); i++) { ppt = myCube->getVertexElement(i).getPt(); UT_Vector4 P = ppt->getPos(); P *= xform; ppt->setPos(P); } VRAY_clusterThis::setInstanceAttributes(myCube); } if(myCVEX_Exec) VRAY_clusterThis::runCVEX(inst_gdp, mb_gdp, myCVEXFname, CLUSTER_CVEX_POINT); if(myCVEX_Exec_prim) VRAY_clusterThis::runCVEX(inst_gdp, mb_gdp, myCVEXFname_prim, CLUSTER_CVEX_PRIM); return 0; }
void transform_seq_set_transform(TransformSequence* seq, const double time, const UnalignedTransformd44& transform) { Transformd xform(transform.get_local_to_parent().as_foundation_matrix(), transform.get_parent_to_local().as_foundation_matrix()); seq->set_transform(time, xform); }
xyMultimap_t baseXYData::GetCustom(wxString Xformula, wxString Yformula) { xyMultimap_t map; double x,y; xyMultimap_t::iterator it; gpFormula xform( std::string( Xformula.mb_str()) ); gpFormula yform( std::string( Yformula.mb_str()) ); for(it=m_data.begin(); it!= m_data.end(); it++) { if(Xformula.IsEmpty())x=it->first; else{ xform.AddVariable("X", it->first); xform.AddVariable("Y", it->second); x = xform; } if(Yformula.IsEmpty())y=it->second; else{ yform.AddVariable("X", it->first); yform.AddVariable("Y", it->second); y = yform; } map.insert( pair<double, double>( x, y ) ); } return map; }
unsigned __int64 PlanEntryModelManager::GetMostRecentEntryTimeByAttribute(const TCHAR *pAttr, const TCHAR *pValue) { unsigned __int64 id = 0; StringBuffer conv(32); StringBuffer sb(_T("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>")); sb.append(_T("<xsl:stylesheet version=\"1.0\" xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\" xmlns:msxsl=\"urn:schemas-microsoft-com:xslt\">")); sb.append(_T("<xsl:output method=\"text\" />")); sb.append(_T("<xsl:template match=\"*\">")); sb.append(_T("<xsl:variable name=\"entries\">")); sb.append(_T("<xsl:for-each select=\"timeentry[@")); sb.append(pAttr); sb.append(_T("='")); sb.append(pValue); sb.append(_T("']\"><xsl:sort select=\"@start\" data-type=\"text\" order=\"descending\" />")); sb.append(_T("<entry><xsl:value-of select=\"@start\" /></entry>")); sb.append(_T("</xsl:for-each></xsl:variable>")); sb.append(_T("<xsl:value-of select=\"msxsl:node-set($entries)/entry[1]\" />")); sb.append(_T("</xsl:template></xsl:stylesheet>")); BSTR xslt = SysAllocString(sb); XMLTransform xform(xslt); SysFreeString(xslt); xslt = 0; HRESULT hr = m_pRoot->transformNode(xform.m_pStyleSheet, &xslt); if(hr == S_OK && xslt) { id = ModelUtils::fromHexString(xslt, _tcslen(xslt)); SysFreeString(xslt); } else { DebugBreak(); } return id; }
int SKY_BOX::DrawGradient(CVIEWptr &v) { //DebugBreak(); update_position(); //center at the eye position Patch* p = get_patch(); assert(p); Skybox_Texture* tex = get_tex<Skybox_Texture>(p); assert(tex); glPushAttrib(GL_ENABLE_BIT | GL_CURRENT_BIT ); glEnable(GL_DEPTH_TEST); // set xform: glMatrixMode(GL_MODELVIEW); glPushMatrix(); glMultMatrixd(xform().transpose().matrix()); // draw the mesh normally: int ret= tex->draw(v); glMatrixMode(GL_MODELVIEW); glPopMatrix(); glPopAttrib(); GL_VIEW_PRINT_GL_ERRORS("(regular) : "); return ret; }
void TestLocalXform::testIOHDF5() { USING_NK_NS USING_NKHIVE_NS LocalXform xform(vec3d(0.1, 0.2, 0.5)); LocalXform xform2; CPPUNIT_ASSERT(xform != xform2); remove("testingHDF5.hv"); VolumeFile file("testingHDF5.hv", VoidFile::WRITE_TRUNC); HDF5Group root_group; root_group.open(file.m_id, NK_NS::String("/")); HDF5Id root_group_id = root_group.id(); xform.write(root_group_id); file.close(); VolumeFile file2("testingHDF5.hv", VoidFile::READ_ONLY); HDF5Group root_group2; root_group2.open(file2.m_id, NK_NS::String("/")); HDF5Id root_group_id2 = root_group2.id(); xform2.read(root_group_id2); CPPUNIT_ASSERT(xform == xform2); file2.close(); remove("testingHDF5.hv"); }
bool ON_BezierCageMorph::Create( ON_3dPoint P0, ON_3dPoint P1, ON_3dPoint P2, ON_3dPoint P3, int point_countX, int point_countY, int point_countZ ) { if ( point_countX < 2 || point_countY < 2 || point_countZ < 2 || !P0.IsValid() || !P1.IsValid() || !P2.IsValid() || !P3.IsValid() ) { ON_ERROR("ON_BezierCageMorph::Create - invalid input"); } m_bValid = false; ON_3dVector X = P1-P0; ON_3dVector Y = P2-P0; ON_3dVector Z = P3-P0; ON_Xform xform(1.0); xform[0][0] = X.x; xform[1][0] = X.y; xform[2][0] = X.z; xform[0][1] = Y.x; xform[1][1] = Y.y; xform[2][1] = Y.z; xform[0][2] = Z.x; xform[1][2] = Z.y; xform[2][2] = Z.z; xform[0][3] = P0.x; xform[1][3] = P0.y; xform[2][3] = P0.z; double min_pivot = 0.0; m_bValid = xform.Invert(&min_pivot); if (m_bValid) { ON_3dPoint box_corners[8]; box_corners[0] = P0; box_corners[1] = P1; box_corners[2] = P0+X+Y; box_corners[3] = P2; box_corners[4] = P3; box_corners[5] = P3+X; box_corners[6] = P3+X+Y; box_corners[7] = P3+Y; m_bValid = m_rst2xyz.Create(box_corners,point_countX,point_countY,point_countZ); m_xyz2rst = xform; } else { ON_ERROR("ON_BezierCageMorph::Create - invalid input - P0,P1,P2,P3 are coplanar"); m_rst2xyz.Destroy(); } return m_bValid; }
//------------------------------------------------------------------------------ // void GLPickingSelect::processTriangles( const SubNode::Ptr rootNode, const double seconds, const size_t numTriangles, VBOProxy::VBOMode vboMode ) { const unsigned int bufferSize = (unsigned int)std::min(numTriangles,size_t(100000)); boost::shared_array<GLuint>buffer (new GLuint[bufferSize*4]); M3dView view = fSelectInfo.view(); MMatrix projMatrix; view.projectionMatrix(projMatrix); MMatrix modelViewMatrix; view.modelViewMatrix(modelViewMatrix); unsigned int x, y, w, h; view.viewport(x, y, w, h); double viewportX = static_cast<int>(x); // can be less than 0 double viewportY = static_cast<int>(y); // can be less than 0 double viewportW = w; double viewportH = h; fSelectInfo.selectRect(x, y, w, h); double selectX = static_cast<int>(x); // can be less than 0 double selectY = static_cast<int>(y); // can be less than 0 double selectW = w; double selectH = h; MMatrix selectAdjustMatrix; selectAdjustMatrix[0][0] = viewportW / selectW; selectAdjustMatrix[1][1] = viewportH / selectH; selectAdjustMatrix[3][0] = ((viewportX + viewportW/2.0) - (selectX + selectW/2.0)) / viewportW * 2.0 * selectAdjustMatrix[0][0]; selectAdjustMatrix[3][1] = ((viewportY + viewportH/2.0) - (selectY + selectH/2.0)) / viewportH * 2.0 * selectAdjustMatrix[1][1]; MMatrix localToPort = modelViewMatrix * projMatrix * selectAdjustMatrix; view.beginSelect(buffer.get(), bufferSize*4); view.pushName(0); { Frustum frustum(localToPort.inverse()); MMatrix xform(modelViewMatrix); DrawShadedState state(frustum, seconds, vboMode); DrawShadedTraversal traveral(state, xform, false, Frustum::kUnknown); rootNode->accept(traveral); } view.popName(); int nbPick = view.endSelect(); if (nbPick > 0) { unsigned int Zdepth = closestElem(nbPick, buffer.get()); float depth = float(Zdepth)/MAX_HW_DEPTH_VALUE; fMinZ = std::min(depth,fMinZ); } }
bool Game::Render() { quat orientation; orientation.RotateAroundOwnX(-PIF/5); ui_manager_->SetCameraPosition(xform(orientation, vec3(0, -0.4f, 0.6f))); const PixelRect full_rect(0, 0, ui_manager_->GetCanvas()->GetWidth(), ui_manager_->GetCanvas()->GetHeight()); ui_manager_->Render(full_rect); return true; }
int CameraMatrix::get_pixels_per_meter(int p_for_pixel_width) const { Vector3 result = xform(Vector3(1,0,-1)); return int((result.x * 0.5 + 0.5) * p_for_pixel_width); }
void CloudLayer::renderObject( ObjectRenderInst *ri, SceneRenderState *state, BaseMatInstance *mi ) { GFXTransformSaver saver; const Point3F &camPos = state->getCameraPosition(); MatrixF xfm(true); xfm.setPosition(camPos); GFX->multWorld(xfm); if ( state->isReflectPass() ) GFX->setProjectionMatrix( state->getSceneManager()->getNonClipProjection() ); GFX->setShader( mShader ); GFX->setShaderConstBuffer( mShaderConsts ); GFX->setStateBlock( mStateblock ); // Set all the shader consts... MatrixF xform(GFX->getProjectionMatrix()); xform *= GFX->getViewMatrix(); xform *= GFX->getWorldMatrix(); mShaderConsts->setSafe( mModelViewProjSC, xform ); mShaderConsts->setSafe( mEyePosWorldSC, camPos ); LightInfo *lightinfo = LIGHTMGR->getSpecialLight(LightManager::slSunLightType); const ColorF &sunlight = state->getAmbientLightColor(); Point3F ambientColor( sunlight.red, sunlight.green, sunlight.blue ); mShaderConsts->setSafe( mAmbientColorSC, ambientColor ); const ColorF &sunColor = lightinfo->getColor(); Point3F data( sunColor.red, sunColor.green, sunColor.blue ); mShaderConsts->setSafe( mSunColorSC, data ); mShaderConsts->setSafe( mSunVecSC, lightinfo->getDirection() ); for ( U32 i = 0; i < TEX_COUNT; i++ ) mShaderConsts->setSafe( mTexOffsetSC[i], mTexOffset[i] ); Point3F scale( mTexScale[0], mTexScale[1], mTexScale[2] ); mShaderConsts->setSafe( mTexScaleSC, scale ); Point3F color; color.set( mBaseColor.red, mBaseColor.green, mBaseColor.blue ); mShaderConsts->setSafe( mBaseColorSC, color ); mShaderConsts->setSafe( mCoverageSC, mCoverage ); mShaderConsts->setSafe( mExposureSC, mExposure ); GFX->setTexture( mNormalHeightMapSC->getSamplerRegister(), mTexture ); GFX->setVertexBuffer( mVB ); GFX->setPrimitiveBuffer( mPB ); GFX->drawIndexedPrimitive( GFXTriangleList, 0, 0, smVertCount, 0, smTriangleCount ); }
/* ****************************************************************************** * Function Name : instanceGrid() * * Description : Instance a grid * * Input Arguments : GU_Detail *inst_gdp, GU_Detail *mb_gdp * * Return Value : int * ***************************************************************************** */ int VRAY_clusterThis::instanceGrid(GU_Detail * inst_gdp, GU_Detail * mb_gdp) { #ifdef DEBUG std::cout << "VRAY_clusterThis::instanceGrid()" << std::endl; #endif GEO_Primitive * myGrid; GU_GridParms grid_parms; UT_XformOrder xformOrder(UT_XformOrder::TRS, UT_XformOrder::XYZ); UT_Matrix4 xform(1.0); xform.rotate(myPointAttributes.N[0], myPointAttributes.N[1], myPointAttributes.N[2], xformOrder); grid_parms.rows = 2; grid_parms.cols = 2; grid_parms.xsize = mySize[0] * myPointAttributes.pscale; grid_parms.ysize = mySize[1] * myPointAttributes.pscale; grid_parms.xcenter = myPointAttributes.myNewPos[0]; grid_parms.ycenter = myPointAttributes.myNewPos[1]; grid_parms.zcenter = myPointAttributes.myNewPos[2]; grid_parms.plane = GU_PLANE_XY; myGrid = inst_gdp->buildGrid(grid_parms, GU_GRID_POLY); for(int i = 0; i < myGrid->getVertexCount(); i++) { GEO_Point * ppt = myGrid->getVertexElement(i).getPt(); UT_Vector4 P = ppt->getPos(); P *= xform; ppt->setPos(P); } VRAY_clusterThis::setInstanceAttributes(myGrid); if(myDoMotionBlur == CLUSTER_MB_DEFORMATION) { grid_parms.xcenter = myPointAttributes.myMBPos[0]; grid_parms.ycenter = myPointAttributes.myMBPos[1]; grid_parms.zcenter = myPointAttributes.myMBPos[2]; myGrid = mb_gdp->buildGrid(grid_parms, GU_GRID_POLY); for(int i = 0; i < myGrid->getVertexCount(); i++) { GEO_Point * ppt = myGrid->getVertexElement(i).getPt(); UT_Vector4 P = ppt->getPos(); P *= xform; ppt->setPos(P); } VRAY_clusterThis::setInstanceAttributes(myGrid); } if(myCVEX_Exec) VRAY_clusterThis::runCVEX(inst_gdp, mb_gdp, myCVEXFname, CLUSTER_CVEX_POINT); if(myCVEX_Exec_prim) VRAY_clusterThis::runCVEX(inst_gdp, mb_gdp, myCVEXFname_prim, CLUSTER_CVEX_PRIM); return 0; }
void SKY_BOX::update_position() //centers the sky box around the camera { Wpt eye = VIEW::eye(); if (eye.dist_sqrd(xform().origin()) > 0) { //only update when really needed set_xform(Wtransf(eye)); err_adv(debug, "SKY_BOX::update_position: updated skybox"); } }
STDMETHODIMP CSubPicAllocatorPresenterImpl::SetVideoAngle(Vector v) { XForm xform(Ray(Vector(), v), Vector(1, 1, 1), false); if (m_xform != xform) { m_xform = xform; Paint(false); return S_OK; } return S_FALSE; }
void bt_soft_body::set_transform(vec3f const &position, quatf const &rotation) { vec3f tp = position; quatf tr = rotation; btTransform xform(btQuaternion(tr[1], tr[2], tr[3], tr[0]), btVector3(tp[0], tp[1], tp[2])); // m_body->setWorldTransform(xform); m_body->transform(xform); }
yo_shape transform_shape(yo_shape shape, ym_vec3f pos, ym_vec3f rot, ym_vec3f s) { ym_mat4f xf = xform(pos, rot, s); for (int i = 0; i < shape.nverts; i++) { ym_vec3f* pos = (ym_vec3f*)shape.pos + i; *pos = ym_transform_point3f(xf, *pos); ym_vec3f* norm = (ym_vec3f*)shape.norm + i; *norm = ym_transform_direction3f(xf, *norm); } return shape; }
void CanvasItem::draw_set_transform(const Point2& p_offset, float p_rot, const Size2& p_scale) { if (!drawing) { ERR_EXPLAIN("Drawing is only allowed inside NOTIFICATION_DRAW, _draw() function or 'draw' signal."); ERR_FAIL(); } Matrix32 xform(p_rot,p_offset); xform.scale_basis(p_scale); VisualServer::get_singleton()->canvas_item_set_transform(canvas_item,xform); }
bool GcBaseView::onGesture(const MgMotion& motion) { if (motion.gestureType != kGiGesturePan || !_zoomEnabled){ return false; } if (motion.gestureState <= kMgGestureBegan) { _lastScale = xform()->getZoomValue(_lastCenter); } else if (motion.gestureState == kMgGestureMoved) { Vector2d vec(motion.point - motion.startPt); xform()->zoom(_lastCenter, _lastScale); // 先恢复 xform()->zoomPan(vec.x, vec.y); // 平移到当前点 _zooming = true; cmdView()->regenAll(false); } else if (_zooming) { _zooming = false; cmdView()->regenAll(false); } return true; }
bool ON_Plane::SwapCoordinates( int i, int j ) { bool rc = false; if ( 0 <= i && i < 3 && 0 <= j && j < 3 ) { ON_Xform xform(1); xform[i][i] = 0.0; xform[j][j] = 0.0; xform[i][j] = 1.0; xform[j][i] = 1.0; rc = Transform(xform); } return rc; }
/* * generate a transformation that maps the frustum with apex at the origin, * apex angle=fov and clipping planes y=n and y=f into the double-unit cube. * plane y=n maps to y'=-1, y=f maps to y'=1 */ int persp(Space *t, double fov, double n, double f){ Matrix m; double z; if(n<=0 || f<=n || fov<=0 || 180<=fov) /* really need f!=n && sin(v)!=0 */ return -1; z=1/tan(radians(fov)/2); m[0][0]=z; m[0][1]=0; m[0][2]=0; m[0][3]=0; m[1][0]=0; m[1][1]=(f+n)/(f-n); m[1][2]=0; m[1][3]=f*(1-m[1][1]); m[2][0]=0; m[2][1]=0; m[2][2]=z; m[2][3]=0; m[3][0]=0; m[3][1]=1; m[3][2]=0; m[3][3]=0; xform(t, m); return 0; }
Vector2d moveActionsInView(Box2d& rect) { Vector2d off; Box2d viewrect(0.f, 0.f, (float)xform()->getWidth(), (float)xform()->getHeight()); if (!rect.isEmpty() && !viewrect.contains(rect)) { if (rect.xmin < 0) { off.x = -rect.xmin; } else if (rect.xmax > viewrect.xmax) { off.x = viewrect.xmax - rect.xmax; } if (rect.ymin < 0) { off.y = -rect.ymin; } else if (rect.ymax > viewrect.ymax) { off.y = viewrect.ymax - rect.ymax; } } return off; }
void TestLocalXform::testComparisonOperators() { USING_NK_NS USING_NKHIVE_NS LocalXform xform(vec3d(0.1, 0.2, 0.3)); LocalXform xform2(vec3d(0.1, 0.2, 0.3)); LocalXform xform3(vec3d(0.1, 0.1, 0.1)); CPPUNIT_ASSERT(xform == xform2); CPPUNIT_ASSERT(xform != xform3); CPPUNIT_ASSERT(xform2 != xform3); CPPUNIT_ASSERT(xform3 != xform); }