本文整理汇总了Python中panda3d.core.TransformState.makeMat方法的典型用法代码示例。如果您正苦于以下问题:Python TransformState.makeMat方法的具体用法?Python TransformState.makeMat怎么用?Python TransformState.makeMat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类panda3d.core.TransformState
的用法示例。
在下文中一共展示了TransformState.makeMat方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: complete_shape
# 需要导入模块: from panda3d.core import TransformState [as 别名]
# 或者: from panda3d.core.TransformState import makeMat [as 别名]
def complete_shape(self, id_mb1, node, transform):
""" create the shape then call recursive function"""
#print "complete shape {}".format(node)
## construct the node
self.add_node_to_shape(node, id_mb1, transform)
if node.gen_type == 'piece':
self.shape_building_status[node] = True
elif node.gen_type() == 'link':
self.link_building_status[node][1] = (id_mb1, TransformState.makeMat(transform.getMat()))
self.build_link(node)
## recursive loop over the edges
for face, edge in enumerate(node.edges[1:]):
if edge.type() != 'empty':
transform = self.change_transform(transform, face + 1, type)
if edge.gen_type() == 'shape':
if not self.shape_building_status[edge]:
#then we have to add this node (because it
#is not entirely finished
self.complete_shape(id_mb1, edge, transform)
elif edge.gen_type() == 'link':
if self.link_building_status[edge][0][0] is None:
# first time we see this link
#print "hi new link"
self.add_node_to_shape(edge, id_mb1, transform)
self.link_building_status[edge][0] = (id_mb1, TransformState.makeMat(transform.getMat()))
else:
# link is complete:
#print " hi end link"
self.add_node_to_shape(edge, id_mb1)
self.link_building_status[edge][1] = (id_mb1, TransformState.makeMat(transform.getMat()))
self.build_link(edge)
transform = self.change_back_transform(transform, face + 1, type)
示例2: build_link
# 需要导入模块: from panda3d.core import TransformState [as 别名]
# 或者: from panda3d.core.TransformState import makeMat [as 别名]
def build_link(self, node):
(id_bda, ta), (id_bdb, tb) = self.link_building_status[node]
bda = self.factory.multiboxes[id_bda]
bdb = self.factory.multiboxes[id_bdb]
pos = bda.body.getPosition()
quat = LQuaternionf(bda.body.getQuaternion())
mat = TransformState.makePosQuatScale(pos, quat, Vec3(1, 1, 1)).getMat()
mat = ta.getMat() * mat
print "ta", ta
print "absol", TransformState.makeMat(mat)
mat = LMatrix4f.translateMat(Vec3(0.5, 0, 0)) * mat
anchor = TransformState.makeMat(mat).getPos()
print "absol", TransformState.makeMat(mat)
axis = self.quat_dict[1][1]
if node.orientation == 1:
t = LMatrix4f.rotateMat(*self.quat_dict[4]) * mat
else:
t = LMatrix4f.rotateMat(*self.quat_dict[2]) * mat
row = t.getRow(0)
print "rotation", t.getRow(0), type(t.getRow(0))
#axis = t.getQuat().getAxis()
axis = Vec3(row.getX(), row.getY(), row.getZ())
print "axis",axis
print "anchor", anchor
mat = LMatrix4f.translateMat(Vec3(0.5, 0, 0)) * mat
mat = tb.getInverse().getMat() * mat
t = TransformState.makeMat(mat)
posb = t.getPos()
quatb = t.getQuat()
bdb.body.setPosition(posb)
bdb.body.setQuaternion(quatb)
cs = OdeHingeJoint(self.physics.world, self.physics.servogroup)
cs.attach(bda.body, bdb.body)
cs.setAxis(axis)
cs.setAnchor(anchor)
#add the motor
cs.setParamFMax(self.satu_cmd)
cs.setParamFudgeFactor(0.5)
cs.setParamCFM(11.1111)
cs.setParamStopCFM(11.1111)
cs.setParamStopERP(0.444444)
cs.setParamLoStop(- math.pi * 0.5)
cs.setParamHiStop(math.pi * 0.5)
pid = PID()
self.dof_motors[node] = (cs, pid)
print "add constraint"
示例3: move_city
# 需要导入模块: from panda3d.core import TransformState [as 别名]
# 或者: from panda3d.core.TransformState import makeMat [as 别名]
def move_city(self, task):
# moves the city, using the transformation matrix
# first, get the current transformation matrix
# getTransform() returns a TransformState, which is a higher level
# abstraction of our matrix
# getMat() retrieves the inner matrix. the returned matrix is const
# though
oldmat = self.cityModel.getTransform().getMat()
# oldmat ist a const Mat4, we need one we can manipulate
newmat = Mat4(oldmat)
# the matrices in Panda3d are suitable for row-vector multiplication, that is
# vector * Matrix (same as opengl). the bottom row (3) is therefore the
# translation in xyzt order
#
# replace it with a different one, we want to move the value of
# time, which is the number of seconds passed since starting this task
newmat.setRow(3, Vec4(1-task.time, 3, 0, 1))
# we need to create a new TransformState from the matrix, and set it
# to apply the transformation
self.cityModel.setTransform(TransformState.makeMat(newmat))
return Task.cont
示例4: __init__
# 需要导入模块: from panda3d.core import TransformState [as 别名]
# 或者: from panda3d.core.TransformState import makeMat [as 别名]
def __init__(self):
""" Creates a new ShadowSource. After the creation, a lens can be added
with setupPerspectiveLens or setupOrtographicLens. """
self.index = self._generateUID()
DebugObject.__init__(self, "ShadowSource-" + str(self.index))
ShaderStructElement.__init__(self)
self.valid = False
self.camera = Camera("ShadowSource-" + str(self.index))
self.camera.setActive(False)
self.cameraNode = NodePath(self.camera)
self.cameraNode.reparentTo(Globals.render.find("RPCameraDummys"))
self.cameraNode.hide()
self.resolution = 512
self.atlasPos = Vec2(0)
self.doesHaveAtlasPos = False
self.sourceIndex = 0
self.mvp = UnalignedLMatrix4f()
self.sourceIndex = -1
self.nearPlane = 0.0
self.farPlane = 1000.0
self.converterYUR = None
self.transforMat = TransformState.makeMat(
Mat4.convertMat(Globals.base.win.getGsg().getInternalCoordinateSystem(),
CSZupRight))
示例5: _createInputHandles
# 需要导入模块: from panda3d.core import TransformState [as 别名]
# 或者: from panda3d.core.TransformState import makeMat [as 别名]
def _createInputHandles(self):
""" Defines various inputs to be used in the shader passes. Most inputs
use pta-arrays, so updating them is faster than using setShaderInput all the
time. """
self.cameraPosition = PTAVecBase3f.emptyArray(1)
self.currentViewMat = PTALMatrix4f.emptyArray(1)
self.currentProjMatInv = PTALMatrix4f.emptyArray(1)
self.lastMVP = PTALMatrix4f.emptyArray(1)
self.currentMVP = PTALMatrix4f.emptyArray(1)
self.frameIndex = PTAInt.emptyArray(1)
self.frameDelta = PTAFloat.emptyArray(1)
self.renderPassManager.registerStaticVariable("lastMVP", self.lastMVP)
self.renderPassManager.registerStaticVariable("currentMVP", self.currentMVP)
self.renderPassManager.registerStaticVariable("frameIndex", self.frameIndex)
self.renderPassManager.registerStaticVariable("cameraPosition", self.cameraPosition)
self.renderPassManager.registerStaticVariable("mainCam", self.showbase.cam)
self.renderPassManager.registerStaticVariable("mainRender", self.showbase.render)
self.renderPassManager.registerStaticVariable("frameDelta", self.frameDelta)
self.renderPassManager.registerStaticVariable("currentViewMat", self.currentViewMat)
self.renderPassManager.registerStaticVariable("currentProjMatInv", self.currentProjMatInv)
self.renderPassManager.registerStaticVariable("zeroVec2", Vec2(0))
self.renderPassManager.registerStaticVariable("zeroVec3", Vec3(0))
self.renderPassManager.registerStaticVariable("zeroVec4", Vec4(0))
self.transformMat = TransformState.makeMat(Mat4.convertMat(CSYupRight, CSZupRight))
示例6: ledgeCollisionCallback
# 需要导入模块: from panda3d.core import TransformState [as 别名]
# 或者: from panda3d.core.TransformState import makeMat [as 别名]
def ledgeCollisionCallback(self,action):
ledge = action.game_obj2
ghost_body = self.character_obj_.getActionGhostBody()
self.character_obj_.getStatus().ledge = ledge
self.character_obj_.setStatic(True)
# detemining position of ghost action body relative to character
pos = ghost_body.node().getShapePos(0)
if not self.character_obj_.isFacingRight(): # rotate about z by 180 if looking left
pos.setX(-pos.getX())
# creating transform for placement of character relative to ledge
ref_np = self.character_obj_.getReferenceNodePath()
tf_obj_to_ghost = LMatrix4.translateMat(pos)
tf_ghost_to_object = LMatrix4(tf_obj_to_ghost)
tf_ghost_to_object.invertInPlace()
tf_ref_to_ledge = ledge.getMat(ref_np)
tf_ref_to_obj = TransformState.makeMat(tf_ref_to_ledge * tf_ghost_to_object)
pos = tf_ref_to_obj.getPos()
# placing character on ledge
self.character_obj_.setX(ref_np,pos.getX())
self.character_obj_.setZ(ref_np,pos.getZ())
self.character_obj_.setLinearVelocity(Vec3(0,0,0))
# turning off collision
ghost_body.node().setIntoCollideMask(CollisionMasks.NO_COLLISION)
logging.debug(inspect.stack()[0][3] + ' invoked')
示例7: draw_debugging_arrow
# 需要导入模块: from panda3d.core import TransformState [as 别名]
# 或者: from panda3d.core.TransformState import makeMat [as 别名]
def draw_debugging_arrow(base, v_from, v_to):
arrowModel = base.loader.loadModel('models/debuggingArrow')
mat = align_to_vector(v_to-v_from)
arrowModel.setTransform(TransformState.makeMat(mat))
arrowModel.setPos(*v_from)
arrowModel.reparentTo(base.render)
return arrowModel
示例8: computeMVP
# 需要导入模块: from panda3d.core import TransformState [as 别名]
# 或者: from panda3d.core.TransformState import makeMat [as 别名]
def computeMVP(self):
""" Computes the modelViewProjection matrix for the lens. Actually,
this is the worldViewProjection matrix, but for convenience it is
called mvp. """
projMat = self.converterYUR
transformMat = TransformState.makeMat(
Mat4.convertMat(Globals.base.win.getGsg().getInternalCoordinateSystem(),
CSZupRight))
modelViewMat = transformMat.invertCompose(
Globals.render.getTransform(self.cameraNode)).getMat()
self.mvp = UnalignedLMatrix4f(modelViewMat * projMat)
示例9: attachCubes
# 需要导入模块: from panda3d.core import TransformState [as 别名]
# 或者: from panda3d.core.TransformState import makeMat [as 别名]
def attachCubes(self, loader):
for collider in self.colliders:
for i in range(collider.node().getNumShapes()):
shape = collider.node().getShape(i)
mat = collider.node().getShapeMat(i)
scale = shape.getHalfExtentsWithMargin()
transform = TransformState.makeMat(mat)
cube = loader.loadModel("cube.egg")
cube.setTransform(transform)
cube.setScale(scale)
cube.reparentTo(collider)
示例10: _computeMVP
# 需要导入模块: from panda3d.core import TransformState [as 别名]
# 或者: from panda3d.core.TransformState import makeMat [as 别名]
def _computeMVP(self):
""" Computes the current mvp. Actually, this is the
worldViewProjectionMatrix, but for convience it's called mvp. """
camLens = self.showbase.camLens
projMat = Mat4.convertMat(
CSYupRight,
camLens.getCoordinateSystem()) * camLens.getProjectionMat()
transformMat = TransformState.makeMat(
Mat4.convertMat(self.showbase.win.getGsg().getInternalCoordinateSystem(),
CSZupRight))
modelViewMat = transformMat.invertCompose(
self.showbase.render.getTransform(self.showbase.cam)).getMat()
return UnalignedLMatrix4f(modelViewMat * projMat)
示例11: moveRBnode
# 需要导入模块: from panda3d.core import TransformState [as 别名]
# 或者: from panda3d.core.TransformState import makeMat [as 别名]
def moveRBnode(self,node, trans, rotMat):
mat = rotMat.copy()
# mat[:3, 3] = trans
# mat = mat.transpose()
mat = mat.transpose().reshape((16,))
# print mat,len(mat),mat.shape
pMat = Mat4(mat[0],mat[1],mat[2],mat[3],
mat[4],mat[5],mat[6],mat[7],
mat[8],mat[9],mat[10],mat[11],
trans[0],trans[1],trans[2],mat[15],)
pTrans = TransformState.makeMat(pMat)
nodenp = NodePath(node)
nodenp.setMat(pMat)
示例12: _computeAdditionalData
# 需要导入模块: from panda3d.core import TransformState [as 别名]
# 或者: from panda3d.core.TransformState import makeMat [as 别名]
def _computeAdditionalData(self):
""" Internal method to recompute the spotlight MVP """
self.ghostCameraNode.setPos(self.position)
transMat = TransformState.makeMat(
Mat4.convertMat(Globals.base.win.getGsg().getInternalCoordinateSystem(),
CSZupRight))
converterMat = Mat4.convertMat(CSYupRight,
self.ghostLens.getCoordinateSystem()) * self.ghostLens.getProjectionMat()
modelViewMat = transMat.invertCompose(
Globals.render.getTransform(self.ghostCameraNode)).getMat()
self.mvp = modelViewMat * converterMat
示例13: addMultiCylinderRB
# 需要导入模块: from panda3d.core import TransformState [as 别名]
# 或者: from panda3d.core.TransformState import makeMat [as 别名]
def addMultiCylinderRB(self,rads,centT1,centT2,**kw):
inodenp = self.worldNP.attachNewNode(BulletRigidBodyNode("Cylinder"))
inodenp.node().setMass(1.0)
centT1 = ingr.positions[0]#ingr.transformPoints(jtrans, rotMat, ingr.positions[0])
centT2 = ingr.positions2[0]#ingr.transformPoints(jtrans, rotMat, ingr.positions2[0])
for radc, p1, p2 in zip(rads, centT1, centT2):
length, mat = helper.getTubePropertiesMatrix(p1,p2)
pMat = self.pandaMatrice(mat)
# d = numpy.array(p1) - numpy.array(p2)
# s = numpy.sum(d*d)
shape = BulletCylinderShape(radc, length,1)#math.sqrt(s), 1)# { XUp = 0, YUp = 1, ZUp = 2 } or LVector3f const half_extents
inodenp.node().addShape(shape, TransformState.makeMat(pMat))#
self.setRB(inodenp,**kw)
inodenp.setCollideMask(BitMask32.allOn())
self.world.attachRigidBody(inodenp.node())
return inodenp
示例14: drawLeaf
# 需要导入模块: from panda3d.core import TransformState [as 别名]
# 或者: from panda3d.core.TransformState import makeMat [as 别名]
def drawLeaf(nodePath, vdata, pos=LVector3(0, 0, 0), vecList=[LVector3(0, 0, 1), LVector3(1, 0, 0), LVector3(0, -1, 0)], scale=0.125):
# use the vectors that describe the direction the branch grows to make the right
# rotation matrix
newCs = LMatrix4(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
newCs.setRow(0, vecList[2]) # right
newCs.setRow(1, vecList[1]) # up
newCs.setRow(2, vecList[0]) # forward
newCs.setRow(3, (0, 0, 0))
newCs.setCol(3, (0, 0, 0, 1))
axisAdj = LMatrix4.scaleMat(scale) * newCs * LMatrix4.translateMat(pos)
# orginlly made the leaf out of geometry but that didnt look good
# I also think there should be a better way to handle the leaf texture other than
# hardcoding the filename
leafModel = loader.loadModel('models/shrubbery')
leafTexture = loader.loadTexture('models/material-10-cl.png')
leafModel.reparentTo(nodePath)
leafModel.setTexture(leafTexture, 1)
leafModel.setTransform(TransformState.makeMat(axisAdj))
示例15: NodePath
# 需要导入模块: from panda3d.core import TransformState [as 别名]
# 或者: from panda3d.core.TransformState import makeMat [as 别名]
axisAdj = Mat4.scaleMat(scale) * newCs * Mat4.translateMat(pos)
except TypeError, e:
print e
print scale, pos
# orginlly made the leaf out of geometry but that didnt look good
# I also think there should be a better way to handle the leaf texture other than
# hardcoding the filename
# leafModel=loader.loadModel('models/shrubbery')
# leafTexture=loader.loadTexture('models/material-10-cl.png')
leafModel = NodePath("leaf")
nodePath.leafModel.copyTo(leafModel)
leafModel.reparentTo(nodePath)
leafModel.setTexture(nodePath.leafTex, 1)
leafModel.setTransform(TransformState.makeMat(axisAdj))
# recursive algorthim to make the tree
def make_fractal_tree(
bodydata,
nodePath,
length,
pos=Vec3(0, 0, 0),
numIterations=11,
numCopies=4,
vecList=[Vec3(0, 0, 1), Vec3(1, 0, 0), Vec3(0, -1, 0)],
):
if numIterations > 0:
draw_body(nodePath, bodydata, pos, vecList, length.getX())