Page 27 of 71

Re: MP3D Engine Alpha 31

Posted: Fri May 31, 2013 7:00 pm
by AndyLy
This is not an emergency. Rest, then you will work on the engine with new forces. )
Happy holidays!

Re: MP3D Engine Alpha 31

Posted: Fri May 31, 2013 9:01 pm
by Psychophanta
Of course, we expect you take advantage of your holidays to improve the MP3D lib.

Re: MP3D Engine Alpha 31

Posted: Fri Jun 07, 2013 7:20 pm
by mpz
Hi,

@Alexi Do you use the correct pb version 5.11 ?!? I think it is an error mesage from an old pb version 4.11 or older.

I work on some bugfixes and have a new nice Physic command MP_ChangePhysikHull(Mesh, Typ) Now. If you change a mesh (vertex commands or size) the comamnd actualised the physic body for collisions. Next step are help file and make the new version

Demosample
http://www.flasharts.de/mpz/Physic.exe

Image


Greetings Michael

Re: MP3D Engine Alpha 31

Posted: Thu Jun 20, 2013 8:51 am
by deseven
Hello. I need some help :)

Code: Select all

If Not MP_Graphics3D(800,600,0,1) : End : EndIf

Player = MP_LoadSprite("player.png")
BgTile = MP_LoadSprite("grass.png")

Repeat
  MP_DrawTiledSprite(BgTile,0,0)
  MP_Box(0,0,415,315,$ffff00,1)
  MP_DrawSprite(Player,400,300)
  MP_SpriteSetZ(BgTile,1)
  MP_SpriteSetZ(Player,0)
  
  MP_RenderWorld()
  MP_Flip()
Until MP_KeyDown(#PB_Key_Escape) Or WindowEvent() = #PB_Event_CloseWindow
grass.png:
Image

player.png:
Image

1. Why the box is on top of all sprites?
2. What's wrong with alpha in player sprite?

Can someone explain how it works and what am i doing wrong?
Thanks in advance.

Re: MP3D Engine Alpha 31

Posted: Thu Jun 20, 2013 11:51 am
by leonhardt
deseven wrote:Hello. I need some help :)

Code: Select all

If Not MP_Graphics3D(800,600,0,1) : End : EndIf

Player = MP_LoadSprite("player.png")
BgTile = MP_LoadSprite("grass.png")

Repeat
  MP_DrawTiledSprite(BgTile,0,0)
  MP_Box(0,0,415,315,$ffff00,1)
  MP_DrawSprite(Player,400,300)
  MP_SpriteSetZ(BgTile,1)
  MP_SpriteSetZ(Player,0)
  
  MP_RenderWorld()
  MP_Flip()
Until MP_KeyDown(#PB_Key_Escape) Or WindowEvent() = #PB_Event_CloseWindow
grass.png:
Image

player.png:
Image

1. Why the box is on top of all sprites?
2. What's wrong with alpha in player sprite?

Can someone explain how it works and what am i doing wrong?
Thanks in advance.
Because SpriteSetZ shouldn't be used like this,it only changes the Z buffer depth,I have used HGE functions (for Delphi) to change Z buffer like this and get the same ugly(alpha value) result,so there is no bug with your code neither the MP3D engine,if changing the Z-order is your goal,you can check this code by MPZ

Code: Select all

;////////////////////////////////////////////////////////////////
;//
;// Project Title: MP 3D Engine Beispielprogramme
;// Dateiname: MP_SpriteOrder.pb
;// Erstellt am: 16.11.2011
;// Update am  : 
;// Author: Michael Paulwitz
;// 
;// Info: 
;// Order of Sprites
;// Darstellungsreihenfolge der Sprites
;//
;//
;////////////////////////////////////////////////////////////////

Global wX = 640
Global wY = 480

;- ***  Create Window
MP_Graphics3DWindow(0, 0, wX, wY, "Sprite oder: Change order of Sprite with Space", #PB_Window_ScreenCentered | #PB_Window_SystemMenu)

If CreateImage(0, 164, 164)
  MP_CreateImageColored(0, 0, #Yellow,#Yellow,#Red,#Red)
  StartDrawing(ImageOutput(0))
  DrawingMode(#PB_2DDrawing_Transparent)
  DrawText(40,0,"Hallo ich bin",$10101); ,$10101) means rgb(1,1,1) = black, but not transaprent
  DrawText(60,20,"Sprite 1",$10101)
  StopDrawing() 
EndIf

If CreateImage(1, 164, 164)
  MP_CreateImageColored(1, 0, #Red,#Red,#Blue,#Blue)     
  StartDrawing(ImageOutput(1))
  DrawingMode(#PB_2DDrawing_Transparent)
  DrawText(40,0,"Hallo ich bin",$10101)
  DrawText(60,20,"Sprite 2",$10101)
  StopDrawing() 
EndIf

If CreateImage(2, 164, 164)
  MP_CreateImageColored(2, 0, #Blue,#Blue,#Green,#Green)     
  StartDrawing(ImageOutput(2))
  DrawingMode(#PB_2DDrawing_Transparent)
  DrawText(40,0,"Hallo ich bin",$10101)
  DrawText(60,20,"Sprite 3",$10101)
  StopDrawing() 
EndIf

If CreateImage(3, 164, 164)
  MP_CreateImageColored(3, 0, #Green,#Green,#Yellow,#Yellow)     
  StartDrawing(ImageOutput(3))
  DrawingMode(#PB_2DDrawing_Transparent)
  DrawText(40,0,"Hallo ich bin",$10101)
  DrawText(60,20,"Sprite 4",$10101)
  StopDrawing() 
EndIf

Texture1 = MP_ImageToTexture(0)
Texture2 = MP_ImageToTexture(1)
Texture3 = MP_ImageToTexture(2)
Texture4 = MP_ImageToTexture(3)
FreeImage(0)
FreeImage(1)
FreeImage(2)
FreeImage(3)


; Display result of initialization order
Sprite1 = MP_SpriteFromTexture(Texture1)
Sprite2 = MP_SpriteFromTexture(Texture2)
Sprite3 = MP_SpriteFromTexture(Texture3)
Sprite4 = MP_SpriteFromTexture(Texture4)

MessageRequester("Info", "You have "+Str(MP_ListGetSize(9))+" Sprites")


Repeat
  Event = WindowEvent() 
  
  MP_DrawSprite(Sprite1, 25, 25)
  MP_DrawSprite(Sprite2, 65, 65)
  MP_DrawSprite(Sprite3, 105, 105)
  MP_DrawSprite(Sprite4, 145, 145)
  
  MP_DrawSprite(Sprite1, 225, 225)
  MP_DrawSprite(Sprite2, 265, 265)
  MP_DrawSprite(Sprite3, 305, 305)
  MP_DrawSprite(Sprite4, 345, 345)
  
  If MP_KeyDown( #PB_Key_Space)
    
    ;MP_ListGetElement(9,Random(3))

    
    
    MP_ListSwapElements(9,     MP_ListGetElement(9,Random(3)),MP_ListGetElement(9,Random(3)))
    ;MP_ListSwapElements(9, Sprite2, Sprite3)
    ;MP_ListSwapElements(9, Sprite3, Sprite4)
    ;MP_ListSwapElements(9, Sprite4, Sprite1)
  EndIf
  
  
  MP_RenderWorld() ; Render World yeh go on
  MP_Flip ()
  
  
Until MP_KeyDown(#PB_Key_Escape) Or Event=#PB_Event_CloseWindow
use the MP_ListSwapElements function instead :)

Re: MP3D Engine Alpha 31

Posted: Thu Jun 20, 2013 12:05 pm
by deseven
leonhardt wrote: use the MP_ListSwapElements function instead :)
Thank you, but it doesn't fix the transparency issue.

Code: Select all

If Not MP_Graphics3D(800,600,0,1) : End : EndIf

Player = MP_LoadSprite("player.png")
BgTile = MP_LoadSprite("grass.png")
MP_ListSwapElements(9,MP_ListGetElement(9,0),MP_ListGetElement(9,1))

Repeat
  MP_DrawTiledSprite(BgTile,0,0)
  MP_Box(0,0,415,315,$ffff00,1)
  MP_DrawSprite(Player,400,300)
  MP_RenderWorld()
  MP_Flip()
Until MP_KeyDown(#PB_Key_Escape) Or WindowEvent() = #PB_Event_CloseWindow
Still the same ugly player sprite.

UPD: It seems that I got the logic :)
The list is filled in order of the sprite loading. So, the easy way is to load sprites in the order of their appearance.
1. BgTile = MP_LoadSprite("grass.png")
2. Player = MP_LoadSprite("player.png")
But there is still some problem with alphachannel.
I got this
Image
instead of that
Image

Re: MP3D Engine Alpha 31

Posted: Thu Jun 20, 2013 1:58 pm
by Sveinung
If you change the color of the players body to somthing like (5,5,5), it will work.
Color (0,0,0) is the transperant color.

Regards
Sveinung

Re: MP3D Engine Alpha 31

Posted: Thu Jun 20, 2013 2:24 pm
by leonhardt
Sveinung wrote:If you change the color of the players body to somthing like (5,5,5), it will work.
Color (0,0,0) is the transperant color.

Regards
Sveinung
you mean this?
no,it doesn't work.

Code: Select all

If Not MP_Graphics3D(800,600,0,1) : End : EndIf
SetCurrentDirectory("c:\rad\projects")
BgTile = MP_LoadSprite("grass.png")
;MP_ListSwapElements(9,MP_ListGetElement(9,0),MP_ListGetElement(9,1))
Player = MP_LoadSprite("player.png")
MP_TransparentSpriteColor(Player,RGB(5,5,5))

;MP_AmbientSetLight($FF2233)
Repeat
  
  MP_DrawTiledSprite(BgTile,0,0)
  MP_Box(0,0,300,300,$FFFF00,1)
  MP_DrawSprite(Player,400,300)
  MP_RenderWorld()
  MP_Flip()
Until MP_KeyDown(#PB_Key_Escape) Or WindowEvent() = #PB_Event_CloseWindow

Re: MP3D Engine Alpha 31

Posted: Thu Jun 20, 2013 2:40 pm
by mpz
Hello to all,

thanks for you help...

@deseven

1. Why the box is on top of all sprites?
The render order is: Sprite and then 2D. To change this you can exchange the MP_RenderWorld() function (2D has no Z-Order) with the following Render commands

Code: Select all

  ; MP_RenderWorld()     

  MP_RenderBegin()
      ; Draw 2D first
      MP_Render2D()
      ; Draw your sprite last and over text
      MP_RenderSprite() 
   MP_RenderEnd()
2. What's wrong with alpha in player sprite?
* Ist not a alpha image, it is only a rgb image. The problem, is i use DX9 sprite and in DX9 sprite the black color rgb(0,0,0) is all times transparent. Perhaps i find a solution but for now i have change the black rgb(0,0,0) to rgb(1,1,1) and it works. Test the following image please...

Image

Greetings

Re: MP3D Engine Alpha 31

Posted: Thu Jun 20, 2013 8:24 pm
by deseven
mpz wrote: 2. What's wrong with alpha in player sprite?
* Ist not a alpha image, it is only a rgb image. The problem, is i use DX9 sprite and in DX9 sprite the black color rgb(0,0,0) is all times transparent. Perhaps i find a solution but for now i have change the black rgb(0,0,0) to rgb(1,1,1) and it works. Test the following image please...
Thank you!
But it's actually a RGBA image which have a usuall RGB + additional alpha-channel. Is there a way to load and display theese correctly?
Another small question - how can i hide the mouse cursor?

And... Maybe someone can advice me how to make flashlight effect on top of sprites? I tried to use a big sprite with alpha and rotation, but probably this isn't the best solution...
http://dl.dropboxusercontent.com/u/9439 ... -28-25.jpg

Re: MP3D Engine Alpha 31

Posted: Thu Jun 20, 2013 10:30 pm
by mpz
Hi dseven,

if you use the color rgb(1,1,1) for the black color the sprite do what you want.

- how can i hide the mouse cursor?

Have a look on the MP_UseCursor(a) command

- big sprite with alpha and rotation, but probably this isn't the best solution..

Why not? Other solution is to create a shader (Postprocessing).The shader make the light or darknes from the sprite as circle


Greetings Michael

Re: MP3D Engine Alpha 31

Posted: Fri Jun 21, 2013 10:04 am
by deseven
mpz wrote: - big sprite with alpha and rotation, but probably this isn't the best solution..
Why not? Other solution is to create a shader (Postprocessing).The shader make the light or darknes from the sprite as circle
Thanks.
I made it by using another technique (found it in google :) ):
- draw a shadow mask (1x1 white sprite with 80-95% transparency, scaled to the whole screen)
- draw any lights as a semi-transparent white sprites
- draw a background with MP_SpriteBlendingMode(sprite,1,3)
http://dl.dropbox.com/u/943974/td_proto ... -55-74.png

But with this approach i don't know how to draw objects which have their own transparency... Any ideas?

And another small question - how can i set filtering level? Do i need to use MP_SetSamplerState?

Re: MP3D Engine Alpha 31

Posted: Fri Jun 21, 2013 10:12 am
by leonhardt
mpz wrote:Hello to all,

thanks for you help...

@deseven

1. Why the box is on top of all sprites?
The render order is: Sprite and then 2D. To change this you can exchange the MP_RenderWorld() function (2D has no Z-Order) with the following Render commands

Code: Select all

  ; MP_RenderWorld()     

  MP_RenderBegin()
      ; Draw 2D first
      MP_Render2D()
      ; Draw your sprite last and over text
      MP_RenderSprite() 
   MP_RenderEnd()
2. What's wrong with alpha in player sprite?
* Ist not a alpha image, it is only a rgb image. The problem, is i use DX9 sprite and in DX9 sprite the black color rgb(0,0,0) is all times transparent. Perhaps i find a solution but for now i have change the black rgb(0,0,0) to rgb(1,1,1) and it works. Test the following image please...

Image

Greetings
but the normal pb sprite3d lib could handle this png file correctly,it use DX9 too, check this code:

Code: Select all

InitSprite()
InitSprite3D()
UsePNGImageDecoder()

OpenWindow(0,0,0,800,600,"",$CF1001)
OpenWindowedScreen(WindowID(0),0,0,800,600)
CreateSprite3D(0,LoadSprite(-1,"player.png",#PB_Sprite_Texture|#PB_Sprite_AlphaBlending))
Repeat
  ClearScreen($FFFFFF)
  Start3D()
    DisplaySprite3D(0,200,200)
  Stop3D()
  FlipBuffers()
Until WindowEvent()=16


Re: MP3D Engine Alpha 31

Posted: Fri Jun 21, 2013 10:22 am
by deseven
leonhardt wrote: but the normal pb sprite3d lib could handle this png file correctly,it use DX9 too, check this code:
That's true...
But whatever, it's not hard to use $010101 instead of $000000

P.S. Better flashlight sprite :) http://dl.dropboxusercontent.com/u/9439 ... oto_sh.png

Re: MP3D Engine Alpha 31

Posted: Fri Jun 21, 2013 4:31 pm
by dobro
@mpz Excellent Work ! :shock: