<commit_before>"""Load .3DS files

This module allows Vision Egg programs to use 3D models in the .3DS
file format.  We thank the lib3ds project at
http://lib3ds.sourceforge.net/ for providing the library used.

Several aspects of .3ds files are not yet implemented.  The most
important of these is that only the first texture map is used from the
material properties of an object.  Lighting is not used, so the
specular, ambient and diffuse material properties will have no effect.

Classes:

Model3DS -- A 3D model from a .3ds file
"""

# Copyright (c) 2002 <NAME>.  Distributed under the terms of the
# GNU Lesser General Public License (LGPL).

import os, types, string
import VisionEgg
import VisionEgg.Core
import VisionEgg.Textures
import VisionEgg._lib3ds # helper functions in C
import OpenGL.GL
import Numeric
gl = OpenGL.GL

__version__ = VisionEgg.release_name
__cvs__ = string.split('$Revision$')[1]
__date__ = string.join(string.split('$Date$')[1:3], ' ')
__author__ = '<NAME> <<EMAIL>>'

class Model3DS(VisionEgg.Core.Stimulus):
    """Model3DS -- A 3D model from a .3ds file"""
    parameters_and_defaults = {'scale':(Numeric.array((1.0, 1.0, 1.0),'f'),Numeric.ArrayType),
                               'position':(Numeric.array((0.0, 0.0, 0.0),'f'),Numeric.ArrayType),
                               'orient_angle':(0.0,types.FloatType),
                               'orient_axis':(Numeric.array((0.0, 1.0, 0.0),'f'),Numeric.ArrayType)}
    constant_parameters_and_defaults = {'filename':(None,types.StringType),
                                        'texture_mag_filter':(gl.GL_LINEAR,types.IntType),
                                        'texture_min_filter':(gl.GL_LINEAR_MIPMAP_LINEAR,types.IntType),
                                        'texture_wrap_s':(gl.GL_CLAMP_TO_EDGE,types.IntType),
                                        'texture_wrap_t':(gl.GL_CLAMP_TO_EDGE,types.IntType),
                                        'mipmaps_enabled':(1,types.IntType),
                                        'shrink_texture_ok':(0,types.IntType), # boolean
                                        }
    def __init__(self,**kw):
        # Initialize base class
        VisionEgg.Core.Stimulus.__init__(self,**kw)

        max_dim = gl.glGetIntegerv( gl.GL_MAX_TEXTURE_SIZE )
        if max_dim is None:
            raise RuntimeError("A screen must be open before you create an instance of Model3DS.");

        cp = self.constant_parameters # shorthand
        # Do C initialization stuff
        if cp.filename is None:
            raise RuntimeError("Must specify filename for Object3DS class.")
        orig_dir = os.path.abspath(os.curdir)
        directory,name = os.path.split(cp.filename)
        if directory:<commit_msg>Major: Upgraded to new VisionEgg type system<commit_after>"""Load .3DS files

This module allows Vision Egg programs to use 3D models in the .3DS
file format.  We thank the lib3ds project at
http://lib3ds.sourceforge.net/ for providing the library used.

Several aspects of .3ds files are not yet implemented.  The most
important of these is that only the first texture map is used from the
material properties of an object.  Lighting is not used, so the
specular, ambient and diffuse material properties will have no effect.

Classes:

Model3DS -- A 3D model from a .3ds file
"""

# Copyright (c) 2002 <NAME>.  Distributed under the terms of the
# GNU Lesser General Public License (LGPL).

import os, types, string
import VisionEgg
import VisionEgg.Core
import VisionEgg.ParameterTypes as ve_types
import VisionEgg.Textures
import VisionEgg._lib3ds # helper functions in C
import OpenGL.GL
import Numeric
gl = OpenGL.GL

__version__ = VisionEgg.release_name
__cvs__ = string.split('$Revision$')[1]
__date__ = string.join(string.split('$Date$')[1:3], ' ')
__author__ = '<NAME> <<EMAIL>>'

# Use Python's bool constants if available, make aliases if not
try:
    True
except NameError:
    True = 1==1
    False = 1==0
    
class Model3DS(VisionEgg.Core.Stimulus):
    """Model3DS -- A 3D model from a .3ds file"""
    parameters_and_defaults = {'scale':((1.0, 1.0, 1.0),
                                        ve_types.Sequence3(ve_types.Real)),
                               'position':((0.0, 0.0, 0.0),
                                           ve_types.Sequence3(ve_types.Real)),
                               'orient_angle':(0.0,
                                               ve_types.Real),
                               'orient_axis':((0.0, 1.0, 0.0),
                                              ve_types.Sequence3(ve_types.Real)),
                               }
    constant_parameters_and_defaults = {'filename':(None,
                                                    ve_types.String),
                                        'texture_mag_filter':(gl.GL_LINEAR,
                                                              ve_types.Integer),
                                        'texture_min_filter':(gl.GL_LINEAR_MIPMAP_LINEAR,
                                                              ve_types.Integer),
                                        'texture_wrap_s':(gl.GL_CLAMP_TO_EDGE,
                                                          ve_types.Integer),
                                        'texture_wrap_t':(gl.GL_CLAMP_TO_EDGE,
                                                          ve_types.Integer),
                                        'mipmaps_enabled':(True,
                                                           ve_types.Boolean),
                                        'shrink_texture_ok':(False,
                                                             ve_types.Boolean), # boolean
                                        }
    def __init__(self,**kw):
        # Initialize base class
        VisionEgg.Core.Stimulus.__init__(self,**kw)

        max_dim = gl.glGetIntegerv( gl.GL_MAX_TEXTURE_SIZE )
        if max_dim is None:
            raise RuntimeError("A screen must be open before you create an instance of Model3DS.");

        cp = self.constant_parameters # shorthand
        # Do C initialization stuff
        if cp.filename is None:
            raise RuntimeError("Must specify filename for Object3DS class.")
        orig_dir = os.path.abspath(os.curdir)
        directory,name = os.path.split(cp.filename)
        if directory:
{'fraction_non_alphanumeric': 0.09192331866750471, 'fraction_numerical': 0.014927718416090509, 'mean_word_length': 1.7470867501078982, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 35, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7268393', 'n_tokens_mistral': 1731, 'n_tokens_neox': 1672, 'n_words': 462}