Exemplo n.º 1
0
class WV_ViewServer(object):
    def __init__(self, handler, fname=None):
        self.wv = WV_Wrapper()
        self.buf = self.wv.get_bufflen()*'\0'
        self.handler = handler  # need this to send the msgs
        self.geometry_file = fname

    def send_binary_data(self, wsi, buf, ibuf):
        try:
            #dat = msgpack.packb(buf, encoding=None)
            #self.handler.write_message(dat, binary=True)
            self.handler.write_message(buf, binary=True)
        except Exception as err:
            ERROR("Exception in send_binary_data:", err)
            return -1
        return 0

    def send_geometry(self, first=False):
        self.wv.prepare_for_sends()

        if first:
            self.wv.send_GPrim(self, self.buf,  1, self.send_binary_data)  # send init packet
            self.wv.send_GPrim(self, self.buf, -1, self.send_binary_data)  # send initial suite of GPrims
        else:  #FIXME: add updating of GPRims here...
            pass

        self.wv.finish_sends()

    def on_message(self, message):
        DEBUG("binary ws got message: %s" % [ord(c) for c in message])

    def on_close(self):
        DEBUG("binary WebSocket closed")

    def open(self):
        DEBUG("binary WebSocket opened. addr=%d" % id(self))
        DEBUG("fname = %s" % self.geometry_file)
        try:
            self.create_geom()
            self.send_geometry(first=True)
        except Exception as err:
            ERROR('Exception: %s' % traceback.format_exc())
Exemplo n.º 2
0
 def __init__(self, handler, fname=None):
     self.wv = WV_Wrapper()
     self.buf = self.wv.get_bufflen()*'\0'
     self.handler = handler  # need this to send the msgs
     self.geometry_file = fname
Exemplo n.º 3
0
from pyV3D.pyV3D import WV_Wrapper
from numpy import array, float64, float32, int32, uint8


myWV = WV_Wrapper()

eye    = array([1.0, 0.0, 7.0], dtype=float32)
center = array([0.0, 0.0, 0.0], dtype=float32)
up     = array([0.0, 1.0, 0.0], dtype=float32)

myWV.createContext(0, 30.0, 1.0, 10.0, eye, center, up)

# box
# v6----- v5
# /| /|
# v1------v0|
# | | | |
# | |v7---|-|v4
# |/ |/
# v2------v3
#
# vertex coords array
vertices = [
    1, 1, 1, -1, 1, 1, -1,-1, 1, 1,-1, 1, # v0-v1-v2-v3 front
    1, 1, 1, 1,-1, 1, 1,-1,-1, 1, 1,-1, # v0-v3-v4-v5 right
    1, 1, 1, 1, 1,-1, -1, 1,-1, -1, 1, 1, # v0-v5-v6-v1 top
   -1, 1, 1, -1, 1,-1, -1,-1,-1, -1,-1, 1, # v1-v6-v7-v2 left
   -1,-1,-1, 1,-1,-1, 1,-1, 1, -1,-1, 1, # v7-v4-v3-v2 bottom
    1,-1,-1, -1,-1,-1, -1, 1,-1, 1, 1,-1 ] # v4-v7-v6-v5 back