OpenInventor SoMarkerSet的使用方法

1.addMark()是用来添加新Mark的,并为其设置一个索引(Index);
如:
static unsigned char arrowBits[] = {
0x00, 0xff, 0xff, 0x01, 0x00, 0x00, 0xff, 0xff, 0x01, 0x00, 0x00, 0xff,
0xff, 0x01, 0x00, 0x00, 0xff, 0xff, 0x01, 0x00, 0x00, 0xff, 0xff, 0x01,
0x00, 0x00, 0xff, 0xff, 0x01, 0x00, 0x00, 0xff, 0xff, 0x01, 0x00, 0x00,
0xff, 0xff, 0x01, 0x00, 0x00, 0xff, 0xff, 0x01, 0x00, 0x00, 0xff, 0xff,
0x01, 0x00, 0x00, 0xff, 0xff, 0x01, 0x00, 0x00, 0xff, 0xff, 0x01, 0x00,
0x00, 0xff, 0xff, 0x01, 0x00, 0x00, 0xff, 0xff, 0x01, 0x00, 0x00, 0xff,
0xff, 0x01, 0x00, 0x00, 0xff, 0xff, 0x01, 0x00, 0x00, 0xff, 0xff, 0x01,
0x00, 0x00, 0xff, 0xff, 0x01, 0x00, 0x00, 0xff, 0xff, 0x01, 0x00, 0x00,
0xff, 0xff, 0x01, 0x00, 0x00, 0xff, 0xff, 0x01, 0x00, 0x00, 0xff, 0xff,
0x01, 0x00, 0xff, 0xff, 0xff, 0xff, 0x01, 0xff, 0xff, 0xff, 0xff, 0x01,
0xfe, 0xff, 0xff, 0xff, 0x00, 0xf8, 0xff, 0xff, 0x3f, 0x00, 0xe0, 0xff,
0xff, 0x0f, 0x00, 0xc0, 0xff, 0xff, 0x03, 0x00, 0x00, 0xff, 0xff, 0x01,
0x00, 0x00, 0xfc, 0x7f, 0x00, 0x00, 0x00, 0xf8, 0x1f, 0x00, 0x00, 0x00,
0xe0, 0x07, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00
};
SoMarkerSet::addMarker(90, SbVec2s(17, 17), targetBits);

2.设置坐标

SbVec3f markersCoords[NUM_MARKERS] = {
SbVec3f(0.5f, 0.5f, 0.0f), SbVec3f(1.5f, 3.8f, 0.0f),
SbVec3f(1.8f, 1.2f, 0.0f), SbVec3f(2.4f, 1.9f, 0.0f),
SbVec3f(3.2f, 6.3f, 0.0f), SbVec3f(4.5f, 7.2f, 0.0f),
SbVec3f(6.3f, 9.3f, 0.0f), SbVec3f(6.9f, 7.2f, 0.0f),
SbVec3f(8.0f, 6.0f, 0.0f), SbVec3f(8.5f, 6.3f, 0.0f)
};
// Sets the coordinates of the markers.

SoCoordinate3 *coords = new SoCoordinate3;

coords->point.setValues(0, NUM_MARKERS, markersCoords);
其中markersCoords坐标数组。

3.设置显示何种marker
int32_t markersIndexes[NUM_MARKERS] = {
90, 91, 92, SoMarkerSet::CIRCLE_FILLED_9_9, SoMarkerSet::SQUARE_FILLED_9_9,
SoMarkerSet::DIAMOND_FILLED_9_9, SoMarkerSet::TRIANGLE_FILLED_9_9,
SoMarkerSet::RHOMBUS_FILLED_9_9, SoMarkerSet::HOURGLASS_FILLED_9_9
};
// Sets the indices of the markers.
SoMarkerSet *markerSet = new SoMarkerSet;
markerSet->markerIndex.setValues(0, NUM_MARKERS, markersIndexes);
其中markersIndexes为marker的Index数组。
若只想用一种形状,则可以这样:
markerSet->markerIndex.setValue(SoMarkerSet::DIAMOND_FILLED_9_9);
4.设置材质绑定方式
SoMaterialBinding *matBind = new SoMaterialBinding;
matBind->value = SoMaterialBinding::PER_VERTEX;//表明One material for each vertex of object
5.设置每一个marker的颜色
// Sets the color of the markers.
SoMaterial *mat = new SoMaterial;
mat->diffuseColor.setValues(0, NUM_MARKERS, markersColors);
6.节点的添加顺序
root->addChild(coords);
root->addChild(matBind);
root->addChild(mat);
root->addChild(markerSet);

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值