python vec3_基于osg的python三维程序开发(三)------几何形体及纹理

本文档介绍了如何使用Python和osg库创建3D几何形状,包括点、线、线段、线环、多边形、四边形条带和三角形,同时涉及了颜色和法线的设置,以及纹理的应用。
摘要由CSDN通过智能技术生成

1 defcreateScene():2 geode =osg.Geode()3 pointsGeom =osg.Geometry()4 vertices =osg.Vec3Array()5 vertices.push_back((-1.02168, -2.15188e-09, 0.885735))6 vertices.push_back((-0.976368, -2.15188e-09, 0.832179))7 vertices.push_back((-0.873376, 9.18133e-09, 0.832179))8 vertices.push_back((-0.836299, -2.15188e-09, 0.885735))9 vertices.push_back((-0.790982, 9.18133e-09, 0.959889))10 pointsGeom.setVertexArray(vertices)11 colors =osg.Vec4Array()12 colors.push_back((1.0,1.0,0.0,1.0))13 geode =osg.Geode()14 pointsGeom.setColorArray(colors, osg.BIND_OVERALL)15 normals =osg.Vec3Array()16 normals.push_back((0.0,-1.0,0.0))17 pointsGeom.setNormalArray(normals, osg.BIND_OVERALL)18 pointsGeom.addPrimitiveSet(osg.DrawArrays(osg.POINTS,0,vertices.size()))19 geode.addDrawable(pointsGeom)20 #create LINES

21 linesGeom =osg.Geometry()22 arr = np.array([-1.13704, -2.15188e-09, 0.40373,23 -0.856897, -2.15188e-09, 0.531441,24 -0.889855, -2.15188e-09, 0.444927,25 -0.568518, -2.15188e-09, 0.40373,26 -1.00933, -2.15188e-09, 0.370773,27 -0.716827, -2.15188e-09, 0.292498,28 -1.07936, 9.18133e-09, 0.317217,29 -0.700348, 9.18133e-09, 0.362533],np.float32)30 arr = np.reshape(arr,(-1,3))31 vertices =osg.Vec3Array(arr)32 linesGeom.setVertexArray(vertices)33 colors =osg.Vec4Array()34 colors.push_back((1.0,1.0,0.0,1.0))35 linesG

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值