MP3D Engine Alpha 33

Applications, Games, Tools, User libs and useful stuff coded in PureBasic
vladimir
New User
New User
Posts: 7
Joined: Thu Sep 20, 2012 4:11 pm
Location: russia

Re: MP3D Engine Alpha 31

Post by vladimir »

Hello! Help please with an example, detection of collisions of two sprites, I tried to make itself, but it defines not so precisely.
Here my code

Code: Select all

;UsePNGImageDecoder()


;{
#width = 640 ; height wondow
#height = 480 ; width window
;}

MP_Graphics3D(#width,#height,32,2)
MP_VSync(1)
SetWindowTitle(0,"title")

player = MP_LoadSprite("player.bmp");player image 16x16
ground = MP_LoadSprite("ground.bmp"); ground image 640x32


groundx = 0
groundy = 400
playerX = 150
playery = 150
playerGrav = 5
collisionPlayer = #False



While Not WindowEvent()=#PB_Event_CloseWindow
    If collisionPlayer = #False
        playery + playerGrav
    EndIf
    If MP_SpritePixelCollision(ground,groundx,groundy,player,playerx,playery,0,1)
        collisionPlayer = #True
    Else 
        collisionPlayer = #False
    EndIf
    
    If MP_KeyDown(#PB_Key_Right)
        playerx +3
    ElseIf MP_KeyDown(#PB_Key_Left)
        playerx - 3
    EndIf
    
    If MP_KeyDown(#PB_Key_Up)
        collisionPlayer = #False
        playery - 15
    EndIf
    
    MP_DrawSprite(ground,groundx,groundy-MP_SpriteGetHeight(ground),0)
   MP_DrawSprite(player,playerx,playery,0)
    MP_RenderWorld()
    MP_Flip()
Wend
End
Here the program image
Image
Forgive for my bad knowledge of English
applePi
Addict
Addict
Posts: 1404
Joined: Sun Jun 25, 2006 7:28 pm

Re: MP3D Engine Alpha 31

Post by applePi »

Hi
your program works okay with me, the small square hit the ground and then stop upon collision.
here is the sprites for who may want to try the program
Image
Image
vladimir
New User
New User
Posts: 7
Joined: Thu Sep 20, 2012 4:11 pm
Location: russia

Re: MP3D Engine Alpha 31

Post by vladimir »

applePi wrote:Hi
your program works okay with me, the small square hit the ground and then stop upon collision.
here is the sprites for who may want to try the program
my images as your own, just as bmp :)
applePi
Addict
Addict
Posts: 1404
Joined: Sun Jun 25, 2006 7:28 pm

funny animated robot

Post by applePi »

i have found a funny animated robot (3ds file) in several freeware libraries for blitz3d , so i have converted it to directX "*.x" file using 3ds max with the Panda DirectX Exporter from http://www.andytather.co.uk/panda/direc ... loads.aspx
attached the example to show this model using MP3D library
you can download the model 3ds file, and directx file, textures, code from here (231 KB)
http://www.mediafire.com/?3mf23h9qqfsbs9s
Image

* the robot are downloaded from http://dev-ch.com/coding/devilengines
other place to download http://philippe.c.pagesperso-orange.fr/#GOM

Code: Select all

Global xres=640, yres=480
MP_Graphics3D (xres,yres,0,3)
SetWindowTitle(0, "animated sporty robots")
;MP_Wireframe(1)
camera=MP_CreateCamera()

light = MP_CreateLight(2)
light2 = MP_CreateLight(2)
MP_LightSetColor (light, RGB(255,255,255))
;MP_InitShadow()
Width=256
Height=256
robot = MP_LoadAnimMesh("mak4.x")
robot2 = MP_LoadAnimMesh("mak4.x")
robot3 = MP_LoadAnimMesh("mak_boss.x")
MP_ScaleEntity(robot,0.1,0.1,0.1)
MP_ScaleEntity(robot2,0.05,0.05,0.05)
MP_ScaleEntity(robot3,0.03,0.03,0.03)
MP_PositionEntity(robot,0,0,-3)
MP_PositionEntity(robot2,-3,0,-3)

texture3 = MP_CreateTextureColor(256, 256, RGBA(2, 100, 230, 1))
sphere = MP_CreateSphere(30)
MP_EntitySetColor(sphere,RGB(255,255,0))
MP_ScaleMesh(sphere,0.3,0.3,0.3)
;cone = MP_CreateCone(64, 10)
teapot = MP_CreateTeapot()
MP_EntitySetColor(teapot,RGB(0,255,0))
MP_PositionEntity(teapot, 0, 1, 0)
MP_ScaleMesh(teapot, 1, 1, 1)
MP_RotateEntity(teapot, 0, 0, 0)

plane = MP_CreatePlane(24, 24)
MP_PositionEntity(plane, 0, 0, 0)
MP_EntitySetTexture(plane, texture3)

MP_RotateEntity(plane, 0, 90, 90)

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

;MP_PositionEntity(light, 0, 10, 20)
MP_EntityLookAt(light,0,0,0)
MP_PositionEntity(light2, 10, 5, 10)
MP_LightSetColor (light2, RGB(255,255,255))

x.f : y.f = 2.5 :z.f: x2.f: y2.f = 2.5: z2.f: angle2.f = 40
x3.f: y3.f = 2.5: z3.f: angle3.f = 70
While Not MP_KeyDown(#PB_Key_Escape) And Not WindowEvent() = #PB_Event_CloseWindow
    
  angle.f + 0.7
  angle2 + 0.7
  angle3 + 0.7
  
  x = Cos(Radian(angle)) * 3: z = Sin(Radian(angle)) * 3
  x2 = Cos(Radian(angle2)) * 3: z2 = Sin(Radian(angle2)) * 3
  x3 =  Cos(Radian(angle3)) * 3: z3 = Sin(Radian(angle3)) * 3
   
  MP_PositionEntity(light, x , y, z)
  MP_PositionEntity(sphere, x , y, z)
  MP_PositionEntity(robot, x , 0, z)
  MP_PositionEntity(robot2, x2 , 0, z2)
  MP_PositionEntity(robot3, x3 , 0, z3)
  
  ;to turn the robots so its face will be the same as the
  ;tangent to the circle circumference (the robots orbit)
  MP_RotateEntity(robot, 0, -90, -angle)
  MP_RotateEntity(robot2, 0, -90, -angle2)
  MP_RotateEntity(robot3, 0, -90, -angle3)
  MP_EntityLookAt(light,0,0,0)
  MP_RenderWorld()
   
  MP_Flip ()

Wend
 
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 »

What is the differens between MP_EntityComputeNormals() and MP_EntitySetNormals()

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,

i was a little bit ill and had no times to answer in the last time, sorry...

At "vladimir" i will have a look on the collisions of two sprites, perhaps i will find a better "precisely" kind. i must check the mathematic routine...

At "applePi" , hey greate demo thanks
P.S. And yes i WILL make a better shadow function, sorry for the delay ;)

At Sveinung: Difference between: MP_EntityComputeNormals() and MP_EntitySetNormals()
There are no difference. I made a mistake, both functions use the same dx9 function:
http://msdn.microsoft.com/en-us/library ... 85%29.aspx
Thanks for the information, In the future version of mp3d i will delete one of these functions...

Greetings Michael
Working on - MP3D Library - PB 5.73 version ready for download
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 "vladimir",

the collision is "precisely". The last "1" of the function activate the debug mode
MP_SpritePixelCollision(ground,groundx,groundy,player,playerx,playery,0,1)
This means that a box around the box is shown (34x34 and not 32x32 like the sprite and 642x43 and not 640x32).
There you think the colision is not "precisely" but it is correct, because you see the box around the sprite...

the correct funktion is
MP_SpritePixelCollision(ground,groundx,groundy,player,playerx,playery,0)

and to show the sprite it is
MP_DrawSprite(ground,groundx,groundy); -MP_SpriteGetHeight(ground)) is wrong...
MP_DrawSprite(player,playerx,playery)

and not (...,0) for unseen sprites

the var -> playerGrav = 5 is not good, because the collison could have 5 pixel overlapped maximised. if you use
playerGrav = 1 you have maximises 1 pixel overlapped

i hope you find the information helpful,
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 »

As Michael returned, I also write.
Yes, 3D shadows are very strange (weird), I would like you to be something done to them.
And I have another problem: Ide does not see MP3D help and does not show the command in autocompletion. (Reinstalled several times PureBasic and MP3D.)
Again, the problem with sprites transparency, but it no hurry. Later, I'll write.
'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
vladimir
New User
New User
Posts: 7
Joined: Thu Sep 20, 2012 4:11 pm
Location: russia

Re: MP3D Engine Alpha 31

Post by vladimir »

Michael thanks, it helped me :)
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 Michael,
I wanted to write on your forum, but there is registration only for selected people so I will ask here.
I really miss commands to control the system of particles, such as:StartEmitter(Entity) StopEmitter(Entity).
I want to create an emitter (specify all features) and then, when necessary, enable and disable it.
Also, I would like to emitter (when in motion), left a "trail".
And the size of the particles, I would like to do less. Too big they are obtained.
To make it clearer, here's what I want to do (roughly).
http://www.youtube.com/watch?v=nBXItKydUGo
'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,

everyone can register and send then a message in my forum. If not there could only be a problem and i will solve it. What exactly is the problem? Do you can't register your name or cant send an message ?


In the mp3d_32 you will find much new particel commands like:

Code: Select all

3) New command: MP_ParticleEmitterStartTime(Entity, StartTime.f); Wait before ParticleEmitter starts
4) New command: MP_KillParticleEmitter(Entity, MaxParticle) ; killed ParticleEmitter after MaxParticle
14) problem with "old" particle Emmmiter solved, they did not send particles
15) new functions: particle Emmmiter has now 48 partice, 24 and the next 24 particle with halve size 
18) New command: MP_ParticleVarSize(Entity, Size.f) ; change the particle size over the particle livetime 
Do you think you need more functions and what could they do? I think you can use a oneshotemmiter for this and if you want to kill the emitter for the time you can use the MP_KillParticleEmitter command.

Your video look good.

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 »

The problem with the particle size, I decided - has increased the size of objects (tanks). Not what I wanted, well, okay.
I did emitters from oneshotemmiters for leave a trace with particles. Crooked but whatever.

Let me explain, I wrote my own particle system for sprites and it satisfies me completely. (It can be seen on the video.)
But I can not use it because that the command MP_SpriteSetZ () works for me is not right. I can set Z are 0 and 1, with other values ​​sprite is not visible. So I use yours.
I have some commands do not work properly, do not know why. For example MP_KeyHit () - sometimes works, sometimes not.
MP_KillParticleEmitter - not kill emitter it only limits the number of particles.

By the way, if you want, I can send you my system of particles maybe find something interesting.
'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,

if you send me your particle system i find a solution for the MP_SpriteSetZ problem. If you have a example for the MP_KeyHit () and MP_KillParticleEmitter() Problem i will solve the problems too. My engioen works with the response ( and time i did not have enough) of the users...

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 »

If other people are working normally there is no sense to send you the code. Then the problem is on my side.
I buy a new computer, I will reinstall everything, then we will see.
'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
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 »

everyone can register and send then a message in my forum. If not there could only be a problem and i will solve it. What exactly is the problem? Do you can't register your name or cant send an message ?
Sorry but you cannot register at this time because the administrator has disabled new account registrations.
P.S. Decided to try to enable the shadow. Got this "effect" :
Image Without shadows
Image With shadows
Image With shadows, after a couple of minutes.
'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