SKY.builder

From Director Online Wiki
Jump to: navigation, search

SKY.builder Project

The SKY.builder is a free tool for creating and saving your custom Shockwave3D skydome.

It's still in a very early stage and still needs some work.

Content and detailled description will be added soon.

Error creating thumbnail: Unable to save thumbnail to destination

Project Description

mSkyDome movie script

-- lbxCreateSkyDomeGradient
-- Creates a sky texture gradient for spherical mapping
--   Example:
--   member("sky-gradient").image = lbxCreateSkyDomeGradient(1024,512,rgb(20,47,116),rgb(161,177,210), 300)
 
global gVerticalBalance
global skyDomeSizeX
global skyDomeSizeY
 
 
on lbxCreateSkyDomeGradient startRGB, endRGB, starCount
  updateTexSize()
 
  if gVerticalBalance = 50 then
    firstHalfSkyDome = image(skyDomeSizeX, skyDomeSizeY / 2, 32, 0)
    firstHalfSkyDome = lbxVerticalGradientColor(skyDomeSizeX,skyDomeSizeY / 2,startRGB,endRGB)
    if starCount <> 0 then
      firstHalfSkyDome = lbxAddStarfield(firstHalfSkyDome,starCount)
    end if
    mySkyDomeGradient = image(skyDomeSizeX, skyDomeSizeY, 32, 0)
    mySkyDomeGradient.fill(mySkyDomeGradient.rect,endRGB)
    mySkyDomeGradient.copyPixels(firstHalfSkyDome,firstHalfSkyDome.rect,firstHalfSkyDome.rect)
 
  else if gVerticalBalance > 50 then
    halfY = skyDomeSizeY / 2
    gradientSizeY = halfY - integer((gVerticalBalance - 50) / 50.0 * halfY)
 
    firstHalfSkyDome = image(skyDomeSizeX, gradientSizeY, 32, 0)
    firstHalfSkyDome = lbxVerticalGradientColor(skyDomeSizeX,gradientSizeY,startRGB,endRGB)
    if starCount <> 0 then
      firstHalfSkyDome = lbxAddStarfield(firstHalfSkyDome,starCount)
    end if
    mySkyDomeGradient = image(skyDomeSizeX, skyDomeSizeY, 32, 0)
    mySkyDomeGradient.fill(mySkyDomeGradient.rect, endRGB)
    mySkyDomeGradient.copyPixels(firstHalfSkyDome,firstHalfSkyDome.rect,firstHalfSkyDome.rect)
 
  else if gVerticalBalance < 50 then
    halfY = skyDomeSizeY / 2
    gradientSizeY = integer(gVerticalBalance / 50.0 * halfY)
    gradientOffsetY = halfY - gradientSizeY
 
    firstHalfSkyDome = image(skyDomeSizeX, gradientSizeY, 32, 0)
    firstHalfSkyDome = lbxVerticalGradientColor(skyDomeSizeX,gradientSizeY,startRGB,endRGB)
    if starCount <> 0 then
      firstHalfSkyDome = lbxAddStarfield(firstHalfSkyDome,starCount)
    end if
    mySkyDomeGradient = image(skyDomeSizeX, skyDomeSizeY, 32, 0)
    mySkyDomeGradient.fill(mySkyDomeGradient.rect, endRGB)
    mySkyDomeGradient.fill(rect(0,0,skyDomeSizeX,gradientOffsetY), startRGB)
 
    mySkyDomeGradient.copyPixels(firstHalfSkyDome,rect(0,gradientOffsetY,skyDomeSizeX,(firstHalfSkyDome.height + gradientOffsetY)),firstHalfSkyDome.rect)
 
  end if
 
  -- add horizon additive
  mySkyDomeGradient.copyPixels(member("horizon-additive").image, mySkyDomeGradient.rect, member("horizon-additive").image.rect, [#ink: 33])
 
  -- update texture
  member("world").texture("sky").image = mySkyDomeGradient
 
  firstHalfSkyDome = ""
  -- return mySkyDomeGradient
end
 
 
-- lbxVerticalGradientColor gradientSizeX, gradientSizeY,startRGB,endRGB
-- Erstellt ein Bild mit einem linearen, vertikalen, additiven Farbverlauf
--   Example:
--   member("sky-gradient").image = lbxVerticalGradientColor(1024,512,rgb(20,47,116),rgb(161,177,210))
 
on lbxVerticalGradientColor gradientSizeX, gradientSizeY,startRGB,endRGB
  myGradientImage = image(gradientSizeX, gradientSizeY, 32, 0)
  copyInk = 34
  if startRGB = endRGB then
    myGradientImage.fill(myGradientImage.rect, startRGB)
    return myGradientImage
  else
    myGradientImage.fill(myGradientImage.rect, rgb(0,0,0))
  end if
  redDiff = endRGB.red - startRGB.red
  if redDiff = 0 then redDiff = 1
  if redDiff then
    absDiff = abs(redDiff)
    dir = redDiff/absDiff
    compGradient = image(1,absDiff,32,0)
    repeat with y = 0  to absDiff
      compGradient.fill(rect(0,y,1,y+1),rgb(startRGB.red+y*dir,0,0))
    end repeat
    myGradientImage.copyPixels(compGradient,myGradientImage.rect,compGradient.rect,[#ink:copyInk])
  end if
  greenDiff = endRGB.green - startRGB.green
  if greenDiff = 0 then greenDiff = 1
  if greenDiff then
    absDiff = abs(greenDiff)
    dir = greenDiff/absDiff
    compGradient = image(1,absDiff,32,0)
    repeat with y = 0  to absDiff
      compGradient.fill(rect(0,y,1,y+1),rgb(0,startRGB.green+y*dir,0))
    end repeat
    myGradientImage.copyPixels(compGradient,myGradientImage.rect,compGradient.rect,[#ink:copyInk])
  end if
  blueDiff = endRGB.blue - startRGB.blue
  if blueDiff = 0 then blueDiff = 1
  if blueDiff then
    absDiff = abs(blueDiff)
    dir = blueDiff/absDiff
    compGradient = image(1,absDiff,32,0)
    repeat with y = 0  to absDiff
      compGradient.fill(rect(0,y,1,y+1),rgb(0,0,startRGB.blue+y*dir))
    end repeat
    myGradientImage.copyPixels(compGradient,myGradientImage.rect,compGradient.rect,[#ink:copyInk])
  end if
  compGradient = ""
  return myGradientImage
end
 
 
-- lbxAddStarfield skyDomeImage, starCount
-- build a starfield with starCount stars
--   Example:
--   member("sky-gradient").image = lbxAddStarfield(member("sky-gradient").image,300)
 
on lbxAddStarfield skyDomeImage, starCount
  -- add n stars of random color and location
  repeat with i = 1 to starCount
    c = random(100) + 127
    x = random(skyDomeImage.width)
    y = random(skyDomeImage.height)
    skyDomeImage.setPixel(point(x,y),rgb(c,c,c))
  end repeat
  return skyDomeImage
end
 
 
on updateTexSize
  myTexSize = sendAllSprites(#RadioGroup_SelectedButton, "texSize")
  put myTexSize
  case myTexSize.number of
    1:
      skyDomeSizeX = 512
      skyDomeSizeY = 256
    2:
      skyDomeSizeX = 1024
      skyDomeSizeY = 512
    3:
      skyDomeSizeX = 2048
      skyDomeSizeY = 1024
  end case
end

Downloads

Nothing to download yet, sorry

To Do List

  • UI Design enhancements
  • Integration into Director Authoring Environment
  • More features :)
  • external Castlib for clouds textures
  • Code optimization
  • Publish project files

Missing Director Features

  • This tool and similar tools could strongly benefit of an option to save W3D files with compressed textures. Currently the saved W3D files rapidly get huge, as saveW3D saves textures uncompressed.