Page 1 of 1

coin3d的坐标系

Posted: Tue Jun 02, 2020 1:48 pm
by johnwang
用如下的宏画了一个六面体。宽10,高20,深50。可以看出coin3d用的是屏幕坐标系。屏幕是x-y平面。从屏幕出来是z的正方向。相当于freeCad的top view.

Code: Select all

from pivy import coin

sg = FreeCADGui.ActiveDocument.ActiveView.getSceneGraph()
cub = coin.SoCube()
cub.width=10
cub.height=20
cub.depth=50
myCustomNode = coin.SoSeparator()
myCustomNode.addChild(cub)
sg.addChild(myCustomNode)
coin3dcube.jpg
coin3dcube.jpg (3.59 KiB) Viewed 946 times

Re: coin3d的坐标系

Posted: Tue Jun 02, 2020 4:48 pm
by paullee
一直不懂 Scenegraph / Coin, 歡迎多點教材 :)

Re: coin3d的坐标系

Posted: Tue Jun 02, 2020 11:00 pm
by johnwang
paullee wrote:
Tue Jun 02, 2020 4:48 pm
一直不懂 Scenegraph / Coin, 歡迎多點教材 :)
Scenegraph就是个绘图空间。你造好一个六面体,贴好标签(SoSeparator),扔到里面就可以了。

标签上写着各种如何摆放的指示。比如刷什么颜色,平移到哪里,转个角度什么的。当然,这些辅助的东西,必须在做标签之前就有了。比如对应颜色,必须先准备好油漆。

Code: Select all

from pivy import coin

#找到绘图空间
sg = FreeCADGui.ActiveDocument.ActiveView.getSceneGraph()

#做六面体
cub = coin.SoCube()
cub.width=10
cub.height=20
cub.depth=50

#做标签
myCustomNode = coin.SoSeparator()

#把标签挂到六面体上
myCustomNode.addChild(cub)

#扔到绘图空间里
sg.addChild(myCustomNode)

Re: coin3d的坐标系

Posted: Wed Jun 03, 2020 12:37 pm
by paullee
johnwang wrote:
Tue Jun 02, 2020 11:00 pm

Code: Select all

from pivy import coin

#找到绘图空间
sg = FreeCADGui.ActiveDocument.ActiveView.getSceneGraph()

#做六面体
cub = coin.SoCube()
cub.width=10
cub.height=20
cub.depth=50

#做标签
myCustomNode = coin.SoSeparator()

#把标签挂到六面体上
myCustomNode.addChild(cub)

#扔到绘图空间里
sg.addChild(myCustomNode)
感謝 ! 希望 有更多人 可學習 及應用 :D