CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

ObjectARX 开发指南

相关分类

示例 1:坐标系

2022-12-31 15:02| 发布者: admin| 查看: 276| 评论: 0|来自: AutoCAD

此示例采用在模型坐标中定义的线段,并在眼睛和显示坐标中创建其等效线段。显示时,所有行将重叠。

 void 
      AsdkCoordSamp::subViewportDraw       (AcGiViewportDraw* pV)     
 { 
 pV->subEntityTraits().setFillType(kAcGiFillAlways); 
  
 const int count = 3; 
 AcGePoint3d verts[count]; 
      verts[0] =       AcGePoint3d(0.0, 0.0, 0.0);     
 verts[1] = AcGePoint3d(1.0, 0.0, 0.0); 
 verts[2] = AcGePoint3d(1.0, 1.0, 0.0); 
  
      // Draw model space line segment.     
      //     
      pV-       >subEntityTraits().setColor(kBlue);     
 pV->geometry().polygon(count, verts); 
  
 // Compute its representation in eye space. 
 // 
 AcGeMatrix3d mat; 
      pV->viewport       ().getModelToEyeTransform(mat);     
  
 for (int i = 0; i < count; i++) { 
 verts[i].x += 0.01; 
 verts[i].y += 0.01; 
 verts[i].z += 0.01; 
      verts[i].transformBy       (mat);     
 } 
  
 // Display the eye coordinate equivalent of the 
 // model space polygon. 
 // 
      pV->subEntityTraits().setColor(kGreen);     
      pV-       >geometry().polygonEye(count, verts);     
  
 // Convert from eye to display coordinates. 
 // 
      for (int i = 0; i < count; i++) {     
      verts[i].x += 0.01;     
 verts[i].y += 0.01; 
 verts[i].z += 0.01; 
 } 
  
 // Draw the display space equivalent of the 
 // model space polygon. 
 // 
      pV->subEntityTraits       ().setColor(kRed);     
 pV->geometry().polygonDc(count, verts); 
 } 
void
AsdkCoordSamp::viewportDraw(AcGiViewportDraw* pV)
{
    pV->subEntityTraits().setFillType(kAcGiFillAlways);
    const int count = 3;
    AcGePoint3d verts[count];
    verts[0] = AcGePoint3d(0.0, 0.0, 0.0);
    verts[1] = AcGePoint3d(1.0, 0.0, 0.0);
    verts[2] = AcGePoint3d(1.0, 1.0, 0.0);
    // Draw model space line segment.
    //
    pV->subEntityTraits().setColor(kBlue);
    pV->geometry().polygon(count, verts);
    // Compute the line's representation in eye space.
    //
    AcGeMatrix3d mat;
    pV->viewport().getModelToEyeTransform(mat); 
    for (int i = 0; i < count; i++) {
        verts[i].x += 0.01;
        verts[i].y += 0.01;
        verts[i].z += 0.01;
        verts[i].transformBy(mat);
    }
    // Display the eye coordinate equivalent of the 
    // model space polygon.
    //
    pV->subEntityTraits().setColor(kGreen);
    pV->geometry().polygonEye(count, verts);
    // Convert from eye to display coordinates.
    // 
    for (i = 0; i < count; i++) {
        verts[i].x += 0.01;
        verts[i].y += 0.01;
        verts[i].z += 0.01;
    }
    // Draw the display space equivalent of the
    // model space polygon.
    //
    pV->subEntityTraits().setColor(kRed);
    pV->geometry().polygonDc(count, verts);
}

路过

雷人

握手

鲜花

鸡蛋

最新评论

QQ|Archiver|CAD开发者社区 ( 苏ICP备2022047690号-1 )

GMT+8, 2024-5-19 14:59

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部