Ooops
January 26, 2021, 10:54:44 AM
Welcome,
Guest
. Please
login
or
register
.
Did you miss your
activation email
?
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
Home
Forum
Help
Search
Gallery
Login
Register
SyntaxBomb - Indie Coders
»
Languages & Coding
»
Blitz Code Archives
»
3D Graphics - Effects
»
[bb] Wire Primitives and Drawing by N [ 1+ years ago ]
« previous
next »
Print
Pages: [
1
]
Go Down
Author
Topic: [bb] Wire Primitives and Drawing by N [ 1+ years ago ] (Read 599 times)
BlitzBot
Jr. Member
Posts: 1
[bb] Wire Primitives and Drawing by N [ 1+ years ago ]
«
on:
June 29, 2017, 12:28:38 AM »
Title :
Wire Primitives and Drawing
Author :
N
Posted :
1+ years ago
Description :
Functions to create wireframe primitives and draw them
Code :
Code: BlitzBasic
Graphics3D
800
,
600
,
32
,
2
C =
CreateCamera
(
)
CameraClsColor
C,
240
,
255
,
215
WireCylinder = CreateWireCylinder
(
8
)
EntityColor
WireCylinder,
0
,
0
,
0
ScaleEntity
WireCylinder,
1.05
,
1.05
,
1.05
Cylinder =
CreateCylinder
(
8
)
EntityColor
Cylinder,
235
,
255
,
110
EntityAlpha
Cylinder,.7
EntityParent
Cylinder,WireCylinder
Cube =
CreateCube
(
)
WireCube = CreateWireCube
(
)
ScaleEntity
WireCube,
1.05
,
1.05
,
1.05
EntityAlpha
Cube,.7
EntityColor
Cube,
235
,
255
,
110
EntityColor
WireCube,
0
,
0
,
0
EntityParent
Cube,WireCube
Sphere =
CreateSphere
(
4
)
WireSphere = CreateWireSphere
(
4
)
ScaleEntity
WireSphere,
1.05
,
1.05
,
1.05
EntityAlpha
Sphere,.7
EntityColor
Sphere,
235
,
255
,
110
EntityColor
WireSphere,
0
,
0
,
0
EntityParent
Sphere,WireSphere
PositionEntity
WireCube,
3
,
0
,-
3
PositionEntity
WireSphere,-
3
,
0
,
3
PositionEntity
C,
4
,
4
,
4
PointEntity
C,Cylinder
L =
CreateLight
(
2
)
PositionEntity
L,
4
,
4
,
4
LightRange
L,
4
Repeat
HideEntity
Cylinder
HideEntity
Cube
HideEntity
Sphere
TurnEntity
WireCylinder,.5,.6,.7
TurnEntity
WireCube,.5,.6,.7
TurnEntity
WireSphere,.5,.6,.7
DrawWireMeshes
(
C
)
ShowEntity
Cylinder
ShowEntity
Cube
ShowEntity
Sphere
RenderWorld
Flip
Until
KeyHit
(
1
)
Type
WireMesh
Field
Entity
End Type
Function
DrawWireMeshes
(
Camera,Tween#=-
1
)
For
W.WireMesh =
Each
WireMesh
EntityAlpha
WEntity,
1
Next
CameraClsMode
Camera,
1
,
1
WireFrame
True
If
Tween
Then
RenderWorld
Tween
Else
RenderWorld
EndIf
WireFrame
False
CameraClsMode
Camera,
0
,
0
For
W.WireMesh =
Each
WireMesh
EntityAlpha
WEntity,
0
Next
End Function
Function
CreateWireCube
(
)
M=
CreateMesh
(
)
S =
CreateSurface
(
M
)
;outer edges
WireLine3D S,-
1
,-
1
,-
1
,-
1
,
1
,-
1
WireLine3D S,
1
,-
1
,-
1
,
1
,
1
,-
1
WireLine3D S,
1
,-
1
,
1
,
1
,
1
,
1
WireLine3D S,-
1
,-
1
,
1
,-
1
,
1
,
1
;top edges
WireLine3D S,
1
,
1
,
1
,-
1
,
1
,
1
WireLine3D S,
1
,
1
,-
1
,-
1
,
1
,-
1
WireLine3D S,-
1
,
1
,-
1
,-
1
,
1
,
1
WireLine3D S,
1
,
1
,-
1
,
1
,
1
,
1
; bottom edges
WireLine3D S,
1
,-
1
,
1
,-
1
,-
1
,
1
WireLine3D S,
1
,-
1
,-
1
,-
1
,-
1
,-
1
WireLine3D S,-
1
,-
1
,-
1
,-
1
,-
1
,
1
WireLine3D S,
1
,-
1
,-
1
,
1
,-
1
,
1
EntityFX
M,
1
+
16
EntityAlpha
M,
0
W.WireMesh =
New
WireMesh
WEntity = M
Return
M
End Function
Function
CreateWireSphere
(
Segments=
8
)
M =
CreateMesh
(
)
S =
CreateSurface
(
M
)
Dummy =
CreateSphere
(
Segments
)
DS =
GetSurface
(
Dummy,
1
)
For
N =
0
To
CountTriangles
(
DS
)
-
1
V1 =
TriangleVertex
(
DS,N,
0
)
V2 =
TriangleVertex
(
DS,N,
1
)
V3 =
TriangleVertex
(
DS,N,
2
)
If
V1 < Segments*
2
Then
WireLine3D S,
VertexX
(
DS,V1
)
,
VertexY
(
DS,V1
)
,
VertexZ
(
DS,V1
)
,
VertexX
(
DS,V2
)
,
VertexY
(
DS,V2
)
,
VertexZ
(
DS,V2
)
WireLine3D S,
VertexX
(
DS,V2
)
,
VertexY
(
DS,V2
)
,
VertexZ
(
DS,V2
)
,
VertexX
(
DS,V3
)
,
VertexY
(
DS,V3
)
,
VertexZ
(
DS,V3
)
Next
FreeEntity
Dummy
EntityFX
M,
1
+
16
EntityAlpha
M,
0
W.WireMesh =
New
WireMesh
WEntity = M
Return
M
End Function
Function
CreateWireCylinder
(
Segments=
8
)
M =
CreateMesh
(
)
S =
CreateSurface
(
M
)
AngleStep# =
360.0
/Segments
While
N <
360
WireLine3D S,
Sin
(
N
)
,
1
,
Cos
(
N
)
,
Sin
(
N
)
,-
1
,
Cos
(
N
)
WireLine3D S,
Sin
(
N
)
,
1
,
Cos
(
N
)
,
Sin
(
N+AngleStep
)
,
1
,
Cos
(
N+AngleStep
)
WireLine3D S,
Sin
(
N
)
,-
1
,
Cos
(
N
)
,
Sin
(
N+AngleStep
)
,-
1
,
Cos
(
N+AngleStep
)
N = N + AngleStep
Wend
EntityFX
M,
1
+
16
EntityAlpha
M,
0
W.WireMesh =
New
WireMesh
WEntity = M
Return
M
End Function
Function
CreateWireRing
(
Segments=
8
)
M =
CreateMesh
(
)
S =
CreateSurface
(
M
)
AngleStep# =
360.0
/Segments
While
N <
360
WireLine3D S,
Sin
(
N
)
,
0
,
Cos
(
N
)
,
Sin
(
N+AngleStep
)
,
0
,
Cos
(
N+AngleStep
)
N = N + AngleStep
Wend
EntityFX
M,
1
+
16
EntityAlpha
M,
0
W.WireMesh =
New
WireMesh
WEntity = M
Return
M
End Function
Function
WireLine3D
(
S,X#,Y#,Z#,X2#,Y2#,Z2#
)
V=
AddVertex
(
S,X,Y,Z
)
AddVertex
(
S,X2,Y2,Z2
)
AddVertex
(
S,
(
X+X2
)
/
2
,
(
Y+Y2
)
/
2
,
(
Z+Z2
)
/
2
)
AddTriangle
S,V,V+
1
,V+
2
End Function
Comments :
WildStorm(Posted 1+ years ago)
wow, very nice!
Filax(Posted 1+ years ago)
Great !!
puki(Posted 1+ years ago)
Actually that is a nice visual effect - kind of pleasing on the eye - in a way - difficult to describe, but I like it.
N(Posted 1+ years ago)
Glad to hear you liked it.
puki(Posted 1+ years ago)
Hey "Pigeon" has nicked "Noel Cower's" sig - not sure if that will go down too well around here - best you delete it before someone sees it.
N(Posted 1+ years ago)
That's right, I nicked that awesome man's signature so I can be as cool as him.
puki(Posted 1+ years ago)
Well, I'll just have to grass - this might be my ticket back into IRC.
Mikel(Posted 1+ years ago)
Most excellent! Very clean looking. Thanks!
Logged
Print
Pages: [
1
]
Go Up
« previous
next »
SyntaxBomb - Indie Coders
»
Languages & Coding
»
Blitz Code Archives
»
3D Graphics - Effects
»
[bb] Wire Primitives and Drawing by N [ 1+ years ago ]
SimplePortal 2.3.6 © 2008-2014, SimplePortal