#constant c_BSplineMeshColor RGB(3,252,66)
#constant c_BSplineDirectionMeshColor RGB(236,9,9)
#constant c_SegmentIncrement 0.5 `1.0 should the highest unless you want a ton of polygons
type UDT.ConstantVector
x as float
y as float
z as float
endtype
global g_DistVector as dword : g_DistVector = 1
null = make vector3(g_DistVector)
sync on
sync rate 60
autocam off
position camera 0,24,-64
color backdrop 0
`create floor mesh
make object plain 1,512,512
xrotate object 1,90
`create b-spline
PointVector1 as UDT.ConstantVector
DirectionVector1 as UDT.ConstantVector
PointVector2 as UDT.ConstantVector
DirectionVector2 as UDT.ConstantVector
PointVector1.x = -64.0
PointVector1.y = 24.0
PointVector1.z = 0.0
DirectionVector1.x = -36.0
DirectionVector1.y = 64.0
DirectionVector1.z = 0.0
PointVector2.x = 64.0
PointVector2.y = 24.0
PointVector2.z = 0.0
DirectionVector2.x = 36.0
DirectionVector2.y = 64.0
DirectionVector2.z = 0.0
CreateBSplineMesh( PointVector1, DirectionVector1, PointVector2, DirectionVector2 )
do
cr# = 0 : cf# = 0
speed# = 1.0
sm# = 5.0
if rightkey()=1 or KEYSTATE(32)=1 then cr# = -speed#
if leftkey()=1 or KEYSTATE(30)=1 then cr# = speed#
if upkey()=1 or KEYSTATE(17)=1 then cf# = speed#
if downkey()=1 or KEYSTATE(31)=1 then cf# = -speed#
ncr#=curvevalue(cr#,ncr#,sm#)
ncf#=curvevalue(cf#,ncf#,sm#)
cx#=cx#+mousemovey()*0.2
cy#=cy#+mousemovex()*0.2
if cx#>80 then cx#=80
if cx#<-80 then cx#=-80
ncx#=curveangle(cx#,ncx#,sm#)
ncy#=curveangle(cy#,ncy#,sm#)
move camera ncf#
rotate camera 0,wrapvalue(ncy#-90),0
move camera ncr#
rotate camera 0,wrapvalue(ncy#+90),0
rotate camera ncx#,ncy#,0
sync
loop
function CreateWireMesh( Pos1 as UDT.ConstantVector, Pos2 as UDT.ConstantVector, Color as dword )
local FreeObject as integer
local Dist as float
repeat
inc FreeObject
until not object exist(FreeObject)
make object triangle FreeObject ,0,0,0 ,0,0,0 ,0,0,1
position object FreeObject,Pos1.x,Pos1.y,Pos1.z
point object FreeObject,Pos2.x,Pos2.y,Pos2.z
Dist = GetDistVector( Pos1, Pos2 )
scale object FreeObject,0,0,100.0*Dist
set object diffuse FreeObject, Color
set object emissive FreeObject, Color
set object wireframe FreeObject, 1
endfunction
function GetDistVector( Pos1 as UDT.ConstantVector, Pos2 as UDT.ConstantVector )
local Dist as float
set vector3 g_DistVector,Pos2.x-Pos1.x,Pos2.y-Pos1.y,Pos2.z-Pos1.z
Dist = length vector3( g_DistVector )
endfunction Dist
`PV = Point Vector, DV = Direction Vector
function CreateBSplineMesh( PV1 as UDT.ConstantVector, DV1 as UDT.ConstantVector, PV2 as UDT.ConstantVector, DV2 as UDT.ConstantVector )
local Segment as float
local SegStep as float
local OldPointVector as UDT.ConstantVector
local PointVector as UDT.ConstantVector
SegStep = GetDistVector( PV1, PV2 )
SegStep = 1.0 / (SegStep*c_SegmentIncrement)
for Segment = 0.0 to 1.0 step SegStep
PointVector.x = PV1.x*(1-Segment)^3 + 3*DV1.x*(1-Segment)^2*Segment + 3*DV2.x*(1-Segment)*Segment^2 + PV2.x*Segment^3
PointVector.y = PV1.y*(1-Segment)^3 + 3*DV1.y*(1-Segment)^2*Segment + 3*DV2.y*(1-Segment)*Segment^2 + PV2.y*Segment^3
PointVector.z = PV1.z*(1-Segment)^3 + 3*DV1.z*(1-Segment)^2*Segment + 3*DV2.z*(1-Segment)*Segment^2 + PV2.z*Segment^3
if Segment > 0.0
CreateWireMesh( OldPointVector, PointVector, c_BSplineMeshColor )
OldPointVector = PointVector
else
OldPointVector = PointVector
endif
next Segment
`Last point
Segment = 1.0
PointVector.x = PV1.x*(1-Segment)^3 + 3*DV1.x*(1-Segment)^2*Segment + 3*DV2.x*(1-Segment)*Segment^2 + PV2.x*Segment^3
PointVector.y = PV1.y*(1-Segment)^3 + 3*DV1.y*(1-Segment)^2*Segment + 3*DV2.y*(1-Segment)*Segment^2 + PV2.y*Segment^3
PointVector.z = PV1.z*(1-Segment)^3 + 3*DV1.z*(1-Segment)^2*Segment + 3*DV2.z*(1-Segment)*Segment^2 + PV2.z*Segment^3
CreateWireMesh( OldPointVector, PointVector, c_BSplineMeshColor )
`Direction Vectors
CreateWireMesh( PV1, DV1, c_BSplineDirectionMeshColor )
CreateWireMesh( PV2, DV2, c_BSplineDirectionMeshColor )
endfunction
There ya go.
Also, I has a question. If you were on a comp to type in the code, why did you have to use a PSP?
Also, this prog looks nice, I will def track this.