Example #1
0
# but WITHOUT ANY WARRANTY; without even the implied warranty of         #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the           #
# GNU General Public License for more details.                           #
#                                                                        #
# You should have received a copy of the GNU Lesser General Public       #
# License along with AVANGO. If not, see <http://www.gnu.org/licenses/>. #
#                                                                        #
##########################################################################

import avango
from _registry import _register_field


class MFStringDescriptor(object):
    'Simple stream support for MFString'

    key = "MFString"

    def write(self, field, hout):
        if field.value:
            hout.write('\x00')
        hout.write('\x00'.join(field.value))

    def read(self, line):
        field = avango.MFString()
        field.value = line
        return field


_register_field(avango.MFString, MFStringDescriptor())
Example #2
0
# AVANGO is distributed in the hope that it will be useful,              #
# but WITHOUT ANY WARRANTY; without even the implied warranty of         #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the           #
# GNU General Public License for more details.                           #
#                                                                        #
# You should have received a copy of the GNU Lesser General Public       #
# License along with AVANGO. If not, see <http://www.gnu.org/licenses/>. #
#                                                                        #
##########################################################################

import avango
from _registry import _register_field


class SFFloatDescriptor(object):
    'Simple stream support for SFFloat'

    key = "SFFloat"

    def write(self, field, hout):
        hout.write('\x00')
        hout.write(str(field.value))

    def read(self, line):
        field = avango.SFFloat()
        field.value = float(line[0])
        return field


_register_field(avango.SFFloat, SFFloatDescriptor())
Example #3
0
        hout.write('\x00'.join(value))

    def read(self, line):
        field = avango.osg.SFMatrix()
        for x in zip(line[::16], line[1::16], line[2::16], line[3::16],
                     line[4::16], line[5::16], line[6::16], line[7::16],
                     line[8::16], line[9::16], line[10::16], line[11::16],
                     line[12::16], line[13::16], line[14::16], line[15::16]):
            mat = avango.osg.Matrix()
            mat.set_element(0, 0, float(x[0]))
            mat.set_element(0, 1, float(x[1]))
            mat.set_element(0, 2, float(x[2]))
            mat.set_element(0, 3, float(x[3]))
            mat.set_element(1, 0, float(x[4]))
            mat.set_element(1, 1, float(x[5]))
            mat.set_element(1, 2, float(x[6]))
            mat.set_element(1, 3, float(x[7]))
            mat.set_element(2, 0, float(x[8]))
            mat.set_element(2, 1, float(x[9]))
            mat.set_element(2, 2, float(x[10]))
            mat.set_element(2, 3, float(x[11]))
            mat.set_element(3, 0, float(x[12]))
            mat.set_element(3, 1, float(x[13]))
            mat.set_element(3, 2, float(x[14]))
            mat.set_element(3, 3, float(x[15]))
        field.value = mat
        return field


_register_field(avango.osg.SFMatrix, SFMatrixDescriptor())
Example #4
0
#                                                                        #
##########################################################################

import avango.osg
from _registry import _register_field

class SFVec4Descriptor(object):
    'Simple stream support for SFVec4'

    key = "SFVec4"

    def write(self, field, hout):
        if field.value:
            hout.write('\x00')
        value = []
        v = field.value
        value.append(str(v.x))
        value.append(str(v.y))
        value.append(str(v.z))
        value.append(str(v.w))
        hout.write('\x00'.join(value))

    def read(self, line):
        field = avango.osg.SFVec4()
        for x in zip(line[::4], line[1::4], line[2::4], line[3::4]):
            vec = avango.osg.Vec4(float(x[0]), float(x[1]), float(x[2]), float(x[3]))
        field.value = vec
        return field

_register_field(avango.osg.SFVec4, SFVec4Descriptor())
Example #5
0
# AVANGO is distributed in the hope that it will be useful,              #
# but WITHOUT ANY WARRANTY; without even the implied warranty of         #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the           #
# GNU General Public License for more details.                           #
#                                                                        #
# You should have received a copy of the GNU Lesser General Public       #
# License along with AVANGO. If not, see <http://www.gnu.org/licenses/>. #
#                                                                        #
##########################################################################

import avango
from _registry import _register_field


class SFDoubleDescriptor(object):
    'Simple stream support for SFDouble'

    key = "SFDouble"

    def write(self, field, hout):
        hout.write('\x00')
        hout.write(str(field.value))

    def read(self, line):
        field = avango.SFDouble()
        field.value = float(line[0])
        return field


_register_field(avango.SFDouble, SFDoubleDescriptor())
Example #6
0
            values.append(str(v.get_element(3,3)))
        hout.write('\x00'.join(values))

    def read(self, line):
        field = avango.osg.MFMatrix()
        for x in zip(line[::16], line[1::16], line[2::16], line[3::16],
                     line[4::16], line[5::16], line[6::16], line[7::16],
                     line[8::16], line[9::16], line[10::16], line[11::16],
                     line[12::16], line[13::16], line[14::16], line[15::16]):
            mat = avango.osg.Matrix()
            mat.set_element(0,0, float(x[0]))
            mat.set_element(0,1, float(x[1]))
            mat.set_element(0,2, float(x[2]))
            mat.set_element(0,3, float(x[3]))
            mat.set_element(1,0, float(x[4]))
            mat.set_element(1,1, float(x[5]))
            mat.set_element(1,2, float(x[6]))
            mat.set_element(1,3, float(x[7]))
            mat.set_element(2,0, float(x[8]))
            mat.set_element(2,1, float(x[9]))
            mat.set_element(2,2, float(x[10]))
            mat.set_element(2,3, float(x[11]))
            mat.set_element(3,0, float(x[12]))
            mat.set_element(3,1, float(x[13]))
            mat.set_element(3,2, float(x[14]))
            mat.set_element(3,3, float(x[15]))
            field.value.append(mat)
        return field

_register_field(avango.osg.MFMatrix, MFMatrixDescriptor())
Example #7
0
import avango.osg
from _registry import _register_field


class MFVec3Descriptor(object):
    'Simple stream support for MFVec3'

    key = "MFVec3"

    def write(self, field, hout):
        if field.value:
            hout.write('\x00')
        values = []
        for v in field.value:
            values.append(str(v.x))
            values.append(str(v.y))
            values.append(str(v.z))
        hout.write('\x00'.join(values))

    def read(self, line):
        field = avango.osg.MFVec3()
        field.value = [
            avango.osg.Vec3(float(x[0]), float(x[1]), float(x[2]))
            for x in zip(line[::3], line[1::3], line[2::3])
        ]
        return field


_register_field(avango.osg.MFVec3, MFVec3Descriptor())
Example #8
0
# published by the Free Software Foundation, version 3.                  #
#                                                                        #
# AVANGO is distributed in the hope that it will be useful,              #
# but WITHOUT ANY WARRANTY; without even the implied warranty of         #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the           #
# GNU General Public License for more details.                           #
#                                                                        #
# You should have received a copy of the GNU Lesser General Public       #
# License along with AVANGO. If not, see <http://www.gnu.org/licenses/>. #
#                                                                        #
##########################################################################

import avango
from _registry import _register_field

class SFDoubleDescriptor(object):
    'Simple stream support for SFDouble'

    key = "SFDouble"

    def write(self, field, hout):
        hout.write('\x00')
        hout.write(str(field.value))

    def read(self, line):
        field = avango.SFDouble()
        field.value = float(line[0])
        return field

_register_field(avango.SFDouble, SFDoubleDescriptor())
Example #9
0
#                                                                        #
# You should have received a copy of the GNU Lesser General Public       #
# License along with AVANGO. If not, see <http://www.gnu.org/licenses/>. #
#                                                                        #
##########################################################################

import avango
from _registry import _register_field


class MFIntDescriptor(object):
    "Simple stream support for MFInt"

    key = "MFInt"

    def write(self, field, hout):
        if field.value:
            hout.write("\x00")
        values = []
        for v in field.value:
            values.append(str(v))
        hout.write("\x00".join(values))

    def read(self, line):
        field = avango.MFInt()
        field.value = [int(x) for x in line]
        return field


_register_field(avango.MFInt, MFIntDescriptor())
Example #10
0
File: _SFInt.py Project: 4og/avango
# published by the Free Software Foundation, version 3.                  #
#                                                                        #
# AVANGO is distributed in the hope that it will be useful,              #
# but WITHOUT ANY WARRANTY; without even the implied warranty of         #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the           #
# GNU General Public License for more details.                           #
#                                                                        #
# You should have received a copy of the GNU Lesser General Public       #
# License along with AVANGO. If not, see <http://www.gnu.org/licenses/>. #
#                                                                        #
##########################################################################

import avango
from _registry import _register_field

class SFIntDescriptor(object):
    'Simple stream support for SFInt'

    key = "SFInt"

    def write(self, field, hout):
        hout.write('\x00')
        hout.write(str(field.value))

    def read(self, line):
        field = avango.SFInt()
        field.value = int(line[0])
        return field

_register_field(avango.SFInt, SFIntDescriptor())
Example #11
0
# published by the Free Software Foundation, version 3.                  #
#                                                                        #
# AVANGO is distributed in the hope that it will be useful,              #
# but WITHOUT ANY WARRANTY; without even the implied warranty of         #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the           #
# GNU General Public License for more details.                           #
#                                                                        #
# You should have received a copy of the GNU Lesser General Public       #
# License along with AVANGO. If not, see <http://www.gnu.org/licenses/>. #
#                                                                        #
##########################################################################

import avango
from _registry import _register_field

class SFFloatDescriptor(object):
    'Simple stream support for SFFloat'

    key = "SFFloat"

    def write(self, field, hout):
        hout.write('\x00')
        hout.write(str(field.value))

    def read(self, line):
        field = avango.SFFloat()
        field.value = float(line[0])
        return field

_register_field(avango.SFFloat, SFFloatDescriptor())
Example #12
0
import avango.osg
from _registry import _register_field


class SFVec4Descriptor(object):
    'Simple stream support for SFVec4'

    key = "SFVec4"

    def write(self, field, hout):
        if field.value:
            hout.write('\x00')
        value = []
        v = field.value
        value.append(str(v.x))
        value.append(str(v.y))
        value.append(str(v.z))
        value.append(str(v.w))
        hout.write('\x00'.join(value))

    def read(self, line):
        field = avango.osg.SFVec4()
        for x in zip(line[::4], line[1::4], line[2::4], line[3::4]):
            vec = avango.osg.Vec4(float(x[0]), float(x[1]), float(x[2]),
                                  float(x[3]))
        field.value = vec
        return field


_register_field(avango.osg.SFVec4, SFVec4Descriptor())
Example #13
0
# published by the Free Software Foundation, version 3.                  #
#                                                                        #
# AVANGO is distributed in the hope that it will be useful,              #
# but WITHOUT ANY WARRANTY; without even the implied warranty of         #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the           #
# GNU General Public License for more details.                           #
#                                                                        #
# You should have received a copy of the GNU Lesser General Public       #
# License along with AVANGO. If not, see <http://www.gnu.org/licenses/>. #
#                                                                        #
##########################################################################

import avango
from _registry import _register_field

class SFStringDescriptor(object):
    'Simple stream support for SFString'

    key = "SFString"

    def write(self, field, hout):
        hout.write('\x00')
        hout.write(str(field.value))

    def read(self, line):
        field = avango.SFString()
        field.value = line[0]
        return field

_register_field(avango.SFString, SFStringDescriptor())
Example #14
0
#                                                                        #
# You should have received a copy of the GNU Lesser General Public       #
# License along with AVANGO. If not, see <http://www.gnu.org/licenses/>. #
#                                                                        #
##########################################################################

import avango
from _registry import _register_field


class MFIntDescriptor(object):
    'Simple stream support for MFInt'

    key = "MFInt"

    def write(self, field, hout):
        if field.value:
            hout.write('\x00')
        values = []
        for v in field.value:
            values.append(str(v))
        hout.write('\x00'.join(values))

    def read(self, line):
        field = avango.MFInt()
        field.value = [int(x) for x in line]
        return field


_register_field(avango.MFInt, MFIntDescriptor())
Example #15
0
# GNU General Public License for more details.                           #
#                                                                        #
# You should have received a copy of the GNU Lesser General Public       #
# License along with AVANGO. If not, see <http://www.gnu.org/licenses/>. #
#                                                                        #
##########################################################################

import avango.osg
from _registry import _register_field

class MFVec2Descriptor(object):
    'Simple stream support for MFVec2'

    key = "MFVec2"

    def write(self, field, hout):
        if field.value:
            hout.write('\x00')
        values = []
        for v in field.value:
            values.append(str(v.x))
            values.append(str(v.y))
        hout.write('\x00'.join(values))

    def read(self, line):
        field = avango.osg.MFVec2()
        field.value = [avango.osg.Vec2(float(x[0]), float(x[1])) for x in zip(line[::2], line[1::2])]
        return field

_register_field(avango.osg.MFVec2, MFVec2Descriptor())
Example #16
0
# but WITHOUT ANY WARRANTY; without even the implied warranty of         #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the           #
# GNU General Public License for more details.                           #
#                                                                        #
# You should have received a copy of the GNU Lesser General Public       #
# License along with AVANGO. If not, see <http://www.gnu.org/licenses/>. #
#                                                                        #
##########################################################################

import avango
from _registry import _register_field

class SFBoolDescriptor(object):
    'Simple stream support for SFBool'

    key = "SFBool"

    def write(self, field, hout):
        hout.write('\x00')
        if field.value:
            hout.write('1')
        else:
            hout.write('0')

    def read(self, line):
        field = avango.SFBool()
        field.value = bool(int(line[0]))
        return field

_register_field(avango.SFBool, SFBoolDescriptor())