Page 12 of 71

Re: MP3D Engine Alpha 31

Posted: Mon Aug 27, 2012 1:52 pm
by mpz
Hello,

thanks on applePi and Sveinung for your good help. AndyLy, you star system look great, i hope you can give me the code to have a nice mp3d demo...

The problem with the Alpha blending is a dx9 problem with the distance of the meshs to the camera. for these problem i have made the "MP_MeshAlphaSort()" comand to solve these. Use these command before the MP_RenderWorld() comes

...
MP_MeshAlphaSort()
MP_RenderWorld()
...

Have a look on the "MP_AlphaTranzparenz.pb" demo in the Alpha folder and you see what i mean...

Greetings Michael

Re: MP3D Engine Alpha 31

Posted: Mon Aug 27, 2012 2:09 pm
by AndyLy
Hi mpz
MP_MeshAlphaSort () seems to work, now I will correct the program. Thank you for your help.
MP_AlphaTranzparenz.pb - have already looked at it and figured out.
What about the code: its not finished, I plan to make an animated initial screen for my new game, if it works, then I will not give you the full code, only partial. OK?

Re: MP3D Engine Alpha 31

Posted: Mon Aug 27, 2012 2:40 pm
by mpz
Hi AndyLy,

only a little code as demo (For example I mean the code for your Solorsys.exe). It is nice to have more demos for the mp3d engine...

Greetings Michael

Re: MP3D Engine Alpha 31

Posted: Mon Aug 27, 2012 11:23 pm
by AndyLy
mpz
Good work, but I probably will for a long time to understand.
Can you add to the particle system, the ability to use your own sprites? It's much would increase the possibility and usefulness of the system of particles.

And: I drew a sprite in the front layer, and although it is transparent, it is completely blocked particles.
Maybe there is some secret technique?

Re: MP3D Engine Alpha 31

Posted: Mon Aug 27, 2012 11:40 pm
by mpz
Hi Andyly,

for now the particle system use point sprites. you can use you own texture (like sprites) and anim texture too.

If you use sprites they are in front of the screen. If you use the MP_SpriteSetZ command you can set it in the deep of the screen (behind or in front of the particle emmiter)

P.S: I hope you mean this with you question ?!?

Greetings Michael

Re: MP3D Engine Alpha 31

Posted: Tue Aug 28, 2012 12:35 am
by AndyLy
I wanted to add semitransparent fog in the foreground. Planets visible normally, under the fog, but the particles cover fully.
Image

Re: MP3D Engine Alpha 31

Posted: Tue Aug 28, 2012 2:51 pm
by mpz
Hi,

how do you use the fog? is it a sprite ? if you use a sprite the MP_SpriteBlendingMode function could help, please see
MP_Sprite3DBlendmodus.pb and MP_Sprite3DBlendmodus_2.pb

Greetings Michael

Re: MP3D Engine Alpha 31

Posted: Wed Aug 29, 2012 5:05 am
by AndyLy
Thanks Michael, that tried to help.
Yes, I tried MP_SpriteBlendingMode, but nothing happened. So I dropped this idea.

Re: MP3D Engine Alpha 31

Posted: Wed Aug 29, 2012 9:47 am
by mpz
Hi Andyly,

if you send me the code and grafic file i can have a look on it. It can only be a litte propblem...


Greetings MichAel

Re: MP3D Engine Alpha 31

Posted: Wed Aug 29, 2012 12:24 pm
by AndyLy
Hi.
Actually, there's more than one problem, I do not write here, because it may be my mistake in the code.
I will gather all the necessary later, write a description and send it to you.
While lay out what has been accomplished. That's not what I wanted, but close.

https://rapidshare.com/files/1736129685/Solarsys.rar

Re: MP3D Engine Alpha 31

Posted: Thu Aug 30, 2012 3:16 pm
by mpz
Hi Andyly,

i have solved the "semitransparent fog in the foreground" problem. It was a problem between the particle and sprite render sequence.

I will check the other questions you send me and i will anwer with pm.

Greetings Michael

Re: MP3D Engine Alpha 31

Posted: Sat Sep 01, 2012 5:05 pm
by AndyLy
Hi mpz,
i will anwer with pm
Okay, I'll wait.

There is a chance to do so: write a program to "normal" PureBasic and make inclusion on MP3D?
For example:

Code: Select all

.........
Gosub MP3DBlock
.........

MP3DBlock:
StartMP3D ()
.....................
StopMP3D ()
Return
Greetings Andy

Re: MP3D Engine Alpha 31

Posted: Wed Sep 05, 2012 12:58 pm
by mpz
Hello AndyLy,

i post you a pm with the solution of your problems...

I thought about the Start/Stop funktion and created a new function. In the mp3d Forum you find a demo of this new function...

MP_Close() ; closed the mp3d Engine and deleted all resources

Greetings Michael

Re: MP3D Engine Alpha 31

Posted: Wed Sep 05, 2012 1:47 pm
by AndyLy
Hi Michael,
Added your forum to bookmarks. I tried the demo with MP_Close (). Take a closer look later.
As usual, good job.

Driving the sphere over the terrain

Posted: Fri Sep 07, 2012 7:42 pm
by applePi
the following code put the sphere from Sveinung code in the previous page to be used inside the example MP_Terrain.pb by Michael in MP3D Demos\Mesh folder. as a kind of a ufo or organic space entity to fly over the terrain at altitude of 500 over the terrain . I'm still searching for a suitable big terrain.
i have used another formula for deforming the sphere and a texture.
and it moves with keys, the right/Left keys makes the camera to turn around, my difficult task was to keep the sphere in front of the camera as if it is my car. the camera position begins from x=-714 z=-4308 so the angle from 0,0 to the camera will be 99.4, i want the sphere to be 10 units from the camera, so calculating the new coordinates of the sphere to be in front of the camera. look the picture
Image
but i wonder when using MP_TurnCamera(camera, -0.32,0,0) for Left camera turning, i must use for the sphere an increment 0.76. ie a ratio 2.375 so the sphere will follow the camera exactly with a very small unbalance.
i can't see what is the reason, i was expecting to use 0.32 for both the camera turn and the sphere move. it may be a very simple geometry/algebra issue.
* the formula and the texture used are from 3Impact example.
to run the code save the program in the MP3D Demos\Mesh folder and also save this texture to the same folder for the sphere texture.
Image

Code: Select all

;original codes by Michael and Sveinung
MP_Graphics3D (640,480,0,1) ; Erstelle ein WindowsFenster #Window = 0
SetWindowTitle(0, "My first Terrain example, to Move use arrow keys up/down  ,to Turn  use arrow keys right/left") 
Global amplitude.f = 0.10
Global frequency.f = 4.0
Global sp=mp_createsphere(40)
Global sp_o
camera=MP_CreateCamera() ; Kamera erstellen

MP_CameraSetRange(Camera, 0.1, 5000) 

light=MP_CreateLight(2) 
MP_LightSetColor (light, RGB(255,255,255))
MP_PositionEntity(light, 0,200,-5029)

MP_CreateSkyBox ("rhills","jpg",100)

Terrain = MP_LoadTerrain ("rhills_hmap.bmp", 64,64) 
Texture = MP_LoadTexture("rhills_tmap.jpg") 

MP_EntitySetTexture (Terrain,texture)
MP_EntitySetName(Terrain, "Terrain")

sp_o=MP_CopyEntity(sp)
MP_HideEntity(sp_o,1)
texture =  MP_LoadTexture("marble.jpg")
MP_EntitySetTexture(sp, texture)
;MP_MaterialSpecularColor(texture,0,255,255,255,1)
MP_MaterialEmissiveColor (texture,0,255,255,255)
MP_MaterialAmbientColor (texture, 255, 128 , 255, 128) ; 
MP_MaterialSpecularColor (texture, 255, 128 ,255, 128,40) ; 

MP_VSync(1)
MP_Wireframe(0)
Global countvertices.l = mp_countvertices(sp)-1
Procedure ufo()
  ;warping a sphere
  dtime.f=ElapsedMilliseconds()/800
  offset.f
  For i=0 To countvertices
    ;--------------------------------
    vx.f=MP_VertexGetX(sp_o,i)
    vy.f=MP_VertexGetY(sp_o,i)
    vz.f=MP_VertexGetZ(sp_o,i)
    ;--------------------------------
    offset = amplitude * Sin((dtime+MP_VertexGetX(sp_o,i))*frequency)
    vx + offset
    vy + offset
    vz + offset
    MP_VertexSetX(sp,i,vx)
    MP_VertexSetY(sp,i,vy)
    MP_VertexSetZ(sp,i,vz)
  Next
  
   EndProcedure
MP_PositionCamera(camera,-714,500,-4308)
;the beginning angle, press J to know the camera position at any time
angle.f = Degree(ATan(714/4308)+Radian(90)) ; 99.41 degrees
;Debug(StrF(angle))
;the sphere is 10 units away from the camera
;the sphere position differences in x, z coordinates from the camera x, z
xDelta.f = Cos(Radian(angle)) * 10 :  zDelta.f = Sin(Radian(angle)) * 10   
While Not MP_KeyDown(#PB_Key_Escape) And Not WindowEvent() = #PB_Event_CloseWindow; Esc abfrage oder Windows Schliessen

  ufo() ; call the warped sphere
  
  ;Driving the sphere
  If MP_KeyDown(#PB_Key_Up)
      rotY+3 ;sphere rotation
      MP_MoveCamera(camera,0,0,15)
     ElseIf MP_KeyDown(#PB_Key_Down)
       rotY-3 ;sphere rotation
       MP_MoveCamera(camera,0,0,-15)
          
     EndIf 
     
     If MP_KeyDown(#PB_Key_Right)
       rotX+3 
       angle.f - 0.76
       xDelta.f = Cos(Radian(angle)) * 10 :  zDelta.f = Sin(Radian(angle)) * 10
       rotX-3 ;sphere rotation
       MP_TurnCamera(camera, 0.32,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.32,0,0)
       
     EndIf
   
   MP_RotateEntity(sp, rotX, rotY, 0 ) ;sphere rotation
   MP_EntitySetNormals(sp)
  
  ;;pppppppppppppppppppppppppppppppppppppppppppppppppppppp
        
    x.f = MP_CameraGetX (camera)
    z.f = MP_CameraGetZ (camera)
    
    yyyy.f = MP_TerrainGetY (Terrain,x,0,z) + 500
    
    MP_PositionCamera(camera, x, yyyy  , z)
    MP_PositionEntity (sp,x+xDelta,MP_TerrainGetY(Terrain,x,0,z)+500,z+zDelta)
    MP_PositionEntity(light, x-200,200,z)
    
    MouseX = -(MP_MouseDeltaX()/10)
    MouseY = MP_MouseDeltaY()/10
    
    If MP_KeyHit(#PB_Key_J); to know the current camera position
    Debug("x = "+StrF(x))
    Debug("z = "+StrF(z))
    Debug("Altitude = "+ StrF(yyyy))
    Debug("  ")
    
  EndIf
        
    MP_TurnCamera(camera, MouseX, 0,  MouseY);, #PB_Relative)
        
    MP_RenderWorld() ; Erstelle die Welt
    MP_Flip () ; Stelle Sie dar

Wend