def gen_dasharrow(spos=np.array([0, 0, 0]), epos=np.array([.1, 0, 0]), thickness=.005, lsolid=None, lspace=None, rgba=[1, 0, 0, 1], type="rect"): """ :param spos: :param epos: :param thickness: :param lsolid: length of the solid section, 1*thickness by default :param lspace: length of the empty section, 1.5*thickness by default :param rgba: :return: author: weiwei date: 20200625osaka """ dasharrow_trm = trihelper.gen_dasharrow(spos=spos, epos=epos, lsolid=lsolid, lspace=lspace, thickness=thickness, sticktype=type) dasharrow_sgm = StaticGeometricModel(dasharrow_trm) dasharrow_sgm.set_rgba(rgba=rgba) return dasharrow_sgm
def gen_dashframe(pos=np.array([0, 0, 0]), rotmat=np.eye(3), length=.1, thickness=.005, lsolid=None, lspace=None, rgbmatrix=None, alpha=None, plotname="dashframe"): """ gen an axis for attaching :param pos: :param rotmat: :param length: :param thickness: :param lsolid: length of the solid section, 1*thickness by default :param lspace: length of the empty section, 1.5*thickness by default :param rgbmatrix: each column indicates the color of each base :param plotname: :return: author: weiwei date: 20200630osaka """ endx = pos + rotmat[:, 0] * length endy = pos + rotmat[:, 1] * length endz = pos + rotmat[:, 2] * length if rgbmatrix is None: rgbx = np.array([1, 0, 0]) rgby = np.array([0, 1, 0]) rgbz = np.array([0, 0, 1]) else: rgbx = rgbmatrix[:, 0] rgby = rgbmatrix[:, 1] rgbz = rgbmatrix[:, 2] if alpha is None: alphax = alphay = alphaz = 1 elif isinstance(alpha, np.ndarray): alphax = alpha[0] alphay = alpha[1] alphaz = alpha[2] else: alphax = alphay = alphaz = alpha # TODO 20201202 change it to StaticGeometricModelCollection frame_nodepath = NodePath(plotname) arrowx_trm = trihelper.gen_dasharrow(spos=pos, epos=endx, thickness=thickness, lsolid=lsolid, lspace=lspace) arrowx_nodepath = da.trimesh_to_nodepath(arrowx_trm) arrowx_nodepath.setTransparency(TransparencyAttrib.MDual) arrowx_nodepath.setColor(rgbx[0], rgbx[1], rgbx[2], alphax) arrowy_trm = trihelper.gen_dasharrow(spos=pos, epos=endy, thickness=thickness, lsolid=lsolid, lspace=lspace) arrowy_nodepath = da.trimesh_to_nodepath(arrowy_trm) arrowy_nodepath.setTransparency(TransparencyAttrib.MDual) arrowy_nodepath.setColor(rgby[0], rgby[1], rgby[2], alphay) arrowz_trm = trihelper.gen_dasharrow(spos=pos, epos=endz, thickness=thickness, lsolid=lsolid, lspace=lspace) arrowz_nodepath = da.trimesh_to_nodepath(arrowz_trm) arrowz_nodepath.setTransparency(TransparencyAttrib.MDual) arrowz_nodepath.setColor(rgbz[0], rgbz[1], rgbz[2], alphaz) arrowx_nodepath.reparentTo(frame_nodepath) arrowy_nodepath.reparentTo(frame_nodepath) arrowz_nodepath.reparentTo(frame_nodepath) frame_sgm = StaticGeometricModel(frame_nodepath) return frame_sgm