Mouvement and Collision Detection

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Sparks
Posts: 19
Joined: Thu Oct 21, 2004 1:30 am
Location: Montreal

Mouvement and Collision Detection

Post by Sparks »

Hi all,

** before I start I want to point out that I did read both tutorials on the subjects of my thread, and I still cant find answers to my question. **

I want to make a little demo, nothing complex, just a ball bouncing around in a bigger Cube

My knowledge of Irrlicht being pretty limited, I made the cube and ball with milkshape ( and that was pretty hard, first time I used milkshape ). So I import my models and my textures, that works great.

Mouvement & Collision that's where things are getting hard.

I dont wanna re-invent the wheel, so I try to use as much of Irrlicht as possible.

So I use a flyStraightAnimator for my ball ( I dont know how to do anything else ;P ). Now the question as simple as it may be is :

"How do I get the next position of the FlyStraightAnimator to pass it to the SceneCollisionManager?"

When I will be able to get the collision I figure i'm going to flip the FlyStraightAnimator.

*** If there is a better way to do this, dont be shy to tell me :), I try with the node set and get position but it did not work ***

thanks

Sparks
XL Game Development
Sparks
Posts: 19
Joined: Thu Oct 21, 2004 1:30 am
Location: Montreal

Post by Sparks »

ok, so I did some research and found that I have to add a ISceneNodeAnimatorCollisionResponse. So that's what I want to do, but when I try to add it, I need a selector like the one in the tutorial, but my map is not a bsp it's a milkshape file. So how can i get the triangles from the milkshape file?
XL Game Development
jikbar
Posts: 62
Joined: Wed Aug 25, 2004 4:48 pm
Location: Canada
Contact:

Post by jikbar »

ITriangleSelector* sel = smgr->createTriangleSelector(yourCubeMesh, yourCubeNode);
yourCubeNode->setTriangleSelector(sel);

if yourCubeMesh is an IAnimatedMesh* then it should be yourCubeMesh->getMesh(0); instead
Sparks
Posts: 19
Joined: Thu Oct 21, 2004 1:30 am
Location: Montreal

Post by Sparks »

Ahhhh!! that solves my problem, I was trying the getmesh() on the node instead of the AnimatedMesh.... So that works great, I added my animator to my ball, now i'm looking into catching the collision but the getCollisionPoint is asking me for a line... do I have to predict my balls next position? and set that line to it?

For now the ball keeps going pass the wall, never stop for the collision. so I guess I should catch the collision

Ok I did some tests, I removed the flystraight animator and the ball falls to the floor, wich is good because it collides with the floor but bad because I cant use the flystraight animator on my ball.

So let'S say I want to move my ball, can I give it a vector, or a acceleration or something?
XL Game Development
Sparks
Posts: 19
Joined: Thu Oct 21, 2004 1:30 am
Location: Montreal

Post by Sparks »

So after more research, I have found that: maybe a good way to move an object is with the setposition() of the node. I don't really know if it's the best way to do it. But since the number of responces to this thread is pretty low, well that's the way i'm going to go ( for now ).

Ok, so assuming I'm using the setPosition with a core::vector3df; i'm basically gonna give my ball a position. Now, of course, I want to move my ball. Basic physics tells me that moving my ball is done over time, and a change in mouvement over time is called speed or velocity, and a change in velocity over time is acceleration.

Now i'm not gonna need more physics than that. So I'm thinking of making a singleton physics class, with and observer for the elements that are affected by the physics.

so basically i'm gonna have a method, that let's me set a velocity to and object and another method who renders the physics over time. I'm gonna try that out to see what happens

Comments, ideas, suggestion are all welcome feel free to answer, because talking to myself is not all that fun.

note: I dont want to use a physics engine, because I believe it's overkill for ball mouvement. I also think that I have more to learn from coding my own physics than using someone elses.
XL Game Development
Post Reply