the glPointSize_(4) does not affect the points in Ogre 3D, so glEnable_(#GL_POINT_SMOOTH) is very handy and a shortcut for the busy Impatient men/women.
comment the line glEnable_(#GL_POINT_SMOOTH) to see the difference
compile with Opengl subsystem (Compiler--> Compiler Options--> Library Subsystem: opengl )
tested with PB 5.62 in windows xp/32 . may be some old graphics cards can't display thick points in opengl subsystem.
Code: Select all
CompilerIf Subsystem("OpenGL") = #False
MessageRequester("Error", "Please set the Library subsystem to OpenGL from IDE : Compiler... Compiler Options")
End
CompilerEndIf
Procedure.f RandF(Min.f, Max.f, Resolution.i = 10000)
ProcedureReturn (Min + (Max - Min) * Random(Resolution) / Resolution)
EndProcedure
InitEngine3D()
Add3DArchive(#PB_Compiler_Home + "Examples/3D/Data/Textures", #PB_3DArchive_FileSystem)
Add3DArchive(#PB_Compiler_Home + "Examples/3D/Data/Scripts",#PB_3DArchive_FileSystem)
Parse3DScripts()
InitSprite()
InitKeyboard()
InitMouse()
OpenWindow(0, 0, 0, 800, 600, "Big Points within PB Ogre3D using OpenGL subsystem", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(0), 0, 0, 800, 600)
r.f = 8
s.f:t.f
CreateMesh(0, #PB_Mesh_PointList , #PB_Mesh_Static)
For i=1 To 100000
s=RandF(0,360)
t=RandF(0,90)
s=Radian(s)
t=Radian(t)
x.f = r * Cos(s) * Sin(t)
z.f = r * Sin(s) * Sin(t)
y.f = r * Cos(t)
MeshVertexPosition(x, y, z)
MeshVertexColor(RGB(Random(255),Random(255),Random(255)))
Next
FinishMesh(#True)
glEnable_(#GL_POINT_SMOOTH)
;glPointSize_(4) ; does not work
;Texture
CreateTexture(0,128, 128)
StartDrawing(TextureOutput(0))
Box(0, 0, 128, 128, RGB(255, 255, 255))
StopDrawing()
CreateMaterial(0, TextureID(0))
DisableMaterialLighting(0, #True)
SetMeshMaterial(0, MaterialID(0))
;MaterialBlendingMode(0, #PB_Material_Color ) ;uncomment to make the points transparent
CreateEntity(0,MeshID(0),#PB_Material_None )
;Camera
CreateCamera(0, 0, 0, 100, 100)
MoveCamera(0, 0, 5, 22, #PB_Absolute)
CameraLookAt(0, 0, 0, 0)
Repeat
Repeat
event = WindowEvent()
Select Event
Case #PB_Event_CloseWindow
quit = 1
EndSelect
Until event = 0
RotateEntity(0, 0.0,0.3,0.0,#PB_Relative)
RenderWorld()
FlipBuffers()
ExamineKeyboard()
Until KeyboardPushed(#PB_Key_Escape) Or quit = 1
Code: Select all
CompilerIf Subsystem("OpenGL") = #False
MessageRequester("Error", "Please set the Library subsystem to OpenGL from IDE : Compiler... Compiler Options")
End
CompilerEndIf
Procedure.f RandF(Min.f, Max.f, Resolution.i = 10000)
ProcedureReturn (Min + (Max - Min) * Random(Resolution) / Resolution)
EndProcedure
Declare slice()
Global Dim MeshData.PB_MeshVertex(0)
Global n, sliceFlag
Global incr.f = 0.001
InitEngine3D()
Add3DArchive(#PB_Compiler_Home + "Examples/3D/Data/Textures", #PB_3DArchive_FileSystem)
Add3DArchive(#PB_Compiler_Home + "Examples/3D/Data/Scripts",#PB_3DArchive_FileSystem)
Parse3DScripts()
InitSprite()
InitKeyboard()
InitMouse()
OpenWindow(0, 0, 0, 800, 600, "Big Points within PB Ogre3D using OpenGL subsystem . .Press Space to detach part of the sphere", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(0), 0, 0, 800, 600)
r.f = 8
s.f:t.f
Global Dim pointNum(1)
CreateMesh(0, #PB_Mesh_PointList , #PB_Mesh_Static)
;we plot the points, but we wright in the array pointNum the indices of special points to deform it later
For i=0 To 100000
s=RandF(0,180)
t=RandF(0,360)
If t <= 90
n+1
ReDim pointNum(n)
pointNum(n-1)=i
EndIf
s=Radian(s)
t=Radian(t)
x.f = r * Cos(s) * Sin(t)
z.f = r * Sin(s) * Sin(t)
y.f = r * Cos(t)
MeshVertexPosition(x, y, z)
MeshVertexColor(RGB(Random(255),Random(255),Random(255)))
Next
FinishMesh(#True)
GetMeshData(0,0, MeshData(), #PB_Mesh_Vertex | #PB_Mesh_Color , 0, MeshVertexCount(0)-1)
;glEnable_(#GL_POINT_SIZE)
;glDisable_(#GL_POINT_SIZE)
;glPointSize_(10) ; does not work
glEnable_(#GL_POINT_SMOOTH)
;Texture
CreateTexture(0,128, 128)
StartDrawing(TextureOutput(0))
Box(0, 0, 128, 128, RGB(255, 255, 255))
StopDrawing()
CreateMaterial(0, TextureID(0))
DisableMaterialLighting(0, #True)
SetMeshMaterial(0, MaterialID(0))
;MaterialBlendingMode(0, #PB_Material_Color ) ;uncomment to make the points transparent
CreateEntity(0,MeshID(0), #PB_Material_None )
;Camera
CreateCamera(0, 0, 0, 100, 100)
MoveCamera(0, 0, 10, 30, #PB_Absolute)
;MoveCamera(0, 0, 40, 0.001, #PB_Absolute)
CameraLookAt(0, 0, 0, 0)
Repeat
ExamineKeyboard()
Repeat
event = WindowEvent()
Select Event
Case #PB_Event_CloseWindow
quit = 1
EndSelect
Until event = 0
If KeyboardReleased(#PB_Key_Space)
sliceFlag = 1
;slice()
EndIf
If sliceFlag = 1
slice()
EndIf
RotateEntity(0, 0.0,0.3,0.0,#PB_Relative)
RenderWorld()
FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape) Or quit = 1
Procedure slice()
For i=0 To n
If MeshData(pointNum(i))\x > 9: incr = 0: sliceFlag = 0: EndIf
MeshData(pointNum(i))\x + 0
MeshData(pointNum(i))\y + incr
MeshData(pointNum(i))\z + incr
MeshData(pointNum(i))\Color = RGB(255,100,55)
Next
;Debug n
SetMeshData(0, 0, MeshData(), #PB_Mesh_Vertex | #PB_Mesh_Color , 0, MeshVertexCount(0)-1)
EndProcedure
Code: Select all
CompilerIf Subsystem("OpenGL") = #False
MessageRequester("Error", "Please set the Library subsystem to OpenGL from IDE : Compiler... Compiler Options")
End
CompilerEndIf
Procedure.f RandF(Min.f, Max.f, Resolution.i = 10000)
ProcedureReturn (Min + (Max - Min) * Random(Resolution) / Resolution)
EndProcedure
IncludeFile #PB_Compiler_Home + "Examples/3D/Screen3DRequester.pb"
If InitEngine3D()
Add3DArchive(#PB_Compiler_Home + "Examples/3D/Data/Textures", #PB_3DArchive_FileSystem)
Add3DArchive(#PB_Compiler_Home + "Examples/3D/Data/Scripts",#PB_3DArchive_FileSystem)
Add3DArchive(#PB_Compiler_Home + "Examples/3D/Data/Packs/desert.zip", #PB_3DArchive_Zip)
Parse3DScripts()
InitSprite()
InitKeyboard()
InitMouse()
If Screen3DRequester()
r.f = 8
s.f:t.f
CreateMesh(0, #PB_Mesh_LineList , #PB_Mesh_Static)
For i=1 To 100
s=RandF(0,360)
;s=RandF(0,1) ; uncomment to get a flat disk shape and not a sphere
t=RandF(0,360)
s=Radian(s)
t=Radian(t)
x.f = r * Cos(s) * Sin(t)
y.f = r * Sin(s) * Sin(t)
z.f = r * Cos(t)
MeshVertexColor(RGB(Random(255),Random(255),Random(255)))
MeshVertexPosition(0, 0, 0)
MeshVertexPosition(x, y, z)
Next
FinishMesh(#True)
;Texture
CreateTexture(0,128, 128)
StartDrawing(TextureOutput(0))
Box(0, 0, 128, 128, RGB(255, 255, 255))
StopDrawing()
CreateMaterial(0, TextureID(0))
DisableMaterialLighting(0, #True)
SetMeshMaterial(0, MaterialID(0))
CreateEntity(0,MeshID(0),MaterialID(0) )
; Camera
;
CreateCamera(0, 0, 0, 100, 100)
MoveCamera(0, 20, 5, 20, #PB_Absolute)
CameraLookAt(0, 0, 0, 0)
glEnable_(#GL_LINE_SMOOTH) ; this is an opengl function
;glLineWidth_(6) ; this is an opengl function
Repeat
Screen3DEvents()
RotateEntity(0, 0.5,1,0.5,#PB_Relative)
RenderWorld()
Screen3DStats()
FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape) Or Quit = 1
EndIf
Else
MessageRequester("Error", "The 3D Engine can't be initialized",0)
EndIf
End
more info:
round big points with material script:
http://www.purebasic.fr/english/viewtop ... 36&t=63646
thick and thin lines, and tubes of all shapes:
http://www.purebasic.fr/english/viewtop ... 36&t=61049