MP3D Engine Alpha 33

Applications, Games, Tools, User libs and useful stuff coded in PureBasic
User avatar
N_Gnom
User
User
Posts: 76
Joined: Fri Sep 13, 2013 3:20 pm
Location: Germany

Re: MP3D Engine Alpha 32

Post by N_Gnom »

delete MP_CameraLookAt(camera,0,0,0)
then it works fine.
And please test this....the cylinder is shown in another distance without this.

It seems anything is wrong with the MP_TurnCamera command...smile.

As i said camera control with MP_TurnEntity, MP_MoveEntity, MP_RotateEntity and so on.
Its maybe the better way.
Last edited by N_Gnom on Sun Jan 12, 2014 5:52 pm, edited 1 time in total.
mpz
Enthusiast
Enthusiast
Posts: 497
Joined: Sat Oct 11, 2008 9:07 pm
Location: Germany, Berlin > member German forum

Re: MP3D Engine Alpha 32

Post by mpz »

Hi,

thanks for the information. I have actualized the libs and hope i have solved the first problem:

x86 for PB 511 and older
http://www.flasharts.de/mpz/mp33/pb511/MP3D_Library.zip

x86 for pb 520 and newer
http://www.flasharts.de/mpz/mp33/pb520/MP3D_Library.zip

@ Psychophanta ->Is this a bug?: -> i will have a look on it...

Code: Select all

    MP_Graphics3DWindow(0, 0, 800, 600, "MP3D", 0)
    MP_VSync(2)
    light0 = MP_CreateLight(1)
    MP_PositionEntity(light0, 0, 0, 0)
    cam = MP_CreateCamera()

    MP_PositionCamera(cam, 0, 0, -35)
    MP_AmbientSetLight (RGB( 0, 154, 205))
    cube = MP_CreateCube()
    MP_PositionEntity(cube, 0, 0, 0)

    cube2= MP_CreateSphere(1)
    MP_PositionEntity(cube2,0,0,-25)

    While Not MP_KeyDown(#PB_Key_Escape) And Not WindowEvent() = #PB_Event_CloseWindow
     
       
      If MP_KeyDown(#PB_Key_Down) = 1
        MP_TurnCamera(cam,1,0,0)
      EndIf   
      If MP_KeyDown(#PB_Key_Up) = 1
        MP_TurnCamera(cam,-1,0,0)
      EndIf
      If MP_KeyDown(#PB_Key_Left) = 1
        MP_TurnCamera(cam,0,1,0)
      EndIf
      If MP_KeyDown(#PB_Key_Right) = 1
        MP_TurnCamera(cam,0,-1,0)
      EndIf
        If MP_KeyDown(#PB_Key_W) = 1
        MP_MoveCamera(cam,0,0,1)      ; its the Z axis, should be X Axis
      EndIf
        If MP_KeyDown(#PB_Key_S) = 1
        MP_MoveCamera(cam,0,0,-1)
      EndIf

      MP_DrawText(1,10,"FPS = "+Str(MP_FPS()))
      MP_DrawText(1,25,"MP_EntityGetPitch(cam) = "+MP_EntityGetPitch(cam))
      MP_DrawText(1,45,"MP_EntityGetYaw(cam) = "+MP_EntityGetYaw(cam))
      MP_DrawText(1,65,"MP_EntityGetRoll(cam) = "+MP_EntityGetRoll(cam))
      MP_DrawText(1,85,"Press W to go front and S to go back down")
      MP_DrawText(1,100,"Drück Up/Down sollte MP_TurnCamera(cam, 1, 0, 0) bzw. MP_TurnCamera(cam, -1, 0, 0) sein")
      MP_DrawText(1,125,"ist aber MP_TurnCamera(cam, 0, 1, 0) respektive -1.Hoffe du verstehst was ich meine.")
      MP_DrawText(1,140,"und nun drehe mal die kamera nach oben li/re da ja noch vertauscht, und dann drück W")
      MP_RenderWorld()
      MP_Flip()
    Wend
Working on - MP3D Library - PB 5.73 version ready for download
User avatar
N_Gnom
User
User
Posts: 76
Joined: Fri Sep 13, 2013 3:20 pm
Location: Germany

Re: MP3D Engine Alpha 32

Post by N_Gnom »

thank you mpz...fantastic work.
@mpz and psychophanta:
its a bug in MP_CameraLookAt.in my example all works fine and when i use MP_CameraLookAt(cam, 0, 0, 0) all is wrong.
1 is -1 and -1 is 1.
i.e. forward is backward left is right and turn works not correctly.
Its the MP_CameraLookAt with a little bug in the bag.

edit:
sorry mpz i have found a new but little bug.If i turn the camera on the X axis(Pitch) more then 90 degree the camera flip and up and down is swapped.
Atm not a big problem but if anybody would make a 3D spaceshooter its a problem.
Mythros
Enthusiast
Enthusiast
Posts: 306
Joined: Mon Aug 19, 2013 3:28 pm

Re: MP3D Engine Alpha 32

Post by Mythros »

@mpz: It still crashes for me on Windows 8 (Desktop) / Laptop, whether I'm in unicode & / or non-unicode & / or threadsafe / non-threadsafe... :( Can you please fix this?

Also, can you please release the source for the B3D / 3DS to X object converter? That would help WONDERS for my project (Which I'm doing in Blitz3D).

Thank You so much, @mpz!

Have a wonderful afternoon! :)
User avatar
N_Gnom
User
User
Posts: 76
Joined: Fri Sep 13, 2013 3:20 pm
Location: Germany

Re: MP3D Engine Alpha 32

Post by N_Gnom »

@Mythros: i have the crashed only if my sounddriver was not installed.Or is this with the new mp3d lib?

Btw. Moving lights are very slow and very very jerky.I need it for spotlights on my car...and its not smooth.
My terrain model is not optimized but only with a big lightrange it is okay.


btw: if anybody would moving global and not relativ.
if anybody need this.

Code: Select all

Procedure MP_TranslateEntity(ent, x.f, y.f, z.f)
  MP_PositionEntity(ent, MP_EntityGetX(ent) + x, MP_EntityGetY(ent) + y, MP_EntityGetZ(ent) + z)
EndProcedure 

Procedure MP_TranslateCamera(camera, x.f, y.f, z.f)
  MP_PositionCamera(camera, MP_CameraGetX(camera) + x, MP_CameraGetY(camera) + y, MP_CameraGetZ(camera) + z)
EndProcedure 
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Re: MP3D Engine Alpha 32

Post by Psychophanta »

Yes, looks like there is somethig related with Cameralookat()

The MP_EntityGetYaw() continues changing its sign, at least i miss something.
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
User avatar
N_Gnom
User
User
Posts: 76
Joined: Fri Sep 13, 2013 3:20 pm
Location: Germany

Re: MP3D Engine Alpha 32

Post by N_Gnom »

I have limited to 360...i hope thats what you mean.




Btw: How can i change the alpha transparency of a primitives?
I think a b3d or such one modell with textur(png) with alpha channel.
But what have i to do if i have a primitive.
mpz
Enthusiast
Enthusiast
Posts: 497
Joined: Sat Oct 11, 2008 9:07 pm
Location: Germany, Berlin > member German forum

Re: MP3D Engine Alpha 32

Post by mpz »

Hi,

@Mythos you find the bb sourccode of the converter "Convert_b3d_3ds_x_anim_to_directx_anim.bb"in my
mp3d forum as:
http://www.flasharts.de/mpz/mp33/Mesh_in_Out.zip

Works your pc with the "normal" Alpha 32 and not with the Alpha 33 Version? Do you use pb5.11 or PB 5.20? I have testet the unicode/threadsafe and everything works fine. Soundcard could be a problem...

@N_Gnom swaping and lookat problem, i am searching for the problem...
Alphatranpsparence must work if the texure is alphatransparencing too


Greeting Michael
Working on - MP3D Library - PB 5.73 version ready for download
User avatar
N_Gnom
User
User
Posts: 76
Joined: Fri Sep 13, 2013 3:20 pm
Location: Germany

Re: MP3D Engine Alpha 32

Post by N_Gnom »

@mpz: thank you.with alpha texture it runs fine.
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Re: MP3D Engine Alpha 32

Post by Psychophanta »

Simple Math solution Gift to orbitate the 'eye':

Code: Select all

;How to manually orbitate a camera (eye) around a point (any object) in space without the use of quaternions or tensors
;Use mouse wheel to increase-decrease distance of camera to the point
;Please don't hesitate in contact me (Psychophanta) if you want a fast and easy explanation of this.
Define .f
ExamineDesktops()
Global bitplanes.b=DesktopDepth(0),RX.w=DesktopWidth(0),RY.w=DesktopHeight(0)
MP_Graphics3D(RX,RY,bitplanes,0):MP_VSync(1)
SetWindowTitle(0,"manual camera orbitation")
Global.i camera,light,arrow,cone
camera=MP_CreateCamera()
MP_PositionCamera(camera,2,1,-10)
light=MP_CreateLight(2)
MP_LightSetColor(light,RGB(219,118,50))
MP_PositionEntity(light,-6,10,-5)
MP_AmbientSetLight(RGB(0,100,200))
arrow=MP_CreateCylinder(60,200)
MP_ScaleMesh(arrow,0.025,0.025,0.025)
MP_PositionMesh(arrow,0,0,0)
MP_RotateEntity(arrow,0,0,0)
cone=MP_CreateCone(60,4)
MP_PositionMesh(cone,0,0,-27)
MP_ScaleMesh(cone,0.1,0.1,0.1)
MP_AddMesh(cone,arrow):MP_FreeEntity(cone)
MP_ChangeMeshCoord(arrow)
MP_EntitySetNormals(arrow)
MP_MaterialDiffuseColor(arrow,255,255,128,50)
MP_MaterialSpecularColor(arrow,255,255,255,155,5)
MP_CameraLookAt(camera,MP_EntityGetX(arrow),MP_EntityGetY(arrow),MP_EntityGetZ(arrow))
Structure Vector
  x.f:y.f:z.f
  StructureUnion
    Length.f
    modulo.f
    m.f
  EndStructureUnion
EndStructure
Global CamAngle.Vector
Macro getmodulo(v)
  v#\m=Sqr(v#\x*v#\x+v#\y*v#\y+v#\z*v#\z)
EndMacro
Procedure Rotate_3DVector_by_Angle_adding(*angle.Vector,*radius.Vector)
  Protected vel.Vector
  getmodulo(*radius):getmodulo(*angle)
  If *angle\Length
    ;Calculates the vectorial product of two 3D vectors *vel-> = *angle-> X *radius->
    vel\x=*angle\y**radius\z-*angle\z**radius\y
    vel\y=*angle\z**radius\x-*angle\x**radius\z
    vel\z=*angle\x**radius\y-*angle\y**radius\x
    ;Now do R_t-> = cos(|wt->|)·R_0-> + |R_0->|/|u->|·sin(|wt->|)·u->
    getmodulo(vel)
    *radius\x=Cos(*angle\Length)**radius\x+*radius\Length/vel\Length*Sin(*angle\Length)*vel\x
    *radius\y=Cos(*angle\Length)**radius\y+*radius\Length/vel\Length*Sin(*angle\Length)*vel\y
    *radius\z=Cos(*angle\Length)**radius\z+*radius\Length/vel\Length*Sin(*angle\Length)*vel\z
  EndIf
EndProcedure
Macro OrbitEntity(item,angle,cx,cy,cz,farfactor=1.0)
  nr.Vector
  nr\x=MP_CameraGetX(camera)-cx#:nr\y=MP_CameraGetY(camera)-cy#:nr\z=MP_CameraGetZ(camera)-cz#
  nr\x*farfactor#:nr\y*farfactor#:nr\z*farfactor#
  Rotate_3DVector_by_Angle_adding(@angle#,@nr)
  MP_PositionCamera(item#,nr\x+cx#,nr\y+cy#,nr\z+cz#)
EndMacro
MP_UseCursor(0)
Repeat
  MP_DrawText(1,25,"MP_EntityGetPitch(eye) = "+StrF(MP_EntityGetPitch(camera)))
  MP_DrawText(1,45,"MP_EntityGetYaw(eye) = "+StrF(MP_EntityGetYaw(camera)))
  MP_DrawText(1,65,"MP_EntityGetRoll(eye) = "+StrF(MP_EntityGetRoll(camera)))
  MP_DrawText(1,85,"MP_CameraGetX(eye) = "+StrF(MP_CameraGetX(camera)))
  MP_DrawText(1,105,"MP_CameraGetY(eye) = "+StrF(MP_CameraGetY(camera)))
  MP_DrawText(1,125,"MP_CameraGetZ(eye) = "+StrF(MP_CameraGetZ(camera)))
  If MP_KeyDown(#PB_Key_LeftControl)
    MouseWheel=-MP_MouseDeltaWheel()/1000+1
    mdx.f=MP_MouseDeltaX()/1000:mdy.f=MP_MouseDeltaY()/1000
    CamAngle\x=mdy
    CamAngle\y=mdx
    getmodulo(CamAngle)
    If CamAngle\m Or MouseWheel<>1.0
      OrbitEntity(camera,CamAngle,MP_EntityGetX(arrow),MP_EntityGetY(arrow),MP_EntityGetZ(arrow),MouseWheel)
      MP_CameraLookAt(camera,MP_EntityGetX(arrow),MP_EntityGetY(arrow),MP_EntityGetZ(arrow))
    EndIf
  EndIf
  MP_RenderWorld()
  MP_Flip()
Until MP_KeyDown(#PB_Key_Escape) Or WindowEvent()=#PB_Event_CloseWindow
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
mpz
Enthusiast
Enthusiast
Posts: 497
Joined: Sat Oct 11, 2008 9:07 pm
Location: Germany, Berlin > member German forum

Re: MP3D Engine Alpha 32

Post by mpz »

Hi Psychophanta,

you are my hero, looks greate :) I will check it an perhapst i can put these into my camera functions...

Greatings Michael
Working on - MP3D Library - PB 5.73 version ready for download
User avatar
N_Gnom
User
User
Posts: 76
Joined: Fri Sep 13, 2013 3:20 pm
Location: Germany

Re: MP3D Engine Alpha 32

Post by N_Gnom »

Can anybody help me to use the plasma.fx shader for a moving light over a meshterrain?

I don´t know how i have to use it in the simpliest way.

I have see the examples but its a little bit confusing.
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Re: MP3D Engine Alpha 32

Post by Psychophanta »

mpz wrote:Hi Psychophanta,

you are my hero, looks greate :) I will check it an perhapst i can put these into my camera functions...

Greatings Michael
Welcome!

Beware:
The sample I posted just adds the mousedelta to a 'x' which is 0 and to a 'y' which is also 0, this is, is limited and no good enough.
To make it much better, in the past I made in the Dreamotion engine this:

Code: Select all

CamAngle\x=*camera\rightAxis\x*mdy+*camera\upAxis\x*mdx
CamAngle\y=*camera\rightAxis\y*mdy+*camera\upAxis\y*mdx
CamAngle\z=*camera\rightAxis\z*mdy+*camera\upAxis\z*mdx
getmodulo(CamAngle)
...
instead of:

Code: Select all

CamAngle\x=mdy
CamAngle\y=mdx
getmodulo(CamAngle)
...
The issue is to manage mouse (2 only axis, X and Y) to move an entity (camera in this case) onto a spherical surface, this is, in a constant distance from a given point in space (x,y,z), so there would be necessary to know at any moment the relative X and Y values (vectors) from the camera to add the deltamouse values to them. It can be extracted from camera Roll, Yaw and Pitch but it would be a unnecessary calculation if the programmer had directly the cam relative X and Y vectors.
These vectors, in Dreamotion are:
*camera\rightAxis
and
*camera\upAxis
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
applePi
Addict
Addict
Posts: 1404
Joined: Sun Jun 25, 2006 7:28 pm

Re: MP3D Engine Alpha 32

Post by applePi »

Hi Michael
as i have replied Mythos here http://www.purebasic.fr/english/viewtop ... 59#p434899 today, there is a program called grape3D which its job is (( ((The software reconstructs a 3D model with corresponding texture from a 2D movie file. The resulting model can be imported in any 3D application like Blender, ZBrush©, Maya© or 3DS Max©))
so since MP3D can make a movie from a model, what is the possibilities to make a model from a 2D movie made from a camera for as an example a toy rotating slowly on a table.
Mythros
Enthusiast
Enthusiast
Posts: 306
Joined: Mon Aug 19, 2013 3:28 pm

Re: MP3D Engine Alpha 32

Post by Mythros »

Yes, yes, A MILLION TIMES, YES! We NEED an example EXACTLY like that, @applepi & @mpz! :) And it might help that it can download the textures from colored pixels as well! :D

Thank You both! :D
Post Reply