#include <Inventor\Win\SoWin.h>
#include <Inventor\Win\viewers\SoWinExaminerViewer.h>
#include <Inventor\nodes\SoCoordinate3.h>
#include <Inventor\nodes\SoFaceSet.h>
#include <Inventor\nodes\SoMaterial.h>
#include <Inventor\nodes\SoNormal.h>
#include <Inventor\nodes\SoNormalBinding.h>
#include <Inventor\nodes\SoSeparator.h>
#include <Inventor\nodes\SoVertexProperty.h>
#include <Inventor\nodes\SoShapeHints.h>
#include <Inventor\nodes\SoTexture.h>
#include <Inventor\events\SoKeyboardEvent.h>
#include <Inventor\nodes\SoEventCallback.h>
static const float vertices[12][3] = { //顶点坐标
{ 0, 0, 0 },{ 1, -1, 0 },{ 1, 1, 0 },
{ 0.8f, 0, 0 },{ 0.3f, -0.2f, 0 },{ 0.3f, 0.2f, 0 },
{ 0, 0, 0 },{ 0, -1, 0 },{ 1, -1, 0 },
{ 0.6f, 0, 0 },{ 0.4f, -0.9f, 0 },{ 0.1f, -0.5f, 0 }
};
//多边形中顶点的个数
static int numvertices[4] = { 3, 3, 3, 3 };
SoShapeHints *m_hints;
//对用户的按键事件进行响应
void myKeyPressCB(void *userData, SoEventCallback *eventCB)
{
const SoEvent *event = eventCB->getEvent();
if (SO_KEY_PRESS_EVENT(event, W)) { //是否按下了字母W
if (m_hints->windingType.getValue() == SoShapeHints::ODD_TYPE) {
m_hints->windingType = SoShapeHints::NON_ZERO_TYPE;
printf("SoShapeHints::NON_ZERO_TYPE\n");
}
else if (m_hints->windingType.getValue() == SoShapeHints::NON_ZERO_TYPE) {
m_hints->windingType = SoShapeHints::POSITIVE_TYPE;
printf("SoShapeHints::POSITIVE_TYPE\n");
}
else if (m_hints->windingType.getValue() == SoShapeHints::POSITIVE_TYPE) {
m_hints->windingType = SoShapeHints::NEGATIVE_TYPE;
printf("SoShapeHints::NEGATIVE_TYPE\n");
}
else if (m_hints->windingType.getValue() == SoShapeHints::NEGATIVE_TYPE) {
m_hints->windingType = SoShapeHints::NO_WINDING_TYPE;
printf("SoShapeHints::NO_WINDING_TYPE\n");
}
else if (m_hints->windingType.getValue() == SoShapeHints::NO_WINDING_TYPE) {
m_hints->windingType = SoShapeHints::ABS_GEQ_TWO_TYPE;
printf("SoShapeHints::ABS_GEQ_TWO_TYPE\n");
}
else if (m_hints->windingType.getValue() == SoShapeHints::ABS_GEQ_TWO_TYPE) {
m_hints->windingType = SoShapeHints::ODD_TYPE;
printf("SoShapeHints::ODD_TYPE\n");
}
}
}
//根据不同的环绕规则来创建平面
SoSeparator *makeObjectFaceSet()
{
SoSeparator *result = new SoSeparator();
result->ref();
m_hints = new SoShapeHints;
result->addChild(m_hints);
m_hints->windingType = SoShapeHints::ODD_TYPE;
m_hints->windingType = SoShapeHints::COUNTERCLOCKWISE;
printf("Press 'W' (in selection mode) to change winding rule\n");
printf("SoShapeHints::ODD_TYPE\n");
SoVertexProperty *myVertexProperty = new SoVertexProperty;
//定义材质节点
myVertexProperty->orderedRGBA.setValue(SbColor( 0.4f, 0, 0 ).getPackedValue());
myVertexProperty->normalBinding = SoVertexProperty::OVERALL;
myVertexProperty->normal.set1Value( 0, SbVec3f( 0, 0, 1 ));
//定义每个面的颜色
int i;
for (i = 0; i < 12; i++)
{
myVertexProperty->orderedRGBA.set1Value(i, SbColor( 1, 0, 0 ).getPackedValue());
//定义顶点所使用的坐标
myVertexProperty->vertex.setValues(0, 12, vertices);
//定义 SoFaceSet 面集合
SoFaceSet *myFaceSet = new SoFaceSet;
myFaceSet->numVertices.setValues(0, 4, numvertices);
myFaceSet->vertexProperty.setValue(myVertexProperty);
result->addChild(myFaceSet);
result->unrefNoDelete();
return result;
}
}
int main (int, char **argv)
{
HWND myWindow = SoWin::init(argv[0]);
if (myWindow == NULL) exit(1);
SoSeparator *root = new SoSeparator;
root->ref();
//处理按键事件
SoEventCallback *myEventCB = new SoEventCallback;
myEventCB->addEventCallback(SoKeyboardEvent::getClassTypeId(), myKeyPressCB, root);
root->addChild(myEventCB);
root->addChild(makeObjectFaceSet());
SoWinExaminerViewer *myViewer = new SoWinExaminerViewer(myWindow);
myViewer->setBackgroundColor(SbColor(0.5f, 0.5f, 0.5f));
myViewer->setSceneGraph(root);
myViewer->setTitle("SoShapeHints节点的环绕规则示例");
myViewer->setViewing(FALSE);
myViewer->viewAll();
myViewer->show();
SoWin::show(myWindow);
SoWin::mainLoop();
return 0;
}
没有合适的资源?快使用搜索试试~ 我知道了~
VC6.0.zip_C++_OpenInventor_alarmsensor
共99个文件
pdb:10个
dsw:9个
opt:9个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 137 浏览量
2022-09-14
23:45:15
上传
评论
收藏 17.68MB ZIP 举报
温馨提示
OpenInventor在C++中的相关编程
资源推荐
资源详情
资源评论
收起资源包目录
VC6.0.zip (99个子文件)
VC6.0
SoEnvironment.cpp 3KB
3D TEXT.DSW 522B
B-Spline curve.opt 53KB
AlarmSensor.opt 52KB
File Reader.dsw 530B
File Reader.plg 2KB
3D TEXT.DSP 3KB
OpenGL Callback.cpp 4KB
AlarmSensor.cpp 3KB
SoEnvironment.opt 53KB
File Reader.cpp 2KB
SoShapeHints.dsp 3KB
File Reader.dsp 3KB
SoEnvironment.ncb 41KB
Timer Sensor.dsp 3KB
SoEnvironment.dsw 534B
B-Spline curve.cpp 3KB
File Reader.ncb 33KB
B-Spline curve.ncb 33KB
3D TEXT.ncb 33KB
SoShapeHints.ncb 41KB
2D TEXT.DSW 522B
B-Spline curve.plg 794B
AlarmSensor.dsw 530B
AlarmSensor.ncb 33KB
Timer Sensor.plg 782B
SoEnvironment.plg 789B
2D TEXT.DSP 3KB
OpenGL Callback.dsw 538B
SoShapeHints.cpp 4KB
B-Spline curve.dsw 536B
2D TEXT.PLG 759B
2D TEXT.ncb 41KB
AlarmSensor.dsp 3KB
2D TEXT.OPT 52KB
SoEnvironment.dsp 3KB
File Reader.opt 52KB
Timer Sensor.cpp 3KB
2D TEXT.CPP 2KB
OpenGL Callback.dsp 3KB
OpenGL Callback.ncb 33KB
AlarmSensor.plg 1KB
OpenGL Callback.opt 52KB
SoShapeHints.opt 53KB
SoShapeHints.plg 784B
Timer Sensor.dsw 532B
3D TEXT.CPP 3KB
Debug
AlarmSensor.exe 224KB
Timer Sensor.ilk 479KB
Timer Sensor.pch 4.94MB
OpenGL Callback.obj 55KB
File Reader.pdb 505KB
3D TEXT.pdb 497KB
3D TEXT.obj 65KB
3D TEXT.pch 5.04MB
2D TEXT.pch 4.98MB
SoShapeHints.exe 228KB
SoShapeHints.obj 56KB
2D TEXT.obj 55KB
Timer Sensor.obj 53KB
Timer Sensor.exe 224KB
SoEnvironment.exe 228KB
File Reader.ilk 310KB
File Reader.exe 192KB
SoShapeHints.ilk 510KB
SoEnvironment.ilk 500KB
AlarmSensor.pdb 465KB
B-Spline curve.pch 5.06MB
vc60.idb 505KB
File Reader.obj 34KB
AlarmSensor.obj 54KB
SoShapeHints.pch 5.15MB
2D TEXT.exe 228KB
OpenGL Callback.pdb 25KB
SoEnvironment.pdb 617KB
3D TEXT.ilk 548KB
3D TEXT.exe 232KB
AlarmSensor.pch 4.86MB
AlarmSensor.ilk 461KB
File Reader.pch 4.79MB
OpenGL Callback.pch 4.79MB
2D TEXT.pdb 617KB
vc60.pdb 460KB
Timer Sensor.pdb 473KB
SoShapeHints.pdb 633KB
B-Spline curve.ilk 510KB
2D TEXT.ilk 512KB
SoEnvironment.obj 57KB
B-Spline curve.exe 228KB
B-Spline curve.pdb 489KB
B-Spline curve.obj 59KB
SoEnvironment.pch 5.11MB
Timer Sensor.opt 52KB
B-Spline curve.dsp 3KB
3D TEXT.OPT 53KB
3D TEXT.PLG 759B
Timer Sensor.ncb 33KB
SoShapeHints.dsw 532B
OpenGL Callback.plg 2KB
共 99 条
- 1
资源评论
小贝德罗
- 粉丝: 70
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 基于Typescript的兔子饭店经营类游戏源码设计免费送cocoscreator
- 基于Java的web快速开发数据权限管理脚手架wonder-server设计源码
- 基于Apache Log4cxx的C++日志库设计源码
- 基于Vue3的likeadmin免费任意商用管理后台设计源码
- 基于JavaScript的Chrome扩展WeNote分享插件设计源码
- 基于C++的中泰EM9108S动态库开发示例源码
- gxlx2-p291-1g.dts和gxlx2-p291-1g.dtb
- STM32WBxx Keil芯片包
- 基于CNN+Bi-LSTM+Attention 的自动对对联系统
- 基于Java的IndexBar Android字母索引栏设计源码
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功