hi this my first time playing around with lingo and am using some code out of a book to create a 3d cude with images wrap around it. the problem is that it only using the first 6 sprites for images. and my images are on sprites 27,28,29,30,31,32. does any one no how to change it to read from the vaules i have the images on?? please find code below !!
global gCorners, gCenter, gRectList, gRotate, gPlane
on startMovie
-- initialize lists for a cube
initBox
end
on frameScript
-- add to rotation based on mouse location
gRotate = gRotate - (float(the mouseH-320)/30)*pi()/100
-- calc plane tilt based on mouse location
gPlane = - (float(the mouseV-240)/30)*pi()/20
drawSides
end
on initBox
-- list of corners with x, y and z coordinates
gCorners = [[-60,-60,-60],[60,-60,-60],[60,60,-60],\
[-60,60,-60],[-60,-60,60],[60,-60,60],\
[60,60,60],[-60,60,60]]
-- the screen center
gCenter = point(400,300)
-- list of sides
-- each side has four corners
gRectList = [[1,2,3,4],[1,2,6,5],[3,4,8,7],\
[2,3,7,6],[8,5,1,4],[5,6,7,8]]
end
on drawSides
-- generate a list of screen points and depths based on the
-- gCorners list and the transformation to 2d screen coordiantes
list = []
repeat with i = 1 to gCorners.count
temp = plotPoint(gCorners)
add list,temp
end repeat
-- create a quad list that takes four points to display a side of the cube
repeat with i = 1 to gRectList.count
-- get the four corners that make this side
thisRect = gRectList
-- get the four screen points to draw
q = [list[thisRect[1]][2],list[thisRect[2]][2],\
list[thisRect[3]][2],list[thisRect[4]][2]]
-- get the closest (depth) screen point
z = min(list[thisRect[1]][1],list[thisRect[2]][1],\
list[thisRect[3]][1],list[thisRect[4]][1])
-- draw the side
sprite(i).quad = q
sprite(i).locZ = z
end repeat
end
on plotPoint objectInfo
-- get x, y, and z from objectInfo list
x = getAt(objectInfo,1)
y = getAt(objectInfo,2)
z = getAt(objectInfo,3)
-- TRANSFORM BY ROTATION AROUND Z
-- compute the radius
radius = sqrt(x*x+y*y)
-- compute the angle
if x = 0.0 then angle = atan(the maxInteger)
else angle = atan(float/x)
if y < 0 then angle = angle + pi()
-- rotate
set angle = angle+gRotate
-- compute new x, y, and z
realX = radius*cos(angle)
realZ = radius*sin(angle)
realY = Z
-- TRANSFORM BY ROTATION AROUND X
-- compute then radius
radius = sqrt(realY*realY+realZ*realZ)
-- compute the angle
if realZ = 0 then angle = atan(the maxInteger)
else angle = (atan(realY/realZ))
if realZ < 0 then angle = angle + pi()
-- rotate
angle = angle - gPlane
-- compute then new x, y and z
screenX = realX
screenY = radius*sin(angle)
screenZ = radius*cos(angle)
-- return both z, and the x and y point
return [screenZ,point(screenX,screenY)+gCenter]
end
global gCorners, gCenter, gRectList, gRotate, gPlane
on startMovie
-- initialize lists for a cube
initBox
end
on frameScript
-- add to rotation based on mouse location
gRotate = gRotate - (float(the mouseH-320)/30)*pi()/100
-- calc plane tilt based on mouse location
gPlane = - (float(the mouseV-240)/30)*pi()/20
drawSides
end
on initBox
-- list of corners with x, y and z coordinates
gCorners = [[-60,-60,-60],[60,-60,-60],[60,60,-60],\
[-60,60,-60],[-60,-60,60],[60,-60,60],\
[60,60,60],[-60,60,60]]
-- the screen center
gCenter = point(400,300)
-- list of sides
-- each side has four corners
gRectList = [[1,2,3,4],[1,2,6,5],[3,4,8,7],\
[2,3,7,6],[8,5,1,4],[5,6,7,8]]
end
on drawSides
-- generate a list of screen points and depths based on the
-- gCorners list and the transformation to 2d screen coordiantes
list = []
repeat with i = 1 to gCorners.count
temp = plotPoint(gCorners)
add list,temp
end repeat
-- create a quad list that takes four points to display a side of the cube
repeat with i = 1 to gRectList.count
-- get the four corners that make this side
thisRect = gRectList
-- get the four screen points to draw
q = [list[thisRect[1]][2],list[thisRect[2]][2],\
list[thisRect[3]][2],list[thisRect[4]][2]]
-- get the closest (depth) screen point
z = min(list[thisRect[1]][1],list[thisRect[2]][1],\
list[thisRect[3]][1],list[thisRect[4]][1])
-- draw the side
sprite(i).quad = q
sprite(i).locZ = z
end repeat
end
on plotPoint objectInfo
-- get x, y, and z from objectInfo list
x = getAt(objectInfo,1)
y = getAt(objectInfo,2)
z = getAt(objectInfo,3)
-- TRANSFORM BY ROTATION AROUND Z
-- compute the radius
radius = sqrt(x*x+y*y)
-- compute the angle
if x = 0.0 then angle = atan(the maxInteger)
else angle = atan(float/x)
if y < 0 then angle = angle + pi()
-- rotate
set angle = angle+gRotate
-- compute new x, y, and z
realX = radius*cos(angle)
realZ = radius*sin(angle)
realY = Z
-- TRANSFORM BY ROTATION AROUND X
-- compute then radius
radius = sqrt(realY*realY+realZ*realZ)
-- compute the angle
if realZ = 0 then angle = atan(the maxInteger)
else angle = (atan(realY/realZ))
if realZ < 0 then angle = angle + pi()
-- rotate
angle = angle - gPlane
-- compute then new x, y and z
screenX = realX
screenY = radius*sin(angle)
screenZ = radius*cos(angle)
-- return both z, and the x and y point
return [screenZ,point(screenX,screenY)+gCenter]
end