MP3D Engine Alpha 33

Applications, Games, Tools, User libs and useful stuff coded in PureBasic
User avatar
AndyLy
Enthusiast
Enthusiast
Posts: 228
Joined: Tue Jan 04, 2011 11:50 am
Location: GRI

Re: MP3D Engine Alpha 31

Post by AndyLy »

Perhaps they need to much grafic card ram
I have GeForce GT 640 with 1024 mb memory.
Strange error. I made test: 100 cubes created and uploaded 100 models-works. In my program I load a smaller number of models-crashes.
All models have been tested, I just load another similar one. I do not understand what the problem is.
The error occurs independently of the model, which I load. If I remove any model from load, it works.
I do not understand even where to look for the error.

By the way, I load the same model because MP_CopyEntity (Entity) does not work, it seems wrong to copy the material and texture, the program aborted.
'Happiness for everybody, free, and no one will go away unsatisfied!'
SMsF town: http://www.youtube.com/watch?v=g6RRKYf_Pd0
SMf locations module (Ogre). Game video: http://www.youtube.com/watch?v=ZlhBgPJhAxI
mpz
Enthusiast
Enthusiast
Posts: 497
Joined: Sat Oct 11, 2008 9:07 pm
Location: Germany, Berlin > member German forum

Re: MP3D Engine Alpha 31

Post by mpz »

Hi Andyly,

the problem with meshload look not easy. i will make a testfile and load some other meshs. Perhaps i find something...

For now i can repair the MP_CopyEntity command. Please send me a not working mesh and i can check it and solve the problem...

i make a new testlib in the next days with some important changings. I think some of the function are very interessting for you..

Greetings Michael
Working on - MP3D Library - PB 5.73 version ready for download
User avatar
leonhardt
Enthusiast
Enthusiast
Posts: 220
Joined: Wed Dec 23, 2009 3:26 pm

Re: MP3D Engine Alpha 31

Post by leonhardt »

mpz wrote:Hello to all,

MP is proudly to represent my version of Alpha (31) of the mp3d engine for Windows. A few will have already seen results from it. Please install DX9 before you use it. The library has been written in PureBasic. More as 169 demo files should be easier to get started. There is a installer and if you want you can copy only the directories in the Purebasic folder. The Purebasic version from 4.61 and upper is needed. I have made an English help text, but my english is poor :oops: and i hope somebody check it and send me a better one (i dont think anybody will do that). In a file you must activated "DX9" in compiler -> library subsystem

- what is the purpose?
To make 2D and 3d games and application without using a external dll file

- open / closed source?
closed source, when I'm tired to develop the engine i will published the code

- implementation through library, dll or include?
(tailbite) library

Have fun in the 2rd and 3rd dimension

Installer for the x86 only version
http://www.flasharts.de/mpz/Install_MP3D_31_x86.exe

x86 version without installer
http://www.flasharts.de/mpz/mp3d_31_x86.zip

Installer for the x64 only version
http://www.flasharts.de/mpz/Install_MP3D_31_x64.exe

the Threadsafe only lib for x86, Please replace the original MP3D_Library lib manually
http://www.flasharts.de/mpz/Threadsafe/MP3D_Library

People who like to work on the engine or may be interested log on here. Newer versions appear in this forum
http://www.morty-productions.de/gamedev/


Important Features:
- Support for DirectX 9
- You can use many PureBasic commands directly
- Parent Kid for Sprite and Mesh available
- Sprite engine with rotating and animated sprites
- Sprite collision system, now with pixel pixel check
- Sprite manipulation commands
- mouse, joystick and Force Feedback Support
- Support Material
- Texturing with Mip Level
- Purebasic images to texture system
- Animated textures
- Different Light
- Bump mapping
- Access to Mesh Vertex
- Mesh Picking
- Mesh Animation
- Save the Meshes
- Collision system
- Fog Effect
- Integrated particle engine
- Gui of PureBasic possible
- Texture / pixel / vertex shader support
- Simple physics engine
- Primitives
- Scrolling background
- AnimParticle
- Transparenz of Meshes
- Direct Sound Effects
- Write / read pixels on Surface
- Other collision detection
- Background Scrolling
- Multiple Views
- 2D Draw functions
- fast Surface technologie
- BitmapFonts
- RenderToTexture functions
- integration of many function of the FXLib by Epyx in mp3D (Thanks to the implementation of Epyx).
- post processing with shader.
- Cullum Frustum
- Shadow
- expansion of many shader instructions
- 187 shaders total
- Shadereditor
- 2Dto3D and 3Dto2D calculations
- Physics expansion by Newton physics
- Epyx 3D and vector objects
- Some Updates and new demos
- New command expansions
- 2D Physic with Chipmunk
- Tile Engine by Epyx
- Tile converter for Tiled MapEditor => http://www.mapeditor.org/
- Some new Games

List of mesh sizes:
- Microsoft DirectX (. X, with animation support)
- B3D (. B3d)
- 3D Studio meshes (.3 ds)

Is available for the following platforms:
- Windows 98SE, ME, XP, Vista and Windows 7 (x86 abd x64)

Other functions are in progress

have fun :D
Michael Paulwitz
excellent work! about the English help file,I think you could use the Google Translation,for German to English ,it works well. what a pain for us who can't read German.
poor English...

PureBasic & Delphi & VBA
User avatar
Sveinung
Enthusiast
Enthusiast
Posts: 142
Joined: Tue Oct 07, 2003 11:03 am
Location: Bergen, Norway

Re: MP3D Engine Alpha 31

Post by Sveinung »

Hello MPZ,

I have tested your material commands, and when I change collors often I get memory read error.
[ERROR]invalid memory access.(read error at address 24)

Could you have a look at this, to see if it is me or if there is a little bug :)
I have included the bit of source that fails.

Code: Select all

Procedure ccol(obj.i)
  Protected r.c,g.c,b.c
  Repeat
    r=Random(254)
    g=0
    b=128+Random(127)
    MP_MaterialDiffuseColor (obj,255,r,g,b)
    MP_MaterialAmbientColor (obj, 255, 128 , 0, 128) ; 
    MP_MaterialSpecularColor (obj, 255, 128 ,0, 128,40);
    Delay(100+Random(3000)) 
  ForEver
EndProcedure
Regards
Sveinung
User avatar
Sveinung
Enthusiast
Enthusiast
Posts: 142
Joined: Tue Oct 07, 2003 11:03 am
Location: Bergen, Norway

Re: MP3D Engine Alpha 31

Post by Sveinung »

One more thing, is there a way to set 2D/3D draworder?

Regards
Sveinung
mpz
Enthusiast
Enthusiast
Posts: 497
Joined: Sat Oct 11, 2008 9:07 pm
Location: Germany, Berlin > member German forum

Re: MP3D Engine Alpha 31

Post by mpz »

Hello Sveinung,

thanks for you interessting of mp3d. I have checked the commands an could not find a bug. Please tell me a little bit more of you program. Could it be that you use the "Procedure ccol(obj.i)" as threat?!? Can you show me please how you use the command in your program? If you use it a threat, the comand MP_MaterialDiffuseColor etc are not Threatsafe and this could be the problem...

The set 2D/3D draworder settings are fixed, but if you want you can make your own draw oder with the following comands:

MP_RenderBegin()
MP_RenderText()
MP_RenderSky()
MP_RenderSurface()
MP_RenderMesh()
MP_RenderPrimitives()
MP_RenderAnimMesh()
MP_RenderSprite ()
MP_RenderPartikel()
MP_RenderPrimitives()
MP_Render2D ()
MP_RenderEnd()


(for example)

Code: Select all

MP_Graphics3D (640,480,0,0)

Sprite = MP_CatchSprite(?MyData, ?EndOfMyData - ?MyData)

While Not MP_KeyDown(#PB_Key_Escape) And Not WindowEvent() = #PB_Event_CloseWindow; Esc abfrage oder Windows Schliessen
    
    MP_AmbientSetLight (RGB(0,50,128))
    
    MP_DrawText(0,0, "Hello World")
    
    MP_DrawSprite(Sprite, 40, 0)
    
    MP_RenderBegin()
    
      ; Draw your text first
      MP_RenderText() 
    
      ; Draw your sprite last and over text
      MP_RenderSprite() 
      
    MP_RenderEnd()

    MP_Flip () ; Stelle Sie dar

Wend

DataSection
  MyData:
     IncludeBinary #PB_Compiler_Home + "Examples\Sources\Data\Geebee2.bmp"
  EndOfMyData:
EndDataSection
Greeting Michael
Working on - MP3D Library - PB 5.73 version ready for download
User avatar
Sveinung
Enthusiast
Enthusiast
Posts: 142
Joined: Tue Oct 07, 2003 11:03 am
Location: Bergen, Norway

Re: MP3D Engine Alpha 31

Post by Sveinung »

The procedure was threaded...change that...works fine.
Thank You!!!!!!!!! :D

Regards
Sveinung
User avatar
AndyLy
Enthusiast
Enthusiast
Posts: 228
Joined: Tue Jan 04, 2011 11:50 am
Location: GRI

Re: MP3D Engine Alpha 31

Post by AndyLy »

Hi,
how I can flip Normals in Mesh?
'Happiness for everybody, free, and no one will go away unsatisfied!'
SMsF town: http://www.youtube.com/watch?v=g6RRKYf_Pd0
SMf locations module (Ogre). Game video: http://www.youtube.com/watch?v=ZlhBgPJhAxI
mpz
Enthusiast
Enthusiast
Posts: 497
Joined: Sat Oct 11, 2008 9:07 pm
Location: Germany, Berlin > member German forum

Re: MP3D Engine Alpha 31

Post by mpz »

Hi,

i think the best is it to change the nx,ny,nz to -nx,-ny,-nz for the mesh.

Please test this:

Code: Select all

For n = 0 To MP_CountVertices(Mesh)-1 ; Anzahl der Vertices in dem Würfel
  
    nx.f = MP_VertexGetNX (Mesh,n) ; nx Wert auslesen
    ny.f = MP_VertexGetNY (Mesh,n) ; ny Wert auslesen
    nz.f = MP_VertexGetNZ (Mesh,n) ; nz Wert auslesen

    MP_VertexSetNX (Mesh,n, -nx) ; n = -n
    MP_VertexSetNY (Mesh,n, -ny ); n = -n      ; 
    MP_VertexSetNZ (Mesh,n, -nz) ; n = -n
    
Next
Greetings Michael
Working on - MP3D Library - PB 5.73 version ready for download
User avatar
AndyLy
Enthusiast
Enthusiast
Posts: 228
Joined: Tue Jan 04, 2011 11:50 am
Location: GRI

Re: MP3D Engine Alpha 31

Post by AndyLy »

Thanks, MPZ, I tried, but I do not understand: the texture displays on both sides of the polygon?
'Happiness for everybody, free, and no one will go away unsatisfied!'
SMsF town: http://www.youtube.com/watch?v=g6RRKYf_Pd0
SMf locations module (Ogre). Game video: http://www.youtube.com/watch?v=ZlhBgPJhAxI
mpz
Enthusiast
Enthusiast
Posts: 497
Joined: Sat Oct 11, 2008 9:07 pm
Location: Germany, Berlin > member German forum

Re: MP3D Engine Alpha 31

Post by mpz »

Hi andyly,

i think i know what you mean. If you have mesh with triangels (a triangle has 3 Vertex) you have the position Vertex 1,2 and 3 ore you have the position Vertex 1,3,2. If you use the SetRenderState funktion you can use different Cullmodes. This means you see the trinangle only from on side (front or back or both sides). To use differnt Cullmodes you can use these function in mp3d, the MP_SetRenderState(#D3DRS_CULLMODE, Var =1 to 3) function. Please see the microsoft function: http://msdn.microsoft.com/en-us/library ... s.85).aspx

Here i make one mesh with 3 kinds of cullmodes,
first Mesh = see both sides, second mesh see back, third mesh see front
mp3d use as standard #D3DCULL_NONE

DX9 needs the nx,ny and nz function to calculate the effect of light hitting a triangle

have fun...
Michael

Code: Select all


;http://msdn.microsoft.com/en-us/library/bb174454(v=vs.85).aspx
#D3DRS_CULLMODE = 22 ;/* D3DCULL */

#D3DCULL_NONE = 1
#D3DCULL_CW = 2
#D3DCULL_CCW = 3


MP_Graphics3D (640,480,0,3) ; Erstelle ein WindowsFenster mit 3D Funktion #Window = 0
SetWindowTitle(0, "Cullmode") ; Setzt einen Fensternamen

If CreateImage(0, 255, 255)

    Font = LoadFont(#PB_Any, "Arial"  , 138) 
    StartDrawing(ImageOutput(0))

    Box(0, 0, 128, 128,RGB(255,0,0))
    Box(128, 0, 128, 128,RGB(0,255,0))
    Box(0, 128, 128, 128,RGB(0,0,255))
    Box(128, 128, 128, 128,RGB(255,255,0))

    DrawingFont(FontID(Font))
    DrawingMode(#PB_2DDrawing_Transparent)
    DrawText(73,35,"5",RGB(0,0,0))
  
    StopDrawing() 
    
EndIf

camera=MP_CreateCamera() ; Kamera erstellen

light=MP_CreateLight(1) ; Es werde Licht


Mesh=MP_CreateCube() ; Und jetzt eine Würfel
;Mesh= MP_CreateSphere(4)

Textur = MP_ImageToTexture(0)
MP_EntitySetTexture(Mesh, Textur) 

MP_PositionEntity (Mesh,0,0,6) ; 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_RenderBegin()
   
   MP_SetRenderState(#D3DRS_CULLMODE, #D3DCULL_NONE)
   MP_PositionEntity (Mesh,-2,0,6) ; Move mesh left
   MP_RenderMesh(Mesh)
   
   MP_SetRenderState(#D3DRS_CULLMODE, #D3DCULL_CW)
   MP_PositionEntity (Mesh,0,0,6) ; Move mesh middle
   MP_RenderMesh(Mesh)
   
   MP_SetRenderState(#D3DRS_CULLMODE, #D3DCULL_CCW)
   MP_PositionEntity (Mesh,2,0,6) ;  Move mesh right
   MP_RenderMesh(Mesh)
    
   MP_RenderEnd()
   
   MP_Flip () ; Stelle Sie dar
    
Wend

Working on - MP3D Library - PB 5.73 version ready for download
User avatar
AndyLy
Enthusiast
Enthusiast
Posts: 228
Joined: Tue Jan 04, 2011 11:50 am
Location: GRI

Re: MP3D Engine Alpha 31

Post by AndyLy »

I know about the method of display in Directx 9, I mean in MP3D. I sent you a letter explaining.
What about (do not know how it's called) the range of drawing?
Textures are blurred at a distance, not visible scrolling textures ...
How to increase the range of drawing objects?
'Happiness for everybody, free, and no one will go away unsatisfied!'
SMsF town: http://www.youtube.com/watch?v=g6RRKYf_Pd0
SMf locations module (Ogre). Game video: http://www.youtube.com/watch?v=ZlhBgPJhAxI
mpz
Enthusiast
Enthusiast
Posts: 497
Joined: Sat Oct 11, 2008 9:07 pm
Location: Germany, Berlin > member German forum

Re: MP3D Engine Alpha 31

Post by mpz »

Hi,

here comes a little explanation of dx9 texturing. In dx9 you can load a texture. Normaly the texture is loades and some miplevels are created too. This means the first mipmap have a texture with full resolution, the next miplevel with half resolution, the next miplevel has quarter resolution and so on. The idea here is that far objects need only less texture resolutions and not need full computing power for that. The problem is that sometime the texture are blurred. For that case you can make im MP3d a texture with or without miplevels:

MP_LoadTexture(File.s [, Alpha [, MipLevels]]), Miplevel = 1 means only one texture


Greetings Michael
Working on - MP3D Library - PB 5.73 version ready for download
applePi
Addict
Addict
Posts: 1404
Joined: Sun Jun 25, 2006 7:28 pm

Re: MP3D Engine Alpha 31

Post by applePi »

Hi
i'm trying to light a textured sphere with two lights , red light from right and green light from left, the problem is that i think i must use for the texture something like this:
MP_MaterialEmissiveColor (Texture,255,255,0,0)
MP_MaterialDiffuseColor (Texture,255,255,0,0)
to be able to light the right side a red color
but what about the left side which should be colored green and so the midpoint between left and right should be gradually yellow.
i have experimented with the "MP_Alphablending" example from MP3D and this is the picture of the result:
Image

the texture have an alpha channel ,the code and the texture "ministones.tga" can be downloaded from here:
http://www.mediafire.com/?ets2eew6e2egt6x

Code: Select all

MP_Graphics3D (640,480,0,3) 

SetWindowTitle(0, "Alpha Blending test: Key 1,2,3,4") 

camera=MP_CreateCamera()

light=MP_CreateLight(2)
light2=MP_CreateLight(2)
MP_PositionEntity (light,-6,0,3)
MP_LightSetColor(light,RGB(0,255,0))
MP_EntityLookAt(light,0,0,3)

MP_PositionEntity (light2,6,0,3)
MP_LightSetColor(light2,RGB(255,0,0))
MP_EntityLookAt(light2,0,0,3)

sphere=MP_CreateSphere(16)

Texture = MP_LoadTexture("ministones.tga",1)
;MP_MaterialSpecularColor(Texture,255,0,255,128,1)
MP_MaterialEmissiveColor (Texture,255,255,0,0)
MP_MaterialDiffuseColor (Texture,255,255,0,0)
;MP_MaterialEmissiveColor (Texture,255,0,255,0)
;MP_MaterialDiffuseColor (Texture,255,0,255,0)

MP_PositionEntity (sphere,0,0,3)

MP_EntitySetTexture (sphere, Texture) 
MP_MeshSetAlpha (sphere,2)


While Not MP_KeyDown(#PB_Key_Escape) And Not WindowEvent() = #PB_Event_CloseWindow

 If MP_KeyDown(#PB_Key_1)=1 : MP_MeshSetAlpha (sphere,0): EndIf ; Normalmodus aktiv
 If MP_KeyDown(#PB_Key_2)=1 : MP_MeshSetAlpha (sphere,1): MP_EntitySetTexture(sphere, Texture) : EndIf ; Alphamodus 1 ohne Alphakanal
 If MP_KeyDown(#PB_Key_3)=1 : MP_MeshSetAlpha (sphere,1): MP_EntitySetTexture(sphere, Texture) : EndIf ; Alphamodus 1
 If MP_KeyDown(#PB_Key_4)=1 : MP_MeshSetAlpha (sphere,2): MP_EntitySetTexture(sphere, Texture) : EndIf ; Alphamodus 2
 If MP_KeyDown(#PB_Key_5)=1 : MP_MeshSetAlpha (sphere,3): MP_EntitySetTexture(sphere, Texture) : EndIf ; Alphamodus 3
 If MP_KeyDown(#PB_Key_6)=1 : MP_MeshSetAlpha (sphere,3): MP_EntitySetTexture(sphere, Texture) : EndIf ; Alphamodus 3
 If MP_KeyDown(#PB_Key_7)=1 : MP_MeshSetAlpha (sphere,4): MP_EntitySetTexture(sphere, Texture) : EndIf ; Alphamodus 4
 If MP_KeyDown(#PB_Key_8)=1 : MP_MeshSetAlpha (sphere,1): MP_EntitySetTexture(sphere, Texture) : MP_CreateTextureAlpha(Texture, Texture):EndIf ; Alphamodus 2
 
 
 
  MP_TurnEntity (sphere,0.05,0.5,1) 
  MP_MeshAlphaSort(1)
  MP_RenderWorld ()
  MP_Flip ()

Wend
on the other hand here is an equivalent opengl program "lesson 18" which i have downloaded it years ago from :
http://purebasic.developpez.com/sources/ look 3D section
i have changed it to make a left and right green, red light. it is more correctly displaying the two lights on the texture as in this image
Image
rotate the sphere with keys, the source with the texture are found in the same mediafire download above. you must disable the debugger before run.
i never remeber the complexities of opengl, i just have used the available example to demonstrate my issue.
even the opengl example are not completely correct since the inner side on the texture on the sphere must reflect the color of the opposite light
regards
User avatar
AndyLy
Enthusiast
Enthusiast
Posts: 228
Joined: Tue Jan 04, 2011 11:50 am
Location: GRI

Re: MP3D Engine Alpha 31

Post by AndyLy »

Image

Code: Select all

Texture = MP_LoadTexture("ministones.tga",1)
;MP_MaterialSpecularColor(Texture,255,0,255,128,1)
;MP_MaterialEmissiveColor (Texture,255,255,0,0)
;MP_MaterialDiffuseColor (Texture,0,155,155,155)
MP_MaterialEmissiveColor (Texture,0,50,50,50)
;MP_MaterialDiffuseColor (Texture,255,0,255,0)
'Happiness for everybody, free, and no one will go away unsatisfied!'
SMsF town: http://www.youtube.com/watch?v=g6RRKYf_Pd0
SMf locations module (Ogre). Game video: http://www.youtube.com/watch?v=ZlhBgPJhAxI
Post Reply