r=0:g=0:b=255
MeshVertexColor(RGBA(r,g,b,100))
now after filling the MeshData with points positions and its colours, i want to isolate the blue points only
Code: Select all
Procedure isolate()
For i=0 To 100000
If MeshData(i)\Color = RGBA(255,0,0,100)
MeshData(i)\x+1
MeshData(i)\y+1
EndIf
Next
SetMeshData(0,0, MeshData(), #PB_Mesh_Vertex, 0, MeshVertexCount(0)-1)
EndProcedure

Code: Select all
Enumeration
#MESH
#LIGHT
#CAMERA
#mainwin
EndEnumeration
Structure Vector3
x.f
y.f
z.f
EndStructure
Define.Vector3 v1, v2, v3
Global x.f = 0
Global y.f = 10
Global z.f = -30
Global Dim MeshData.PB_MeshVertex(0)
ExamineDesktops()
If OpenWindow(#mainwin, 0, 0, DesktopWidth(0), DesktopHeight(0), "isolate blue points from a cloud", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
Define.f KeyX, KeyY
Declare UpdateMatrix()
Declare CreateMatrix()
Declare DrawMatrix()
Declare isolate()
Declare test()
If InitEngine3D()
Add3DArchive(#PB_Compiler_Home + "Examples/3D/Data/Textures", #PB_3DArchive_FileSystem)
Add3DArchive(#PB_Compiler_Home + "Examples/Sources\Data", #PB_3DArchive_FileSystem)
Add3DArchive("/", #PB_3DArchive_FileSystem)
InitSprite()
InitKeyboard()
OpenWindowedScreen(WindowID(#mainwin), 0, 0, DesktopWidth(0), DesktopHeight(0)-60, 0, 0, 0)
CreateMaterial(0, LoadTexture(0, "White.jpg"))
DisableMaterialLighting(0, #True)
;MaterialShadingMode(0, #PB_Material_Wireframe )
MaterialCullingMode(0, #PB_Material_NoCulling)
CreateMatrix()
CreateCamera(0, 0, 0, 100, 100)
MoveCamera(0, 0, 0, 600, #PB_Absolute)
CameraFOV(0, 70)
CameraBackColor(0, $330000)
CameraLookAt(0,0,0,0)
CreateLight(0, RGB(255,255,255), 10, 60, -10)
AmbientColor(RGB(90, 90, 90))
MaterialBlendingMode(0, #PB_Material_AlphaBlend) ; allow alphablending and vertex alpha
;MaterialBlendingMode(0, #PB_Material_Add )
;MaterialBlendingMode(0, #PB_Material_Color )
DisableMaterialLighting(0, 1)
Repeat
Event = WindowEvent()
If ExamineKeyboard()
If KeyboardReleased(#PB_Key_Right)
x - 0.4 :UpdateMatrix()
ElseIf KeyboardReleased(#PB_Key_Q)
;MessageRequester( "", Str(ArraySize(MeshData())))
test()
EndIf
EndIf
rot.f+0.6
RotateEntity(0,0,rot,0)
isolate() ; call blue points extraction procedure
RenderWorld()
FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape) Or Quit = 1
EndIf
Else
MessageRequester("Error", "The 3D Engine can't be initialized", 0)
EndIf
End
Procedure DrawMatrix()
For i=0 To 100000
x = Random(200)-100:y = Random(200)-100:z = Random(200)-100
If y< -80 And z< -80
r=255:g=0:b=0
ElseIf x < -80 And z< -80
r=0:g=255:b=0
ElseIf x< -80 And y< -80
r=255:g=255:b=0
Else
r=255:g=119:b=119
EndIf
;(x - x0)^2 + (y - y0)^2 + (z - z0)^2 <= r^2
;check if point inside a specific sphere:
If (Pow(x,2) + Pow(y,2) + Pow(z,2)) <= 4900
r=0:g=0:b=255
EndIf
MeshVertexPosition(x, y, z)
MeshVertexColor(RGBA(r,g,b,100))
;MeshVertexColor(RGB(r,g,b))
Next
EndProcedure
Procedure CreateMatrix()
CreateMesh(0, #PB_Mesh_PointList, #True)
DrawMatrix()
FinishMesh(#True)
SetMeshMaterial(0, MaterialID(0))
CreateEntity(0, MeshID(0), #PB_Material_None)
ScaleEntity(0, 2, 2, 2)
GetMeshData(0,0, MeshData(), #PB_Mesh_Vertex ,0, MeshVertexCount(0)-1)
GetMeshData(0,0, MeshData(), #PB_Mesh_Color ,0, MeshVertexCount(0)-1)
EndProcedure
Procedure UpdateMatrix()
For i=0 To 50000
MeshData(i)\x + x
MeshData(i)\y + y
MeshData(i)\z + z
Next
SetMeshData(0,0, MeshData(), #PB_Mesh_Vertex , 0, MeshVertexCount(0)-1)
EndProcedure
Procedure isolate()
For i=0 To 100000
;16711680
;1677721855
If MeshData(i)\Color = RGBA(255,0,0,100)
MeshData(i)\x+1
MeshData(i)\y+1
EndIf
Next
SetMeshData(0,0, MeshData(), #PB_Mesh_Vertex, 0, MeshVertexCount(0)-1)
EndProcedure
Procedure test()
MeshData(3)\Color = RGBA(255,0,0,100)
Debug MeshData(3)\Color
EndProcedure