Game Development Community

Static Mode AdvancedCamera question

by John Klima · in Torque Game Engine · 06/11/2005 (10:11 am) · 2 replies

Heya,

been mucking with the source for AdvancedCamera. using LookAtOffset as a guide, I created my own console method and datablock field called LookAtPoint. i can get it and set it from the console no problem.

my intent is to modify the static mode camera so i can set it's position, and also set the point that it will look at. so, using code in AdvancedCamera::setPosition() as a guide, i modified the "else" block (the static camera handler) to emulate the approach for the other camera modes which use an object to get a look at point.
this is the code for non-static modes:
// Set rotation to point at the tracked object
MatrixF transMat;
ShapeBase* obj = dynamic_cast<ShapeBase*>(static_cast<SimObject*>(mPlayerObject));
if (obj && mMode != StaticMode) {
	Point3F objPos;
	getLookAtPos(&objPos);

	VectorF dirVec = objPos - tPos;
	dirVec.normalize();

	MathUtils::getAnglesFromVector(dirVec, mRot.z, mRot.x);
	mRot.x = 0 - mRot.x;

	transMat = MathUtils::createOrientFromDir(dirVec);

okay, no problem, i get it. so below that, this is my modified static mode code:

} else {

	//Set rotation to point at my current look point
	//just a re-work of other modes to use my point

	VectorF dirVec = mCurrentLookAtPoint - tPos;
	dirVec.normalize();

	MathUtils::getAnglesFromVector(dirVec, mRot.z, mRot.x);
	mRot.x = 0 - mRot.x;

	transMat = MathUtils::createOrientFromDir(dirVec);

                //old static mode code
	//MatrixF xRot, zRot;
	//xRot.set(EulerF(mRot.x, 0, 0));
	//zRot.set(EulerF(0, 0, mRot.z));
	//transMat.mul(zRot, xRot);
		

}

transMat.setColumn(3, tPos);
Parent::setTransform(transMat);

i have a member var mCurrentLookAtPoint that is getting set just fine. in the above block for static camera, i am using the same code as for the other modes, except i replace the object position used by the other modes with my member variable.

in the console if i set the camera position to "0 0 300" and set mCurrentLookAtPoint to "0 0 0", the camera should be looking straight down. problem is, it doesn't. stranger still is that no matter what i set mCurrentLookAtPoint to, nothing happens. i would at least expect SOME change even if my math is wrong. but i get no change in camera angle what-so-ever. what the heck am I missing??

thanks!
j

#1
06/11/2005 (11:53 am)
Ahhh, i see. though i thought i was thorough, i neglected to ::writePacketData and ::readPacketData for my new member variable. so although in the console my set/getLookAtPoint seemed to be working just fine, because i failed to read/write my new datablock field to the server, nothing was happening. hmm, very interesting this.

sorry for answering my own post. i do try to exhaust possibilities before i post, but not accustomed to always thinking in terms of client/server, the net ops slipped by.
j
#2
06/11/2005 (1:27 pm)
Ahhh, i see. though i thought i was thorough, i neglected to ::writePacketData and ::readPacketData for my new member variable. so although in the console my set/getLookAtPoint seemed to be working just fine, because i failed to read/write my new datablock field to the server, nothing was happening. hmm, very interesting this.

sorry for answering my own post. i do try to exhaust possibilities before i post, but not accustomed to always thinking in terms of client/server, the net ops slipped by.
j