Object Sequence Loader

The object sequence loader is a script that loads a sequence of 3d model files in a format Vue can import (obj, vob, 3ds, lwo, shd, cob and some other formats)

[wpdm_package id=100]

Tested using Vue 5 Infinite 5.11-02 and Vue 6 Pre Release

How does it work?

It first loads the objects into the scene. These are then hidden (usually beneath the ground but you can change where they are kept) and then switched into a visible area for each frame you render. By creating an animation, the Python script will automatically switch these objects in and out to give you an animation.

Note: These do not appear as keyframed animations unless you have auto keyframing turned on and have rendered the complete sequence of steps that make up the animation.

What version of Vue does it work with?

The script will work with Vue 5 Infinite and Vue 6 Infinite. Vue 6’s improved importing and real world units provide significant improvements to the results of using the object sequence importer.

What other programmes does it work with?

It has been tested with objects exported from RealFlow 3, RealFlow 4 and XFrog 3.5 Full. It should work with any programme that can make a set of 3d models in a format that Vue can import.

What are the limitations?

This is an early development which is currently limited to standalone animations.

Mini Previews and HyperVue are not supported. The Python script necessitates animation sequences in order to correctly switch the objects between frames.

Object files can consume a lot of memory, so it is best to initially experiment with simple sequences of small object files to learn how to use the script.

How do I prepare the sequence?

Take your 3D objects and place them in a directory.

The sequence must have sequentially numbered file names. The numbering does not have to begin with 0 or 1. For example:

  • 1.lwo, 2.lwo, 3.lwo, 4.lwo… …100.lwo, 101.lwo
  • Mesh010001.obj, Mesh010002.obj, Mesh010003.obj…
  • Flower_blossom_00001.obj, Flower_blossom_00002.obj, Flower_blossom_00003.obj
  • 5.3ds, 6.3ds, 7.3ds

How do I run the Script?

Download the script and uncompress the zip file. You should now have a file called objsequenceloader.py .

Place a copy of the script objsequenceloader.py in the directory with the objects.

Run the Python Script and follow the options. For more help on running a script see my Vue Python for Beginners Tutorials.

The script may not work with script quick load menu in Vue after other operations have been used. For reliable run it with Run python script…

A number of options will be presented to you. Respond to each one in turn. If this is your first time using the script I would suggest using the following options:

  • Group objects: Yes
  • Drop on import: No
  • Align on import: No

I’ll write some documentation to explain all the options soon.

I’m Using XFrog is there anything I should know?

If you are importing a sequence of objects from Xfrog you will be asked for a file name prefix. This is the part of the filename before the first 0 in the numbering sequence. So for a sequence including Flower_blossom_00001.obj use Flower_blossom_.

What Happens when I’ve Answered all the Questions?

When you have completed all of the options the script will start to load the objects.

The settings from your last object import will be used by Vue while importing the files. The loading process may take some time.

Once the script has finished loading the files a dialogue box will pop up to let you know.

The Sequence is Loaded what do I do next?

You will notice several objects in the scene:

  • Imported Object Target
  • Imported Object Out of Shot
  • Either the individual objects or a group of objects depending on the options you selected

The Imported Object Target is where the object for a specific frame will be displayed. You can scale the objects by scaling this object. You can rotate them by rotating it. You can position them by position it. If you selected Drop on import make sure this is over something else in the scene so that when the object is dropped it has somewhere to land. The Imported Object Target will not appear in renders.

The Imported Object Out of Shot is where objects that don’t appear in a specific frame will be placed. It starts at a position that should be out of shot. If it isn’t you can move it. If you do move it and want to see the objects reposition render a frame and all the objects should move. The Imported Object Out of Shot object will not appear in renders.

How do I render my animation?

When you are ready to render the animation open the animation rendering panel. If you do not have any other animation in the scene you will need to tell Vue how many frames to render by selecting Render Sequence and entering appropriate numbers. You should then be able to render your animation.

How can I save the sequence?

If you want to save the sequence the results of using this script you must render the scenes animation before saving. This will create key frames in the scene for the objects. To perform this process quickly render a very small version of the animation with preview quality. Once this has been done delete you can delete Imported Object Target and the Imported Object Out of Shot objects. They will not have any effect on the sequence when it is reloaded.

Vue Crashed while loading the objects. What can I do?

If you have too many objects in the sequence for your computer to cope with Vue may crash. If this happen try loading the sequence in smaller parts and then compiling the final animation in video editing software.

There don’t seem to be any animation paths. Is the script broken?

Earlier versions of the script created animation paths for each object. This technique has now been superseded. Instead a technique similar to a 3d flipbook is used. Each time a frame is rendered the script moves an appropriate object to be displayed and moves the others elsewhere.

I want to have two sequences in the same animation. Can I do this?

Running this script multiple times on the same scene is only possible if the earlier import has had key frames created by rendering an animation sequence. Once a second import is carried out the first import will not be editable by moving the target objects.

Can I use this with Network Rendering?

This script hasn’t been tested with network rendering. It may be possible to network render an animation created using this script by first using the technique for saving the animation. I’ve not tried this. If you try it and it works please e-mail me so I can update other users.

A pop up telling me I have nothing to drop on. What should I do?>

The problem is with the drop on import option. When using drop on import raise the height of the Imported Object Target and ensure it is dropping onto an object.

Can I change the textures of the object in Vue?

Yes.

[codesyntax lang=”python”]

#******************************************************
# Loads a sequence of object files into Vue
#
# - objsequenceloader.py
# - By Mark Caldwell
# - Version 0.2.3
# - 8th December 2006
# - Copyright Mark Caldwell 2006
# - Tested with Vue 6 Pre Release
#
# Warning: This script can be memory intensive with
# complex modesls or when importing long sequences.
# Save your Vue scene before running it.
#
# How to use in 5 easy steps
#
# 1. Download this file onto your computer
#
# 2. Place in Directory Containing Object Files named
#    Mesh01001.obj, Mesh01002.obj, Mesh01003.obj and so on
#    for Realflow, somename_00001.obj, somename_00002.obj and so on
#    for Xfrong (The file extension can be any of
#    the types Vue can import and somename will vary)
#    or 1.obj, 2.obj, 3.obj and so on for other
#    types of file import (The file extension can be any of
#    the types Vue can import)
#
# 3. Then run script and supply responses when prompted.
#
# 4. Wait while it loads the objects in
#
# 5. Position the "Imported Object Target" where you want the
#    objects to be placed during rendering.  Scale or rotate this object
#    to scale and rotate the imported objects.  This object won't appear
#    in your pictures.  You can also move where they are put when not used
#    by moving "Imported Object Out of Shot". After moving this render a
#    single frame to change where the objects are placed.
#
#    To run it go to Python -> Run Python Script
#    Then locate the file on your computer
#
#******************************************************

infinity=[0,0,-10000] # The position to place objects when not displayed [x,y,z]
start=[0,0,0] # The position to place object when displayed [x,y,z]

#----------------------------------------------
# End of Configuration: Don't edit after this
#----------------------------------------------

#----------------------------------------------
# Functions
#----------------------------------------------

def FindExtreemVertex (object,pos,highorlow):
    obj=object.ToMesh()
    verticescount=obj.CountMeshVertices()
    vertices=obj.MeshVertices ()

    if highorlow=='high':
        high=vertices[0][pos]

        for i in range(0,verticescount):
            vertex=vertices[i]
            if vertex [pos]>high:
               high=vertex[pos]
        return high
    elif highorlow=='low':
        low=vertices[0][pos]

        for i in range(0,verticescount):
            vertex=vertices[i]
            if vertex [pos]valmax and highorlow=='high':
                    valmax=val
                elif val=objrecordnumber:
        currentobjnumber=objrecordnumber-2

    if currentobjnumber<0:
        currentobjnumber=0

    obj=objectlist[currentobjnumber]
    position=pyObj.Position()
    rotation=pyObj.GetRotationAngles ()
    scale=pyObj.GetScale()

    x=biggestextremity[0]-extreem[currentobjnumber][0]+position[0]
    y=biggestextremity[1]-extreem[currentobjnumber][1]+position[1]
    z=biggestextremity[2]-extreem[currentobjnumber][2]+position[2]

    if flipyz==1:
        rot=270
    else:
        rot=0

    obj.SetPosition(x,y,z)
    obj.SetRotationAngles (rotation[0]+rot,rotation[1],rotation[2])
    obj.ResizeAxis(scale[0],scale[1],scale[2])

    if drop=='1':
        pyObj.Move(0,0,1000)
        DeselectAll()
        Select(obj)
        Drop()
        pyObj.Move(0,0,-1000)

#----------------------------------------------
# Internal Variables Set Up: Don't alter these
#----------------------------------------------

x=0
objnumber=1
obj=[]
objectlist=[]
extension='obj'
framegap=1
extreem=[]
biggestextremity=[0,0,0]
objrecordnumber=1

#---------------------------------------------------
# Get User Input
#---------------------------------------------------

typeofimport=Prompt('Type of Sequence to Import. \n1: Numbered files \n2: RealFlow3 \n3: RealFlow4\n4: Xfrog','1',true,'Type of Import')

if typeofimport=='2':
    extension='obj'
    filetype=1
    flipyz=2
elif typeofimport=='3':
    extension='obj'
    filetype=2
    flipyz=2
elif typeofimport=='4':
    extension=Prompt('File extension on files \nmaking up sequence','obj',true,'File Extension')
    filestart=Prompt('File name prefix on files \nmaking up sequence','',true,'File Prefix')
    filetype=3
    flipyz=1
else:
    extension=Prompt('File extension on files \nmaking up sequence','obj',true,'File Extension')
    flipyz=Prompt('Switch Y and Z axis \n 1: Yes \n2: No','2',true,'')
    filetype=0

import_type=Prompt('Import whole sequence?\n 1: Yes \n2: No','1',true,'')

if import_type=='2':
    objnumber=Prompt('First frame object number?','1',true,'')
    objnumber=int(objnumber)
    maxobjnumber=Prompt('Last frame object number?','10',true,'')
    maxobjnumber=int(maxobjnumber)
else:
   objnumber=1
   maxobjnumber=10

framegapret=Prompt('Number of frames to wait between loading each object','1',true,'File Extension')
framegap=int(framegapret)

group=Prompt('Group Objects?\n 1: Yes \n2: No','1',true,'')

drop=Prompt('Drop on import \n 1: Yes \n2: No','1',true,'')

align=Prompt('Align on import \n 1: Yes \n2: No','1',true,'')

if align=='1':
    alignx=Prompt('Alignment X \n1: Left \n2: Right','1',true,'')
    if alignx=='1':
        xalign='high'
        biggestextremity[0]=-10000
    else:
        xalign='low'
        biggestextremity[0]=10000

    aligny=Prompt('Alignment Y \n 1: Back \n2: Front','1',true,'')
    if aligny=='1':
        yalign='high'
        biggestextremity[1]=-10000
    else:
        yalign='low'
        biggestextremity[1]=10000

    alignz=Prompt('Alignment Z \n 1: Top \n2: Bottom','1',true,'')

    if alignz=='1':
        zalign='high'
        biggestextremity[2]=-10000
    else:
        zalign='low'
        biggestextremity[2]=10000

if group=='1':
    group=1
else:
    group=2

#---------------------------------------------------
# Main Script Body
#---------------------------------------------------

SetCurrentFrame (0)

# Load objects

while obj!=None and objnumber<=maxobjnumber:
    if filetype==1:
        x=3-len(str(objnumber))
        filename='Mesh01'+'0'*x+str(objnumber)+'.'+extension
    elif filetype==2:
        x=5-len(str(objnumber))
        filename='Mesh01'+'0'*x+str(objnumber)+'.'+extension
    elif filetype==3:
        x=5-len(str(objnumber))
        filename=filestart+'0'*x+str(objnumber)+'.'+extension
    else:
        filename=str(objnumber)+'.'+extension

    obj=ImportObject(filename)

    if obj!=None:
        objnumber=objnumber+1
        objrecordnumber=objrecordnumber+1

        if import_type=='1':
            maxobjnumber=maxobjnumber+1

        objectlist.append(obj)

        obj.SetPosition(infinity[0],infinity[1],infinity[2])

        if flipyz==1:
            obj.SetRotationAngles (270,0,0)

        if align=='1':
            extremityx=FindExtreem (obj,0,xalign)
            if extremityx>biggestextremity[0] and xalign=='high':
                biggestextremity[0]=extremityx
            elif extremityybiggestextremity[1] and yalign=='high':
                biggestextremity[1]=extremityy
            elif extremityybiggestextremity[2] and zalign=='high':
                biggestextremity[2]=extremityz
            elif extremityz0:
    pyObj=AddPythonObject((-5,-5,-5),(5,5,5),true)
    pyObj.SetPosition(0,0,0)
    pyObj.SetInitFrameCallback(FlickBookCallback)
    pyObj.SetName('Imported Object Target')
    pyObjInf=AddPythonObject((-5,-5,-5),(5,5,5),true)
    pyObjInf.SetPosition(infinity[0],infinity[1],infinity[2])
    pyObjInf.SetName('Imported Object Out of Shot')

    # Group imported objects

    if group==1:
        DeselectAll()
        for i in range(0,(objrecordnumber-1)):
            Select(objectlist[i])
        Group()
        DeselectAll()

    Message("Objects Imported","Success")
else:
    Message("No Objects Imported","Failure")

[/codesyntax]

I’d like to thank e-on software, greenworks and Roderick Davies for their help in developing and testing this script.

impworks © Copyright Mark Caldwell 1996 - 2024