# normals

Hello,

We’re working with some kids for a summer camp (9th and 10th graders) and they are creating a snowboarding and a soccer game…all in one week. We have the soccer game running, and they are about to start the snowboarding game.

Normally we’d try to go through all the documentation, etc. but we need a quick answer on taking the normal from the terrain and applying it to our character in order to have the character “tilted” the correct amount when going down the slope. We’re using collission detection, so if it’s the collision normal, then we just need to know how to apply it to the character in order to get the right orientation for going down the hill. Is there a a trivial solution to this? If not, then we’ll have to come up with a work around, but any help would be much appreciated by the Ohio Supercomputing Center.

Thanks,

Brian

You can try:

``````
actor.headsUp(actor.getPos() + Vec3(0, 1, 0), normal)``````

This call causes the actor to rotate so that its Z axis is aligned with the “up” vector specified by the second parameter, and its Y axis is aligned as nearly as possible given the Z constraint with the “forward” vector implied by the first parameter - self.getPos().

It is similar to lookUp() except that the preference is to align the Z axis before the Y axis.

David

Hi David,

Thanks for the help. I do have a few more questions about how headsUp works. is it over writing the Pos value for my actor when it’s called? The problem I’m now running into is that I can get the character to follow the terrain, but I can’t get it to turn left or write. We’re using the Roaming Ralph code to everything to work, so we’re using the following code for turning…

if (self.keyMap[“left”]!=0):
self.ralph.setH(self.ralph.getH() + elapsed*300)

We can get the character currently facing one direction, and that’s it. If I hold down the right arrow and the forward arrow, it seems to be going every so slightly left or right according to the arrow. I think I’m just not sending part of the code at the right time or not updating something properly.

On another note, the kids did get their soccer project working. 3 9th/10th graders and about 5 days for planning, motion capture, texture mapping, and code. Once the summer camp is over this week, is there a place where we can stick the code as an example for other people? Not the most intricate game, but for a couple of 15 year olds and less than a week, it’s not bad.

Thanks again for the help.

Brian

The headsUp() call will not overwrite the pos value, but it will overwrite your hpr value. So you will probably be best off creating an intervening node, for instance a parent node, that you call headsUp() on, and then do setHpr() on the child node.

I don’t have any great ideas for places to park your sample code, though it does sound like a great thing to provide for the community. Maybe one of these free file storage sites would host it for you?

David