Page 22 of 71
Re: MP3D Engine Alpha 31
Posted: Fri Feb 22, 2013 7:54 am
by applePi
Hi Michael, the example for big points in Ogre like this:
to use a points wich have the dimension of 20 ( I think it is 20 X 20 not sure)
save the following material script to Examples\3D\Data\Scripts :
Points20.material :
Code: Select all
material def_Points_20
{
receive_shadows off
technique
{
pass
{
point_size 20
lighting off
diffuse vertexcolour
}
}
}
then save the following code to Examples\3D :
Code: Select all
Enumeration
#MESH
#LIGHT
#CAMERA_ONE
#BUTTON
#mainwin
EndEnumeration
Quit.b = #False
ExamineDesktops()
If OpenWindow(#mainwin, 0, 0, DesktopWidth(0), DesktopHeight(0), " Big Points", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
;Initialize environment
InitEngine3D()
InitSprite()
OpenWindowedScreen(WindowID(#mainwin), 0, 0, DesktopWidth(0), DesktopHeight(0)-70, 0, 0, 0)
WorldShadows(#PB_Shadow_Additive)
InitKeyboard()
SetFrameRate(60)
Add3DArchive("Data/Textures", #PB_3DArchive_FileSystem)
Add3DArchive("Data/Scripts", #PB_3DArchive_FileSystem)
Parse3DScripts()
CreateLight(0,RGB(255,255,255),-100,40,30)
AmbientColor(RGB(100,100,100))
CreateCamera(#CAMERA_ONE, 0, 0, 400, 400)
MoveCamera(#CAMERA_ONE, 0, 4, 9)
CameraLookAt(#CAMERA_ONE, 0, 2, 0)
RotateCamera(#CAMERA_ONE, -15, 0, 0)
EndIf
CreateMesh(1, #PB_Mesh_PointList, #PB_Mesh_Dynamic )
;CreateMesh(1, #PB_Mesh_PointList, #False)
GetScriptMaterial(0, "def_Points_20")
SetMeshMaterial(1, MaterialID(0))
DisableMaterialLighting(0, #True)
Global Stars = CreateNode(#PB_Any)
AttachNodeObject(Stars, MeshID(1))
MeshVertexPosition(-0.175999999,0.0016000271,0.1156001091)
MeshVertexColor(RGB(0,255,0))
MeshVertexPosition(-0.4800000191,0.0239999294,-0.4963999987)
MeshVertexColor(RGB(255,255,0))
MeshVertexPosition(0.0624001026,-0.5196000338,-0.1699999571)
MeshVertexColor(RGB(255,0,0))
MeshVertexPosition(-0.1563999653,0.4960000515,-0.9924000502)
MeshVertexColor(RGB(0,255,0))
FinishMesh(#False)
NormalizeMesh(1)
;Main loop
Repeat
Event = WindowEvent()
y + 1
RotateNode(Stars, x, y, z)
RenderWorld()
FlipBuffers()
ExamineKeyboard()
Until Quit = #True Or Event = #PB_Event_CloseWindow

there is also possible to texture the big point (point sprite) by adding
point_sprites on to the material script file and assigning a texture to it
the material script in this case can be like this:
Code: Select all
material PointsSprites
{
technique
{
pass
{
cull_hardware none
cull_software none
scene_blend alpha_blend
lighting off
diffuse 1 1 1 1
ambient 1 1 1 1
specular 1 1 1 1
emissive 1 1 1 1
point_sprites on
point_size 20
//point_size_min 2.0
//point_size_max 256.0
depth_write off
depth_check on
depth_func less_equal
//point_size_attenuation on 1.0 0.0 3.5
texture_unit
{
filtering anisotropic
max_anisotropy 16
texture flare.png
}
}
}
}
in fact i know about point sprites for the first time just yesterday when IdeasVacuum asked about it m and i have answered with an example here:
http://www.purebasic.fr/english/viewtop ... 36&t=53605
i have refered there also to your example about point sprites in MP3D. i have to study it.
Re: MP3D Engine Alpha 31
Posted: Fri Feb 22, 2013 1:38 pm
by mpz
Hello,
@IdeasVacuum , i have test the orthographic view mode with mp3d and it works fine. I have create a optional flag.f command for the Camera
MP_CreateCamera([Flag.f])
if flag = orthographic view mode activated, flag.f is the parameter of the the size of the view
@applePi
Do you think these function is important? I habe create a optional Size.f command for the
MP_SetPrimitives(Entity, Vertex, x.f, y.f, z.f, Color [,Size.f])
. These funtion works only with the PointPrimitives, not for the other primitives
i will make an new lib in some hours for testing
Greetings Michael
Re: MP3D Engine Alpha 31
Posted: Fri Feb 22, 2013 2:11 pm
by applePi
Hi Michael, not so important, but for the MP3D to be side by side with other 3D engines. sometimes it is usefull to display a little thicker points to make it more clear to the eyes.
you suggest this syntax:
MP_SetPrimitives(Entity, Vertex, x.f, y.f, z.f, Color [,Size.f])
yes it is great.
in Ogre i think i can't specify different point sizes to the same mesh.
i read somewhere that it is not possible, you either specify point size A or Point size B in the material script.
but if you can do this ie different point sizes inside the same mesh will be great, as an example we can plot prime number as a big point and the composite number as small. but if it is not possible in Direct 3D then it is enough to be like Ogre is.
the importance of MP3D is that its syntax are fixed and it can be used with any version of PB.
Re: MP3D Engine Alpha 31
Posted: Sun Feb 24, 2013 6:49 pm
by mpz
Hi,
i added a new alpha made with pb 5.10 in the mp3d forum. But there are much changing in the struktures and bug in Tailbite. Have no time to test all, but hope it works...
Greetings Michael
Re: MP3D Engine Alpha 31
Posted: Sun Feb 24, 2013 7:40 pm
by applePi
Hi Michael
i have tested the points and points sizes, it is very great and unique to MP3D Library to be able to select the size of the point any time during calculations.
here is a demo which show a prime numbers spiral , if the number is prime color is green and point size is 3, if not color is red and point size is 1
press space to stop rotation, z/x to zoom in/out . i will test the other features
thank you very much
Code: Select all
;edited to work with MP3D v32 prerelease
Global xres=640, yres=480
MP_Graphics3D (xres,yres,0,3)
SetWindowTitle(0, "Prime Numbers Spiral, press space key to stop rotation, press Z, X keys to zoom in/out")
camera=MP_CreateCamera()
light=MP_CreateLight(2)
MP_LightSetColor (light, RGB(255,255,255))
;MP_InitShadow()
MP_PositionCamera(camera, 0, 5, 10)
MP_CameraLookAt(camera,0,0,0)
MP_PositionEntity(light, 0, 10, 20)
MP_EntityLookAt(light,0,0,0)
Global Entity= MP_CreatePrimitives (2000000, 7) ; 7 ie sizable points
Global.f x, y, z
Define.f red, green, blue
Procedure IsPrime(Number.l)
n = Sqr(number)
For t = 2 To n
If number % t = 0
ProcedureReturn 0
EndIf
Next t
ProcedureReturn 1
EndProcedure
Quit.b = #False : pointSize.f=3
;==============================================================
iterations = 100000
For number = 0 To 100000
t.f+0.01 ; the angle
; the spiral equation
x = t*Cos(6*t)
y = t*Sin(6*t)
z = t
i+1
a=IsPrime(number)
If a=1
red=0:green=255:blue=0 : pointSize = 3
Else
red=255:green=0:blue=0 : pointSize = 1
EndIf
MP_SetPrimitives(Entity, number, x, y, z, MP_ARGB(0,red,green,blue) ,pointSize)
Next
MP_ScaleEntity(Entity, 0.1, 0.1, 0.1)
;MP_MeshSetAlpha(Entity,2)
MP_PositionCamera(camera, 0, 0, 10)
MP_CameraLookAt(camera,0,0,0)
MP_PositionEntity(light, 0 , 0, 10)
MP_EntityLookAt(light,0,0,0)
xx.f=0 :zz.f=0 : turn.b = 0: rot.f=0.5
While Not MP_KeyDown(#PB_Key_Escape) And Not WindowEvent() = #PB_Event_CloseWindow
If MP_KeyDown(#PB_Key_Z)
;xx.f + 0.1
zz.f + 0.1
ElseIf MP_KeyDown(#PB_Key_X)
;xx.f - 0.1
zz.f - 0.1
ElseIf MP_KeyHit(#PB_Key_Space)
If turn
rot=0.5
Else
rot=0
EndIf
turn ! 1
EndIf
MP_PositionEntity(Entity, xx, 0, zz)
MP_TurnEntity(Entity,0,rot,0)
MP_RenderWorld()
MP_Flip ()
Wend
Re: MP3D Engine Alpha 31
Posted: Sun Feb 24, 2013 8:24 pm
by mpz
Hello applePi,
you make all times nice demos for mp3d.
Much thanks
Michael
Re: MP3D Engine Alpha 31
Posted: Sun Feb 24, 2013 11:12 pm
by IdeasVacuum
Hello mpz
i added a new alpha made with pb 5.10 in the mp3d forum
Sorry for being ignorant, but is it the downloads on the first page of this post in this forum, or an external forum somewhere?
Re: MP3D Engine Alpha 31
Posted: Sun Feb 24, 2013 11:52 pm
by mpz
Hi,
here it comes
http://www.morty-productions.de/gamedev ... hp?tid=145
Here a little piece of code with OrthoView. Not good, but a fast sample. I found some little problems with the camera functions and the change of the perspectivity. i will solve this the next days...
Code: Select all
MP_Graphics3D (640,480,0,3) ; Erstelle ein WindowsFenster mit 3D Funktion #Window = 0
SetWindowTitle(0, "4 CameraViewPorts") ; Setzt einen Fensternamen
camera1=MP_CreateCamera() ; Kamera erstellen
camera2=MP_CreateCamera(0.22) ; Kamera erstellen (Orthoview)
light=MP_CreateLight(1) ; Es werde Licht
Mesh=MP_CreateCube() ; Und jetzt ein TeaPot
MP_PositionCamera(camera1,0,0,-3)
MP_PositionCamera(camera2,0,0,-3)
BackColor1 = RGB(0,0,123)
BackColor2 = RGB(0,66,123)
camera5 = MP_CameraViewPort (camera1,0,0,640/2,240,BackColor1)
camera6 = MP_CameraViewPort (camera2,640/2,0,640/2,240,BackColor2)
While Not MP_KeyDown(#PB_Key_Escape) And Not WindowEvent() = #PB_Event_CloseWindow; Esc abfrage oder Windows Schliessen
MP_TurnEntity (Mesh,0.1,0.1,0.1) ; dreh den Würfel
MP_RenderWorld () ; Hier gehts los
MP_Flip ()
Wend
Greetings Michael
Re: MP3D Engine Alpha 31
Posted: Mon Feb 25, 2013 12:10 am
by IdeasVacuum
Wow, quick response and it's already tomorrow in your location! You are working late (me too). Thanks Michael

Re: MP3D Engine Alpha 31
Posted: Mon Feb 25, 2013 3:05 am
by IdeasVacuum
...ah, looks like there are some other up-to-date files necessary to try the Alpha32 lib. I tried installing Alpha31(for PB4.61) and then overwriting the lib file with the latest from the forum, but it fails with:
Camera01 = MP_CreateCamera(100)
[COMPILER] Line 523: MP_CreateCamera(): Incorrect number of parameters
I think I'm going to have other troubles anyway, as I'm using a WindowedScreen - it has system issues using DX9 but is fine with OpenGL.
Re: MP3D Engine Alpha 31
Posted: Mon Feb 25, 2013 10:43 am
by mpz
Hello IdeasVacuum,
i have tested the new file from the forum and it works....
1) Install the MP_31 (x86) version.
2) get the
http://www.flasharts.de/mpz/x86/MP3D_Library.zip zip file. unzip the file and replace the MP3D_Library file in the
C:\Programme\PureBasic\SubSystems\DX9\purelibraries\userlibraries\
or for x64 Systems
C:\Programme(x86)\PureBasic\SubSystems\DX9\purelibraries\userlibraries\
3) Restart Purebasic
If the error message "MP_CreateCamera(): Incorrect number of parameters" appears the MP3D_Library was not changed, you use the old one...
Greetings Michael
Re: MP3D Engine Alpha 31
Posted: Mon Feb 25, 2013 2:13 pm
by IdeasVacuum
ah, I was putting it in C:\Program Files\PureBasic\PureLibraries\UserLibraries - doh!
Edit: Still no luck, from the debug:
Camera01 = MP_CreateCamera(100)
[ERROR] Invalid memory access. (write error at address 8 )
I'm using WinXP SP3 x86. Set the Compiler to DX9 (Using Unicode, in-line ASM, thread safe, XP skin support)
Not to worry for now, the app is working for my purposes and I will come back to the code later when it needs to go out to customers.
Edit Edit: I understand now - much more MP3D needs to be used, for example in this case MP3D's own MP_Graphics3DWindow(). Massive lib, fantastic work!
3D KNOT
Posted: Mon Feb 25, 2013 8:19 pm
by applePi
note: this example needs version Alpha 32 of the library, look Michael instructions above how to install it
a proof about the importance of the new additions to
MP_SetPrimitives function regarding the
points plotting: here we will plot a 3D knot. but if we plot it in the same color we will not be able to see if its really a knot or not and which rope goes over or behind the other. also making parts of the knot thicker or thinner we can easily discriminate its strucure .
and thanks for Michael for enabling us to reposition a certain vertex to another position, this is because every vertex have a number and we access it by that number, we can cut this knot this way in half.
press space to stop the rotation, z/x to zoom
Code Edited for version 26 Feb 2013

more knots equations from here:
http://www.mi.sanu.ac.rs/vismath/taylor2009/index.html
http://virtualmathmuseum.org/SpaceCurves/
Code: Select all
Global xres=640, yres=480
MP_Graphics3D (xres,yres,0,3)
SetWindowTitle(0, "3D Knot, press space key to stop rotation, press Z, X keys to zoom in/out")
camera=MP_CreateCamera()
light=MP_CreateLight(2)
MP_LightSetColor (light, RGB(255,255,255))
MP_PositionCamera(camera, 0, 5, 10)
MP_CameraLookAt(camera,0,0,0)
MP_PositionEntity(light, 0, 10, 20)
MP_EntityLookAt(light,0,0,0)
Global Entity= MP_CreatePrimitives (2000000, 7)
Global.f x, y, z
Define.f red, green, blue
Quit.b = #False
;==============================================================
red = 0: green = 255: blue = 0
pointSize.f=20
NumOfPoints = 3.14159*2 / 0.003
For PointNumber = 0 To NumOfPoints
t.f+0.003
;x = Cos(2*t) + 0.75*Cos(5*t)
;y = Sin(2*t) + 0.75*Sin(5*t)
;z = 0.4*Sin(6*t)
x = Cos(t) + 1.5*Cos(-2*t)
y = Sin(t) + 1.5*Sin(-2*t)
;z = 0.35 * Sin(3*t)
z = 1 * Sin(3*t)
If PointNumber > 1000
PointSize = 3: red = 255:green=255:blue=255
EndIf
MP_SetPrimitives(Entity, PointNumber, x, y, z, MP_ARGB(0,red,green,blue) ,pointSize)
Next
MP_ScaleEntity(Entity, 1.5, 1.5, 1.5)
MP_PositionCamera(camera, 0, 0, 10)
MP_CameraLookAt(camera,0,0,0)
MP_PositionEntity(light, 0 , 0, 10)
MP_EntityLookAt(light,0,0,0)
xx.f=0 :zz.f=0 : turn.b = 0: rot.f=0.5
While Not MP_KeyDown(#PB_Key_Escape) And Not WindowEvent() = #PB_Event_CloseWindow
If MP_KeyDown(#PB_Key_Z)
;xx.f + 0.1
zz.f + 0.1
ElseIf MP_KeyDown(#PB_Key_X)
;xx.f - 0.1
zz.f - 0.1
ElseIf MP_KeyHit(#PB_Key_Space)
If turn
rot=0.5
Else
rot=0
EndIf
turn ! 1
EndIf
MP_PositionEntity(Entity, xx, 0, zz)
MP_TurnEntity(Entity,0,rot,0)
MP_RenderWorld()
MP_Flip ()
Wend
Re: MP3D Engine Alpha 31
Posted: Mon Feb 25, 2013 10:26 pm
by Psychophanta
@mpz
About speed,
as you can see, the difference is extreme:
Test this:
Code: Select all
Global xres=640, yres=480
MP_Graphics3D (xres,yres,0,3)
SetWindowTitle(0, "3D Knot, press space key to stop rotation, press Z, X keys to zoom in/out")
camera=MP_CreateCamera()
light=MP_CreateLight(2)
MP_LightSetColor (light, RGB(255,255,255))
Global Entity= MP_CreatePrimitives (2000000, 1)
Global.f x, y, z
Define.f red, green, blue
Quit.b = #False
;==============================================================
red = 0: green = 255: blue = 0
pointSize.f=20
NumOfPoints = 3.14159*2 / 0.003
For PointNumber = 0 To NumOfPoints
t.f+0.003
;x = Cos(2*t) + 0.75*Cos(5*t)
;y = Sin(2*t) + 0.75*Sin(5*t)
;z = 0.4*Sin(6*t)
x = Cos(t) + 1.5*Cos(-2*t)
y = Sin(t) + 1.5*Sin(-2*t)
;z = 0.35 * Sin(3*t)
z = 1 * Sin(3*t)
If PointNumber > 1000
PointSize = 3: red = 255:green=255:blue=255
EndIf
MP_SetPrimitives(Entity, PointNumber, x, y, z, MP_ARGB(0,red,green,blue))
Next
MP_ScaleEntity(Entity, 1.5, 1.5, 1.5)
MP_PositionCamera(camera, 0, 0, 10)
MP_CameraLookAt(camera,0,0,0)
MP_PositionEntity(light, 0 , 0, 10)
MP_EntityLookAt(light,0,0,0)
xx.f=0 :zz.f=0 : turn.b = 0: rot.f=0.5
While Not MP_KeyDown(#PB_Key_Escape) And Not WindowEvent() = #PB_Event_CloseWindow
If MP_KeyDown(#PB_Key_Z)
;xx.f + 0.1
zz.f + 0.1
ElseIf MP_KeyDown(#PB_Key_X)
;xx.f - 0.1
zz.f - 0.1
ElseIf MP_KeyHit(#PB_Key_Space)
If turn
rot=0.5
Else
rot=0
EndIf
turn ! 1
EndIf
MP_PositionEntity(Entity, xx, 0, zz)
MP_TurnEntity(Entity,0,rot,0)
MP_RenderWorld()
MP_Flip ()
Delay(16)
Wend
Against this one in DM3D, which is the equivalent:
Code: Select all
IncludePath "Include\":IncludeFile "dreamotion3d.pbi"
Global *luz.CLight,*camera.CCamera,*Entity.CSpline
Global xres=640, yres=480
InitSprite():InitKeyboard():InitMouse()
DM_Graphics3D(xres,yres,32,0,1,0,"3D Knot, press space key to stop rotation, press Z, X keys to zoom in/out",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
*camera=DM_CreateCamera()
*pivot.CEntity=DM_CreatePivot()
*luz=DM_CreateLight(#D3DLIGHT_DIRECTIONAL)
DM_LightColor(*luz,255,255,255,255)
*Entity=DM_CreateLine(2000000)
Global.f x, y, z
Define.f red, green, blue
Quit.b = #False
;==============================================================
red = 0: green = 255: blue = 0
pointSize.f=20
NumOfPoints = 3.14159*2 / 0.003
For PointNumber = 0 To NumOfPoints
t.f+0.003
;x = Cos(2*t) + 0.75*Cos(5*t)
;y = Sin(2*t) + 0.75*Sin(5*t)
;z = 0.4*Sin(6*t)
x = Cos(t) + 1.5*Cos(-2*t)
y = Sin(t) + 1.5*Sin(-2*t)
;z = 0.35 * Sin(3*t)
z = 1 * Sin(3*t)
If PointNumber > 1000
PointSize = 3: red = 255:green=255:blue=255
EndIf
DM_LinePoint(*Entity,x, y, z,red,green,blue)
Next
DM_CloseLine(*Entity)
DM_ScaleEntity(*Entity, 1.5, 1.5, 1.5)
DM_PositionEntity(*camera, 0, 0, 10)
DM_PointEntity(*camera,*pivot)
DM_PositionEntity(*luz, 0 , 0, 10)
DM_PointEntity(*luz,*pivot)
xx.f=0 :zz.f=0 : turn.b = 0: rot.f=0.5
Repeat
ExamineKeyboard():ExamineMouse();:ShowCursor_(0)
If KeyboardPushed(#PB_Key_Z)
;xx.f + 0.1
zz.f + 0.1
ElseIf KeyboardPushed(#PB_Key_X)
;xx.f - 0.1
zz.f - 0.1
ElseIf KeyboardReleased(#PB_Key_Space)
If turn
rot=0.5
Else
rot=0
EndIf
turn ! 1
EndIf
DM_PositionEntity(*Entity, xx, 0, zz)
DM_TurnEntity(*Entity,0,rot,0)
DM_BeginScene()
DM_RenderWorld(*camera)
DM_EndScene()
Delay(16)
Until KeyboardPushed(#PB_Key_Escape)
DM_ClearGraphics()
End
Don't worry: here you have this one compiled, it should work, just run it and compare:
http://depositfiles.com/files/hh0etu4fy
Thanks!
Re: MP3D Engine Alpha 31
Posted: Mon Feb 25, 2013 11:33 pm
by mpz
Hello Psychophanta,
nice speedcheck but you must check two same functions

. I have changed the structure of the point mesh to make all point sizeabel. With an older lib the mp3d code works as fast as the DM code, but the point size is not sizeabel. In my opinion the DM_CreateLine has not sizeable points too. The question is: sizeable points or more speed without them or two different primitives one with and one without sizeabel points ?!?!
Possible solution, a flag for sizeable points: MP_CreatePrimitives (VertexCount, Modus[,Flag]) ; Flag = 1, Sizeable points...
or a new Modus for sizeable Points , MP_CreatePrimitives (VertexCount, Modus); Mode = 7 sizeable Points
Greetings Michael