Hi
visible from all sides
in the mesh made from triangles usually this phenomena because the absence of this line
MaterialCullingMode(#MAT, #PB_Material_NoCulling )
also try MeshVertexNormal(x, y, z) after every MeshVertexPosition
your mesh are made from points, note that the array MeshData(i) have the structure item \NormalX to Z. but you should first fill the array with mormalize using GetMeshData with #PB_Mesh_Normal then apply something like
MeshData(i)\NormalX = 1
MeshData(i)\NormalY = 1
MeshData(i)\NormalZ = 1
and then use SetMeshData with #PB_Mesh_Normal
may be MeshVertexNormal are sufficient.
think of converting your points mesh to triangles mesh and this is a hard task but there are people who are doing this look
http://meshlabstuff.blogspot.com/2009/0 ... louds.html
http://lcni.uoregon.edu/~dow/Projects/B ... _mesh.html
but it is a nightmare realy, look my post here
http://www.forums.purebasic.com/english ... 36&t=54708
and here
http://www.purebasic.fr/english/viewtop ... &start=375 a very crude attempt to convert mandelbrot set to mesh (very rough), but it seems the author succeeded
also try MP3D, try the same previous code in MP3D , but i cant give points an alpha i will ask after making more tests
note: the cube are deceiving the eye at first (at least my eyes) but it is rotating left,
Code: Select all
; code for MP3D
Declare DrawMatrix()
;Declare isolate()
Global xres=640, yres=480
MP_Graphics3D (xres,yres,0,3)
SetWindowTitle(0, "Mandel 3D, press Z, X keys to zoom ")
camera=MP_CreateCamera()
light=MP_CreateLight(2)
MP_LightSetColor (light, RGB(255,255,255))
MP_PositionEntity(light, 0, 10, 20)
MP_EntityLookAt(light,0,0,0)
Global Entity= MP_CreatePrimitives (2000000, 1)
Define.f red, green, blue
Quit.b = #False
;==============================================================
MP_ScaleEntity(Entity, 1.5, 1.5, 1.5)
MP_MeshSetBlendColor(Entity, $FFFFFFFF)
MP_MeshSetAlpha(Entity,3)
MP_MeshAlphaSort(Entity)
DrawMatrix()
;MP_SaveMesh("asd.x",Entity) ; not work with points
MP_PositionCamera(camera, 0, 0, 700)
MP_CameraLookAt(camera,0,0,0)
MP_PositionEntity(light, 0 , 0, 10)
MP_EntityLookAt(light,0,0,0)
xx.f=0 :zz.f=0
While Not MP_KeyDown(#PB_Key_Escape) And Not WindowEvent() = #PB_Event_CloseWindow
If MP_KeyDown(#PB_Key_Z)
zz.f + 20
ElseIf MP_KeyDown(#PB_Key_X)
zz.f - 20
EndIf
MP_PositionEntity(Entity, xx, 0, zz)
MP_TurnEntity(Entity,0,1,0)
MP_RenderWorld()
MP_Flip ()
Wend
Procedure DrawMatrix()
For i=0 To 100000
x = Random(200)-100:y = Random(200)-100:z = Random(200)-100
;(x - x0)^2 + (y - y0)^2 + (z - z0)^2 <= r^2
;check if point inside a specific sphere:
q.f = (Pow(x,2) + Pow(y,2) + Pow(z,2))
If q <= 4900
r=0:g=0:b=255
MP_SetPrimitives(Entity, i, x, y, z, MP_ARGB(100,r,g,b))
ElseIf q > 4900 And q <= 10000
r=255:g=0:b=0
MP_SetPrimitives(Entity, i, x, y, z, MP_ARGB(100,r,g,b))
ElseIf q>10000
;r=255:g=119:b=119
r=0:g=255:b=0
MP_SetPrimitives(Entity, i, x, y, z, MP_ARGB(100,r,g,b))
EndIf
Next
EndProcedure