Page 13 of 71

Re: MP3D Engine Alpha 31

Posted: Sun Sep 09, 2012 2:10 pm
by mpz
Hi applePi,

if i use your code, the mesh is moving faster as the camera. If i change the code (0.76 for mesh and camera) everything works fine.

Your code with the different floats (0.32 an 0.76) works fine on your pc?!?
Can you make an exe file please i can test this here again

Greetings Michael

The following chnageing works fine.

Code: Select all

     If MP_KeyDown(#PB_Key_Right)
       rotX+3 
       angle.f - 0.76 ; ---- Angle of 
       xDelta.f = Cos(Radian(angle)) * 10 :  zDelta.f = Sin(Radian(angle)) * 10
       rotX-3 ;sphere rotation
       MP_TurnCamera(camera, 0.76,0,0)
     ElseIf MP_KeyDown(#PB_Key_Left)
       angle.f + 0.76
       xDelta.f = Cos(Radian(angle)) * 10 :  zDelta.f = Sin(Radian(angle)) * 10
       rotX-3 ;sphere rotation
       MP_TurnCamera(camera, -0.76,0,0)
     EndIf

Re: MP3D Engine Alpha 31

Posted: Sun Sep 09, 2012 4:11 pm
by AndyLy
Hi!
Prompt how make a window without a border in MP_Graphics3D ()?
And how make the shading ( fading ) screen?

Re: MP3D Engine Alpha 31

Posted: Sun Sep 09, 2012 7:48 pm
by mpz
Hi Andyly,

very easy, it is like the pb windows funktion:

boderless windows

Code: Select all

MP_Graphics3DWindow (0,0,640,480,"Test",#PB_Window_BorderLess) ; Erstelle ein WindowsFenster mit 3D Funktion #Window = 0
windows with size Gadget

Code: Select all

MP_Graphics3DWindow (0,0,640,480,"Test",#PB_Window_SizeGadget) ; Erstelle ein WindowsFenster mit 3D Funktion #Window = 0

camera=MP_CreateCamera() ; Kamera erstellen

light=MP_CreateLight(1) ; Es werde Licht

Mesh=MP_CreateCube() ; Und jetzt eine Würfel
 
MP_PositionEntity (Mesh,0,0,3) ; Position des Würfels

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() ; Erstelle die Welt
    MP_Flip () ; Stelle Sie dar
    
Wend
Greetings Michael

Re: MP3D Engine Alpha 31

Posted: Sun Sep 09, 2012 9:11 pm
by applePi
Hi Michael
i think it is a hardware efficiency problem, because i have tried it on another poor card Radeon 5450 and even most your MP3D examples run smoothly but this program are too slow and even the sphere does not turn at all and its deformation are too slow and it stick over the terrain and only the camera rotate, so the way we produce the sphere deformation needs a more powerfull card.
i have uninstalled that card and returnd to my original card geforce 210 wich are even poor card but much more powerfull than Radeon 5450.
in my previous post i have'nt said that i was running while Debug mode are On, this is my fault, mesh 76 camera 32 in the debug mode show equal rotation, but when debug mode are off here is the results:
mesh 76 camera 32 - rotation of mesh are speedier than camera (like in your computer)
mesh 76 camera 76 - rotation of mesh are slower than camera

attached the exe of the 76-76 case which should work with equal rotation on your computer, but not with me.
http://www.mediafire.com/?wrhqn5fk0zd6eiw
regards

PS: if i commented line 92 MP_EntitySetNormals(sp) then
mesh 76 camera 76 - rotation of mesh are speedier than camera , so MP_EntitySetNormals(sp) consume much power.

Re: MP3D Engine Alpha 31

Posted: Sun Sep 09, 2012 10:38 pm
by AndyLy
MP_Graphics3DWindow
I'm blind! Where do I look? Thank you.

What about shading the screen? I tried the black sprite with a screen size and change the transparency, but there was a bug with rendering.

Re: MP3D Engine Alpha 31

Posted: Mon Sep 10, 2012 12:07 am
by mpz
Hi ApplePi,

the MP_EntitySetNormals comamnd is the dx9 command "D3DXComputeNormals (Mesh()\Mesh,0)", i cant make it faster. The mesh has 3000 vertices and this need time...

first solution: in normal case you use a shader for that, the shader is fast enough and you don't need the MP_EntitySetNormals anymore
second solution: you use the MP_SaveMode(1) fats speed mode, it speed up very fast...


Hi AndyLy,

you mean a transparency windows ?!? Please make a little examle an i will have a look on it...

Greeitings Michael

Re: MP3D Engine Alpha 31

Posted: Mon Sep 10, 2012 1:36 pm
by AndyLy
you mean a transparency windows ?
No. I try do this:

Code: Select all

InitSprite(): InitSprite3D(): InitKeyboard()
OpenScreen(1024,768,32,"Fade")
CreateSprite(1,1024,768,4): CreateSprite3D(1,1): TransparentSpriteColor(1,#White)
fade=250: fadedlt=2
Repeat
fade-fadedlt: If fade<2 Or fade>253: fadedlt* -1: EndIf
ClearScreen(#Blue)
Start3D(): DisplaySprite3D(1,0,0,fade): Stop3D()
FlipBuffers()
ExamineKeyboard(): If KeyboardPushed(#PB_Key_Escape): Quite=1: EndIf
Until quite=1

Re: MP3D Engine Alpha 31

Posted: Mon Sep 10, 2012 3:48 pm
by mpz
Hi AndyLy,

here the code in mp3d:

Greetings Michael

Code: Select all

MP_Graphics3D (1024,768,0,0)
Texture = MP_CreateTextureColor(1024, 768, MP_ARGB(255,1,1,1))
Sprite= MP_SpriteFromTexture(Texture)
MP_AmbientSetLight (#Blue)
fade=250: fadedlt=2
While Not MP_KeyDown(#PB_Key_Escape) And Not WindowEvent() = #PB_Event_CloseWindow

    fade-fadedlt: If fade<2 Or fade>253: fadedlt* -1: EndIf
    MP_DrawSprite(Sprite, 0, 0,fade)
    MP_RenderWorld() ; Erstelle die Welt
    MP_Flip () ; Stelle Sie dar

Wend

Re: MP3D Engine Alpha 31

Posted: Mon Sep 10, 2012 4:29 pm
by AndyLy
Of course I did so. Now try this code:

Code: Select all

MP_Graphics3D (1024,768,0,0)
Texture = MP_CreateTextureColor(1024, 768, MP_ARGB(255,1,1,1))
Sprite= MP_SpriteFromTexture(Texture)

Texture2 = MP_CreateTextureColor(400,300, MP_ARGB(255,150,150,1))
Sprite2= MP_SpriteFromTexture(Texture2):; MP_SpriteSetZ(Sprite2,1)

MP_AmbientSetLight (#Blue)
fade=250: fadedlt=2
While Not MP_KeyDown(#PB_Key_Escape) And Not WindowEvent() = #PB_Event_CloseWindow

    fade-fadedlt: If fade<2 Or fade>253: fadedlt* -1: EndIf
    MP_DrawSprite(Sprite2, 100, 100)
    MP_DrawSprite(Sprite, 0, 0,fade)
    MP_RenderWorld() ; Erstelle die Welt
    MP_Flip () ; Stelle Sie dar

Wend

Re: MP3D Engine Alpha 31

Posted: Tue Sep 11, 2012 9:13 am
by mpz
Hi AndyLy,

the question is, what do you want as solution?!?

I think you want that the yellow sprite will be white while sprite and sprite2 will add?

for these kind of additions you have the MP_SpriteBlendingMode. Here comes an example for testing with these codes:

best regard Michael

Code: Select all

;Konstante vor Sprite3DBlendingMode

#D3DBLEND_ZERO            = 1
#D3DBLEND_ONE             = 2
#D3DBLEND_SRCCOLOR        = 3
#D3DBLEND_INVSRCCOLOR     = 4
#D3DBLEND_SRCALPHA        = 5
#D3DBLEND_INVSRCALPHA     = 6
#D3DBLEND_DESTALPHA       = 7
#D3DBLEND_INVDESTALPHA    = 8
#D3DBLEND_DESTCOLOR       = 9
#D3DBLEND_INVDESTCOLOR    = 10
#D3DBLEND_SRCALPHASAT     = 11
#D3DBLEND_BOTHSRCALPHA    = 12
#D3DBLEND_BOTHINVSRCALPHA = 13


MP_Graphics3D (1024,768,0,0)
Texture = MP_CreateTextureColor(1024, 768, MP_ARGB(255,1,1,1))
Sprite= MP_SpriteFromTexture(Texture)

Texture2 = MP_CreateTextureColor(400,300, MP_ARGB(255,150,150,1))
Sprite2= MP_SpriteFromTexture(Texture2):; MP_SpriteSetZ(Sprite2,1)

MP_AmbientSetLight (#Blue)
fade=250: fadedlt=2

a = #D3DBLEND_SRCALPHA
b = #D3DBLEND_SRCALPHA

While Not MP_KeyDown(#PB_Key_Escape) And Not WindowEvent() = #PB_Event_CloseWindow
  
      If MP_KeyHit(#PB_Key_1)
        a + 1
        If a > 13 
          a = 1
        EndIf  
      EndIf
      
      If MP_KeyHit(#PB_Key_2)
        b + 1
        If b > 13 
          b = 1
        EndIf  
      EndIf
      
    MP_SpriteBlendingMode(Sprite, a, b)
    MP_SpriteBlendingMode(Sprite2, a, b)
  
    fade-fadedlt: If fade<2 Or fade>253: fadedlt* -1: EndIf
    MP_DrawSprite(Sprite2, 100, 100)
    MP_DrawSprite(Sprite, 0, 0,fade)
    
   MP_DrawText(1,1,"Sprite3DBlendingMode, Source = "+Str(a)+ " Destination = "+Str(b))
    
    MP_RenderWorld() ; Erstelle die Welt
    MP_Flip () ; Stelle Sie dar
    
Wend

Re: MP3D Engine Alpha 31

Posted: Tue Sep 11, 2012 11:18 am
by AndyLy
Hi Michael.
All right. Another attempt. )
I need this (see below), but for windowed mode and using MP3D.

Code: Select all

InitSprite(): InitKeyboard(): OpenScreen(1024,768,32,"fade")
gamma=254: gammadlt=-1
Repeat: ClearScreen(#Gray)
StartDrawing(ScreenOutput())
   For i=1 To 10: Box(Random(1000),Random(700),Random(100),Random(100),RGB(Random(250),Random(250),Random(250))): Next
StopDrawing()
gamma+gammadlt: If gamma<1 Or gamma>254: gammadlt* -1: EndIf
ChangeGamma(gamma,gamma,gamma)
ExamineKeyboard(): If KeyboardPushed(#PB_Key_Escape): Quite=1: EndIf
FlipBuffers(): Until Quite=1: End

Re: MP3D Engine Alpha 31

Posted: Tue Sep 11, 2012 4:14 pm
by mpz
Hi AndyLy,

there are different ways to make a windows version with mp3d from them. Here the image function from pb and the sprite funtion for fading...

greetings Michael

Code: Select all

MP_Graphics3D (1024,768,0,1)
Texture = MP_CreateTextureColor(1024, 768, MP_ARGB(255,1,1,1))
Sprite= MP_SpriteFromTexture(Texture)

Texture2 = MP_CreateTextureColor(400,300, MP_ARGB(255,150,150,1))
Sprite2= MP_SpriteFromTexture(Texture2):; MP_SpriteSetZ(Sprite2,1)

MP_AmbientSetLight (#Blue)
fade=250: fadedlt=2

#Image = 0
CreateImage(#Image, 1024,768,32)

While Not MP_KeyDown(#PB_Key_Escape) And Not WindowEvent() = #PB_Event_CloseWindow
  
  StartDrawing(ImageOutput(#Image))
   For i=1 To 10: Box(Random(1000),Random(700),Random(100),Random(100),RGB(Random(250),Random(250),Random(250))): Next
  StopDrawing()
  
  ; Clear the surface
  MP_FreeSurface(Surface)
  
  ; make a surface from image
  Surface = MP_ImageToSurface(0) 
  MP_SurfaceSetPosition(Surface,0,0,1)
  
  ; Empty the Image
  StartDrawing(ImageOutput(#Image))
    Box(0,0,1024,768,0)
  StopDrawing()
  
 
    fade-fadedlt: If fade<2 Or fade>253: fadedlt* -1: EndIf
    MP_DrawSprite(Sprite, 0, 0,fade)
   
    MP_RenderWorld() ; Erstelle die Welt
    MP_Flip () ; Stelle Sie dar
   
Wend;Konstante vor Sprite3DBlendingMode

Re: MP3D Engine Alpha 31

Posted: Tue Sep 11, 2012 5:13 pm
by applePi
Hi Michael
just some wishes for the future MP3D versions
1- MP_SetPixel3D(x,y,z,color) to put a pixell in a 3D space
2- shadow with color such as MP_InitShadow(1, color,intensity)
3- solving the shadow problem in wich when the light are at low height then there is an additional shadow at the edges of the plane
in the attached code here the sphere just denote where the light is.
when we put the light higher the erroneous shadows at the edges will be shifted more far from center. in the following code press Z key to shift light higher and the edges shadows will be out of sight and thats good, press X key to shift light lower but the edges shadows will appear again.

Code: Select all

Global xres=640, yres=480
MP_Graphics3D (xres,yres,0,3)
SetWindowTitle(0, "shadow, press Z, X keys to shift light higher or lower")
;MP_Wireframe(1)
camera=MP_CreateCamera()

light=MP_CreateLight(2)
MP_LightSetColor (light, RGB(255,255,255))
MP_InitShadow()
Width=256
Height=256

texture2 = MP_CreateTextureColor(256, 256, RGBA(0, 255, 255, 0))
texture = MP_CreateTextureColor(256, 256, RGBA(0, 0, 255, 255))
sphere = MP_CreateSphere(30)
MP_EntitySetColor(sphere,RGB(0,255,0))
MP_EntitySetTexture(sphere, texture2)
MP_ScaleMesh(sphere,0.3,0.3,0.3)
cone = MP_CreateCone(64, 10)
MP_EntitySetTexture(cone, texture2)
MP_PositionEntity(cone, 0, 2, 0)
MP_ScaleMesh(cone, 0.5, 0.5, 0.5)
MP_RotateEntity(cone, 0, 90, 0)

plane = MP_CreatePlane(10, 10)
MP_EntitySetTexture(plane, texture)
MP_RotateEntity(plane, 0, 90, 90)

MP_PositionCamera(camera, 10, 5, 6)
MP_CameraLookAt(camera,0,0,0)

MP_PositionEntity(light, 0, 10, 20)
MP_EntityLookAt(light,0,0,0)

x.f : y.f = 2.5 :z.f
While Not MP_KeyDown(#PB_Key_Escape) And Not WindowEvent() = #PB_Event_CloseWindow
  
  If MP_KeyDown(#PB_Key_Z) 
    y + 0.05
  ElseIf MP_KeyDown(#PB_Key_X) 
    y - 0.05
  EndIf 
  count.f + 1
  
  x = Cos(Radian(count)) * 3: z = Sin(Radian(count)) * 3
   
  MP_PositionEntity(light, x , y, z)
  MP_PositionEntity(sphere, x , y, z)
  
  MP_EntityLookAt(light,0,0,0)
  MP_RenderWorld()
   
  MP_Flip ()

Wend
 
  

Re: MP3D Engine Alpha 31

Posted: Tue Sep 11, 2012 11:14 pm
by mpz
Hi AplePi,

nice test programm. I have a look on it an will make my "shadow" better...

Greetings Michael

Re: MP3D Engine Alpha 31

Posted: Wed Sep 12, 2012 11:34 am
by AndyLy
Michael, thank you for trying to help.