Dark Bit Factory & Gravity
PROGRAMMING => Freebasic => Topic started by: Clyde on March 05, 2007
-
Hi,
I wonder if anyone can help me. I am trying to either find a website that shows how to code your own mesh routines; mostly cylinder meshes, or if anyone knows how to go about coding such a routine. What I'm after is a routine that makes a cylinder from a start x,y,z and the length ( is stops ) at end x,y,z.
Cheers and many thanks,
Clyde.
-
Cylinder should be fairly easy to make.. Take the formula for making a circle;
X=radius*cos (theta)
Y=radius*sin (theta)
work out your step size and just generate 2 circles, one with a positive z value, one with a negative z value, then it would be a matter of playing join the dots.
There are other methods of generating shapes that are pretty cool using cubic splines and also subdivision, for instance, you could generate a sphere by recursively subdividing an icosohedra.
-
Thanks; I'll see what I come up with. I will be stuck on the connections.
-
This is what I've managed to come up with, but it is very wrong.
Any ideas on what's up with it please?
Sub CreateTube()
Dim As Single SX,SY,SZ
Dim As Single EX,EY,EZ
Dim a,v
Dim As Single Radius=2.00, Segments=8, Length=10, Angle, AngleInc
AngleInc=360.0/Segments
Dim v1(Segments)
Dim v2(Segments)
For a=0 to Segments-1
'
' Starting X/Y/Z
'
SX=Radius*Cos(Angle*(D2R))
SY=Radius*Sin(Angle*(D2R))
SZ=0
v1(a)=AddVertex( SX,SY,SZ)
'
' End X/Y/Z
'
EX=Radius*Cos(Angle*(D2R))
EY=Radius*Sin(Angle*(D2R))
EZ=-Length
v2(a)=AddVertex( EX,EY,EZ)
Angle+=AngleInc
Next
Dim vt0,vt1,vt2
For v=0 To segments-1
VT0=V1(v)
VT1=V2(v)
VT2=V1(v+1)
AddTriangle( VT0,VT1,VT2)
AddTriangle( VT1,VT2,VT0)
Next
End Sub
Cheers,
Clyde.
-
What is/isn't it doing? Cause the trig is ok, as long as you have set D2R earlier in the prog somewhere.
The only thing that I noticed is that you add the same triangle twice down the bottom there.
Also, what data type are you setting your, "v1" and "v2" arrays to hold, cause at the moment they would just be integers, maybe you need a User defined type containing 3 singles (for x,y and z)
@me -> Bah! Less talk and more code buddy. hang on....
-
This works in FreeBasic 0.16
Declare Sub CreateCylinder()
Declare Sub DrawCylinder()
Const Segments = 8
Const Length = 10
Const Pi = Atn(1) * 4.0
Const Radius = 2
Const SCR_W=640
Const SCR_H=400
Const ViewDistance = 275
Type VerticeType
x As Single
y As Single
z As Single
End Type
Dim Shared v1(1 To Segments) As VerticeType
Dim Shared v2(1 To Segments) As VerticeType
Screen 17
CreateCylinder
DrawCylinder
Sleep
Sub CreateCylinder()
Dim Angle As Single
For a=1 To Segments
Angle=(a-1) * (Pi*2.0/Segments)
v1(a).x = Cos(Angle) * Radius
v1(a).y = Sin(Angle) * Radius
v1(a).z = -Length/2
v2(a).x = v1(a).x
v2(a).y = v1(a).y
v2(a).z = Length/2
Next a
End Sub
Sub DrawCylinder()
Dim As Single x,y,z
For a=1 To Segments
'Scale em bigger so we can see em
x=v1(a).x * 35
y=v1(a).y * 35
z=v1(a).z * 35
'Project 3d to 2d
x1 = SCR_W/2 + (x*ViewDistance) / (z+ViewDistance)
y1 = SCR_H/2 + (y*ViewDistance) / (z+ViewDistance)
PSet (x1,y1),15
'Now draw the second set
x=v2(a).x * 35
y=v2(a).y * 35
z=v2(a).z * 35
'Project 3d to 2d
x1 = SCR_W/2 + (x*ViewDistance) / (z+ViewDistance)
y1 = SCR_H/2 + (y*ViewDistance) / (z+ViewDistance)
PSet (x1,y1),15
Next a
End Sub
-
Nice one Voltage dude.
My connections must be wrong.
Cheers and many thanks,
Clyde.
-
Well its beating me, Im having trouble working out the connections; and thats with writing it down on paper :(
Or are they? hmmm.
-
I came across this QB prog. Maybe it will help:
'===========================================================================
' Subject: ROTATING 3D CYLINDER & SPHERE Date: 10-22-96 (17:52)
' Author: Douglas H. Lusher Code: QB, QBasic, PDS
' Origin: comp.lang.basic.misc Packet: GRAPHICS.ABC
'===========================================================================
'this is code to draw and rotate a 3-d image of a cylinder
' and a sphere.
'by Douglas H. Lusher, October 1996
DECLARE SUB DrawPoly (X%(), Y%(), Vertices%, Culler%)
DECLARE FUNCTION KeyPress% ()
CONST Green = 2, White = 15
CONST ESC = 27
CONST HomeKey = -71, EndKey = -79
CONST UpArrow = -72, DnArrow = -80
CONST LArrow = -75, RArrow = -77
'the home key brings the object toward the viewer, the end key
' takes it away from the viewer.
'the up arrow moves the object up, the down arrow moves it down,
' the right arrow moves it right, the left arrow moves it left.
'pressing "y","p", or "r" increases yaw, pitch and roll respectively.
' pressing the uppercase of these letters decreases the values.
RANDOMIZE TIMER
APage% = 1: VPage% = 0
SCREEN 9, , APage%, VPage%
ScrnWid% = 640: ScrnHgt% = 350
CtrX% = ScrnWid% \ 2: CtrY% = ScrnHgt% \ 2
AspectRatio! = 4 * (ScrnHgt% / ScrnWid%) / 3
Pi! = ATN(1) * 4!
DO: R1! = RND: LOOP UNTIL R1! < .628: R1! = R1! * 10!
DO: R2! = RND: LOOP UNTIL R2! < .628: R2! = R2! * 10!
DO: R3! = RND: LOOP UNTIL R3! < .628: R3! = R3! * 10!
'R1! = 0: R2! = 0: R3! = 0
D! = 1200
MX! = 0: MY! = 0: MZ! = -350
Inc! = .02
RInc! = -Inc!
PInc! = -Inc!
YInc! = -Inc!
GOSUB InitCylinder
'GOSUB InitSphere
'MainLoop
DO
SELECT CASE KeyPress%
CASE 0
CASE UpArrow: MY! = MY! + 10!
CASE DnArrow: MY! = MY! - 10!
CASE LArrow: MX! = MX! + 10!
CASE RArrow: MX! = MX! - 10!
CASE HomeKey: MZ! = MZ! + 10!
CASE EndKey: MZ! = MZ! - 10!
CASE ASC("r")
RInc! = RInc! + Inc!: IF RInc! > 1 THEN RInc! = 1
CASE ASC("R")
RInc! = RInc! - Inc!: IF RInc! < -1 THEN RInc! = -1
CASE ASC("y")
YInc! = YInc! + Inc!: IF YInc! > 1 THEN YInc! = 1
CASE ASC("Y")
YInc! = YInc! - Inc!: IF YInc! < -1 THEN YInc! = -1
CASE ASC("p")
PInc! = PInc! + Inc!: IF PInc! > 1 THEN PInc! = 1
CASE ASC("P")
PInc! = PInc! - Inc!: IF PInc! < -1 THEN PInc! = -1
CASE ESC: EXIT DO
END SELECT
R1! = R1! + YInc!: IF R1! > 6.28 THEN R1! = 0
R2! = R2! + RInc!: IF R2! > 6.28 THEN R2! = 0
R3! = R3! + PInc!: IF R3! > 6.28 THEN R3! = 0
SR1! = SIN(R1!): CR1! = COS(R1!)
SR2! = SIN(R2!): CR2! = COS(R2!)
SR3! = SIN(R3!): CR3! = COS(R3!)
CLS
GOSUB DrawCylinder
'GOSUB DrawSphere
SWAP APage%, VPage%
WAIT &H3DA, 8
SCREEN , , APage%, VPage%
LOOP
SCREEN 0: WIDTH 80
END
PerspectiveCalculations:
X! = -X!
XA! = CR1! * X! - SR1! * Z!
ZA! = SR1! * X! + CR1! * Z!
X! = CR2! * XA! + SR2! * Y!
YA! = CR2! * Y! - SR2! * XA!
Z! = CR3! * ZA! - SR3! * YA!
Y! = SR3! * ZA! + CR3! * YA!
X! = X! + MX!
Y! = Y! + MY!
Z! = Z! + MZ!
SX% = CINT(D! * X! / Z!) + CtrX%
SY% = CINT(D! * Y! / Z! * AspectRatio!) + CtrY%
RETURN
CheckVisibility:
'plane equation method of hidden surface removal
SP1! = -X1! * (Y2! * Z3! - Y3! * Z2!)
SP2! = X2! * (Y3! * Z1! - Y1! * Z3!)
SP3! = X3! * (Y1! * Z2! - Y2! * Z1!)
VisibleSurface% = ((SP1! - SP2! - SP3!) <= 0)
RETURN
'========================================================================
InitCylinder:
L! = 40! 'half the length of the cylinder
R! = 20! 'the radius of the cylinder
Divs% = 18 'the number of steps around the cylinder
StepAmount! = (Pi! * 2!) / CSNG(Divs%)
S1% = 1: S2% = Divs% \ 3: S3% = S2% + S2%
REDIM X1!(1 TO Divs% + 1), X2!(1 TO Divs% + 1)
REDIM Y1!(1 TO Divs% + 1), Y2!(1 TO Divs% + 1)
REDIM Z1!(1 TO Divs% + 1), Z2!(1 TO Divs% + 1)
REDIM SX1%(1 TO Divs% + 1), SY1%(1 TO Divs% + 1)
REDIM SX2%(1 TO Divs% + 1), SY2%(1 TO Divs% + 1)
REDIM X%(1 TO 4), Y%(1 TO 4)
Xtra% = Divs% + 1
RETURN
DrawCylinder:
R5! = 0
FOR T% = 1 TO Divs%
XX! = SIN(R5!) * R!: YY! = COS(R5!) * R!
'one end of cylinder
X! = XX!: Y! = YY!: Z! = L!
GOSUB PerspectiveCalculations
X1!(T%) = X!: Y1!(T%) = Y!: Z1!(T%) = Z!
SX1%(T%) = SX%: SY1%(T%) = SY%
'other end of cylinder
X! = XX!: Y! = YY!: Z! = -L!
GOSUB PerspectiveCalculations
X2!(T%) = X!: Y2!(T%) = Y!: Z2!(T%) = Z!
SX2%(T%) = SX%: SY2%(T%) = SY%
R5! = R5! + StepAmount!
NEXT
X1!(Xtra%) = X1!(1): X2!(Xtra%) = X2!(1)
Y1!(Xtra%) = Y1!(1): Y2!(Xtra%) = Y2!(1)
Z1!(Xtra%) = Z1!(1): Z2!(Xtra%) = Z2!(1)
SX1%(Xtra%) = SX1%(1): SX2%(Xtra%) = SX2%(1)
SY1%(Xtra%) = SY1%(1): SY2%(Xtra%) = SY2%(1)
FOR Q1% = 1 TO Divs% 'draw the side polygons of the cylinder
Q2% = Q1% + 1
X1! = X1!(Q1%): Y1! = Y1!(Q1%): Z1! = Z1!(Q1%)
X2! = X1!(Q2%): Y2! = Y1!(Q2%): Z2! = Z1!(Q2%)
X3! = X2!(Q2%): Y3! = Y2!(Q2%): Z3! = Z2!(Q2%)
GOSUB CheckVisibility
IF VisibleSurface% THEN
X%(1) = SX1%(Q1%): Y%(1) = SY1%(Q1%)
X%(2) = SX1%(Q2%): Y%(2) = SY1%(Q2%)
X%(3) = SX2%(Q2%): Y%(3) = SY2%(Q2%)
X%(4) = SX2%(Q1%): Y%(4) = SY2%(Q1%)
CALL DrawPoly(X%(), Y%(), 4, White)
END IF
NEXT
'draw one end
X1! = X1!(S1%): Y1! = Y1!(S1%): Z1! = Z1!(S1%)
X2! = X1!(S3%): Y2! = Y1!(S3%): Z2! = Z1!(S3%)
X3! = X1!(S2%): Y3! = Y1!(S2%): Z3! = Z1!(S2%)
GOSUB CheckVisibility
IF VisibleSurface% THEN
CALL DrawPoly(SX1%(), SY1%(), Divs%, White)
END IF
'draw the other end
X1! = X2!(S1%): Y1! = Y2!(S1%): Z1! = Z2!(S1%)
X2! = X2!(S2%): Y2! = Y2!(S2%): Z2! = Z2!(S2%)
X3! = X2!(S3%): Y3! = Y2!(S3%): Z3! = Z2!(S3%)
GOSUB CheckVisibility
IF VisibleSurface% THEN
CALL DrawPoly(SX2%(), SY2%(), Divs%, White)
END IF
RETURN
'========================================================================
InitSphere:
R! = 40! 'the radius of the sphere
Divs% = 18
StepAmount! = (Pi! * 2!) / CSNG(Divs%)
REDIM X1!(1 TO Divs% + 1), X2!(1 TO Divs% + 1)
REDIM Y1!(1 TO Divs% + 1), Y2!(1 TO Divs% + 1)
REDIM Z1!(1 TO Divs% + 1), Z2!(1 TO Divs% + 1)
REDIM SX1%(1 TO Divs% + 1), SY1%(1 TO Divs% + 1)
REDIM SX2%(1 TO Divs% + 1), SY2%(1 TO Divs% + 1)
REDIM X%(1 TO 4), Y%(1 TO 4)
Xtra% = Divs% + 1
RETURN
DrawSphere:
'north polar area
'R5! = 0: X! = SIN(R5!) * R!: Y! = COS(R5!) * R!: Z! = 0
X! = 0!: Y! = R!: Z! = 0
GOSUB PerspectiveCalculations
X3! = X!: Y3! = Y!: Z3! = Z!
X%(3) = SX%: Y%(3) = SY%
R5! = StepAmount!: GOSUB CalcAround
FOR Q1% = 1 TO Divs%
Q2% = Q1% + 1
X1! = X2!(Q2%): Y1! = Y2!(Q2%): Z1! = Z2!(Q2%)
X2! = X2!(Q1%): Y2! = Y2!(Q1%): Z2! = Z2!(Q1%)
GOSUB CheckVisibility
IF VisibleSurface% THEN
X%(1) = SX2%(Q2%): Y%(1) = SY2%(Q2%)
X%(2) = SX2%(Q1%): Y%(2) = SY2%(Q1%)
CALL DrawPoly(X%(), Y%(), 3, Green)
END IF
NEXT
'middle of sphere
R5! = StepAmount!
FOR T2% = 1 TO (Divs% \ 2) - 2
FOR Q1% = 1 TO Divs% + 1
X1!(Q1%) = X2!(Q1%): Y1!(Q1%) = Y2!(Q1%): Z1!(Q1%) = Z2!(Q1%)
SX1%(Q1%) = SX2%(Q1%): SY1%(Q1%) = SY2%(Q1%)
NEXT
R5! = R5! + StepAmount!: GOSUB CalcAround
FOR Q1% = 1 TO Divs%
Q2% = Q1% + 1
X1! = X1!(Q1%): Y1! = Y1!(Q1%): Z1! = Z1!(Q1%)
X2! = X1!(Q2%): Y2! = Y1!(Q2%): Z2! = Z1!(Q2%)
X3! = X2!(Q2%): Y3! = Y2!(Q2%): Z3! = Z2!(Q2%)
GOSUB CheckVisibility
IF VisibleSurface% THEN
X%(1) = SX1%(Q1%): Y%(1) = SY1%(Q1%)
X%(2) = SX1%(Q2%): Y%(2) = SY1%(Q2%)
X%(3) = SX2%(Q2%): Y%(3) = SY2%(Q2%)
X%(4) = SX2%(Q1%): Y%(4) = SY2%(Q1%)
CALL DrawPoly(X%(), Y%(), 4, Green)
END IF
NEXT
NEXT
'south polar area
R5! = Pi!: X! = SIN(R5!) * R!: Y! = COS(R5!) * R!: Z! = 0
GOSUB PerspectiveCalculations
X3! = X!: Y3! = Y!: Z3! = Z!
X%(3) = SX%: Y%(3) = SY%
FOR Q1% = 1 TO Divs%
Q2% = Q1% + 1
X1! = X2!(Q1%): Y1! = Y2!(Q1%): Z1! = Z2!(Q1%)
X2! = X2!(Q2%): Y2! = Y2!(Q2%): Z2! = Z2!(Q2%)
GOSUB CheckVisibility
IF VisibleSurface% THEN
X%(1) = SX2%(Q2%): Y%(1) = SY2%(Q2%)
X%(2) = SX2%(Q1%): Y%(2) = SY2%(Q1%)
CALL DrawPoly(X%(), Y%(), 3, Green)
END IF
NEXT
RETURN
CalcAround:
R4! = 0!: XX! = SIN(R5!) * R!: YY! = COS(R5!) * R!
FOR T% = 1 TO Divs%
X! = COS(R4!) * XX!: Y! = YY!: Z! = SIN(R4!) * XX!
GOSUB PerspectiveCalculations
X2!(T%) = X!: Y2!(T%) = Y!: Z2!(T%) = Z!
SX2%(T%) = SX%: SY2%(T%) = SY%
R4! = R4! + StepAmount!
NEXT
X1!(Xtra%) = X1!(1): X2!(Xtra%) = X2!(1)
Y1!(Xtra%) = Y1!(1): Y2!(Xtra%) = Y2!(1)
Z1!(Xtra%) = Z1!(1): Z2!(Xtra%) = Z2!(1)
SX1%(Xtra%) = SX1%(1): SX2%(Xtra%) = SX2%(1)
SY1%(Xtra%) = SY1%(1): SY2%(Xtra%) = SY2%(1)
RETURN
SUB DrawPoly (X%(), Y%(), Vertices%, Culler%)
PSET (X%(Vertices%), Y%(Vertices%)), Culler%
FOR Q% = 1 TO Vertices%
LINE -(X%(Q%), Y%(Q%)), Culler%
NEXT
END SUB
FUNCTION KeyPress%
KP$ = INKEY$
IF LEN(KP$) THEN
KP% = ASC(KP$): IF KP% = 0 THEN KP% = -ASC(MID$(KP$, 2))
END IF
KeyPress% = KP%
END FUNCTION
-
Cheers RDC, I'll take a look.
Many thanks,
Clyde.
-
Heres a cilinder function i made in Blitz 3D, pretty easy to follow I hope
Graphics3D 800,600,32,2
Function Create_Cylinder( radius#, height#, segment )
If segment < 3 Then segment = 3
If segment > 360 Then segment = 360
Local deltaAngle# = 360.0 / Float(segment)
Local i
Local tx1#
Local ty1#
Local ta1#
Local tx2#
Local ty2#
Local ta2#
Local mesh = CreateMesh()
Local surf = CreateSurface(mesh)
Local v1,v2,v3,v4
Local vCt,vCb
Local tv1,tv3
vCb = AddVertex( surf, 0,0,0 )
vCt = AddVertex( surf, 0,height#, 0 )
For i = 0 To segment-1
ta1# = deltaAngle# * Float(i)
tx1# = radius# * Sin( ta1# )
ty1# = radius# * Cos( ta1# )
v1 = AddVertex( surf, tx1#, 0.0, ty1# )
v3 = AddVertex( surf, tx1#, height#, ty1# )
If i = segment - 1
AddTriangle( surf, v1,tv1,v3 )
AddTriangle( surf, tv1,tv3,v3 )
AddTriangle( surf, v1,vCb,tv1 )
AddTriangle( surf, v3,tv3,vCt )
Else
ta2# = deltaAngle# * Float(i + 1)
tx2# = radius# * Sin( ta2# )
ty2# = radius# * Cos( ta2# )
v2 = AddVertex( surf, tx2#, 0.0, ty2# )
v4 = AddVertex( surf, tx2#, height#, ty2# )
AddTriangle( surf, v1,v2,v3 )
AddTriangle( surf, v2,v4,v3 )
AddTriangle( surf, v1,vCb,v2 )
AddTriangle( surf, v3,v4,vCt )
EndIf
If i = 0
tv1 = v1
tv3 = v3
EndIf
Next
UpdateNormals( mesh )
Return mesh
End Function
Global Cylinder = Create_Cylinder( 1, 4, 36 )
ScaleEntity( Cylinder, 10,10,10 )
PositionEntity( CreateCamera(), 0, 0, -70 )
RotateEntity( CreateLight(), 90, 0, 0 )
WireFrame 1
While Not KeyDown(1)
TurnEntity( Cylinder, 0.4, 0.0, 0.1 )
RenderWorld
Flip
Cls
Wend
-
heres the same code for making a tube
Graphics3D 800,600,32,2
Function Create_Tube( radius#, height#, segment )
If segment < 3 Then segment = 3
If segment > 360 Then segment = 360
Local deltaAngle# = 360.0 / Float(segment)
Local i
Local tx1#
Local ty1#
Local ta1#
Local tx2#
Local ty2#
Local ta2#
Local mesh = CreateMesh()
Local surf = CreateSurface(mesh)
Local v1,v2,v3,v4
Local tv1,tv3
For i = 0 To segment-1
ta1# = deltaAngle# * Float(i)
tx1# = radius# * Sin( ta1# )
ty1# = radius# * Cos( ta1# )
v1 = AddVertex( surf, tx1#, 0.0, ty1# )
v3 = AddVertex( surf, tx1#, height#, ty1# )
If i = segment - 1
AddTriangle( surf, v1,v3,tv1 )
AddTriangle( surf, tv1,v3,tv3 )
Else
ta2# = deltaAngle# * Float(i + 1)
tx2# = radius# * Sin( ta2# )
ty2# = radius# * Cos( ta2# )
v2 = AddVertex( surf, tx2#, 0.0, ty2# )
v4 = AddVertex( surf, tx2#, height#, ty2# )
AddTriangle( surf, v1,v3,v2 )
AddTriangle( surf, v2,v3,v4 )
EndIf
If i = 0
tv1 = v1
tv3 = v3
EndIf
Next
UpdateNormals( mesh )
Return mesh
End Function
Global Tube = Create_Tube( 1, 4, 36 )
ScaleEntity( Tube, 10,10,10 )
PositionEntity( CreateCamera(), 0, 0, -70 )
RotateEntity( CreateLight(), 90, 0, 0 )
While Not KeyDown(1)
TurnEntity( Tube, 0.4, 0.0, 0.1 )
RenderWorld
Flip
Cls
Wend
-
finally heres a tube that faces outwards with no ends and is textured, this unlike the previous ones and creates extra verticies, but its needed for the extra UV coords.
Function Create_Tube( radius#, height#, segment )
If segment < 3 Then segment = 3
If segment > 360 Then segment = 360
Local deltaAngle# = 360.0 / Float(segment)
Local i
Local tx1#
Local ty1#
Local ta1#
Local tx2#
Local ty2#
Local ta2#
Local mesh = CreateMesh()
Local surf = CreateSurface(mesh)
Local v1,v2,v3,v4
Local tv1,tv3
Local u#
For i = 0 To segment-1
ta1# = deltaAngle# * Float(i)
tx1# = radius# * Sin( ta1# )
ty1# = radius# * Cos( ta1# )
u# = 1.0 - ((1.0 / 360.0 ) * ta1#)
v1 = AddVertex( surf, tx1#, 0.0, ty1#, u#, 1.0 )
v3 = AddVertex( surf, tx1#, height#, ty1#, u#, 0.0 )
ta2# = deltaAngle# * Float(i + 1)
tx2# = radius# * Sin( ta2# )
ty2# = radius# * Cos( ta2# )
u# = 1.0 - ((1.0 / 360.0 ) * ta2#)
v2 = AddVertex( surf, tx2#, 0.0, ty2#, u#, 1.0 )
v4 = AddVertex( surf, tx2#, height#, ty2#, u#, 0.0 )
AddTriangle( surf, v1,v2,v3 )
AddTriangle( surf, v2,v4,v3 )
Next
UpdateNormals( mesh )
Return mesh
End Function
Graphics3D 800,600,32,2
Global Tube = Create_Tube( 10, 40, 36 )
Global texture = CreateTexture( 256,256 )
SetBuffer( TextureBuffer( texture ) )
ClsColor 0,255,0 : Cls : Color 255,0,0
Text -50, 120, "abcdefghijklmnopqrstuvwxyz"
Text 205, 120, "abcdefghijklmnopqrstuvwxyz"
Line 0,0, 0,110
Line 0,140, 0,256
EntityTexture( Tube, texture )
SetBuffer( BackBuffer() )
ClsColor 0,0,0
PositionEntity( CreateCamera(), 0, 20, -50 )
RotateEntity( CreateLight(), 90, 0, 0 )
While Not KeyDown(1)
TurnEntity( Tube, 0.0, -0.5, 0.0 )
RenderWorld
Flip
Cls
Wend
-
Cheers Tetra :)
-
I cant tell you how much I really appreciate the help dudes, it means a lot. As Im planning on making a sequel to Kryton with my new found knowledge.
What I'm wanting to try and do is to connect the tubes up to other tubes; for arguments sake lets call them segments.
I've looked at other B3D Cylinders / Tube methods; but they are all share the same principle of using height & radius to determine the size. I am using Freebasic, and am not planning on using any OGL / etc stuffs.
With the above method of the CreateTube(); would It be possible to adapt it so as to control the orientation through x,y,z starting positions to meet up with ending positions and cater forlength etc?
Cheers and humble thanks,
Clyde.
-
I see what you are trying to do, I'd say that what you're suggesting is of course possible, but really what you're wanting to do with cylinders is not to make cylinders, you're trying to make a bigger mesh If you are on the outside of your object looking at it and let's say there are two cylinders joined, it would not matter about the ends matching up if your routine had a z buffer because you'd never see it.
You should really concentrate on making your 3D engine work, then you can use your primitives to build objects.. What you're suggesting doesn't seem to me to be the best way of doing this.
Thinking about it, you could make an amazing program that generates a pq torus like you said, but what else could you use it for?
I'd say make your engine first mate.