Contents
Articles
Behaviors
Books
Director News
Director Web Sites
FAQ
Games
Mailing Lists
News Groups
Project Examples
Reviews
Software
Tools
Useful Web Sites
Utilities
Xtras

Don't miss these
Multimixer Xtra
Toggle ImageEnabled Property of a Flash Member
Random numbers from file names -w/ BuddyAPI
Ripple image when clicked using Imaging Lingo
NJC - Space Invaders
Detecting Quicktime
File Association and save
Dress Up
Set ButtonsEnabled Property of a Flash Cast member
Behavior Property Inspector
 

 

 

Behavior 3D controller example

Added on 1/31/2000

 

Compatibilities:
behavior D7 D8 Mac PC Shockwave

Rating:

Author: KimNordström

Basic 3D COntroler Example

Download PC Source    Download Mac Source
--More examples available at http://www.piggelin.com/macromedia/examples.htm
-- Created by kim@nevermind.net -99
-- If you´ll use this script please notify me so i can see what cool stuff you´ve made...

global ca, cb, cc
global sa, sb, sc
global a, b, c
global x1, y1, z1, xp, yp, zp, xg, yg, zg
global lineCnt, lineComb, pointCnt
global zSort

on startmovie
  a = 0.0
  b = 0.0
  c = 0.0
  x1 = [-10,10,10,-10,-10,10,10,-10]
  --x1 = [-30,-10,-10,-30,-30,-10,-10,-30]
  y1 = [-10,-10,10,10,-10,-10,10,10]
  z1 = [10,10,10,10,-10,-10,-10,-10]
  lineComb = [[1,2,3,4],[2,6,7,3],[7,8,4,3],[4,8,5,1],[2,1,5,6],[6,5,8,7]]
  lineCnt = lineComb.count
  pointCnt = x1.count
  xp = []
  yp = []
  zp = []
  xg = 1
  yg = 5
  zg = 2
  repeat with t = 1 to lineCnt
    puppetsprite t, true
  end repeat
end

on t  
  av = 50
  siz = 10.0
  --siz = the mouseH / 60.0
  ca = cos(a)
  cb = cos(b)
  cc = cos(c)
  sa = sin(a)
  sb = sin(b)
  ac = sin(c)
  repeat with t = 1 to pointCnt
    x = x1[t]
    y = y1[t]
    z = z1[t]
    nx = x*cb*cc + y*(sa*sb*cc + ca*sc) + z*(sa*sc - ca*sb*cc)
    ny = x*cb*sc + y*(ca*cc - sa*sb*sc) + z*(ca*sb*sc + sa*cc)
    nz = x*sb - y*sa*cb + z*ca*cb
    rx = (nx * av/(nz + av))*siz
    ry = (ny * av/(nz + av))*siz
    xp[t] = integer(rx + 200)
    yp[t] = integer(ry + 200)
    zp[t] = (-nz * 5) + 128
  end repeat
  zSort = [:]  
  repeat with cntLines = 1 to lineCnt
    sumTemp = 0
    repeat with koords = 1 to 4
      sumTemp = sumTemp + zp[lineComb[cntLines][koords]]
    end repeat
    sumTemp = sumTemp / 4
    zSort.addProp(sumTemp, cntLines)
  end repeat
  sort zSort
  repeat with setZ = 1 to lineCnt
    sprite(zSort[setZ]).locZ = setZ
  end repeat
  repeat with t = 1 to lineCnt
    tt = []
    tt[1] = [ xp[lineComb[t][1]] , yp[lineComb[t][1]] ]
    tt[2] = [ xp[lineComb[t][2]] , yp[lineComb[t][2]] ]
    tt[3] = [ xp[lineComb[t][3]] , yp[lineComb[t][3]] ]
    tt[4] = [ xp[lineComb[t][4]] , yp[lineComb[t][4]] ]
    --sprite(t).membernum = (t+14)
    sprite(t).quad = tt
  end repeat
  a = a + xg * 3.14 / 270    -- y
  b = b + yg * 3.14 / 270    -- x
  --c = c + zg * 3.14 / 180    -- z
end

 


Contact

MMI
36 South Court Sq
Suite 300
Newnan, GA 30263
USA

Send e-mail