示例#1
0
void Tamer::onInit()
{
	Game::Object::onInit();

	model.deserialize("model_shiveil.txt");


	addCollider(CircleCollider(Vector2D(), 50.f));

	setInput("up", Control::Input(sf::Keyboard::W));
	setInput("down", Control::Input(sf::Keyboard::S));
	setInput("left", Control::Input(sf::Keyboard::A));
	setInput("right", Control::Input(sf::Keyboard::D));

	setInput("s1", Control::Input(sf::Keyboard::Q, Control::Input::keyboard, Control::Input::stay));
	setInput("s2", Control::Input(sf::Keyboard::E));

	// realms
	// position
	getPos().inverseMass = 0.9f;
	getPos().resetVelocity = 0.8f;

	// rotation
	getRot().inverseMass = 0.5;
	getRot().resetVelocity = 0.75f;
}
示例#2
0
	void PhysicsNode::render(AbstractRender *render) const {

		if (render_body) {
			if (body->getBody() == Nutmeg::BODY_CAPSULE) {

				vec3 size = body->getSize();
				float diameter = math::min(size.x, size.y);
				float height = size.z;

				renderCapsule(getScene(), render, diameter, height, getPos(true), getRot(true));

			} else {
				render->setMatrix(origin);
				render->drawMesh(scene->getPrimitive(body->getBody()));
			}
		}
	
		/*
		if (render_body) {
			//mat4 matrix;
			//body->getMatrix(matrix);
			//matrix = mat4::scale(scale) * matrix;
			//render->setMatrix(matrix);

			render->setMatrix(origin);
			render->drawMesh(scene->getPrimitive(body->getBody()));
		}
		*/

	}
示例#3
0
	void PhysicsNode::invalidateMatrix() {

		if (!do_invalidate_matrix) return;

		Node::invalidateMatrix();

		if (body == NULL) return;

		vec3 global_scale = getScale(true);
		vec3 global_pos = getPos(true);
		quat global_rot = getRot(true);

		vec3 newSize = (box.max - box.min) * global_scale;
		if (body->getSize().equals(newSize, 0.0001f) == false) {
			body->setSize(newSize);
		}

		origin = mat4::scale(global_scale) * global_rot.getMatrix() * mat4::translate(global_pos);
		inverse = mat4::translate(-global_pos) * (-global_rot).getMatrix() * mat4::scale(vec3(1.0f, 1.0f, 1.0f) / global_scale);

		mat4 m = origin;
		m.normalize();
		body->setMatrix(m);

		if (do_init_state) {
			init_pos = pos;
			init_rot = rot;
			init_scale = scale;
		}

	}
示例#4
0
const Vector3F &Turret::getCompassRotation (void)
{
	static Vector3F rot;

	rot.set (0, 0, turretRotation + getRot().z);

	return rot;
}
示例#5
0
void Demon::onInit()
{
	Game::Object::onInit();

	model.deserialize("modelHero1.txt");

	addCollider(CircleCollider( Vector2D(), 50.f ) );

	// realms
	// position
	getPos().position = Vector2D(200, 200);
	getPos().inverseMass = 0.9f;
	getPos().resetVelocity = 0.8f;

	// rotation
	getRot().inverseMass = 0.5;
	getRot().resetVelocity = 0.75f;
}
示例#6
0
void Character::onInit()
{
	Game::Object::onInit();

	model.deserialize("model_shiveil.txt");
	initAllModels();


	addCollider(CircleCollider(Vector2D(), 50.f));

	idAnimAtU = addResource(Resource<float>());
	getResource_f(idAnimAtU).resetVelocity = 0.75;
	getResource_f(idAnimAtU).inverseMass = 0.5;

	idAnimAtH = addResource(Resource<float>());
	getResource_f(idAnimAtH).resetVelocity = 0.75;
	getResource_f(idAnimAtH).inverseMass = 0.5;

	setInput("up", Control::Input(sf::Keyboard::W));
	setInput("down", Control::Input(sf::Keyboard::S));
	setInput("left", Control::Input(sf::Keyboard::A));
	setInput("right", Control::Input(sf::Keyboard::D));

	setInput("s1", Control::Input(sf::Mouse::Left));
	setInput("s2", Control::Input(sf::Mouse::Right));


	addAnimation("block", Animation("animBlockShield.txt"));
	addAnimation("atackH", Animation("swordAnim.txt"));
	addAnimation("atackU", Animation("swordAnimPush.txt"));

	// realms
	// position
	getPos().inverseMass = 0.9f;
	getPos().resetVelocity = 0.8f;

	// rotation
	getRot().inverseMass = 0.5;
	getRot().resetVelocity = 0.75f;
	gen.addParticle("particleTest.txt", 250, 1);
	//genSword.addParticle("swordParticle.txt", 50, 0.5);
}
示例#7
0
float Player::coverage (Point3F eye)
{
	float total = 0;
	Point3F foot = getLinearPosition () + collisionImage.sphere.center / 2;
	Point3F head = foot + collisionImage.sphere.center;
	Point3F temp;
	Point3F lshoulder;
	Point3F rshoulder;
	temp = getRot ();
	RMat3F rot (EulerF(temp.x, temp.y, temp.z));
	
	temp.set (collisionImage.bbox.fMin.x / 2, 0, 0);
	m_mul (temp, rot, &lshoulder);
	lshoulder += getLinearPosition ();
	lshoulder.z += collisionImage.sphere.center.z;
	lshoulder.z += collisionImage.sphere.center.z / 4;
	
	temp.set (collisionImage.bbox.fMax.x / 2, 0, 0);
	m_mul (temp, rot, &rshoulder);
	rshoulder += getLinearPosition ();
	rshoulder.z += collisionImage.sphere.center.z;
	rshoulder.z += collisionImage.sphere.center.z / 4;
	
	SimContainerQuery cq;
	cq.id = getId();
	cq.type = -1;
	cq.mask = SimTerrainObjectType | SimInteriorObjectType | SimPlayerObjectType | StaticObjectType;

	cq.box.fMin = eye;
	cq.box.fMax = foot;
	SimCollisionInfo info;
	SimContainer* root = findObject(manager,SimRootContainerId,(SimContainer*)0);
	bool obstructed = root->findLOS (cq, &info);
	if (!obstructed)
		total += 0.25;

	cq.box.fMax = head;
	obstructed = root->findLOS (cq, &info);
	if (!obstructed)
		total += 0.25;

	cq.box.fMax = lshoulder;
	obstructed = root->findLOS (cq, &info);
	if (!obstructed)
		total += 0.25;

	cq.box.fMax = rshoulder;
	obstructed = root->findLOS (cq, &info);
	if (!obstructed)
		total += 0.25;

	return total;
}
示例#8
0
void Player::setMountObject (GameBase *object, int in_mountPoint)
{
   if(mount)
      clearNotify(mount);

   setMaskBits(MountMask);
   mount = object;
   mountPoint = in_mountPoint;
   if(mount)
		{
	      deleteNotify(mount);

		   TMat3F tmat;
			mount->getObjectMountTransform(mountPoint, &tmat);
			if (!mountPoint)
				{
					Point3F rot = getRot ();
					tmat.set (EulerF (rot.x, rot.y, rot.z), tmat.p);
				}
		   setTransform(tmat);
			EulerF angles;
			tmat.angles(&angles);
			if (mountPoint < 1)
				setRot (Point3F (0, 0, angles.z));
			else
				if (mountPoint == 1)
					setRot (Point3F (0, 0, 0));
				else
					{
						Point3F rot = getRot ();
						rot.z -= angles.z;
						setRot (rot);
					}

         setImageTriggerUp(0);

			setLinearVelocity (Point3F (0, 0, 0));
		}
}
示例#9
0
//==========================================================
// Name :
// Desc : カメラ
//==========================================================
void CObj3dCar::camera()
{
	D3DXVECTOR3 rot = getRot();
	D3DXVECTOR3 pos = getPos();

	//Tamama
	_eye.x=pos.x-sinf(rot.y)*10;
	_eye.y=3.0f;
	_eye.z=pos.z-cosf(rot.y)*10;

	_at.x=pos.x;
	_at.y=1.0f;
	_at.z=pos.z;
}
示例#10
0
void obj::removeParenting()
{
	if(parent == NULL)
		return;	//No parents already
	pos = getPos();	//Reset position
	rot = getRot();
	
	for(list<obj*>::iterator i = parent->children.begin(); i != parent->children.end(); i++)
	{
		if(*i == this)
		{
			parent->children.erase(i);
			break;	//Done
		}
	}
	parent = NULL;
}
示例#11
0
	void CameraNode::invalidateMatrix() {
		Node::invalidateMatrix();
		if (doInvalidateMatrix) {
			camera.pos = getPos(true);
			camera.setRot(getRot(true));
			
			vec3 globalScale = getScale(true);
			camera.fov = globalScale.z * 45.0f;
			if (camera.fov > 179.0f) camera.fov = 179.0f;
			if (camera.fov < 1.0f) camera.fov = 1.0f;
			camera.ratio = globalScale.x / globalScale.y;

			//camera.ratio = ca
			
			camera.invalidate();
		}
	}
示例#12
0
//==========================================================
// Name :
// Desc : 車の動き
//==========================================================
void CObj3dCar::move()
{

	D3DXVECTOR3	ang = getRot();
	D3DXVECTOR3 pos = getPos();

	ang.y += _angVel * dt;

	if(boostCounter != 0)
	{
		boostCounter--;
		_vel = maxVel*2;
	}

	pos.x += sinf(ang.y) * _vel;
	pos.z += cosf(ang.y) * _vel;
	//pos.z += 
	
	setRot(ang);
	setPos(pos);
	//camera();

}
示例#13
0
void Camera::rotate(Scalar a)//fix for 2d
{
    setRot(getRot()+a);
}
示例#14
0
// initialization
void className::onInit()
{
	baseClassName::onInit();

	//////////////// Most typical efect
	//////////////// uncomment if need
	//// graphics
	//addEfect(efModel = new EfectModel("model_.txt", nullptr, true, true) );
	//addEfect(efParticle = new EfectParticle( "particle_.txt", 1, 1, 1, 0, &efModel->model, nullptr) );
	//addEfect(efFollowCam = new EfectFollowCam( &efModel->model, -350) );
	//addEfect(efAnimation = new EfectAnimation("", "animation_.txt") );

	//// collision
	//addEfect(efCollidionResponse = new EfectCollisionResponse(5.5, 0.001, Vector2D() ) );
	//addEfect(efDamageOnCollision = new EfectDamageOnCollision(-0,-0) );
	//addEfect(efCheckForCollision = new EfectCheckForCollision(&world) );


	//// movement
	//addEfect(efTppMovement = new EfectTppMovement(4, 0.5) );
	//addEfect(efFollowAim = new EfectFollowAim(nullptr,0,0,1.f,Vector2D(),Vector2D(),false, false));

	//// debug
	//addEfect(efDebugCollider = new EfectDebugCollider(&efModel->model, sf::Keyboard::Z, Color(200, 200, 200, 100)));
	//addEfect(efDebugStat = new EfectDebugStat(Game::Event::hp, true, "object hp", Control::Input(sf::Keyboard::K)));

	//////////////// Collider
	//addCollider(CircleCollider(Vector2D(), 100.f));
	//////////////// Animation
	//addAnimation("", Animation("animation_.txt"));

	//////////////// Realms
	//// position
	getPos().position = Vector2D();
	getPos().velocity = Vector2D();
	getPos().force = Vector2D();
	getPos().inverseMass = 1;
	getPos().resetVelocity = 0.75;
	getPos().resetForce = 0;

	//// rotation
	getRot().position = 0;
	getRot().velocity = 0;
	getRot().force = 0;
	getRot().inverseMass = 1;
	getRot().resetVelocity = 0.75;
	getRot().resetForce = 0;

	//// hp
	getHp().position = 100;
	getHp().velocity = 0;
	getHp().force = 0;
	getHp().inverseMass = 1;
	getHp().resetVelocity = 0;
	getHp().resetForce = 0;

	//// vis
	getVis().position = 0;
	getVis().velocity = 0;
	getVis().force = 0;
	getVis().inverseMass = 1;
	getVis().resetVelocity = 0.75;
	getVis().resetForce = 0;
}
示例#15
0
void WaterBlock::draw(Renderer* renderer) {
    renderer->draw(getShape(), getPos(), getRot());
}