Page 14 of 71
Re: MP3D Engine Alpha 31
Posted: Thu Sep 20, 2012 4:31 pm
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

Forgive for my bad knowledge of English
Re: MP3D Engine Alpha 31
Posted: Fri Sep 21, 2012 9:55 am
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

Re: MP3D Engine Alpha 31
Posted: Fri Sep 21, 2012 7:08 pm
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

funny animated robot
Posted: Sat Sep 22, 2012 11:08 am
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
* 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
Re: MP3D Engine Alpha 31
Posted: Sat Sep 22, 2012 3:37 pm
by Sveinung
What is the differens between MP_EntityComputeNormals() and MP_EntitySetNormals()
Regards
Sveinung
Re: MP3D Engine Alpha 31
Posted: Mon Oct 01, 2012 1:41 pm
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
Re: MP3D Engine Alpha 31
Posted: Mon Oct 01, 2012 3:31 pm
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
Re: MP3D Engine Alpha 31
Posted: Tue Oct 02, 2012 11:58 am
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.
Re: MP3D Engine Alpha 31
Posted: Thu Oct 04, 2012 12:39 am
by vladimir
Michael thanks, it helped me

Re: MP3D Engine Alpha 31
Posted: Mon Oct 08, 2012 11:13 pm
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
Re: MP3D Engine Alpha 31
Posted: Tue Oct 09, 2012 8:35 am
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
Re: MP3D Engine Alpha 31
Posted: Tue Oct 09, 2012 9:31 am
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.
Re: MP3D Engine Alpha 31
Posted: Tue Oct 09, 2012 11:16 am
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
Re: MP3D Engine Alpha 31
Posted: Tue Oct 09, 2012 4:23 pm
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.
Re: MP3D Engine Alpha 31
Posted: Wed Oct 10, 2012 4:51 pm
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" :

Without shadows

With shadows

With shadows, after a couple of minutes.