@Derekioh
I thought about what you had written a little more and I get the impression that you want the bridge to change shape or angle based on the position of the observer (camera). I didn't take this approach before because based on your diagrams, the camera was always centered behind the wall, which made me think that the bridge would only form when the user was behind the wall in such a way that it blocked the gap completely from view.
Now the vibe I get is that you want the angle of the bridge to change. I though this was quite interesting so I knocked together an example of that!
It's similar to the idea I posted earlier but without the distance check. The trigger is the left mouse button and the right mouse button.
When you press the left mouse button, the wall will fall and all of the stacked bricks will shift left or right across the gap based on the camera angle. When you press the right mouse button, the wall will stand back up.
The example I'm supplying actually has very little code. Half of it is just drawing the brick texture! The idea is the wall is made up of individual blocks. Each block is a limb tied to the base block. Each block is offset a certain distance from the key block which is in the bottom center position.
Based on the camera y angle relative to the y angle of the wall, the blocks are shifted on the local x axis (i.e. the x axis of the wall object itself - not the world axis) when the trigger is set off. This is accomplished by using only the x portion of polar coordinate calculations. That sounds more complicated than it is... basically the value for the shift is
((height_of_a_block)*cos(adjusted angle y))+(block x pos)
Which can be attained using the newxvalue() command
newx#=newxvalue(block x pos,y angle, height of block)
So, here's the example:
remstart
==============================================================
= Title : Perspective Bridge
= Author : latch
= Date : 02/07/2012
= Update :
= Version: .02
==============================================================
Comments
Build a bridge across a gap from any angle based on
a camera facing a wall.
The wall will be built from separate blocks and then
the blocks positioned at the proper positions based
on a projected angle away from the camera. In this
scenario, we'll use 25 blocks (5x5 wall).
==============================================================
remend
rem =============================================================
rem = SET UP DISPLAY
rem =============================================================
autocam off
set display mode 800,600,32
sync on
sync rate 60
hide mouse
rem =============================================================
rem = MAIN
rem =============================================================
_main:
gosub _init
do
text 0,0,"Camera angle y = "+str$(cangy#)
gosub _build_bridge
gosub _move_camera
sync
loop
end
rem =============================================================
rem = SUBROUTINES - PROCEDURES
rem =============================================================
_init:
rem build wall
gosub _brick_texture
gosub _build_wall
rem build floor
gosub _floor
rem position camera
position camera 0,40,0
return
`=================================================================
_floor:
rem make 2 matrices to form a floor with a gap
make matrix 1,1000,450,1,1
set matrix wireframe off 1
make matrix 2,1000,450,1,1
set matrix wireframe off 2
position matrix 2,0,0,550
return
`=================================================================
_build_wall:
remstart
Stack 25 blocks so that they form a wall. Make the pivot
at the bottom of the first brick and place the first brick
at the bottom center row.
remend
wall=1
make object box wall,100,30,10
offset limb wall,0,0,15,0
make mesh from object wall,wall
delete object wall
make object wall,wall,0
rem create limbs from the wall mesh (blocks) and stack them
`bottom row
add limb wall,1,wall : offset limb wall,1,-200,0,0
add limb wall,2,wall : offset limb wall,2,-100,0,0
add limb wall,3,wall : offset limb wall,3,100,0,0
add limb wall,4,wall : offset limb wall,4,200,0,0
`rest of blocks
lmb=4
for y=1 to 4
for x=0 to 4
inc lmb
xpos#=(100*x)-200
ypos#=y*30
add limb wall,lmb,wall
offset limb wall,lmb,xpos#,ypos#,0
next x
next y
`texture wall
texture object wall,1
scale object texture wall,3,1
position object wall,500,0,425
return
`=================================================================
_brick_texture:
for x=0 to 257
for y=0 to 255
ink rgb(rnd(70)+64,rnd(50)+64,rnd(100)+64),0
dot x,y
next y
next x
ink 0,0
box 0,62,256,65
box 0,126,256,129
box 0,190,256,193
box 0,253,256,256
ink rgb(255,255,255),0
line 0,65,256,65
line 0,129,256,129
line 0,193,256,193
ink rgb(180,180,180),0
line 0,0,256,0
line 0,255,256,255
rem vertical lines
ink 0,0
box 62,0,65,63
box 190,0,193,63
box 126,63,129,127
box 190,127,193,192
box 62,128,65,192
box 126,192,129,256
box 252,63,256,127
box 252,193,256,256
ink rgb(255,255,255),0
line 65,0,65,63
line 193,0,193,63
line 129,63,129,126
line 255,63,255,126
line 255,193,255,256
line 65,128,65,190
line 193,128,193,190
line 129,193,129,253
for n=1 to 1000
ink rgb(255,255,255),0
dot rnd(257),rnd(257)
next n
sync
for n=1 to 4
blur bitmap 0,2
next n
get image 1,0,0,256,256
sync
return
`=================================================================
_move_camera:
move camera (upkey()-downkey())*5
yang#=wrapvalue(camera angle y()+mousemovex())
yrotate camera yang#
return
`=================================================================
_build_bridge:
remstart
Check for mouse click. If left click, topple the wall
and arrange the bricks based on the camera angle. If
right click, rebuild the wall.
remend
cangy#=camera angle y()
rem left click
if mouseclick()=1 and xang#=0
rem topple wall
xang#=0
repeat
inc xang#,1
xrotate object wall,xang#
sync
until xang#=90
rem shift all blocks except the bottom row based on the
rem camera angle
lmb=4
for y=1 to 4
for x=0 to 4
inc lmb
xpos#=limb offset x(wall,lmb)
rem adjust angle for a wall facing any y direction
yangle#=wrapvalue(cangy#-object angle y(wall))
if yangle# > 90 and yangle# < 270
yangle#=wrapvalue(yangle#+180)
endif
newx#=newxvalue(xpos#,yangle#,30*y)
offset limb wall,lmb,newx#,limb offset y(wall,lmb),0
next x
next y
endif
if mouseclick()=2 and xang#=90
rem raisee wall
xang#=90
repeat
dec xang#,1
xrotate object wall,xang#
sync
until xang#=0
rem restore wall blocks
lmb=4
for y=1 to 4
for x=0 to 4
inc lmb
xpos#=(100*x)-200
ypos#=y*30
offset limb wall,lmb,xpos#,ypos#,0
next x
next y
endif
return
`=================================================================
`=================================================================
The same idea could be used for a single mesh - say an actual bridge model. The difference would be that you would have to shift the local x vertices. That would likely skew the bridge in strange ways, but you could put a limit on just how far the verts get shifted. The transformation from the wall to the bridge could be handled in various ways (as was discussed in a previous thread and also some suggestions were made in this thread).
But I think (hopefully), this is what you are after.
Enjoy your day.