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
cXtraDateTimePicker
List Inspector
VideoCodecCheck II
Text Outliner
Pad Number with Zeros
Sprite recorder v.2
QTGrab
Find Drive Movie Is Plating From
ControlXtra
Help Wizard
 

 

 

Behavior 3D Quad

Added on 1/31/2000

 

Compatibilities:
D7 D8 Mac PC Script Shockwave

This item has not yet been rated

Author: DaveCole

Rotates a quad in 3D Requires Dave"s 3D engine The newest version and full example files are always available at http://www.dubbus.com/devnull

-- 3DQuad, v7.1 Dave Cole, dcole@sigma6.com

global debug, degree, sortSprites, halffov, cullBackfaces, cullBackfaces_cw, DWatcher, DWatcher_newChange, use3DWatcher
property spritenum, myVPos, vPList, pList, mySprite, depthCue_blend
property origSprite, origMember, origBlend, origInk, scriptEvents,
property mouseWithinS, mouseDownS, mouseUpS, mouseLeaveS, initBlend, initInk
property myBlend, myInk, myMember
property initMember, initRect, initVis, initZ, initPuppet

on new me, mypList, spriteNumber, theInk, theBlend, dCue_blend, theMember
  
  if debug then put "3DQuad created"
  
  initMember = sprite(spriteNumber).member
  initz = sprite(spritenumber).locZ
  initRect = sprite(spriteNumber).rect
  initVis = sprite(spriteNumber).visible
  initBlend = sprite(spriteNumber).blend
  initInk = sprite(spriteNumber).ink
  initPuppet = sprite(spriteNumber).puppet
  
  sprite(spriteNumber).puppet = TRUE
  
  set pList = duplicate(mypList)
  set vPList = []
  set myVPos = [0,0,0,0]
  
  set mySprite = spriteNumber
  set the spritenum of me = spriteNumber
  
  set scriptEvents = 0
  
  set origInk = theInk
  set myInk = theInk
  
  set the ink of sprite spriteNumber = theInk
  sprite(spriteNumber).blend = theBlend
  
  set origBlend = theBlend
  set myBlend = theBlend
  
  
  set depthCue_blend = dCue_blend
  
  if depthCue_blend then
    set the ink of sprite mySprite = 32
    set myInk = 32
    set the blend of sprite spriteNumber = theBlend
  end if
  
  set the member of sprite the spritenum of me = theMember
  set myMember = theMember
  set origMember = theMember
  
  set mouseWithinS = EMPTY
  set mouseDownS = EMPTY
  set mouseUpS = EMPTY
  set mouseLeaveS = EMPTY
  
  
  if DWatcher = VOID then
    spawnDWatcher
  end if
  
  
  sprite(me.spritenum).visible = true
  
  return me
end

on kill me
  
  sprite(mySprite).member = initMember
  sprite(mySprite).locZ = initZ
  sprite(mySprite).rect = initRect
  sprite(mySprite).blend = initblend
  sprite(mySprite).ink = initInk
  sprite(mySprite).visible = false -- initVis
  sprite(mysprite).puppet = false
  sprite(mysprite).puppet = true
  sprite(mySprite).visible = true
  --sprite(mySprite).quad = initRect
  sprite(mySprite).puppet = initPuppet
end

on Transform me
  -- Transform all 4 vertices
  if (NOT use3DWatcher) OR DWatcher_newChange then
    set t = 0
    set tt = 0
    repeat with i = 1 to 4
      set z = xFormPoint(pList[i])
      if z <> 0 then
        t = t + 1
        tt = tt + z[3]
      end if
      vPList[i] = z
    end repeat    
    if t <> 0 then
      myVPos[3] = (tt / float(t))
    else
      myVPos[3] = -9999
    end if
  end if
end


on drawMe me
  if debug then put "drawing 3DQuad.."
  set x = 1
  repeat with i = 1 to 4
    if vPList[i] = 0 then set x = 0
  end repeat
  
  if x then
    if DWatcher_newChange OR (NOT use3DWatcher) then
      if cullBackfaces AND isBackfacing(vPList) then
        sprite(mySprite).visible = false
      else
        
        set the visible of sprite the spritenum of me = true
        sprite(mySprite).quad = [[vPList[1][1], vPList[1][2]],[vPList[2][1], vPList[2][2]],[vPList[3][1], vPList[3][2]],[vPList[4][1], vPList[4][2]]]
        
        -- blending ??
      end if
    end if
  else
    
    set the visible of sprite the spritenum of me = false
  end if
  -- blending ??
  
  
end





on setMouseWithin me, scriptName
  set scriptEvents = 1
  deleteOne(the scriptInstanceList of sprite mySprite, me)
  add(the scriptInstanceList of sprite mySprite, me)
  set mouseWithinS = scriptName
end

on setMouseDown me, scriptName
  set scriptEvents = 1
  deleteOne(the scriptInstanceList of sprite mySprite, me)
  add(the scriptInstanceList of sprite mySprite, me)
  set mouseDownS = scriptName
end

on setMouseUp me, scriptName
  set scriptEvents = 1
  deleteOne(the scriptInstanceList of sprite mySprite, me)
  add(the scriptInstanceList of sprite mySprite, me)
  set mouseUpS = scriptName
end

on setMouseLeave me, scriptName
  set scriptEvents = 1
  deleteOne(the scriptInstanceList of sprite mySprite, me)
  add(the scriptInstanceList of sprite mySprite, me)
  set mouseLeaveS = scriptName
end

-- set one element of the local coordinate vertex list to the supplied argument at place "where"
-- where = integer from 1 to 4, vertex = [x,y,z,w]  w typically would equal 1.0
on setVertex me, where, vertex
  setAt(pList, where, vertex)
  
end

-- set the entire local coordinate vertex list to the supplied argument
-- vertices = [[x,y,z,w],[x,y,z,w],[x,y,z,w],[x,y,z,w]]   w typically equals 1.0
on setVertices me, vertices
  set pList = vertices
  
end

-- placeholder does nothing now
on toggleFrontFace me
  
end

-- flipV flips the bitmap in the quad vertically (exchanging the top vertices of the quad with
-- the bottom
on flipV me
  
end

-- flipH flips the bitmap in the quad horizontally (exchanging the left vertices of the quad
-- with the right
on flipH me
  
end

-- rotateClockwise takes either 90, 180, 270, or 360 as arguments and rotates the bitmap
-- in the quad by 90 degrees clockwise (effectively swapping the vertices in the quad
on rotateClockwise me, angle
  
end


on setInk me, theInk
  set the ink of sprite mySprite = theInk
  set myInk = theInk
end

on setBlend me, theBlend
  set the ink of sprite mysprite = 32
  set myInk = 32
  set the blend of sprite mySprite = theBlend
  set myBlend = theBlend
  set origBlend = theBlend
end

on setMember me, memName
  set myMember = member memName
  set the member of sprite mySprite = myMember
end

on setSprite me, spriten
  if scriptEvents then deleteone(the scriptInstanceList of sprite mySprite, me)
  
  set mySprite = spriten
  set the spriteNum of me = mySprite
  
  if scriptEvents then set the scriptInstanceList of sprite mySprite = [me]
end

on getPos me
  return pList
end

on getVPos me
  return vPList
end

on getZPos me
  -- return some composite average of all the z's
  
end


on mouseDown me
  if mouseDownS <> EMPTY then do the text of field mouseDownS
end

on mouseUp me
  if mouseUpS <> EMPTY then do the text of field mouseUpS
end

on mouseWithin me
  if mouseWithinS <> EMPTY then do the text of field mouseWithinS
end

on mouseLeave me
  if mouseLeaveS <> EMPTY then do the text of field mouseLeaveS
end

--------
on SetBlendChange me, mm
  if depthCue_blend then
    if mm = 0 then
      set depthCue_blend = 0
      set myBlend = origBlend
      
      set the blend of sprite mySprite = origBlend
      set the ink of sprite mySprite = origInk
      set myInk = origInk
    end if
  else
    if mm then
      set the ink of sprite mySprite = 32
      set myInk = 32
      set depthCue_blend = 1
    end if
  end if
end

 


Contact

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

Send e-mail