Run iPhone OS 3 project examples under SDK 4 / Base SDK Missing error

Posted by on Dec 29, 2010 in Apple, how to | No Comments

Getting a Base SDK Missing error?

Solution! Select: Project -> Edit Project Settings. When a dialog appears, click the Build tab and change the value in the Base SDK option.

Solution found here.

Caveat: I am new to iPhone development.

determining the bounding box of a Maya object

Posted by on Nov 22, 2010 in code, how to, Maya, MEL | No Comments
float $boboArray[] = `polyEvaluate -b pCube1`;

for a default cube, this will return : // Result: -0.5 0.5 -0.5 0.5 -0.5 0.5 //, the units returned correspond to the 6 coordinate locations of the cubes vertices.

float $boboArray[] = `polyEvaluate -b pSphere1`;

for a default sphere, this will return : // Result: -1 1 -1 1 -1 1 // , the units returned correspond to the coordinate locations of the a cube that is “fitted” to the sphere’s bounding box.

Add a processing applet to a blog post

Posted by on Oct 27, 2010 in default, how to | 2 Comments

Anyone know how to do this? HELP! 😀 I am trying to figure it out.

I want to do it specifically for WordPress, but any info would be welcome.

Here is the applet working at another url.

Thanks,

Oliver

<APPLET name="sketch_oct28a" WIDTH="600" HEIGHT="400" archive="http://oliverwolfson.com/scripts/processing/sketch_oct28a/applet/sketch_oct28a.jar" standby="Loading Processing software..." codebase="http://www.movope.de/assets/java/" code="http://oliverwolfson.com/scripts/processing/sketch_oct28a/applet/sketch_oct28a.class" mayscript="true" scriptable="true" image="http://oliverwolfson.com/scripts/processing/sketch_oct28a/applet/loading.gif" boxmessage="Loading Processing software..." boxcolor="#FFFFFF">
<IMG SRC="http://oliverwolfson.com/scripts/processing/sketch_oct28a/applet/loading.gif" WIDTH="1" HEIGHT="1" />
</APPLET>

Arduino Time Lapse Remote for Nikon

Posted by on Oct 22, 2010 in how to, photography | No Comments

Nikon Remote, controlled by an Arduino Duemilanove, set up for time lapse photography.

Nikon D70
Nikon Remote Controller ML-L3
Arduino Duemilanove

Here is the code, which triggers the shutter every 6 seconds. Based on the “Blink” code that is included in the Arduino IDE, with the only modification being the blink time.

/*
 Time Lapse, based on Blink.
  Triggers camera's shutter every six seconds.

  This example code is in the public domain.
 */

void setup() {                
  // initialize the digital pin as an output.
  // Pin 13 has an LED connected on most Arduino boards:
  pinMode(13, OUTPUT);    
}

void loop() {
  digitalWrite(13, HIGH);   // 0n, trigger the Shutter
  delay(3000);              // remain on for three seconds
  digitalWrite(13, LOW);    // Off
  delay(3000);              // wait for three seconds
}

Nikon Remote Controller ML-L3

Nikon Remote Controller ML-L3 circuit board, with the case removed. I soldered wires to the positive and negative battery terminals, marked in red.

Nikon Remote Controller ML-L3 circuit board, back side. The central zig zagging printed circuit is the circuit that will trigger the infrared LED. I closed the circuit by taping a wire across it, as illustrated by the red line.

The positive wire, from the remote is inserted into pin 13 of the Arduino (I used black for positive, though red would have been a more logical choice ;)). The negative wire is inserted into the GND pin. As the Arduino “Blinks” it supplies power to the remote, and triggers the shutter.

Power is supplied to the Arduino from a 9 volt battery.

Nikon D70’s infrared receiver.

Test: The remote device narcissistically photographs itself.

See http://www.arduino.cc/en/Tutorial/Blink for the tutorial that inspired this experiment.

create a grid of cubes

Posted by on Sep 29, 2010 in code, how to, Maya, MEL, python | No Comments

Grid of cubes in Maya.

# create a grid of cubes, their bottom plane set to zero y, and the center point at zero y.
x = -20
count = 0
cubes = []
while x <= 20:
	z = -20
	while z <= 20:
		cube = mc.polyCube( name = ('polyCube_' + str(count) + '_' + str(x) + str(z)) )
		count +=1
		cubeName=cube[0]
		cubes.append(cubeName)
		mc.setAttr((cubeName + '.translateY'), .5);
		mc.makeIdentity(apply=True, t =True, r=True, s=True, n= 0)
		mc.ResetTransformations()
		mc.move(x, 0, z)
		z += 1
	x +=1

Block of cubes

import maya.cmds as mc
# create a block grid of cubes
# change the mult number below to change the amount of cubes created.
mult =  3;
count = 0
cubes = []
y = mult - mult
while y <= mult *2:
    x = mult * -1
    while x <= mult:
	    z = mult * -1
	    while z <= mult:
		    cube = mc.polyCube( name = ('cube_' + str(count) ) )
		    count +=1
		    cubeName=cube[0]
		    cubes.append(cubeName)
		    mc.move(x, y, z)
		    z += 1
	    x +=1
    y +=1

Make a 3d cube grid, based on a selected object’s bounding box.

//MEL
proc makeCubeGrid(int $cubeGridDiv)
{
    string $cube[];
    string $cubes[] = {};
    string $sel[] = `ls -long -sl`;
    float $bBox[] = `polyEvaluate -b -ae $sel[0]`;

    float $w = ($bBox[1] - $bBox[0]) / $cubeGridDiv;
    float $h = ($bBox[3] - $bBox[2]) / $cubeGridDiv;
    float $d = ($bBox[5] - $bBox[4]) / $cubeGridDiv;

    float $p[3];
    for($i=0;$i<$cubeGridDiv;$i++)
    {
        $p[0] = $bBox[0] + (($bBox[1] - $bBox[0]) / $cubeGridDiv) * $i;
        for($k=0;$k<$cubeGridDiv;$k++)
        {
            $p[1] = $bBox[2] + (($bBox[3] - $bBox[2]) / $cubeGridDiv) * $k;
            for($n=0;$n<$cubeGridDiv;$n++)
            {
                $p[2] = $bBox[4] + (($bBox[5] - $bBox[4]) / $cubeGridDiv) * $n;
                $cube = `polyCube -w $w -h $h -d $d -sx 1 -sy 1 -sz 1 -ax 0 0 0 -ch 0`;
                move ($p[0] + $w / 2) ($p[1] + $h / 2) ($p[2] + $d / 2) $cube[0];
                makeIdentity -apply true -t 1 -r 1 -s 1 -n 0 $cube[0];
                $cubes[`size $cubes`] = $cube[0];
            };
        };
    };
    string $group = `group -em -n "cubes"`;
    parent $cubes $group;
};

makeCubeGrid(10);

Newline / convert newline shell script

Posted by on Sep 26, 2010 in code, how to, Mac | No Comments

When pasting data to a text file, for use with python and other data editing tools, it may be better to use a code text editor, like BB Edit or Text Wrangler. These apps can save your .txt files with UNIX line returns which is necessary to make some scripts work properly.

Technically the line breaks are invisible, but using the ‘tr’ command, in a UNIX shell, you could display them as any character you like, eg:

In the terminal type:

cat /path/some/file.txt | tr '\n' 'U'

In the above example, if the input file uses UNIX style line returns, \n ,each line will have a ‘U’ at the end, or nothing if the file is using another type of return.

To change line returns from Mac to Unix in a data file, try the shell script below.

#!/bin/sh

theFile="$1"

newFile=`basename -s ".txt" $theFile`.UnixLineReturns.txt

theDir=`dirname $theFile`

echo "theFile: $theFile"
echo "newFile: $newFile"
echo "theDir: $theDir"

cat "$theFile"  | tr '\r' '\n' > "$theDir/$newFile"

Apple Mac Pro Bluetooth issue solved

Posted by on Sep 19, 2010 in Apple, default, how to, Mac | 22 Comments

If you are using a Mac Pro with wireless Bluetooth devices, particularly a mouse, you may have noticed an annoying lag or stutter in the performance. I bought the Magic Mouse and a wireless keyboard to solve some ergonomic issues. Unfortunately, poor performance made the situation even worse. Now, after having fixed this problem, my wireless devices are working perfectly.

The problem seems to be poor reception from the Bluetooth unit that shipped with my Mac Pro. I solved this by installing a third party Bluetooth usb adapter. In order for the new usb Bluetooth to operate properly, I had to disable the original internal Bluetooth unit. The instructions to disable the Mac Pro’s Bluetooth are below:

Review the procedure for working on your Mac by downloading a manual here.

1. Turn off Mac Pro. Remove power cord. Remove case cover.
2. Remove the processor tray.

 

Mac Pro Processor Tray

3. Find the Bluetooth unit on the motherboard. It is located near the bottom, on the right hand side as you are looking into the case.

 

Mac Pro bluetooth unit

4. Remove the connector that connects the Bluetooth to the motherboard.

 

Mac Pro bluetooth connector

5. Replace processor tray, and close case.

 

bluetooth USB dongle

6. Install a usb Bluetooth adapter.

Above is the tiny IOGear USB 2.1 Bluetooth Micro Adapter GBU421, which seems to work well with my Mac.

Note: I am using an Intel based MacPro4,1, bought in 2009. If you are using an older Mac Pro, you may want to look at this article and this article, as I believe that the configuration is different.

Caveat: While I am fairly certain that the Mac Pro’s internal Bluetooth could use and antenna redesign, given that so many people are having this same issue, I was not able to completely resolve my issue until I moved the usb Bluetooth adapter up onto my Cinema display, which features usb ports, and is a bit closer to the wireless devices. When I placed the adapter on one of the Mac Pro’s USB ports, on the front of the tower, again the result was poor performance. This leads me to believe that there is some interference from my furniture as well.

Note: If you are using a Magic Mouse, Magic Prefs is a must. It greatly expands the functionality of the Magic Mouse.

Disclaimer

Rsync backup

Posted by on Jun 14, 2010 in code, how to, Mac, tips | No Comments

The scripts, below, allow you to sync directories or drives easily. Great for backups.

Save the scripts to text files with the .sh extension. Make them executable (chmod +x).

syncDir.sh

#!/bin/sh if [ $# -ne 2 ]; then echo 1>&2 "USAGE: syncDir.sh /source/dir /backup/dir/" exit 127 fi rsync --delete -av "$1" "$2"

Usage, in terminal window: path/to/syncDir.sh /source/dir/ /backup/dir/. It is recommended to set up mySync.sh, second script below, to execute syncDir.sh and supply the arguments for source directory and target backup directory.

mySync.sh
Customize the paths to the syncDir.sh script, your source directory and the target backup directory.

~/scripts/syncDir.sh /Volumes/sourceDir/ /Volumes/backupDir

Execute the script in a terminal window (drag and drop and hit enter, or enter the path to the script and hit enter), or set up a cron job to execute this script on a schedule.


Important note!
Seems that sometimes we need to run rsync as superuser, to allow the “–delete” flag to do it’s work deleting or moving files that you have deleted or moved on your source directory. So you can run syncDir.sh as superuser by typing:

sudo ~/scripts/syncDir.sh /Volumes/sourceDir/ /Volumes/backupDir

I recommend testing these scripts thoroughly, with temporary directories and files, before using them on valuable data!

vi text editor introduction

Posted by on May 25, 2010 in code, how to, Mac | No Comments

vi, text editing program for the Unix/Mac terminal.

To open vi, open a file, or create a file type: vi file_name in a terminal window. Or more specifically vi path/to/filename.ext. For example: vi ~/Desktop/hello.sh will open, or create, a file on the Desktop called hello.sh.

To start adding text you need to be in insert mode! hit the i key to get into insert mode.

To delete text, in insert mode, press x for single characters. Press dw for entire words. Press dd to delete entire lines.

To save a file, first hit the ESC key, to enter “command mode”, then type: :w, then hit ENTER (colon+w ENTER)

To exit vi , first hit the ESC key, then type : :q, then hit ENTER (colon+q ENTER)

You can save AND exit by typing :wq, while in command mode.

To move to the beginning of a line, in command mode hit 0 (zero), the end hit $.

Vi cheat sheet

more info here
and here

Load More