
MP3D Engine Alpha 33
Re: MP3D Engine Alpha 32
Is there a way to see the parameters of a MP3D function at the bottom of the PB IDE, like procedures ? Just to see in a glance what parameters are needed for the function without refering to the help file everytime ? 

- Psychophanta
- Always Here
- Posts: 5153
- Joined: Wed Jun 11, 2003 9:33 pm
- Location: Anare
- Contact:
Re: MP3D Engine Alpha 32
I second that request.Joubarbe wrote:Is there a way to see the parameters of a MP3D function at the bottom of the PB IDE, like procedures ? Just to see in a glance what parameters are needed for the function without refering to the help file everytime ?
Thank you Applepi for the corrections.
Re: MP3D Engine Alpha 32
Hi All,
Can someone explain to me what I am doing wrong here? It must be something stupid
I try to use MP_RenderToTexture() to draw some lines on a texture, but on Texture 1 it's behaving weird.
So, I use MP_RenderToTexture() on 4 textures, but texture 1 misbehaves:

But the texture 1 contents should look like this (as shown below drawn to screen at 0,0 and not using MP_RenderToTexture())

Here is an code example:
I want the lines to be shown on the Texture, not cut through it. Any ideas?
Cheers,
Hippy
Can someone explain to me what I am doing wrong here? It must be something stupid

I try to use MP_RenderToTexture() to draw some lines on a texture, but on Texture 1 it's behaving weird.
So, I use MP_RenderToTexture() on 4 textures, but texture 1 misbehaves:

But the texture 1 contents should look like this (as shown below drawn to screen at 0,0 and not using MP_RenderToTexture())

Here is an code example:
Code: Select all
EnableExplicit
;////////////////////////////////////////////////////////////
;// Trying to draw 2D on different textures;
;// Based on.... MP_RenderTotexture.pb - by Michael Paulwitz - 3.11.2010
;// Tested MP3D version 33 with PB 5.40 LTS
;////////////////////////////////////////////////////////////////
MP_Graphics3D (640,480,0,3) : SetWindowTitle(0, "Draw on Texture")
MP_AmbientSetLight (RGB(0,50,128))
; Create Empty Textures and Sprites from them
Global Texture1 = MP_CreateTexture(200, 200)
Global Texture2 = MP_CreateTexture(200, 200)
Global Texture3 = MP_CreateTexture(200, 200)
Global Texture4 = MP_CreateTexture(200, 200)
Global Sprite1 = MP_SpriteFromTexture(Texture1)
Global Sprite2 = MP_SpriteFromTexture(Texture2)
Global Sprite3 = MP_SpriteFromTexture(Texture3)
Global Sprite4 = MP_SpriteFromTexture(Texture4)
;- Draw on Texture 2
MP_Box(0,0,MP_SpriteGetWidth(Sprite2), MP_SpriteGetHeight(Sprite2), RGB($FF,$0,$0), 1) ; <--- red filled box never gets drawn
; MP_DrawText(0,0,"Draw In Texture 2")
MP_LineXY (0,0, MP_SpriteGetWidth(Sprite2), MP_SpriteGetHeight(Sprite2), MP_ARGB($FF,$0,$FF,$0))
MP_LineXY (0, MP_SpriteGetHeight(Sprite2), MP_SpriteGetWidth(Sprite2), 0, MP_ARGB($FF,$0,$FF,$0))
MP_RenderToTexture(Texture2) ; to texture (transparent background?)
;- Draw on Texture 3
MP_Box(0,0,200,200,$0F0F0F,1) ; <--- dark grey box never gets drawn
;MP_DrawText(10,20,"Only In Texture 3")
MP_LineXY (0,0, MP_SpriteGetWidth(Sprite3), MP_SpriteGetHeight(Sprite3), MP_ARGB($FF,$FF,0,0))
MP_LineXY (0, MP_SpriteGetHeight(Sprite3), MP_SpriteGetWidth(Sprite3), 0, MP_ARGB($FF,$FF,0,0))
MP_RenderToTexture(Texture3, MP_ARGB($FF,0,0,$FF)) ; to texture with a blue background
;- Draw on Texture 4
MP_Box(0,0,200,200,RGB(127,127,127),0) ; <--- light grey box never gets drawn
;MP_DrawText(10,20,"Only In Texture 3")
MP_LineXY (0,0, MP_SpriteGetWidth(Sprite4), MP_SpriteGetHeight(Sprite4), MP_ARGB($FF,$0,$0,$FF))
MP_LineXY (0, MP_SpriteGetHeight(Sprite4), MP_SpriteGetWidth(Sprite4), 0, MP_ARGB($FF,$0,$0,$FF))
MP_RenderToTexture(Texture4, MP_ARGB($FF,0,$FF,0)) ; to texture with a green background
While Not MP_KeyDown(#PB_Key_Escape) And Not WindowEvent() = #PB_Event_CloseWindow
;- Draw on Texture 1
MP_Box(0,0,MP_SpriteGetWidth(Sprite1),MP_SpriteGetHeight(Sprite1),$FFFF00,1) ; yellow box
Global k
For k=0 To 200
MP_LineXY(1, k, k, k, RGB(k,0,k)) ; gradient
Next
MP_RenderToTexture(Texture1,MP_ARGB($FF,$00,$FF,$FF)) ; to texture with cyan background
; ^^^ comment this out, and you see the expected contents on the screen at 0,0
; which is a yellow box with a black-purple gradient in half
; when uncommented though, this should be in the Texture1?
; build the display
MP_DrawSprite(Sprite1, 50, 10)
MP_DrawSprite(Sprite2, 300, 10)
MP_DrawSprite(Sprite3, 50, 260)
MP_DrawSprite(Sprite4, 300, 260)
MP_DrawText (550,460,"FPS = "+Str(MP_FPS()))
MP_RenderWorld()
MP_Flip ()
Wend
Cheers,
Hippy
Re: MP3D Engine Alpha 32
too many experiments until i get it to work, but it happened a little change we need to do.
1) if we replace RGB by MP_ARGB in the MP_LineXY(1, k, k, k, RGB(k,0,k)) it will plot the gradient lines on Texture1. which i have moved outside the main loop. 2) clear the Texture2 with MP_ARGB(0,0,0,0))
1) if we replace RGB by MP_ARGB in the MP_LineXY(1, k, k, k, RGB(k,0,k)) it will plot the gradient lines on Texture1. which i have moved outside the main loop. 2) clear the Texture2 with MP_ARGB(0,0,0,0))
Code: Select all
EnableExplicit
;////////////////////////////////////////////////////////////
;// Trying to draw 2D on different textures;
;// Based on.... MP_RenderTotexture.pb - by Michael Paulwitz - 3.11.2010
;// Tested MP3D version 33 with PB 5.40 LTS
;////////////////////////////////////////////////////////////////
MP_Graphics3D (640,480,0,3) : SetWindowTitle(0, "Draw on Texture")
MP_AmbientSetLight (RGB(0,50,128))
; Create Empty Textures and Sprites from them
Global Texture1 = MP_CreateTexture(200, 200)
Global Texture2 = MP_CreateTexture(200, 200)
Global Texture3 = MP_CreateTexture(200, 200)
Global Texture4 = MP_CreateTexture(200, 200)
Global Sprite1 = MP_SpriteFromTexture(Texture1)
Global Sprite2 = MP_SpriteFromTexture(Texture2)
Global Sprite3 = MP_SpriteFromTexture(Texture3)
Global Sprite4 = MP_SpriteFromTexture(Texture4)
;- Draw on Texture 1
MP_Box(0,0,MP_SpriteGetWidth(Sprite1),MP_SpriteGetHeight(Sprite1),$FFFF00,1) ; yellow box
Global k
For k=0 To 200
MP_LineXY(0, k, k, k, MP_ARGB(255,k,0,k)) ; gradient
Next
MP_RenderToTexture(Texture1, MP_ARGB($FF,255,255,0))
;MP_RenderToTexture(Texture1,MP_ARGB($FF,$00,$FF,$FF)) ; to texture with cyan background
;- Draw on Texture 2
MP_Box(0,0,MP_SpriteGetWidth(Sprite2), MP_SpriteGetHeight(Sprite2), RGB($FF,$0,$0), 1) ; <--- red filled box never gets drawn
; MP_DrawText(0,0,"Draw In Texture 2")
MP_LineXY (0,0, MP_SpriteGetWidth(Sprite2), MP_SpriteGetHeight(Sprite2), MP_ARGB($FF,$0,$FF,$0))
MP_LineXY (0, MP_SpriteGetHeight(Sprite2), MP_SpriteGetWidth(Sprite2), 0, MP_ARGB($FF,$0,$FF,$0))
MP_RenderToTexture(Texture2, MP_ARGB(0,0,0,0)) ; to texture (transparent background?)
;- Draw on Texture 3
MP_Box(0,0,200,200,$0F0F0F,1) ; <--- dark grey box never gets drawn
;MP_DrawText(10,20,"Only In Texture 3")
MP_LineXY (0,0, MP_SpriteGetWidth(Sprite3), MP_SpriteGetHeight(Sprite3), MP_ARGB($FF,$FF,0,0))
MP_LineXY (0, MP_SpriteGetHeight(Sprite3), MP_SpriteGetWidth(Sprite3), 0, MP_ARGB($FF,$FF,0,0))
MP_RenderToTexture(Texture3, MP_ARGB($FF,0,0,$FF)) ; to texture with a blue background
;- Draw on Texture 4
MP_Box(0,0,200,200,RGB(127,127,127),0) ; <--- light grey box never gets drawn
;MP_DrawText(10,20,"Only In Texture 3")
MP_LineXY (0,0, MP_SpriteGetWidth(Sprite4), MP_SpriteGetHeight(Sprite4), MP_ARGB($FF,$0,$0,$FF))
MP_LineXY (0, MP_SpriteGetHeight(Sprite4), MP_SpriteGetWidth(Sprite4), 0, MP_ARGB($FF,$0,$0,$FF))
MP_RenderToTexture(Texture4, MP_ARGB($FF,0,$FF,0)) ; to texture with a green background
While Not MP_KeyDown(#PB_Key_Escape) And Not WindowEvent() = #PB_Event_CloseWindow
; ^^^ comment this out, and you see the expected contents on the screen at 0,0
; which is a yellow box with a black-purple gradient in half
; when uncommented though, this should be in the Texture1?
; build the display
MP_DrawSprite(Sprite1, 50, 10)
MP_DrawSprite(Sprite2, 300, 10)
MP_DrawSprite(Sprite3, 50, 260)
MP_DrawSprite(Sprite4, 300, 260)
MP_DrawText (550,460,"FPS = "+Str(MP_FPS()))
MP_RenderWorld()
MP_Flip ()
Wend
Re: MP3D Engine Alpha 32
Thank you, it works as expected nowapplePi wrote:1) if we replace RGB by MP_ARGB in the MP_LineXY(1, k, k, k, RGB(k,0,k))

I actually do this inside the loop as I draw dynamically on the texture, and it's working now, thanks!
Cheers,
Hippy
- Psychophanta
- Always Here
- Posts: 5153
- Joined: Wed Jun 11, 2003 9:33 pm
- Location: Anare
- Contact:
Re: MP3D Engine Alpha 32
Does someone know some trick to merge 2 or more textures on an entity using alpha channel or other thing?
Thanks.
Thanks.
Re: MP3D Engine Alpha 32
Psychophanta, there is this function:
MP_TextureOnTexture(Texture, Texture2, x, y [, transparency [, Rotation.f]])
in the doc: The function MP_TextureOnTexture added a Texture on another Texture
i haven't tested it yet, but may be it what is needed
Edit: yes it is a good function, here the MRAMOR6X6.jpg is like the wood.jpg instead of black/white. and this determined by the transparency and rotation.
the transparency of Texture2: 0 total transparency, 255 no transparency at all
adapted from one of the mp3d examples
MP_TextureOnTexture(Texture, Texture2, x, y [, transparency [, Rotation.f]])
in the doc: The function MP_TextureOnTexture added a Texture on another Texture
i haven't tested it yet, but may be it what is needed
Edit: yes it is a good function, here the MRAMOR6X6.jpg is like the wood.jpg instead of black/white. and this determined by the transparency and rotation.
the transparency of Texture2: 0 total transparency, 255 no transparency at all
Code: Select all
Texture = MP_LoadTexture(#PB_Compiler_Home + "Examples\3D\Data\Textures\wood.jpg")
Texture2 = MP_LoadTexture(#PB_Compiler_Home +"Examples\3D\Data\Textures\MRAMOR6X6.jpg")
a=MP_TextureOnTexture(Texture, Texture2, 1, 1, 50 , 25)
Debug a
MP_EntitySetTexture (plane, Texture)
Code: Select all
;////////////////////////////////////////////////////////////////
;//
;// Project Title: MP 3D Engine Beispielprogramme
;// Dateiname: MP_RotateTextur.pb
;// Erstellt am: 29.1.2010
;// Update am :
;// Author: Michael Paulwitz
;//
;// Info:
;// Rotiert eine Textur
;//
;//
;////////////////////////////////////////////////////////////////
MP_Graphics3D (640,480,0,3) ; Erstelle ein WindowsFenster mit 3D Funktion #Window = 0
SetWindowTitle(0, "Rotiere Textur auf Würfel") ; Setzt einen Fensternamen
camera=MP_CreateCamera() ; Kamera erstellen
MP_PositionEntity (camera,0,0,-50)
light=MP_CreateLight(1) ; Es werde Licht
plane = MP_CreateRectangle(50, 1, 50) ; Bodenplatte kann natürlich auch ein x-beliebiges Mesh sein
MP_ScaleMesh( plane ,1,0.1,1)
MP_PositionEntity (plane,0,-3,10) ; Position des Würfels
MP_RotateEntity(plane, 90, 0, 0)
Texture = MP_LoadTexture(#PB_Compiler_Home + "Examples\3D\Data\Textures\wood.jpg")
Texture2 = MP_LoadTexture(#PB_Compiler_Home +"Examples\3D\Data\Textures\MRAMOR6X6.jpg")
a=MP_TextureOnTexture(Texture, Texture2, 1, 1, 50 , 25)
Debug a
MP_EntitySetTexture (plane, Texture)
;a=MP_TextureOnTexture(Texture, Texture2, 0, 0);, 250 , 0)
MP_AmbientSetLight(RGB(55,34,167))
While Not MP_KeyDown(#PB_Key_Escape) And Not WindowEvent() = #PB_Event_CloseWindow; Esc abfrage oder Windows Schliessen
;Angle.f + 0.5
;MP_RotateTexture (Texture , Angle)
MP_RenderWorld() ; Erstelle die Welt
MP_Flip () ; Stelle Sie dar
Wend
-
- Enthusiast
- Posts: 497
- Joined: Sat Oct 11, 2008 9:07 pm
- Location: Germany, Berlin > member German forum
Re: MP3D Engine Alpha 32
Hi,
i am working for a bugfix for the MP_Setmeshdata command and on new demofiles. Comming this weekend.
@ApplePi, nice demo, here comes my example it with sprites rendered on the fly on a texture. You can also use texturshader to add texures or purbasic_images with pb commands and create texures from them and and and
Greetings Michael
i am working for a bugfix for the MP_Setmeshdata command and on new demofiles. Comming this weekend.
@ApplePi, nice demo, here comes my example it with sprites rendered on the fly on a texture. You can also use texturshader to add texures or purbasic_images with pb commands and create texures from them and and and
Greetings Michael
Code: Select all
MP_Graphics3D (640,480,0,3) ; Erstelle ein WindowsFenster mit 3D Funktion #Window = 0
SetWindowTitle(0, "Rotiere Textur auf Würfel") ; Setzt einen Fensternamen
camera=MP_CreateCamera() ; Kamera erstellen
MP_PositionEntity (camera,0,0,-50)
light=MP_CreateLight(1) ; Es werde Licht
plane = MP_CreateRectangle(50, 1, 50) ; Bodenplatte kann natürlich auch ein x-beliebiges Mesh sein
MP_ScaleMesh( plane ,1,0.1,1)
MP_PositionEntity (plane,0,-3,10) ; Position des Würfels
MP_RotateEntity(plane, 90, 0, 0)
Texture = MP_LoadTexture(#PB_Compiler_Home + "Examples\3D\Data\Textures\wood.jpg")
Texture2 = MP_LoadTexture(#PB_Compiler_Home +"Examples\3D\Data\Textures\MRAMOR6X6.jpg")
SpriteA = MP_SpriteFromTexture(Texture)
SpriteB = MP_SpriteFromTexture(Texture2)
PlaneTexture = MP_CreateBackBufferTexture(400,400)
MP_EntitySetTexture (plane, PlaneTexture)
MP_AmbientSetLight(RGB(55,34,167))
While Not MP_KeyDown(#PB_Key_Escape) And Not WindowEvent() = #PB_Event_CloseWindow; Esc abfrage oder Windows Schliessen
x + 1
If x = 256 : x = 0 : EndIf
MP_RotateSprite(SpriteA, x)
MP_DrawSprite(SpriteA, 1, 1 ,x )
MP_DrawSprite(SpriteB, 1, 1 ,255-x)
MP_RenderToTexture(PlaneTexture)
MP_RenderWorld() ; Erstelle die Welt
MP_Flip () ; Stelle Sie dar
Wend
Working on - MP3D Library - PB 5.73 version ready for download
- Psychophanta
- Always Here
- Posts: 5153
- Joined: Wed Jun 11, 2003 9:33 pm
- Location: Anare
- Contact:
Re: MP3D Engine Alpha 32
Thanks,
I want to alternate 2 textures incrementing and decrementing transparency degree in a real time dinamic mesh.
Like this:
I think sprites are not valid, and the idea from applePi just change one of the textures, so can not return to the original texture.
Any strategy?
I want to alternate 2 textures incrementing and decrementing transparency degree in a real time dinamic mesh.
Like this:
Code: Select all
MP_Graphics3D(1280,720,0,3)
SetWindowTitle(0,"Moving Flag texture")
camera=MP_CreateCamera()
light=MP_CreateLight(1)
#vertices=64
#DPI=6.2831853071795864769;25286766559
grid=MP_CreatePlane(#vertices,#vertices)
If CreateImage(0,1024,1024)
Font=LoadFont(#PB_Any,"Arial",138*4)
StartDrawing(ImageOutput(0))
Box(0,0,512,512,RGB(255,0,0))
Box(512,0,512,512,RGB(0,255,0))
Box(0,512,512,512,RGB(0,0,255))
Box(512,512,512,512,RGB(255,255,0))
StopDrawing()
EndIf
Textur=MP_ImageToTexture(0,0,1,0)
MP_EntitySetTexture(grid,Textur)
MP_ScaleEntity(grid,0.1,0.1,0.1)
i.d=0:freq.d=0.00002:ampl.d=2.2:longo.d=8.0
x.f=0:y.f=0:z.f=0
MP_PositionEntity(camera,0,0,-9)
addi.f=1
While MP_KeyDown(#PB_Key_Escape)=0 And WindowEvent()<>#PB_Event_CloseWindow
If MP_KeyDown(#PB_Key_Left)=1:x-0.1
ElseIf MP_KeyDown(#PB_Key_Right):x+0.1
ElseIf MP_KeyDown(#PB_Key_Down):y-0.1
ElseIf MP_KeyDown(#PB_Key_Up):y+0.1
ElseIf MP_KeyDown(#PB_Key_Z):z+0.1
ElseIf MP_KeyDown(#PB_Key_A):z-0.1
ElseIf MP_KeyDown(#PB_Key_Pad8):freq+0.0000001
ElseIf MP_KeyDown(#PB_Key_Pad2):freq-0.0000001
ElseIf MP_KeyDown(#PB_Key_Pad4):longo-0.025
ElseIf MP_KeyDown(#PB_Key_Pad6):longo+0.025
ElseIf MP_KeyDown(#PB_Key_Pad7):ampl-0.01
ElseIf MP_KeyDown(#PB_Key_Pad1):ampl+0.01
ElseIf MP_KeyHit(#PB_Key_Pause):While MP_KeyDown(#PB_Key_Pause):Delay(20):Wend:While MP_KeyDown(#PB_Key_Pause)=0:Delay(20):Wend
EndIf
MP_PositionEntity(grid,x,y,z)
MP_TurnEntity(grid,0,0.2,0)
MP_RenderWorld()
MP_Flip()
count2.f+addi
If count2>254
addi=-1
ElseIf count2<2
addi=1
EndIf
MP_MaterialEmissiveColor(Textur,count2,255,255,255)
For gz.u=0 To #vertices
For gx.u=gz To gz+#vertices
MP_VertexSetz(grid,gx+gz*#vertices,ampl*Sin(i+gx/longo))
i+freq:If i>#DPI:i-#DPI:EndIf
Next gx
Next gz
Wend
Any strategy?
-
- Enthusiast
- Posts: 497
- Joined: Sat Oct 11, 2008 9:07 pm
- Location: Germany, Berlin > member German forum
Re: MP3D Engine Alpha 32
Hi Psychophanta,
can you show us both texures please? i am not shure to understand what you mean and hope i have an idea if i see the pictures...
Greetings Michael
can you show us both texures please? i am not shure to understand what you mean and hope i have an idea if i see the pictures...
Greetings Michael
Working on - MP3D Library - PB 5.73 version ready for download
Re: MP3D Engine Alpha 32
i think Psychophanta wants to do something like this:
suppose there is 2 textures, clouds and wood.
1- clouds begins to be transparent gradually and so faded away, so the wood will be on the front
2- now the wood begins to to be transparent gradually until it faded away,
now the clouds on the front
but from now the clouds and the wood appears suddenly without fading away gradually.
most likely there is a logical error in my strategy
we should use same sizes pictures, here it is 256x256
i have inserted these lines to the Psychophanta code
this is Psychophanta code modified
clouds --> gradually wood
wood ---> after some seconds --> gradually clouds
clouds ---> after some seconds -->suddenly wood
wood ---> after some seconds -->suddenly clouds
suppose there is 2 textures, clouds and wood.
1- clouds begins to be transparent gradually and so faded away, so the wood will be on the front
2- now the wood begins to to be transparent gradually until it faded away,
now the clouds on the front
but from now the clouds and the wood appears suddenly without fading away gradually.
most likely there is a logical error in my strategy
we should use same sizes pictures, here it is 256x256
i have inserted these lines to the Psychophanta code
Code: Select all
Tex1 = MP_LoadTexture(#PB_Compiler_Home + "Examples\3D\Data\Textures\clouds.jpg")
Tex2 = MP_LoadTexture(#PB_Compiler_Home +"Examples\3D\Data\Textures\Wood.jpg")
Tex3 = MP_LoadTexture(#PB_Compiler_Home +"Examples\3D\Data\Textures\Wood.jpg")
Tex4 = MP_LoadTexture(#PB_Compiler_Home + "Examples\3D\Data\Textures\clouds.jpg")
;......
;......
While MP_KeyDown(#PB_Key_Escape)=0 And WindowEvent()<>#PB_Event_CloseWindow
trans.f + 0.2
If trans > 50: trans = 0: flag ! 1
EndIf
If flag = 0
MP_TextureOnTexture(Tex1, Tex2, 1, 1, trans , 0)
MP_EntitySetTexture (grid, Tex1)
Else
MP_TextureOnTexture(Tex3, Tex4, 1, 1, trans , 0)
MP_EntitySetTexture (grid, Tex3)
EndIf
clouds --> gradually wood
wood ---> after some seconds --> gradually clouds
clouds ---> after some seconds -->suddenly wood
wood ---> after some seconds -->suddenly clouds
Code: Select all
MP_Graphics3D(1280,720,0,3)
SetWindowTitle(0,"Moving Flag texture")
camera=MP_CreateCamera()
light=MP_CreateLight(1)
#vertices=64
#DPI=6.2831853071795864769;25286766559
grid=MP_CreatePlane(#vertices,#vertices)
If CreateImage(0,1024,1024)
Font=LoadFont(#PB_Any,"Arial",138*4)
StartDrawing(ImageOutput(0))
Box(0,0,512,512,RGB(255,0,0))
Box(512,0,512,512,RGB(0,255,0))
Box(0,512,512,512,RGB(0,0,255))
Box(512,512,512,512,RGB(255,255,0))
StopDrawing()
EndIf
Textur=MP_ImageToTexture(0,0,1,0)
Tex1 = MP_LoadTexture(#PB_Compiler_Home + "Examples\3D\Data\Textures\clouds.jpg")
Tex2 = MP_LoadTexture(#PB_Compiler_Home +"Examples\3D\Data\Textures\Wood.jpg")
Tex3 = MP_LoadTexture(#PB_Compiler_Home +"Examples\3D\Data\Textures\Wood.jpg")
Tex4 = MP_LoadTexture(#PB_Compiler_Home + "Examples\3D\Data\Textures\clouds.jpg")
MP_EntitySetTexture(grid,Tex1)
MP_ScaleEntity(grid,0.1,0.1,0.1)
i.d=0:freq.d=0.00002:ampl.d=2.2:longo.d=8.0
x.f=0:y.f=0:z.f=0
MP_PositionEntity(camera,0,0,-9)
addi.f=1
While MP_KeyDown(#PB_Key_Escape)=0 And WindowEvent()<>#PB_Event_CloseWindow
trans.f + 0.2
If trans > 50: trans = 0: flag ! 1
EndIf
If flag = 0
MP_TextureOnTexture(Tex1, Tex2, 1, 1, trans , 0)
MP_EntitySetTexture (grid, Tex1)
Else
MP_TextureOnTexture(Tex3, Tex4, 1, 1, trans , 0)
MP_EntitySetTexture (grid, Tex3)
EndIf
If MP_KeyDown(#PB_Key_Left)=1:x-0.1
ElseIf MP_KeyDown(#PB_Key_Right):x+0.1
ElseIf MP_KeyDown(#PB_Key_Down):y-0.1
ElseIf MP_KeyDown(#PB_Key_Up):y+0.1
ElseIf MP_KeyDown(#PB_Key_Z):z+0.1
ElseIf MP_KeyDown(#PB_Key_A):z-0.1
ElseIf MP_KeyDown(#PB_Key_Pad8):freq+0.0000001
ElseIf MP_KeyDown(#PB_Key_Pad2):freq-0.0000001
ElseIf MP_KeyDown(#PB_Key_Pad4):longo-0.025
ElseIf MP_KeyDown(#PB_Key_Pad6):longo+0.025
ElseIf MP_KeyDown(#PB_Key_Pad7):ampl-0.01
ElseIf MP_KeyDown(#PB_Key_Pad1):ampl+0.01
ElseIf MP_KeyHit(#PB_Key_Pause):While MP_KeyDown(#PB_Key_Pause):Delay(20):Wend:While MP_KeyDown(#PB_Key_Pause)=0:Delay(20):Wend
EndIf
MP_PositionEntity(grid,x,y,z)
;MP_TurnEntity(grid,0,0.2,0)
MP_RenderWorld()
MP_Flip()
count2.f+addi
If count2>254
addi=-1
ElseIf count2<2
addi=1
EndIf
MP_MaterialEmissiveColor(Textur,count2,255,255,255)
For gz.u=0 To #vertices
For gx.u=gz To gz+#vertices
MP_VertexSetz(grid,gx+gz*#vertices,ampl*Sin(i+gx/longo))
i+freq:If i>#DPI:i-#DPI:EndIf
Next gx
Next gz
Wend
- Psychophanta
- Always Here
- Posts: 5153
- Joined: Wed Jun 11, 2003 9:33 pm
- Location: Anare
- Contact:
Re: MP3D Engine Alpha 32
Yes, applePi got it, this is the effect i am looking for
But instead to copy the same textures in different memory places and having to modify textures in a loop, just changing the transparency or alpha channel in a texture in the loop.
Code: Select all
MP_Graphics3D(1280,720,0,3)
SetWindowTitle(0,"Moving Flag texture")
camera=MP_CreateCamera()
light=MP_CreateLight(1)
#vertices=64
#DPI=6.2831853071795864769;25286766559
grid=MP_CreatePlane(#vertices,#vertices)
Tex1=MP_LoadTexture(#PB_Compiler_Home +"Examples\3D\Data\Textures\clouds.jpg")
Tex2=MP_LoadTexture(#PB_Compiler_Home +"Examples\3D\Data\Textures\Wood.jpg")
Tex3=MP_CreateTexture(MP_TextureGetWidth(Tex2),MP_TextureGetHeight(Tex2)):MP_CopyTexture(Tex2,Tex3)
Tex4=MP_CreateTexture(MP_TextureGetWidth(Tex1),MP_TextureGetHeight(Tex1)):MP_CopyTexture(Tex1,Tex4)
MP_EntitySetTexture(grid,Tex1)
MP_ScaleEntity(grid,0.1,0.1,0.1)
i.d=0:freq.d=0.00002:ampl.d=2.2:longo.d=8.0
x.f=0:y.f=0:z.f=0
MP_PositionEntity(camera,0,0,-9)
addi.f=1
While MP_KeyDown(#PB_Key_Escape)=0 And WindowEvent()<>#PB_Event_CloseWindow
trans.f + 1
If trans>50:trans=0:flag.b!1:MP_CopyTexture(Tex4,Tex1):MP_CopyTexture(Tex2,Tex3):EndIf
If flag = 0
MP_TextureOnTexture(Tex1, Tex2,0,0, trans , 0)
MP_EntitySetTexture (grid, Tex1)
Else
MP_TextureOnTexture(Tex3, Tex4,0,0, trans , 0)
MP_EntitySetTexture (grid, Tex3)
EndIf
MP_TurnEntity(grid,0,0.2,0)
MP_RenderWorld()
MP_Flip()
For gz.u=0 To #vertices
For gx.u=gz To gz+#vertices
MP_VertexSetz(grid,gx+gz*#vertices,ampl*Sin(i+gx/longo))
i+freq:If i>#DPI:i-#DPI:EndIf
Next gx
Next gz
Wend
-
- Enthusiast
- Posts: 497
- Joined: Sat Oct 11, 2008 9:07 pm
- Location: Germany, Berlin > member German forum
Re: MP3D Engine Alpha 32
Hi to all,
i am working on a bigger update and hope my created libs works well. Please test them and told me the bugs...
1) The PB Installer is a new one version 0.54
2) You must inly install one MP3D_Lib and the Unicode AND Threadsafe function are integrated in one lib now !
3) I have rewriten the Procdedur.f function (need for the x64 lib) but there was a problem. If you use a GET command and the entity was wrong (=0) it crashes
Mesh = MP_Cube()
x.f = MP_VertexGetX(Mes, 1) ; Crashes, Mes = 0
Now i solved the problem
4) I have made new MP3D_Demofiles and tested them all.
5) The comand MP_GetMeshInfo(Entity, Typ) has new function and a new help file
6) The comand MP_GetMeshData and MP_SetMeshData has the same parameter like the PB Command. Now it is easier to change the Vertex in a *memory field
MP_BewegendeObjekte.pd demo file
7) The comand "MP_SpriteCollision" had a bug. i think it happens with PB 5.24. I had had a longe code line like
if NOT a >b OR c < d OR ..
without "(....)" and so the if condition get wrong. i solved the bug with:
if NOT (a >b OR c < d OR ..)
The comand MP_SpritePixelCollision had the same problem and was 5 times slower as before, see the "MP_SpriteCollision.pb" demo
I worked long on this update and if you find propblems i will solve them ...
Greeting Michael
My MP3D_Installer
http://www.flasharts.de/mpz/mp33_beta/M ... taller.exe
! INFO for manually installation only, for 5.40 LTS < 5.4x
Help File
http://www.flasharts.de/mpz/mp33_beta/H ... ibrary.chm
Demofiles
http://www.flasharts.de/mpz/mp33_beta/E ... _Demos.zip
32 Bit libs for PureBasic\PureLibraries\Windows\Libraries\
http://www.flasharts.de/mpz/mp33_beta/lib32/Lib32.zip
32 Bit MP3D_lib for PureBasic\SubSystems\dx9\purelibraries\userlibraries\
http://www.flasharts.de/mpz/mp33_beta/d ... ibrary.zip
64 Bit libs for PureBasic\PureLibraries\Windows\Libraries\
http://www.flasharts.de/mpz/mp33_beta/lib64/Lib64.zip
64 Bit MP3D_lib for PureBasic\SubSystems\dx9\purelibraries\userlibraries\
http://www.flasharts.de/mpz/mp33_beta/d ... ibrary.zip
i am working on a bigger update and hope my created libs works well. Please test them and told me the bugs...
1) The PB Installer is a new one version 0.54
2) You must inly install one MP3D_Lib and the Unicode AND Threadsafe function are integrated in one lib now !
3) I have rewriten the Procdedur.f function (need for the x64 lib) but there was a problem. If you use a GET command and the entity was wrong (=0) it crashes
Mesh = MP_Cube()
x.f = MP_VertexGetX(Mes, 1) ; Crashes, Mes = 0
Now i solved the problem
4) I have made new MP3D_Demofiles and tested them all.
5) The comand MP_GetMeshInfo(Entity, Typ) has new function and a new help file
6) The comand MP_GetMeshData and MP_SetMeshData has the same parameter like the PB Command. Now it is easier to change the Vertex in a *memory field
MP_BewegendeObjekte.pd demo file
Code: Select all
Memory = MP_GetMeshData(cube, #PB_Mesh_Vertex) ; Put Vertex Mesh Memory in a Memory fild
Laenge = MP_GetMeshInfo (cube, 64) ; Lenghts of Vertex
For n = 0 To MP_CountVertices(cube)-1
x.f = PeekF(memory + n*Laenge )
y.f = PeekF(memory + 4 + n*Laenge )
z.f = PeekF(memory + 8 + n*Laenge )
zufall.f = (Random (1000)-500)/100000
PokeF ((memory + n*Laenge ),x + zufall)
PokeF ((memory + 4 + n*Laenge ),y + zufall)
PokeF ((memory + 8 + n*Laenge ),z + zufall)
Next
typ = MP_GetMeshInfo (cube, 32) ; vertex Type
MP_SetMeshData(cube,typ,Memory,MP_CountVertices(cube))
FreeMemory(Memory)
if NOT a >b OR c < d OR ..
without "(....)" and so the if condition get wrong. i solved the bug with:
if NOT (a >b OR c < d OR ..)

I worked long on this update and if you find propblems i will solve them ...
Greeting Michael
My MP3D_Installer
http://www.flasharts.de/mpz/mp33_beta/M ... taller.exe
! INFO for manually installation only, for 5.40 LTS < 5.4x
Help File
http://www.flasharts.de/mpz/mp33_beta/H ... ibrary.chm
Demofiles
http://www.flasharts.de/mpz/mp33_beta/E ... _Demos.zip
32 Bit libs for PureBasic\PureLibraries\Windows\Libraries\
http://www.flasharts.de/mpz/mp33_beta/lib32/Lib32.zip
32 Bit MP3D_lib for PureBasic\SubSystems\dx9\purelibraries\userlibraries\
http://www.flasharts.de/mpz/mp33_beta/d ... ibrary.zip
64 Bit libs for PureBasic\PureLibraries\Windows\Libraries\
http://www.flasharts.de/mpz/mp33_beta/lib64/Lib64.zip
64 Bit MP3D_lib for PureBasic\SubSystems\dx9\purelibraries\userlibraries\
http://www.flasharts.de/mpz/mp33_beta/d ... ibrary.zip
Working on - MP3D Library - PB 5.73 version ready for download
Re: MP3D Engine Alpha 32
Hi Michael, the new version seems to me the best , i have tried it in windows xp x32 and it is very good, still testing.
if possible to request this feature:
in opengl there is this function:
gluCylinder_(qobj, baseRadius , topRadius, length, 8 , 8 ) ; 8,8: slices, stacks
as you can see we can make baseRadius <> topRadius
i see there is something like that in D3DXCreateCylinder look: https://msdn.microsoft.com/en-us/librar ... s.85).aspx
the usefullness is to be able to make a tree like the one ( here it is in opengl, with very ugly code for lighting, and still trying to texture it). so if there is a cylinder in mp3d with possibility to baseRadius <> topRadius will be great to make trees
note that in opengl the cylinder is going along Z so we have rotated it up by -90 to be able to apply the algorithm (line 131) .
if possible to request this feature:
in opengl there is this function:
gluCylinder_(qobj, baseRadius , topRadius, length, 8 , 8 ) ; 8,8: slices, stacks
as you can see we can make baseRadius <> topRadius
i see there is something like that in D3DXCreateCylinder look: https://msdn.microsoft.com/en-us/librar ... s.85).aspx
the usefullness is to be able to make a tree like the one ( here it is in opengl, with very ugly code for lighting, and still trying to texture it). so if there is a cylinder in mp3d with possibility to baseRadius <> topRadius will be great to make trees
note that in opengl the cylinder is going along Z so we have rotated it up by -90 to be able to apply the algorithm (line 131) .

Code: Select all
UseJPEGImageDecoder()
UsePNGImageDecoder()
Declare DrawBranch( startRadius.f, startlength.f, levels.l, openangle.f, twist.f)
Global cylinderList = 1
Global rota.f = 0
Global dist.f = 4
;Global qobj = glunewquadric
Global qobj = gluNewQuadric_();
gluQuadricDrawStyle_(qobj, #GL_FILL); /* smooth shaded */
gluQuadricNormals_(qobj, #GL_SMOOTH);
gluQuadricTexture_(qobj, #GL_TRUE )
glEnable_(#GL_NORMALIZE);
Define event, quit
InitKeyboard()
OpenWindow(0, 0, 0, 800, 600, "OpenGL demo .. 3D Tree .... change params in line 68 to get other tree, beware of changing 9 to more values")
SetWindowColor(0, RGB(200,220,200))
OpenGLGadget(0, 20, 10, WindowWidth(0)-40 , WindowHeight(0)-20, #PB_OpenGL_Keyboard )
Global Dim LightPos.f(4) ;Light Position
LightPos(0)= 0.0 : LightPos(1)= 5.0 : LightPos(2)=-4.0 : LightPos(3)= 1.0
Global Dim LightAmb.f(4) ;Ambient Light Values
LightAmb(0)= 0.2 : LightAmb(1)= 0.2 : LightAmb(2)= 0.2 : LightAmb(3)= 1.0
Global Dim LightDif.f(4) ;Diffuse Light Values
LightDif(0)= 0.6 : LightDif(1)= 0.6 : LightDif(2)= 0.6 : LightDif(3)= 1.0
Global Dim LightSpc.f(4) ;Specular Light Values
LightSpc(0)=-0.2 : LightSpc(1)=-0.2 : LightSpc(2)=-0.2 : LightSpc(3)= 1.0
Global Dim MatAmb.f(4) ;Material - Ambient Values
MatAmb(0)= 0.4 : MatAmb(1)= 0.4 : MatAmb(2)= 0.4 : MatAmb(3)= 1.0
Global Dim MatDif.f(4) ;Material - Diffuse Values
MatDif(0)= 1.2 : MatDif(1)= 0.6 : MatDif(2)= 0.0 : MatDif(3)= 1.0
Global Dim MatSpc.f(4) ;Material - Specular Values
MatSpc(0)= 0.0 : MatSpc(1)= 0.0 : MatSpc(2)= 0.0 : MatSpc(3)= 1.0
Global Dim MatShn.f(1) ;Material - Shininess
MatShn(0)= 0.0
glClearColor_ (0.0, 0.0, 0.0, 0.0);
glShadeModel_ (#GL_SMOOTH)
glEnable_(#GL_LIGHTING);
glEnable_(#GL_LIGHT0);
glEnable_(#GL_DEPTH_TEST);
glLightfv_(#GL_LIGHT1,#GL_POSITION,LightPos()) ;Set Light1 Position
glLightfv_(#GL_LIGHT1,#GL_AMBIENT,LightAmb()) ;Set Light1 Ambience
glLightfv_(#GL_LIGHT1,#GL_DIFFUSE,LightDif()) ;Set Light1 Diffuse
glLightfv_(#GL_LIGHT1,#GL_SPECULAR,LightSpc()) ;Set Light1 Specular
glEnable_(#GL_LIGHT1) ;Enable Light1
glEnable_(#GL_LIGHTING) ;Enable Lighting
glMaterialfv_(#GL_FRONT,#GL_AMBIENT,MatAmb()) ;Set Material Ambience
glMaterialfv_(#GL_FRONT,#GL_DIFFUSE,MatDif()) ;Set Material Diffuse
glMaterialfv_(#GL_FRONT,#GL_SPECULAR,MatSpc()) ;Set Material Specular
glMaterialfv_(#GL_FRONT,#GL_SHININESS,MatShn());Set Material Shininess
; beginning of code to make a list of sphere (cylinderList)
cylinderList = glGenLists_(1)
glNewList_(cylinderList, #GL_COMPILE_AND_EXECUTE)
;DrawBranch( startRadius.f, startlength.f, levels.l, openangle.f, twist.f)
DrawBranch(0.5, 2, 9, 30,30)
glEndList_()
SetActiveGadget(0)
Repeat
Event = WindowEvent()
If Event = #PB_Event_Gadget And EventGadget() = 0
If EventType() = #PB_EventType_KeyDown
key = GetGadgetAttribute(0,#PB_OpenGL_Key )
If key = #PB_Shortcut_Up
dist.f + 3
ElseIf key = #PB_Shortcut_Down ; Down arrow key
dist.f - 3
ElseIf key = #PB_Shortcut_Space ; to stop and begins rotation
running ! 1
ElseIf key = #PB_Shortcut_Escape ; Esc key to exit
quit = 1
EndIf
EndIf
EndIf
glEnable_(#GL_DEPTH_TEST)
glEnable_(#GL_BLEND);
;glDisable_(#GL_DEPTH_TEST)
glViewport_(0, 0, WindowWidth(0), WindowHeight(0))
glMatrixMode_(#GL_PROJECTION)
glLoadIdentity_()
gluPerspective_(60.0, Abs(WindowWidth(0) / WindowHeight(0)), 0.1, 2000.0)
glMatrixMode_(#GL_MODELVIEW)
glLoadIdentity_()
glClear_(#GL_COLOR_BUFFER_BIT | #GL_DEPTH_BUFFER_BIT)
glLoadIdentity_ ()
;viewing transformation
glTranslatef_(0.0, -6.0, dist);
gluLookAt_(0,10,-30, 0,0.0,0, 0,1,0); (eye, object, vector)
rota+1
glRotatef_(rota, 0.0, 1.0, 0.0)
;glBindTexture_(#GL_TEXTURE_2D, TexID)
glCallList_(cylinderList)
SetGadgetAttribute(0, #PB_OpenGL_FlipBuffers, #True)
Until Event = #PB_Event_CloseWindow Or quit = 1
Procedure DrawBranch( startRadius.f, startlength.f, levels.l, openangle.f, twist.f)
baseRadius.f = startRadius
topRadius.f = baseRadius - startRadius/levels
length.f = startlength
glPushMatrix_()
For i = 1 To levels
glPushMatrix_()
glRotatef_(-90,1,0,0)
gluCylinder_(qobj, baseRadius , topRadius, length, 8, 8) ; 8,8: slices, stacks
glPopMatrix_()
glTranslatef_(0, length, 0)
glRotatef_( openangle,0,0,1)
glRotatef_(twist,0,1,0)
glPushMatrix_();
glRotatef_(-openangle*2,0,0,1)
If i = 1
DrawBranch(topRadius, length, levels-1, -openangle, twist)
Else
DrawBranch(topRadius, length, levels-i, openangle, twist)
EndIf
glPopMatrix_()
baseRadius = topRadius
topRadius = baseRadius - startRadius/levels
length = length - startlength/levels
Next
glPopMatrix_()
EndProcedure
-
- Enthusiast
- Posts: 497
- Joined: Sat Oct 11, 2008 9:07 pm
- Location: Germany, Berlin > member German forum
Re: MP3D Engine Alpha 32
Hi applePi,
no problem. I have actualized the following lib for you for testing:
32 Bit MP3D_lib for PureBasic\SubSystems\dx9\purelibraries\userlibraries\
http://www.flasharts.de/mpz/mp33_beta/d ... ibrary.zip
the command MP_CreateCylinder has now two optional parameters
MP_CreateCylinder(Segmente,h.f[,Rad1,Rad2])
Greetings
Michael
Demoexample
no problem. I have actualized the following lib for you for testing:
32 Bit MP3D_lib for PureBasic\SubSystems\dx9\purelibraries\userlibraries\
http://www.flasharts.de/mpz/mp33_beta/d ... ibrary.zip
the command MP_CreateCylinder has now two optional parameters
MP_CreateCylinder(Segmente,h.f[,Rad1,Rad2])
Greetings
Michael
Demoexample
Code: Select all
MP_Graphics3D (640,480,0,3) ; Create a Window with 3D function #Window = 0
SetWindowTitle(0, "3D with two cylinders")
camera=MP_CreateCamera() ; camera on
light=MP_CreateLight(1) ; yes light
Mesh1=MP_CreateCylinder(10,3) ; my Cylinder normal
Mesh2=MP_CreateCylinder(10,3,1,2) ; my Cylinder with options
MP_PositionEntity (Mesh1,-3,0,8) ; Position mesh1
MP_PositionEntity (Mesh2,3,0,8) ; Position mesh2
While Not MP_KeyDown(#PB_Key_Escape) And Not WindowEvent() = #PB_Event_CloseWindow; Esc abfrage oder Windows Schliessen
MP_TurnEntity (Mesh1,2,1,1) ; go to moving
MP_TurnEntity (Mesh2,-2,-1,1) ; mee too
MP_RenderWorld() ; render the world
MP_Flip () ; show me the world
Wend
Working on - MP3D Library - PB 5.73 version ready for download