Visible rays

odyeiop

01-03-2007 04:19:00

I'm having problems orienting a RayCaster to the playerview in my game and was wondering if there is a way in debug that I can make it visible to see how it is oriented.

If not, perhaps you can help me with what I'm doing wrong in code.
- I have a Player class
- Inside the player is an Entity for the mesh, and a bp<character> for the Nx collision
- The Entity is attached to the same node as the NxCollision
- I go through the skeleton of the entity, and attach a camera to a bone in the head of the character (the character view).
- I use the orientation of the bone to set the direction of the raycaster
- the collision yaws side to side for the player view X
- the bone pitches up and down (with restrictions) for the player view Y
orient = player->getGCEntity()->getSkeleton()->getBone("ART_STICK_BONE_CAMERA")->getOrientation();
_dir = orient * Vector3(0,0,1);
_ori = player->getPlayerCollision()->mNode->getPosition();

mCaster->setOrigin(_ori);
mCaster->setDirection(_dir);


Sorry for all the newbishness lately, I've been trying to wrap this game up. When it's all done I'll make sure to post pics and (if I can) a video.

devachan

01-03-2007 17:46:27

Hi. to be able to see the ray I used the tutorials 305 of NxOgre and Physx. Betajaen occupies an entity "raycasterEnt", to show where it hits the ray. I put a circular wall around my body to see where it hits the ray.

This code update the ray, origin, direction and the entity "raycasterEnt" that draws the impact
centromasa = mbody->mActor->getCMassGlobalPosition();
mRayo->setOrigin(NxTools::convert(centromasa));

//update direction del rayo
NxMat33 m = mbody->mActor->getGlobalOrientation();
m.getColumn(0, dirRayo);
mRayo->setDirection(NxTools::convert(dirRayo));

if (mRayo->cast()) {
if (Vector3(mRayo->mDistance,mTargetLastPosition.y,mTargetLastPosition.z) != mTargetLastPosition) {
mTargetNodo->setPosition(mRayo->mHitPos);
mTargetLastPosition = mTargetNodo->getPosition();
}
}

I leave you a video and the wall if you want.

http://www.badongo.com/file/2352323

With some good view can see the ray hitting the wall :D

Ogre Dagon and NxOgre 0.4RC2

betajaen

01-03-2007 18:09:50

Nice video!, Is that the NxWheel class or a body joint body system for the wheels?

You could even use the code above as part of a small function that would generate a mesh using the manual object; so it can act like a laser beam.

devachan

01-03-2007 21:07:57

NxWheel class, I used like base the toby code :)

http://www.ogre3d.org/phpBB2addons/view ... sc&start=0

odyeiop

01-03-2007 22:52:46

Nice video!, Is that the NxWheel class or a body joint body system for the wheels?

You could even use the code above as part of a small function that would generate a mesh using the manual object; so it can act like a laser beam.

Wouldn't it be easier to use a particle (or string of particles) with a repeatable texture, or stretchable texture, and just have it go along, or stretch across, the ray? If you had a lifespan on them and fade to alpha, it could leave some pretty neat little effects to. Also, if you had it where it hits the wall, at the point where the ray stops you could add a smoke particle, and maybe some wall deco's to where it's burning in.

I managed to get it where the ray can yaw with the player, and shoot along his Y axis. The only problem I am now having, is that the Y angle doesn't change. If the character leans forward or backwards nothing happens.

Now, if I were to take the quaternion I'm using to move the Ray with the players yaw, and add the pivot bones orientation y (getOrientation().y), then multiply it by Vector(0,0,-1), would that work?

I would have thought that I would have been able to use JUST the orientation of the camera, but that is not the case. I'm guessing that it returns the local orientation, and as I'm not rotating it at any point (the node yaws, the bone pitchs) that the orientation is always the same.

Would it perhaps be easier to attach an Nx actor to the end of the gun, and then just use the convert tool?