|
closed (optional) - True joins the outline's last point back to its first (default); False leaves it open smooth (optional) - True passes a curve through the points; False joins them with straight edges (default) |
|
Creates an empty profile - a 2D outline - and returns its handle. A profile is a flat shape measured in metres, with x running right and y up. Three commands turn it into 3D: CreateExtrusion pushes it straight back, CreateLathe spins it round, and CreateSweep draws it along a spline. Between them they make signs, window frames, houses, gears, kerbs, mouldings, vases and columns. Points added with AddProfilePoint and AddProfileArc build one free-form outline, and closed and smooth apply to it. AddProfileCircle and AddProfileRect each add a separate closed outline of their own. You do not have to manage winding or holes. An outline inside another closed outline becomes a hole: a circle inside a circle makes a ring, and a rectangle inside a rectangle a window frame. Outlines can be drawn in either direction. A straight-edged outline keeps a crisp edge wherever it turns by more than 40 degrees and is shaded smoothly elsewhere, so an L-shaped wall stays square while a 32-point circle stays round. An open outline (closed False) makes an open surface, such as a curved strip, a leaf or a single-skinned shell, with no inside. Give it a two-sided brush or EntityFX 16 to see it from behind, or trace back along a second line to give it thickness. CreateLathe closes an open outline whose ends both lie on its axis. A profile is a plain handle, not an entity. Free it with FreeProfile when you have finished; meshes already made from it are not affected. ProfileSurface chooses which surface each part builds. See also: AddProfilePoint, AddProfileCircle, CreateExtrusion, CreateLathe, CreateSweep, FreeProfile. |
; CreateProfile Example
; ---------------------
Graphics3D 640,480,0,2
SetBuffer BackBuffer()
camera=CreateCamera()
PositionEntity camera,0,1,-5
light=CreateLight()
RotateEntity light,45,45,0
; A turntable to display the shape on
turntable=CreatePivot()
PositionEntity turntable,0,1,0
closed=True
smooth=False
shape=0
While Not KeyDown(1)
; C opens or closes the outline, S switches between straight and smooth
If KeyHit(46) Then
closed=Not closed
If shape Then FreeEntity shape
shape=0
EndIf
If KeyHit(31) Then
smooth=Not smooth
If shape Then FreeEntity shape
shape=0
EndIf
If shape=0 Then
; Ten points round a five-pointed star, in metres
star=CreateProfile(closed,smooth)
For index=0 To 9
reach#=1-0.55*(index Mod 2)
AddProfilePoint star,reach*Cos(90+index*36),reach*Sin(90+index*36)
Next
; Push the outline back 30 cm to see it as a solid
shape=CreateExtrusion(star,0.3,False,turntable)
FreeProfile star
EntityColor shape,250,210,60
; An open outline is a surface with no inside, so draw both sides
If Not closed Then EntityFX shape,16
EndIf
TurnEntity turntable,0,0.6,0
; Arrow keys move the camera
If KeyDown(200) Then MoveEntity camera,0,0,0.1
If KeyDown(208) Then MoveEntity camera,0,0,-0.1
If KeyDown(203) Then TurnEntity camera,0,1,0
If KeyDown(205) Then TurnEntity camera,0,-1,0
RenderWorld
Text 0,0,"Arrow keys: move camera C: closed S: smooth Esc: exit"
Text 0,20,"star=CreateProfile("+closed+","+smooth+")"
Text 0,40,"Closed joins the last point to the first; smooth curves through the points"
Flip
Wend
End