Posts Tagged ‘Python Script’
Nicer Python Display
Thursday, July 22nd, 2010
I’ve wanted to improve the display of the code for my Vue python scripts here for quite awhile but I was never entirely happy with the code highlighters I’d tried. I’ve installed and fiddled with a new one tonight and I think I like it but since its really for you (well at least if your here to look at my Vue python scripts) I thought I’d run a little poll to see what you think.
The new style can be seen on Terrain Matcher while the old style can be seen on EcoRotate.
The poll will run for a week and at the end of the week if the vote is in favour of the new style I’ll update the other python script pages to match.
Updated Add Material Layer Scripts
Monday, September 28th, 2009
I’ve just uploaded version 0.4 of my python scripts for Vue that add material layers to all the materials in a scene. This release includes a new script which adds a material layer at the top of the list of layers so long as the material doesn’t include any nodes attached to the Transparency output node. Hopefully this script should be useful for anyone wanting to toon there scene. You can see the code and download the scripts from the Add Material Layer page in my vue python section.
Add Material Layers Updated
Friday, September 4th, 2009
I’ve updated the Add Material Layers python script for Vue I released last week and added a second script. The original script added the layer at the bottom of all the layers. The new script adds a layer at the top.
Updated Save and Load Camera Animation Scripts
Tuesday, September 1st, 2009
After a request for improved features from Vladimir Chopine I’ve updated my Save and Load camera animation python scripts for Vue to cover more than just position and rotation. They now handle Depth of Field, Exposure, Focal Length, Focus Distance, Lens Aberration, Horizontal Film Shift and Vertical Film Shift. They should work with both animated and still cameras.
Add Material Layer Tutorial Video
Monday, August 24th, 2009
I’ve made a short tutorial video which hopefully demonstrates how to edit the addlayertoall.py python script for Vue
More Vue Python Pages and New Scripts
Sunday, August 16th, 2009
I’ve added not one, not two but six new and one revised python scripts for use with Vue tonight. I’ve also really been on the ball and added the pages for them straight away too.
There are three entirely new scripts to switch Vue’s Bump Mapping on selected objects: one to make the mapping negative, one to make it positive and one to invert it.
There are also three new scripts and one revised script to switch between the four different mapping modes for images in materials.
Equal Scale Replicate Python Script for Vue
Sunday, August 16th, 2009
This python script can be run to equalise the scaling of replicated objects. First you replicate an object in the usual way in Vue (Using Edit -> Replicate) and then you run this script. If you applied a scale to any of the dimensions it will alter the way they are scaled. Vue’s normal scaling for replicate is to scale each object by applying the scale factor to the previous object created. This script sets the scaling to be uniform from one object to the next. This allows stepped pyramids and other similar structures to be quickly created.
Download: Vue Equal Replicate (2k Zip Archive)
######################################################################################################
# Equally stepped scalling for objects produced using Vue's replicate feature
#
# - equalreplicate.py
# - By Mark Caldwell
# - Version 0.1.0
# - 7th January 2008
# - Copyright Mark Caldwell 2008
# - Tested with Vue 6 Infinite on a PC
#
# How to use in 3 easy steps
#
# 1. Download and unzip this file onto your computer
#
# 2. Replicate an object in Vue
#
# 3. With the replicated objects still selected run this script
#
######################################################################################################
count=CountSelectedObjects() # Count the number of objects selected
if count>2: # Check there are more than 2 objects so the script will do something
# Use 2nd and 3rd objects replicated as scale return from first object can be missleading
object=GetSelectedObjectByIndex(1) # Get the second object
xyz1=object.GetScale() # Get the scale of the second object
object=GetSelectedObjectByIndex(2) # Get the third object
xyz2=object.GetScale() # Get the scale of the third object
sfx=xyz1[0]/xyz2[0] # Scale factor for x to restore to full size
sfy=xyz1[1]/xyz2[1] # Scale factor for y to restore to full size
sfz=xyz1[2]/xyz2[2] # Scale factor for z to restore to full size
stepx=1-(1/sfx) # Calculate the step scale for equal steps in x
stepy=1-(1/sfy) # Calculate the step scale for equal steps in y
stepz=1-(1/sfz) # Calculate the step scale for equal steps in z
for i in range(1,count): # Loop through the selected objects
object=GetSelectedObjectByIndex(i) # Get the object
object.ResizeAxis(sfx**(i+1),sfy**(i+1),sfz**(i+1)) # Scale it to unscaled size
object.ResizeAxis(1-stepx*i,1-stepy*i,1-stepz*i) # Apply scaling for step
Refresh() # Refresh the display to show the effect of script running
Vue Stereo Image Camera Creation Script
Sunday, August 16th, 2009
This python script creates a pair of cameras for rendering stereo images in Vue. It’s pretty easy to do without the script but this just speeds things up a bit. Christina has two tutorials about making stereo camera’s on her web site. Its a basic solution that doesn’t generate an animated camera and it won’t work with cameras that aren’t flat and level. Originally created after a request from Jim Coe.
Note: This script does not render the scene. Once you have used it you will need to render the scene from each camera yourself and do whatever magic you need to do with the output.
Download: Vue Stereo Camera Script (3k Zip Archive)
Python Code
#******************************************************
# Creates a pair of cameras in a vue scene for
# rendering stereo position images
#
# - vuestereocamera.py
# - By Mark Caldwell
# - Version 0.1
# - 3rd September 2007
# - Copyright Mark Caldwell 2007
# - Tested with Vue 6.5 Infinite
#
# How to use in 3 easy steps
#
# 1. Download this file onto your computer
#
# 2. Position a camera where you want to render a
# stereo image for and make sure it's your selected
# camera
#
# 3. Then run script and wait for it to work
# To run it go to Python -> Run Python Script
# Then locate the file on your computer
#
#******************************************************
#------------------------------------------------------
# Get Input and Test Value is a positive floating point
#------------------------------------------------------
def TestValAngle (messagetxt,titletxt,default):
hit=-2
val=-1
while hit<0:
try:
if float(val)>0:
hit=1;
elif hit==-2:
val=Prompt (messagetxt,default,true,titletxt)
hit=-1
else:
val=Prompt ("Error: Value must an positive number\n\n"+messagetxt,val,true,titletxt)
except:
hit=-1
val=Prompt ("Error: Value must an positive number\n\n"+messagetxt,val,true,titletxt)
return float(val)
#------------------------------------------------------
# Convert Degrees to Radians
#------------------------------------------------------
def degtorad(deg):
rad=deg*(math.pi/180)
return rad
#--------------------------------------------
# Start of Main Code
#--------------------------------------------
import math
separation=TestValAngle ('Eye Separation','Eye Separation','6.5')
camX=StoreCamera ()
SwitchCamera (camX)
SelectByType(VuePython.VUEBasicObject.VOT_Camera)
cam = GetSelectedObjectByIndex(0)
pos=cam.Position()
rot=cam.GetRotationAngles()
y=(math.sin(degtorad(rot[2]))*separation)+pos[1]
x=(math.cos(degtorad(rot[2]))*separation)+pos[0]
cam.SetPosition(x,y,pos[2])
#----------------------------------------------
# End of Script
#----------------------------------------------
Added Page for EcoRotate Python Script
Friday, August 14th, 2009
Keeping up the momentum from yesterday I’ve added a new page for my EcoRotate python script for Vue.
Added Page for EcoSystem Vertical Scatter Script
Thursday, August 13th, 2009
I’m slowly working through old blog posts creating pages for scripts and other bits and stuff that deserve to have more permanant pages so that they can easily be found. Tonight I’ve added one for the EcoSystem Vertical Scatter Script I wrote a couple of years ago.
