[Git]Cant use Vector2 fields in an NxOgre::Vec3 when Raycast

KyleKatarn

25-11-2009 01:16:23

*Raycasting
=========
Hello again, friendly NxOgre community.

We've finally figured out jumping and raycasting and whatnot (courtesy of my teammate Danoli3), now we've hit a snag, it seems when we jump into a wall, while moving forward, the downward motion of gravity is not being applied at all, just the forward motion. I figured we could use another raycast, shot from the players orientation and when it hits a wall, we set the linear velocity to 0.

NxOgre::Vec3 playerPos( pPhysicsBody->getGlobalPosition() );
NxOgre::RaycastHit pRayResult = pPhysScene->raycastClosestShape( NxOgre::Ray( playerPos, NxOgre::Vec3( this->getFacing().x, 0, this->getFacing().y )), NxOgre::Enums::ShapesType_Static );


this->getFacing() returns an Ogre::Vector2 of the players current orientation based off the mesh, because I've frozen all rotations on the physics body.

Anyway, the above generate an error:

Error 1 error C2228: left of '.x' must have class/struct/union c:\cpp-y2\code\visual studio 2008\ogre\mall rush\dependencies\nxogre\sdk\NxOgreVec3.h 63 Player
Error 2 error C2228: left of '.y' must have class/struct/union c:\cpp-y2\code\visual studio 2008\ogre\mall rush\dependencies\nxogre\sdk\NxOgreVec3.h 63 Player
Error 3 error C2228: left of '.z' must have class/struct/union c:\cpp-y2\code\visual studio 2008\ogre\mall rush\dependencies\nxogre\sdk\NxOgreVec3.h 63 Player


Is this because I'm not supposed to use Vector2 fields in Vec3? If so, what would be a better practice? I have tried to port over the Vector2 to a Vector3 and I got the same error:

NxOgre::Vec3 playerPos( pPhysicsBody->getGlobalPosition() );
Ogre::Vector3 playerFacing( this->getFacing().x, 0, this->getFacing().y );
NxOgre::RaycastHit pRayResult = pPhysScene->raycastClosestShape( NxOgre::Ray( playerPos, NxOgre::Functions::XYZ<Ogre::Vector3, NxOgre::Vec3>(playerFacing)), NxOgre::Enums::ShapesType_Static );


This is particularly mindblowing because it should work.

Any suggestions?

deshan

25-11-2009 03:44:07

Have you tried to compile it without this line
NxOgre::RaycastHit pRayResult = pPhysScene->raycastClosestShape( NxOgre::Ray( playerPos, NxOgre::Vec3( this->getFacing().x, 0, this->getFacing().y )), NxOgre::Enums::ShapesType_Static );

if it gives the same error that means error is from somewhere else

as i know this is really fine
Ogre::Vector2 x;
NxOgre::Vec3 a( x.x, 0, x.y );

KyleKatarn

25-11-2009 04:01:50

When I comment out the line, it compiles fine. And yeah, thats what I thought, I mean, I do it all the time without a single error.

KyleKatarn

27-11-2009 15:22:01

I hate to be pushy, but I really need help on this. Am I using the raycast wrong?