tumbling dice
Blitz3D Forums/Blitz3D Programming/tumbling dice
| ||
I'm trying to create code to (roll, tumble) dice in 3D. However, the instructions that I use (RotateMesh, TurnMesh) both work in such a way : Stand in the center of an object, spin the object around you like the earth revolving around the sun. I don't want that kind of motion, but the type of motion I do want is when a person throws a dice onto a board! |
| ||
you have to move the camera a bit backward, to stand outside of the object:Graphics3D 800,600 dice=CreateCube() camera=CreateCamera() light1=CreateLight(1) MoveEntity camera, -3,3,-5 Repeat TurnEntity dice,Rnd(3,4),Rnd(3,4),Rnd(3,4) TranslateEntity dice,Rnd(-0.1,-0.2),0,Rnd(0.2,0.3) UpdateWorld RenderWorld Flip Until KeyHit(1) |
| ||
Thanks MM, How do you guys survive in this world. I'm barey struggling to pay the rent , the phone bill, etc. and you blitzers just give away free advice! One day, I hope I'lll be that good and wealthy to acheive the same effect. Do you mooch off of your girlfriends? |
| ||
I'm barey struggling to pay the rent , the phone bill, etc. and you blitzers just give away free advice! One day, I hope I'lll be that good and wealthy to acheive the same effect. you dont have to be wealthy to have knowledge. Do you mooch off of your girlfriends? I fail to see what that has to do with ANYTHING! but in general ask and you shall recieve as long as its reasonable and wont take much time. |
| ||
That's the joy of sitting in front of the screen staring at code... it costs nothing :) (alright, save for the electricity bill) But yeah, on creation, all the entities in B3D are created at 0,0,0 world-coords, including the camera, so it's always best to move the entities or camera right away :) |
| ||
You could improve it even more by using a Physics library (don't ask me which one =X ), because that would cause the dice to really spin around the point of collision with the table or whatever (like it happens in real life). |