TransformFrame * DotaAnimParser::newKeyframes(int zOrder, unsigned char opacity,
											  float x, float y, float skX, 
											  float skY, float scX, float scY, 
											  const std::string& sound)
{
	TransformFrame *frame = new TransformFrame();
	frame->duration = (int)(round(1 * 1000.f / _frameRate));
	if (!sound.empty())
		frame->sound = sound;

	frame->visible = true;
	// NaN:no tween, 10:auto tween, [-1, 0):ease in, 0:line easing, (0, 1]:ease out, (1, 2]:ease in out
	frame->tweenEasing = AUTO_TWEEN_EASING;
	frame->tweenRotate = 0;
	frame->tweenScale = true;
	frame->displayIndex = 0;
	frame->zOrder = zOrder;

	setTransform(frame->global, x, y, skX, skY, scX, scY);
	setPivot(frame->pivot, 0, 0);

	// copy
	frame->transform = frame->global;
	frame->scaleOffset.x = 0.f;
	frame->scaleOffset.y = 0.f;

	if (opacity != 255)
	{
		frame->color = new ColorTransform();
		setColorTransform(*frame->color, opacity);
	}

	return frame;
}
HRESULT cameraManager::init(float minX, float minY, float maxX, float maxY)
{
	// 기본설정
	setPivot(0.5f, 0.5f);
	RECT rt = RectMake(0, 0, WINSIZEX, WINSIZEY);
	setSize(static_cast<float>(rt.right), static_cast<float>(rt.bottom));
	setPos(getHalfSize().width, getHalfSize().height);

	_minX = minX;
	_minY = minY;
	_maxX = maxX;
	_maxY = maxY;

	return S_OK;
}
예제 #3
0
 void SymbolElement::setTransformation(const math::Matrix<double, 3, 3> & m)
 {
   setPivot(pivot() * getResetMatrix() * m);
   BaseT::setTransformation(m);
 }
예제 #4
0
파일: Arrow2D.cpp 프로젝트: jepessen/wplot
/**
 * Set line coordinates.
 *
 * @param[in] x1 Initial point X coordinate.
 * @param[in] y1 Initial point Y coordinate.
 * @param[in] x2 Final point X coordinate.
 * @param[in] y2 Final point Y coordinate.
 */
void Arrow2D::setLine(const double &x1, const double &y1, const double &x2, const double &y2) {
	setPivot(x1, y1);
	setFinalPoint(x2, y2);
}
예제 #5
0
파일: Arrow2D.cpp 프로젝트: jepessen/wplot
/**
 * Set line coordinates.
 *
 * @param[in] initialPoint Initial point coordinates.
 * @param[in] finalPoint Final point coordinates.
 */
void Arrow2D::setLine(const QPointF &initialPoint, const QPointF &finalPoint) {
	setPivot(initialPoint);
	setFinalPoint(finalPoint);
}
예제 #6
0
int GOConstraint::methodsBridge(lua_State* luaVM) {
	if (isCurrentMethod("getFullID")) {
		lua_pushstring(luaVM, id.c_str());
		return 1;
	}
	if (isCurrentMethod("setPivot")) {
		setPivot(CVector(lua_tonumber(luaVM, 1), lua_tonumber(luaVM, 2), lua_tonumber(luaVM, 3)));
		return 0;
	}
	if (isCurrentMethod("getPivot")) {
		luaPushVector(luaVM, getPivot().x, getPivot().y, getPivot().z);
		return 1;
	}
	if (isCurrentMethod("getConstraintType")) {
		lua_pushinteger(luaVM, getConstraintType());
		return 1;
	}
	if (isCurrentMethod("setSecondObject")) {
		if (lua_isnil(luaVM, 1)) {
			setSecondObject(NULL);
			return 0;
		}
		lua_pushstring(luaVM, "cpointer");
		lua_gettable(luaVM, -2);
		PhysicObject* o = (PhysicObject*)lua_tointeger(luaVM, -1);
		setSecondObject(o);
		lua_pop(luaVM, -1);
		return 0;
	}
	if (isCurrentMethod("getSecondObject")) {
		if (getSecondObject() == NULL || getSecondObject()->getObjectID() == "") {
			lua_pushnil(luaVM);
		}
		lua_getglobal(luaVM, getSecondObject()->getObjectID().c_str());
		return 1;
	}
	if (isCurrentMethod("setSecondPivot")) {
		setSecondPivot(CVector(lua_tonumber(luaVM, 1), lua_tonumber(luaVM, 2), lua_tonumber(luaVM, 3)));
		return 0;
	}
	if (isCurrentMethod("getSecondPivot")) {
		luaPushVector(luaVM, getSecondPivot().x, getSecondPivot().y, getSecondPivot().z);
		return 1;
	}
	if (isCurrentMethod("setSecondObjectID")) {
		string objid = lua_tostring(luaVM, 1);
		PhysicObject* obj = (PhysicObject*)Game::instance->mapManager->findByID(objid);
		setSecondObject(obj);
		return 0;
	}
	if (isCurrentMethod("getSecondObjectID")) {
		if (getSecondObject() == NULL) {
			lua_pushstring(luaVM, "");
			return 0;
		}
		lua_pushstring(luaVM, getSecondObject()->getObjectID().c_str());
		return 1;
	}


	return LuaBridge::methodsBridge(luaVM);
}
예제 #7
0
task main()
{
	initializeRobot();

	int x1, y1, x2;
	int threshold = 8;
	int liftPrecisionFactor = 0;
	//int pivotSet = 0;

	waitForStart();

	/*
	Encoder demo
	while (nMotorEncoder [frontLeft] < driveEncoderCycle)
	{
	motor [frontLeft] = 12 * autoDriveScale;
	}
	motor [frontLeft] = 0 * autoDriveScale;
	*/

	//run loop
	while (1)
	{
		//joystick refresh
		getJoystickSettings(joystick);

		//lift precision factor - manual control of value
		if (joy2Btn(1) == 1) {
			liftPrecisionFactor += 5;
			while (joy2Btn(1) != 0)
			{
			}
		}
		else if (joy2Btn(3) == 1) {
			liftPrecisionFactor -= 5;
			while (joy2Btn(3) != 0)
			{
			}
		}

		//lift precision factor - automatic control of bounds
		if (liftPrecisionFactor <= 0) {
			liftPrecisionFactor = 0;
		}
		else if (liftPrecisionFactor >= 100) {
			liftPrecisionFactor = 95;
		}

		//drive code
	x1 = (abs(joystick.joy1_x1) > threshold) ? ((joystick.joy1_x1 * manualDriveScale) * 0.75) : 0;
	y1 = (abs(joystick.joy1_y1) > threshold) ? ((joystick.joy1_y1 * manualDriveScale) * 0.75) : 0;
	x2 = (abs(joystick.joy1_x2) > threshold) ? ((joystick.joy1_x2 * manualDriveScale) * 0.75) : 0;

		motor [frontLeft] = y1 + x2 + x1;
		motor [frontRight] = y1 - x2 - x1;
		motor [rearLeft] = y1 + x2 - x1;
		motor [rearRight] = y1 - x2 + x1;
		//pivot control
		if (joystick.joy2_y1 > 110 || joystick.joy2_y2 > 110)
			if (pivotTarget < 1000)
		{
			pivotTarget += pivotIncrement;
			setPivot(pivotTarget/1000.0);
		}
		if (joystick.joy2_y1 < -110 || joystick.joy2_y2 < -110)
			if (pivotTarget > 0)
		{
			pivotTarget -= pivotIncrement;
			setPivot(pivotTarget/1000.0);
		}
		//arm control
		if (joy2Btn(5) == 1) {
			motor [lift] = 100 - liftPrecisionFactor;
		}
		else if (joy2Btn(7) == 1) {
			motor [lift] = -100 + liftPrecisionFactor;
		}
		else {
			motor [lift] = 0;
		}
		if (joy2Btn(6) == 1)
		{
			motor [arm] = -50;
		}
		else if (joy2Btn(8) == 1)
		{
			motor [arm] = 50;
		}
		else
		{
			motor [arm] = 0;
		}
		if (joystick.joy2_TopHat == 6)
		{
			servo [leftHook] = 22;
			servo [rightHook] = 209;
		}
		else if (joystick.joy2_TopHat == 2)
		{
			servo [leftHook] = 255;
			servo [rightHook] = 0;
		}
		if (joystick.joy2_TopHat == 4)
		{
			servo [spinner] = 255;
		}
		else if (joystick.joy2_TopHat == 0)
		{
			servo [spinner] = 0;
		}
		else if (joy2Btn(2) == 1 || joy2Btn(4) == 1)
		{
			servo [spinner] = 128;
		}
		if (joy1Btn(10) && joy2Btn(10))
		{
			servo [guiderDrop] = 0;
		}
		//if (joy2Btn(4) == 1)
		//{
		//	if (pivotSet == 0)
		//	{
		//		servo [pivot] = 255;
		//		pivotSet = 1;
		//	}
		//	else if (pivotSet == 1)
		//	{
		//		servo [pivot] = 0;
		//		pivotSet = 0;
		//	}
		//}
	}
}
예제 #8
0
void Vehicle::initialize(btDiscreteDynamicsWorld &dynamicsWorld_in)
{		
	
//	SceneObject *nullObj;
	if (!cmap_obj)
	{
		cmap_obj = new Mesh;
		cmap_obj->cloneStructure(*obj);
	}



#ifndef ARCH_PSP
#ifndef OPENGL_ES
#ifndef ARCH_DC
	cmap_obj->triangulate();
#endif
#endif
#endif
	
	
	cmap = new CollisionMap;
	cmap->addMesh(*cmap_obj);
	
	colShape = cmap->makeCollisionShape(mass);

//	if (wheelObj)
//	{
//		// front left
//		wheelRef[0].bind(*wheelObj);
//		wheel[0].bindChild(wheelRef[0]);
//		wheel[0].setPosition(XYZ(0.486f,0.141f,-0.9125f));
//		wheel[0].setMatrixLock(true);
//		
//		// front right
//		wheelRef[1].bind(*wheelObj);
//		wheelRef[1].setRotation(XYZ(0,180,0));
//		wheel[1].bindChild(wheelRef[1]);
//		wheel[1].setPosition(XYZ(-0.486f,0.141f,-0.9125f));
//		wheel[1].setMatrixLock(true);
//
//		// front left
//		wheelRef[2].bind(*wheelObj);
//		wheelRef[2].setRotation(XYZ(0,180,0));
//		wheel[2].bindChild(wheelRef[2]);
//		wheel[2].setPosition(XYZ(0.486f,0.141f,0.843f));
//		wheel[2].setMatrixLock(true);
//		
//		// front right
//		wheelRef[3].bind(*wheelObj);
//		wheel[3].bindChild(wheelRef[3]);
//		wheel[3].setPosition(XYZ(-0.486f,0.141f,0.843f));
//		wheel[3].setMatrixLock(true);
//	}

	btVector3 wheelAxleCSR,wheelAxleCSL;

	wheelDirectionCS0 = btVector3(0,-1,0);
	wheelAxleCS = btVector3(-1,0,0);
	
	RigidSceneObject::initialize(dynamicsWorld_in);

	btTransform tr;
	tr.setIdentity();

	setPivot(XYZ(0,0,0));

	btCompoundShape* compound = new btCompoundShape();

	btTransform localTrans;
	localTrans.setIdentity();

	localTrans.setOrigin(btVector3(0,0,0));

	compound->addChildShape(localTrans,colShape);

	tr.setOrigin(btVector3(0,0.f,0));

	setMass(mass);

	mRigidBody = &createRigidBody(*compound);
	
	// reset scene
	gVehicleSteering = 0.f;
	mRigidBody->setCenterOfMassTransform(btTransform::getIdentity());
	mRigidBody->setLinearVelocity(btVector3(0,0,0));
	mRigidBody->setAngularVelocity(btVector3(0,0,0));

	//	dynamicsWorld->getBroadphase()->getOverlappingPairCache()->cleanProxyFromPairs(m_carChassis->getBroadphaseHandle(),dynamicsWorld->getDispatcher());
		
	/// create vehicle
	m_vehicleRayCaster = new btDefaultVehicleRaycaster(dynamicsWorld);
	m_vehicle = new btRaycastVehicle(m_tuning,mRigidBody,m_vehicleRayCaster);
			
	///never deactivate the vehicle
	mRigidBody->setActivationState(DISABLE_DEACTIVATION);

	dynamicsWorld->addVehicle(m_vehicle);
	
	//choose coordinate system
	m_vehicle->setCoordinateSystem(rightIndex,upIndex,forwardIndex);

//	btVector3 connectionPointCS0(axelWidth/2.0f,connectionHeight,frontAxelZ);
	
	for (unsigned int i = 0; i < wheels.size(); i++)
	{
		btVector3 wpos = wheels[i]->getWheelPosition().cast();
		
//		printf("Wheel Radius: %f\n",wheels[i]->getWheelRadius());
//		printf("Wheel Width: %f\n",wheels[i]->getWheelWidth());
		
		m_vehicle->addWheel(wpos,wheelDirectionCS0,wheelAxleCS,wheels[i]->getSuspensionRest(),wheels[i]->getWheelRadius(),m_tuning,wheels[i]->getSteering());
	}

//	connectionPointCS0 = btVector3(axelWidth/2.0f,connectionHeight,rearAxelZ);
//	m_vehicle->addWheel(connectionPointCS0,wheelDirectionCS0,wheelAxleCS,suspensionRestLength,wheelRadius,m_tuning,isFrontWheel);
	
	updateSuspension();

	/// end car

	//worldspaceChildren = true;
}