Page 32 of 71

Re: MP3D Engine Alpha 32

Posted: Fri Sep 27, 2013 5:54 pm
by AndyLy
applePi
Thanks. If you have experience with animation in MP3D - I invite you to take part in the development of the game . I want to make at least a minimum animations for the characters .

Re: MP3D Engine Alpha 32

Posted: Fri Sep 27, 2013 7:47 pm
by applePi
Thanks AndyLy,
sorry i don't know about the animations subject in general , i have just started reading about the subject from the book "hands on milkshape" . i'm not a games developer. just an amateur .
the MP3D Library are too big and i have covered just a little of it related to data plotting , the same with PB 3D engine. Michael have done a very big project.
i wonder where are Michael, he seems disappeared i hope he is okay.

Re: MP3D Engine Alpha 32

Posted: Fri Sep 27, 2013 8:39 pm
by AndyLy
i wonder where are Michael, he seems disappeared i hope he is okay.
Michael sent me a letter of 13 September , and then silence . I hope he is just too busy .

Re: MP3D Engine Alpha 32

Posted: Fri Sep 27, 2013 9:04 pm
by mpz
Hi,

i had not much time the last two weeks, but this weekend i can make some functiona an a new beta lib for 5.11 and 5.20.I have found some bugs in the old lib version and work on it too...

Greetings Michael,

Re: MP3D Engine Alpha 32

Posted: Sat Sep 28, 2013 3:05 pm
by Mythros
Hi, mpz! What can I say? I LOVE this library! It has solved MANY problems I have had in the past with many MANY Purebasic functions.

I can't wait for the 5.11 weekend beta! =D

Also would be nice for you to include a scrolling map demo (like Legend Of Zelda) with animated character so I can see how that works!

Meanwhile, I'm trying to load my own map & it won't work for some reason. What am I doing wrong?

Code: Select all

EP_Init2dMap()

MP_Graphics3D(800,600,32,2)
MP_AmbientSetLight(RGB(102, 102, 255))
EP_LoadMap("testgrass.map")

  While Not MP_KeyHit(#PB_Key_Escape) And Not WindowEvent() = #PB_Event_CloseWindow
    EP_SetMapArea(0,0,800,600)
   
    EP_DrawMap()
    
    MP_DrawText(10,10,Str(EP_GetMapSizeX()))
    MP_RenderWorld()
    MP_Flip()
    
  Wend

End
testgrass.tmx:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<map version="1.0" orientation="orthogonal" width="100" height="100" tilewidth="32" tileheight="32">
 <tileset firstgid="1" name="testgrass" tilewidth="32" tileheight="32">
  <image source="grass.png" width="100" height="100"/>
 </tileset>
 <layer name="Tile Layer 1" width="100" height="100">
  <data encoding="base64" compression="zlib">
   eJztw8EJAAAMA6H7ZP+VC51DwVVTVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVX/AWtAw1E=
  </data>
 </layer>
</map>
I DO have grass.png stored in the same folder as the map file.

grass.png:

Image

Help would be WONDERFUL!

Thank you very much & have a nice day! :)

Re: MP3D Engine Alpha 32

Posted: Sat Sep 28, 2013 7:09 pm
by mpz
Hi Mythros,

Thank for your message...

The map funktion is part of the epxy lib and i think you need a not compressed (your file is zlib commpressed) tmx file and you must convert this file with the epyx Tiled_Convert.pb file into a map file. I will ask Epyx to have a look on this problem and help you in this case...

Greetings Michael

Re: MP3D Engine Alpha 32

Posted: Sun Sep 29, 2013 11:28 am
by mpz
Hi ApplePi,

one question to your add function

Code: Select all

Hi Michael
i suggest to add MP_GetPrimitives in addition to the MP_SetPrimitives
so for some point we can get something like:
MP_GetPrimitives\color
MP_GetPrimitives\x
MP_GetPrimitives\y
MP_GetPrimitives\z
thanks
Do you want something in this kind:

Code: Select all

Structure PointVertex
  x.f
  y.f
  z.f
  Size.f
  Color.l;d3dcolor
EndStructure

*myvertex.PointVertex = MP_GetPrimitives(Entity, Vertex)

x.f = *myvertex\x
y.f =  *myvertex\y
z.f = *myvertex\z
...
or do you want

Code: Select all


x.f =  MP_GetPrimitivesX(Entity, Vertex)
y.f =  MP_GetPrimitivesY(Entity, Vertex)
z.f =  MP_GetPrimitivesZ(Entity, Vertex)
...
for a functions like

Code: Select all

color.l = MP_GetPrimitives\color
i need to make interfaces for the commands but i want to make a clear easy handling of command (stupid but easy)...

Greetings Michael

Re: MP3D Engine Alpha 32

Posted: Sun Sep 29, 2013 1:09 pm
by applePi
Hi Michael
i prefer the first scheme :
Structure PointVertex
x.f
.....

because i suggest it to be compatible approximately with the PB 3D engine function GetMeshData() http://www.purebasic.com/documentation/ ... hdata.html
which are in parallel with SetMeshData() http://www.purebasic.com/documentation/ ... hdata.html

you may want to do it in your own way, just as a guidlines look my example http://www.purebasic.fr/english/viewtop ... 36&t=56732 to rotate only blue points in the middle of a points mesh which have blue and red points.
==============
the logic in pb 3D engine like this using my example above:
draw the points somewhere in memory
while ....
MeshVertexPosition(x, y, z)
MeshVertexColor(RGBA(r,g,b,100))
Wend

===============
store the info of those points in an array MeshData() which elements have a structure:
GetMeshData(0,0, MeshData(), #PB_Mesh_Vertex ,0, MeshVertexCount(0)-1)
GetMeshData(0,0, MeshData(), #PB_Mesh_Color ,0, MeshVertexCount(0)-1)

=================
now suppose we want to check the points color to do something we use that array with the structure
If MeshData(i)\Color = RGBA(255,0,0,100)
rotate it by this formula
nx.f = Cos(-angle)*MeshData(i)\x - Sin(angle)*MeshData(i)\z
nz.f = Cos(-angle)*MeshData(i)\z + Sin(angle)*MeshData(i)\x

and reset the red points coordiates to the new positions:
MeshData(i)\x = nx
MeshData(i)\z = nz

===================
and after we change the MeshData array we flush it again to the points mesh so the new positions will be active:
SetMeshData(0,0, MeshData(), #PB_Mesh_Vertex, 0, MeshVertexCount(0)-1)
=====================
in the PB Ogre it is possible there are superficial error since if i want blue color i write
If MeshData(i)\Color = RGBA(255,0,0,100)

Re: MP3D Engine Alpha 32

Posted: Sun Oct 06, 2013 2:30 am
by Mythros
Hi. Is there anyway you can update your threadsafe link? I want to be able to create thread & unicode executables again so my program doesn't lag sometimes.

I tried your MP3D_Library file, put it in PureLibraries, and when I restart PureBasic 5.11, it crashes. :( I run Windows 7 - 64 bit, but 32 bit runs on it too.

Re: MP3D Engine Alpha 32

Posted: Mon Oct 07, 2013 4:03 pm
by mpz
Hello,

i was some days in holiday and i am back now.

@applePi
i have made an "easy" MP_GetPrimitives with a structure an will make a beta version in my forum with a test file in the next days.

@ Mythros
I can make a thread & unicode version in the future. I have only done a thread save version but have nor experince and a unicode version. i will make a beta version in my forum in the next days and you can test this if you want...



Greetings
Michael

Re: MP3D Engine Alpha 32

Posted: Sat Oct 12, 2013 8:27 pm
by mpz
Hello,

some little news

@applePi
MP_GetPrimitives is ready, beta version in my forum with example

@ Mythros
beta PB511 (x86) file with threadsave and unicode is ready, beta version in my forum with example

@News
i have made a video save funktion for mp3d. The only problem, the function is slow (6-8 fps) on my pc. My dream was to create a 3d film for my 3d lg tv. If you use the following xvid codec, you can create with the beta version a mp3d xvid avi film:

Xvid codec
http://www.xvidmovies.com/codec/

3D Film technic for my lg 3d. Two cameras with different eye positions looking on one point. The "two picture" film ist writtine in a avi film. On the lg you must activate the "two picture" film function.

Image

Her comes my first 3d Film for lg 3d tvs
http://www.flasharts.de/mpz/mp33/film.avi

Does the film work on other 3d tvs too? Please test this an inform me...

Greetings Michael

Re: MP3D Engine Alpha 32

Posted: Sun Oct 13, 2013 8:02 am
by applePi
Hi Michael
i have downloaded the new library from http://www.morty-productions.de/gamedev ... hp?tid=160
i can't find an example but i guess the used structure for the MP_GetPrimitives is as you have suggested before
Structure PointVertex
x.f
y.f
z.f
Size.f
Color.l;d3dcolor
EndStructure

*myvertex.PointVertex = MP_GetPrimitives(Entity, Vertex)

x.f = *myvertex\x
y.f = *myvertex\y
z.f = *myvertex\z
sz.f = *myvertex\Size
Col.l= *myvertex\Color

i will test it and report the findings, also i have downloaded the video, i don't have lg 3d tvs but running it on the windows media player there are 2 knots and it is good quality even it is elongated slightly, i guess we can see it as a 3D object if we colored them differently and looking to it in a 2 color glass . i suggest to add an example as a showcase how to save the film. a great feature realy.
thanks for all your efforts.

Re: MP3D Engine Alpha 32

Posted: Sun Oct 13, 2013 12:08 pm
by mpz
Hi AppliPi,

i have written some examples in the post tread
http://www.morty-productions.de/gamedev ... hp?tid=160
as Post#11, Post#12, and Post#17 (see on the second page) to show the new commands

I think to make a "red cyan 3d film" you need a shader to add the both pictures with the correct color. Perhaps i can make a example for that...

Greetings Michael

in this examples the vertex coords are "random" changing...

Code: Select all

Code:
;////////////////////////////////////////////////////////////////
;//
;// Project Title: MP 3D Engine Beispielprogramme
;// Dateiname: MP_Primitives_Changing.pb
;// Erstellt am: 07.03.2010
;// Update am  :
;// Author: Michael Paulwitz
;//
;// Info:
;// Creates three lines of a primitive
;// Erstellt drei Linien eins Primitives
;//
;//
;////////////////////////////////////////////////////////////////

;- ProgrammStart


Procedure.f FlRand()
  
  ProcedureReturn (Random(100)/100-0.5)/20
  
EndProcedure


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

camera=MP_CreateCamera() ; Kamera erstellen

Entity = MP_CreatePrimitives (6, 2) ; 6 Vertexe und LINELIST (einzelne Linien)

MP_EntitySetZ (Entity, 8)
    
MP_SetPrimitives(Entity, 0,  0, 2, 0,  $FFFFFFFF)
MP_SetPrimitives(Entity, 1,  0, -2, 0, $FF0000FF)
MP_SetPrimitives(Entity, 2,  -2, 0, 0, $FF00FF00)
MP_SetPrimitives(Entity, 3, 2, 0, 0,   $FF00FFFF)    
MP_SetPrimitives(Entity, 4, 0, 0, 2,   $FFFF0000)
MP_SetPrimitives(Entity, 5, 0, 0, -2,  $FFFF00FF)    

Structure PointVertex
  x.f
  y.f
  z.f
  Size.f
  Color.l;d3dcolor
EndStructure

*myvertex.PointVertex

While Not MP_KeyDown(#PB_Key_Escape) And Not WindowEvent() = #PB_Event_CloseWindow; Esc abfrage oder Windows Schliessen
  
    For n = 0 To 5
      
      *myvertex = MP_GetPrimitives(Entity, n)
      MP_SetPrimitives(Entity, n,  *myvertex\x+FlRand(), *myvertex\y+FlRand(), *myvertex\z+FlRand(),  *myvertex\color)
            
    Next  
  
    MP_TurnEntity (Entity,0.1,0.1,0.1) ; dreh den Würfel
    MP_RenderWorld() ; Erstelle die Welt
    MP_Flip () ; Stelle Sie dar

Wend

Re: MP3D Engine Alpha 32

Posted: Sun Oct 13, 2013 12:14 pm
by applePi
here is an example of using MP_GetPrimitives , here it rotates only the green points at the middle of the cube. the whole mesh are rotating and we can see that the green points are rotating really by commenting line 62 MP_TurnEntity(Entity,0,1,0)
i can't decide visually to which way the green points are rotating due to the confusion between front and the back points may be it needs better lighting and alpha . but this is a speedy example for the uses of the function, also we can change the color, i have focused only now on rotating the green points , the number of points here are 100000

Code: Select all

Structure PointVertex
  x.f
  y.f
  z.f
  Size.f
  Color.l;d3dcolor
EndStructure
; code for MP3D
Declare DrawMatrix()
Declare isolate()

Global angle.f
Global xres=640, yres=480
MP_Graphics3D (xres,yres,0,3)
SetWindowTitle(0, "press up/down to move camera  ")

camera=MP_CreateCamera()

light=MP_CreateLight(2)
MP_LightSetColor (light, RGB(255,255,255))

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

Global Entity= MP_CreatePrimitives (2000000, 1)   
  

Define.f red, green, blue


Quit.b = #False

;==============================================================
        
MP_ScaleEntity(Entity, 1.5, 1.5, 1.5)
;MP_MeshSetBlendColor(Entity, $FFFFFFFF)
;MP_MeshSetAlpha(Entity,3)
;MP_MeshAlphaSort(Entity)


DrawMatrix()
MP_PrimitivesBlendingMode(Entity, 5,2)

MP_PositionCamera(camera, 0, 0, 700)
MP_CameraLookAt(camera,0,0,0)
MP_PositionEntity(light, 0 , 0, 10)
MP_EntityLookAt(light,0,0,0)

xx.f=0 :zz.f=0
While Not MP_KeyDown(#PB_Key_Escape) And Not WindowEvent() = #PB_Event_CloseWindow
  
  If MP_KeyDown(#PB_Key_Up) 
    
    zz.f + 20
  ElseIf MP_KeyDown(#PB_Key_Down) 
    
    zz.f - 20
  
  EndIf 
      
    MP_PositionEntity(Entity, xx, 0, zz)
    MP_TurnEntity(Entity,0,1,0) 
    
    isolate(); call the routine for rotating only the green points
    
  MP_RenderWorld()
   
  MP_Flip ()

Wend

Procedure DrawMatrix()
    For i=0 To 100000 
  x = Random(200)-100:y = Random(200)-100:z = Random(200)-100
 
;check if point inside a specific sphere:  
  q.f = (Pow(x,2) + Pow(y,2) + Pow(z,2))
  If q <= 4900
    r=0:g=255:b=0
    MP_SetPrimitives(Entity, i,  x, y, z,  MP_ARGB(200,r,g,b))
    
    ElseIf q>10000
      r=255:g=0:b=0
      MP_SetPrimitives(Entity, i,  x, y, z,  MP_ARGB(200,r,g,b))
   
    
  EndIf 

Next
    
EndProcedure  

Procedure isolate() ; rotate green core
angle.f = 0.05

  size = 100000
  For i=0 To size
     
   *myvertex.PointVertex = MP_GetPrimitives(Entity, i)
   col.l = *myvertex\Color
   If MP_Green(col) = 255
   ;x.f = *myvertex\x
   y.f = *myvertex\y
   ;z.f = *myvertex\z
   nx.f = Cos(-angle)* *myvertex\x - Sin(angle)* *myvertex\z
   nz.f = Cos(-angle)* *myvertex\z + Sin(angle)* *myvertex\x
   
   
   MP_SetPrimitives(Entity, i,  nx, y, nz,  MP_ARGB(200,0,255,0))
   EndIf
       
  
   Next
      
 EndProcedure
 
 
edit: a speedier version :performing calculations and MP_SetPrimitives only upon finding the green color , and now i can see the direction of the green points rotation, and moving the camera with arrows are a little more easier

Re: MP3D Engine Alpha 32

Posted: Sun Oct 13, 2013 2:01 pm
by Psychophanta
Great work Michael :!: