예제 #1
0
///////////////////////////////////////////////////////////////////////
// Class				:	CXform
// Method				:	translate
// Description			:	Append a translation. Note that the last
//							specified transformation is applied first
// Return Value			:	-
// Comments				:
void	CXform::translate(float dx,float dy,float dz) {
	matrix	tmp,tmp2;

	translatem(tmp,-dx,-dy,-dz);
	mulmm(tmp2,tmp,to);
	movmm(to,tmp2);

	translatem(tmp,dx,dy,dz);
	mulmm(tmp2,from,tmp);
	movmm(from,tmp2);
}
예제 #2
0
// Update the position matrices, and
// update the world-space bounding box and hotspots.
// This is called once whenever the gate's position
// or angle changes.
void guiGate::updateBBoxes(bool noUpdateWires) {
	// Get the translation vars:
	float x, y;
	this->getGLcoords(x, y);

	// Get the angle vars:
	istringstream iss(gparams["angle"]);
	GLfloat angle;
	iss >> angle;

	loadidentitym(mModel);
	translatem(mModel, x, y);
	rotatem(mModel, angle);

	// Update all of the hotspots' world coordinates:
	map< string, gateHotspot* >::iterator hs = hotspots.begin();
	while(hs != hotspots.end()) {
		(hs->second)->worldLocation = modelToWorld((hs->second)->modelLocation);
		(hs->second)->calcBBox();
		hs++;
	}

	// Convert bbox to world-space:
	klsBBox worldBBox;
	worldBBox.addPoint(modelToWorld( modelBBox.getTopLeft()    ) );
	worldBBox.addPoint(modelToWorld( modelBBox.getTopRight()   ) );
	worldBBox.addPoint(modelToWorld( modelBBox.getBottomLeft() ) );
	worldBBox.addPoint(modelToWorld( modelBBox.getBottomRight()) );
	this->setBBox(worldBBox);

	// Update the connected wires' shapes to accomidate the new gate position:
	map < string, guiWire* >::iterator connWalk = connections.begin();
	while(!noUpdateWires && connWalk != connections.end()) {
		(connWalk->second)->updateConnectionPos(this->getID(), connWalk->first);
		connWalk++;
	}
}