Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


Mind Calamity

Member Since 23 Dec 2010
Offline Last Active Jul 02 2013 07:33 AM

Topics I've Started

Vector/Quaternion help - pitch bone to direction vector

17 June 2013 - 12:33 PM

Hello, so I'm having a problem making my character look down. I'm using the OGRE3D as my rendering engine, and the math facilities it provides.

What I need to do is basically determine the amount of pitch needed to get the bone to the same direction as my crosshair/camera direction.

// mDirection is the direction of the character
Vector3 boneDir = getBoneWorldOrientation(mEntity, mHips) * mDirection;
// This is the direction of the crosshair
 Vector3 dir = mCameraTrans->_getDerivedDirection();
Quaternion rot = boneDir.getRotationTo(dir);

// The code below has been taken from the sinbad character controller and adapted to pitch, instead of yaw
Real pitchToGoal = rot.getPitch().valueDegrees();
Real pitchAtSpeed = pitchToGoal / Ogre::Math::Abs(pitchToGoal) * timeSinceLastUpdate * 100.0f;
if (pitchToGoal < 0) pitchToGoal = std::min<Real>(0, std::max<Real>(pitchToGoal, pitchAtSpeed)); //yawToGoal = Math::Clamp<Real>(yawToGoal, yawAtSpeed, 0);
else if (pitchToGoal > 0) pitchToGoal = std::max<Real>(0, std::min<Real>(pitchToGoal, pitchAtSpeed)); //yawToGoal = Math::Clamp<Real>(yawToGoal, 0, yawAtSpeed);
 mHips->pitch(Degree(pitchToGoal));
The above code has been adapted from multiple sources and somewhat works, but only on one axis. I know I'm probably doing some horrible things to the math related to this, so I appreciate any tips and pointers. :)
 
Unfortunately I'm not that good with Vector/Quaternion math, and I get the following bug:
Here's a YouTube video showasing the problem (I didn't find a way to embed it into the post): https://www.youtube.com/watch?v=IwUpzEE3uwI
It seems to work properly on +Z, it's shaking a bit on -Z, and it just continues to rotate on +X/-X.
 
I also posted on the OGRE3D forums, and am mirroring the post here to increase my chance of a reply.
 
For any future Googlers that happen to stumble upon this post, here's the link just in case: http://ogre3d.org/forums/viewtopic.php?f=2&t=78213
 
Note to moderators: If you think the Math and Physics is more appropriate, please move it there. smile.png

Can't seem to bind a class - Compile errors.

30 January 2013 - 04:53 PM

Hello, I've been struggling with registering/binding my class with AngelScript for the past few days, and I've went over the documentation a fair amount of times, but I haven't figured out the problem. I have a class like this:

 

class ENGINE_EXPORT GameObject : public Object
{
	friend class Level;
public:
	GameObject(uint32 id, String name, bool isStatic = false);
	int			addRef();
	int			release();
	
protected:
	~GameObject();
	Level*	mCreator;

	int mRefCount;
};

 

And I'm registering it like this:

void bindGameObject(asIScriptEngine* engine)
{
	int r;
	r = engine->RegisterObjectType("GameObject", 0, asOBJ_REF);
	r = engine->RegisterObjectBehaviour("GameObject", asBEHAVE_ADDREF, "void f()", asMETHOD(GameObject, addRef), asCALL_THISCALL); assert( r >= 0 );
	r = engine->RegisterObjectBehaviour("GameObject", asBEHAVE_RELEASE, "void f()", asMETHOD(GameObject, release), asCALL_THISCALL); assert( r >= 0 );
	r = engine->RegisterObjectMethod("GameObject", "const string& getName()", asMETHOD(GameObject, getName), asCALL_THISCALL); assert( r >= 0 );
}

 

 

The game objects are created by a class "Level" which is registered like so:

void bindLevel(asIScriptEngine* engine)
{
	engine->RegisterObjectType("Level", 0, asOBJ_REF | asOBJ_NOHANDLE);

	int r = engine->RegisterObjectMethod("Level", "void createSky()", asMETHOD(Level, createSky), asCALL_THISCALL); assert( r >= 0 );
	r = engine->RegisterObjectMethod("Level", "const string& getName()", asMETHOD(Level, getName), asCALL_THISCALL); assert( r >= 0 );
	//r = engine->RegisterObjectMethod("Level", "bool getGameObject(const string &in, GameObject &out)", asMETHODPR(Level, getGameObject, (const String&, GameObject&), bool), asCALL_THISCALL); assert (r >= 0);
	r = engine->RegisterObjectMethod("Level", "const GameObject @+ getGameObject(const string &in name)", asMETHOD(Level, getGameObject), asCALL_THISCALL); assert( r >= 0 );
	//	int r = engine->RegisterObjectMethod("")
}

 

The problem is with the getGameObject function, it's declared on the C++ like this:

// String is just a typedef of std::string.
GameObject* getGameObject(const String& name);

 

And in my actual script I have this:

void testGet()
{
	GameObject@ obj = level.getGameObject("CamObj");
}

 

But I get "Error Compiling void testGet()".

 

Any ideas as to where my problem is ? (Sorry for the spammy code)

 

BTW - The addRef and release functions are taken from the Game sample, as is the way of registering.


Wipeout/F-Zero-like Dynamics ?

17 February 2012 - 12:50 PM

Hi, guys!

I'm trying to do a game like F-Zero/Wipeout, and I have no idea where to start on the physics/game dynamics, I tried with Bullet and applying force/impulse while a key is pressed.

That sort of worked, but it's far from playable, so I'm thinking of abandoning Bullet for a collision detection-only library (like Minimal OGRE Collision) (or using only Bullet's collision-detection facilities) and coding my own dynamics, now trouble is - I have no idea how to actually make the dynamics I mean that hovery effect Wipeout has, or smooth turning around corners and tilting the craft among others...

So what I need is hints and tips on:
  • Keeping the craft hovering (but not a static Y-only hover - see video below)
  • Tilting the craft while turning and making the turns smooth
  • Any other information about making the gameplay dynamics Wipeout-like
This is the first time I'm doing something like this so any help is much appreciated.

Here's what I'd like the gameplay to be like:
http://www.youtube.com/watch?v=PnCn3yra2jQ

Any help is greatly appreciated!

I will post a video and code from my Bullet progress later.

OGRE Forums mirror - just in case anyone needs something like this in the future and stumbles upon this.

Spectrum Analysis with SFML

20 November 2011 - 09:59 AM

As I already said in the description, feel free to suggest free/opensource (or at least free for commercial use) libraries that preferably offer functions such as FMOD's getSpectrum(), or BASS' GetChannelData() (+ BASS_DATA_FFT2048).

I've tried BASS and FMOD, and their spectrum retrieval functions work perfectly, but the problem is my application is going to be commercial, and I literally have no budget.

The quote below is from my original post on the SFML forums.

So, I've been trying to make an application that needs spectrum analysis, and not paying $200+ (or 6000 in the case of FMOD), so after a bit of researching I concluded that SFML will probably be the best choice for me, so now the problem is: How ?

I have no idea how to do it, all I know is I need to implement the FFT algorithm and use it with the sound buffer samples, or so I read in a thread similar to mine, to be precise it said:

1. Get playing offset
2. Get small amount of samples starting from that offset
3. Use FFT on those samples
4. Visualize


Does anyone have any idea how to do that ?

I've been thinking of using FFTW for FFT, but it's C, which I don't really like, and it seems like it's pretty tricky to compile with VS, I also found FFTReal, which is C++, but I still have no idea how to use it, as it has no tutorials, nor documentation, so yeah...

I'm open to suggestions, also if anyone is going to suggest another library, I need it to be free for commercial use.


MP3 Licensing

17 November 2011 - 11:56 PM

So, whatever audio library I choose to use, FMOD, BASS, irrKlang, etc...

They all seem to "require" the same thing for MP3s, a license, so, since my game is to be a no-budget, (probably) non-commercial game, it doesn't make any sense for me to just burn $2500, and I got the idea to convert the files to .ogg.

If I do so, will I be infringing the MP3 license ?

PARTNERS