本文整理汇总了Python中panda3d.core.GeomVertexWriter.setData3f方法的典型用法代码示例。如果您正苦于以下问题:Python GeomVertexWriter.setData3f方法的具体用法?Python GeomVertexWriter.setData3f怎么用?Python GeomVertexWriter.setData3f使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类panda3d.core.GeomVertexWriter
的用法示例。
在下文中一共展示了GeomVertexWriter.setData3f方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: projectVerticesToShadow
# 需要导入模块: from panda3d.core import GeomVertexWriter [as 别名]
# 或者: from panda3d.core.GeomVertexWriter import setData3f [as 别名]
def projectVerticesToShadow(self):
inVertices=self.unmodifiedVertexData
modelWorldX=self.modelWorldX
modelWorldY=self.modelWorldY
modelWorldZ=self.modelWorldZ
zRotationDegrees=self.modelRotation
lightWorldX=self.lightWorldX
lightWorldY=self.lightWorldY
lightWorldZ=self.lightWorldZ
zRotationRadians=zRotationDegrees*(math.pi/180.0)
mathCosZRotationRadians=math.cos(zRotationRadians)
mathSinZRotationRadians=math.sin(zRotationRadians)
vdata=self.pandaVertexData
vertex = GeomVertexWriter(vdata, 'vertex')
for inVertex in inVertices:
vertexModelX,vertexModelY,vertexModelZ=inVertex
vertexModelOldX=vertexModelX
vertexModelOldY=vertexModelY
vertexModelX=vertexModelOldX*mathCosZRotationRadians-vertexModelOldY*mathSinZRotationRadians
vertexModelY=vertexModelOldX*mathSinZRotationRadians+vertexModelOldY*mathCosZRotationRadians
vertexWorldX=modelWorldX+vertexModelX
vertexWorldY=modelWorldY+vertexModelY
vertexWorldZ=modelWorldZ+vertexModelZ
vertexLightZDiff=vertexWorldZ-lightWorldZ
shadowVertexX=lightWorldX+((vertexWorldX-lightWorldX)*-lightWorldZ/vertexLightZDiff)
shadowVertexY=lightWorldY+((vertexWorldY-lightWorldY)*-lightWorldZ/vertexLightZDiff)
normalisedShadowVertexX=shadowVertexX-modelWorldX
normalisedShadowVertexY=shadowVertexY-modelWorldY
normalisedShadowVertexZ=0
vertex.setData3f(normalisedShadowVertexX,normalisedShadowVertexY,normalisedShadowVertexZ)
示例2: interpolate_maps
# 需要导入模块: from panda3d.core import GeomVertexWriter [as 别名]
# 或者: from panda3d.core.GeomVertexWriter import setData3f [as 别名]
def interpolate_maps(self, task):
# First, the actual interpolation
t_index = self.last_time
current_map = {}
for x in range(0, self.sidelength):
for y in range(0, self.sidelength):
# calculate vertices
p_1 = self.map_a[(x, y)]
p_2 = self.map_b[(x, y)]
v_x = p_1[0]*(1.0-t_index) + p_2[0]*t_index
v_y = p_1[1]*(1.0-t_index) + p_2[1]*t_index
v_z = p_1[2]*(1.0-t_index) + p_2[2]*t_index
current_map[(x, y)] = (v_x, v_y, v_z)
# Set up the writers
vertex = GeomVertexWriter(self.vdata, 'vertex')
normal = GeomVertexWriter(self.vdata, 'normal')
# We don't use vertex readers as we don't care about the
# current state, but if we did, it'd look like this:
# vertex_reader = GeomVertexReader(self.vdata, 'vertex')
# v = vertex_reader.getData3f()
# Remember that all vertex readers working on a
# GeomVertexData have to be created *after* the writers
# working on it (due to engine internals; see the manual).
for x in range(0, self.sidelength):
for y in range(0, self.sidelength):
v_x, v_y, v_z = current_map[(x, y)]
vertex.setData3f(v_x, v_y, v_z)
# Calculate the normal
if x==0 and y==0:
s_0 = Vec3( 0.0, 1.0, v_z - current_map[(x, y+1)][2])
s_1 = Vec3( 1.0, 0.0, v_z - current_map[(x+1, y)][2])
e_0 = s_0.cross(s_1)
# Flip if necessary, then normalize
if e_0[2] < 0.0:
e_0 = e_0*-1.0
n = e_0
n = n/n.length()
elif x==0 and y==(self.sidelength-1):
# First, we calculate the vectors to the neighbors.
s_1 = Vec3( 1.0, 0.0, v_z - current_map[(x+1, y)][2])
s_2 = Vec3( 0.0, -1.0, v_z - current_map[(x, y-1)][2])
e_1 = s_1.cross(s_2)
# Flip if necessary, then normalize
if e_1[2] < 0.0:
e_1 = e_1*-1.0
n = e_1
n = n/n.length()
elif x==(self.sidelength-1) and y==0:
# First, we calculate the vectors to the neighbors.
s_0 = Vec3( 0.0, 1.0, v_z - current_map[(x, y+1)][2])
s_3 = Vec3(-1.0, 0.0, v_z - current_map[(x-1, y)][2])
e_3 = s_3.cross(s_0)
# Flip if necessary, then normalize
if e_3[2] < 0.0:
e_3 = e_3*-1.0
n = e_3
n = n/n.length()
elif x==(self.sidelength-1) or y==(self.sidelength-1):
# First, we calculate the vectors to the neighbors.
s_2 = Vec3( 0.0, -1.0, v_z - current_map[(x, y-1)][2])
s_3 = Vec3(-1.0, 0.0, v_z - current_map[(x-1, y)][2])
e_2 = s_2.cross(s_3)
# Flip if necessary, then normalize
if e_2[2] < 0.0:
e_2 = e_2*-1.0
n = e_2
n = n/n.length()
elif x==0:
# First, we calculate the vectors to the neighbors.
s_0 = Vec3( 0.0, 1.0, v_z - current_map[(x, y+1)][2])
s_1 = Vec3( 1.0, 0.0, v_z - current_map[(x+1, y)][2])
s_2 = Vec3( 0.0, -1.0, v_z - current_map[(x, y-1)][2])
e_0 = s_0.cross(s_1)
e_1 = s_1.cross(s_2)
# Flip if necessary, then normalize
if e_0[2] < 0.0:
e_0 = e_0*-1.0
if e_1[2] < 0.0:
e_1 = e_1*-1.0
n = e_0 + e_1
n = n/n.length()
elif y==0:
# First, we calculate the vectors to the neighbors.
s_0 = Vec3( 0.0, 1.0, v_z - current_map[(x, y+1)][2])
s_1 = Vec3( 1.0, 0.0, v_z - current_map[(x+1, y)][2])
s_3 = Vec3(-1.0, 0.0, v_z - current_map[(x-1, y)][2])
e_0 = s_0.cross(s_1)
e_3 = s_3.cross(s_0)
# Flip if necessary, then normalize
if e_0[2] < 0.0:
e_0 = e_0*-1.0
if e_3[2] < 0.0:
e_3 = e_3*-1.0
n = e_0 + e_3
n = n/n.length()
elif x==(self.sidelength-1):
# First, we calculate the vectors to the neighbors.
s_1 = Vec3( 1.0, 0.0, v_z - current_map[(x+1, y)][2])
s_2 = Vec3( 0.0, -1.0, v_z - current_map[(x, y-1)][2])
s_3 = Vec3(-1.0, 0.0, v_z - current_map[(x-1, y)][2])
#.........这里部分代码省略.........