Monday, 27 December 2010

Developer Journal 24

* Storing position and orientation in physics object instead of data object
* Using physics object rotation to rotate force vector
* Capped agent linear velocity


I can't believe I took so long to fix the segmentation fault error yesterday. I should have realized that segmentation fault errors often involve pointers.

Sometimes I have to explain what I'm doing as briefly as I can and there are times when I have to go from a one sentence explanation to multiple sentences.

I've found that people find the he one sentence explanation, while brief, challenging to understand.

Do you start with the goal?

To create a robot capable of moving, communicating, and learning.

Do you start with the method?

What if you had 1000 robots? What if they had to learn to survive by themselves? What if these robots were shaped like us? What if they had our needs and limitations? What if they had face environments similar to ours? Would they develop in ways similar to we did? Would they learn to communicate and cooperate?

Working on simplifying use of position variable. The position variable is in three places, the data object, the physics object, and the graphics object.

There are a number of gotchas. When I add an object to the physics engine, the physics engine uses the position in the object. That means I have to set the object position before adding the object to the physics engine.

I could add code in the object to update the physics engine but then I would be integrating the physics engine into my object.

I could have a pointer to a physics object inside my data object but that will create problem with serialization.

I could update the physics engine with my data object position all the time but that seems wasteful.

Argh! I don't know what to do.

I think a good way is to add a defensive piece of code to remind me to set the position before adding to the physics engine.

What if I change the data object position but forget to tell the physics engine?

I can add a flag to my data object to tell the physics engine when it needs to synchronize with my data object.

Or I can add a check in the physics code to ensure that they match up. If performance is a problem, then I can change to a flag.

Then we get to the problem of orientation and making sure the data object and the physics object are synchronized.

I think I'd better add some physics code to the data object instead of trying to keep everything synchronized myself.

Problem is, I don't know how to get the orientation from the physics code in a way I can use to create a force vector.

It took a while but I finally found it in the bullet forum.

* apply a force/impulse relative to a rigidbody

I keep thinking that it'll be a good idea to write some basic OGRE and Bullet tutorials based on the things I've learned.

No comments:

Post a Comment