Пример #1
0
TransformObject::TransformObject(void)
{
	SetPosition(Vector3f());
	SetRotation(Vector3f());
	SetScale(1.0f);
}
Пример #2
0
Matrix4x4::Matrix4x4(const Quaternion& q)
{
	SetRotation(q);
}
Пример #3
0
void
Entity::ScriptSetRotation( const float rotation )
{
    SetRotation( Ogre::Degree( rotation ) );
}
Пример #4
0
/*virtual*/ void Bullet::HandleCollision(const IEntity* other) /*override*/
{
	const Character* temp = reinterpret_cast<const Character*>(other);

	if (temp && owner && owner->GetOwner() && (temp->GetIsEnemy() != owner->GetOwner()->GetIsEnemy()))
	{
		// create a hit marker to indicate damage
		SGD::Color enemyColor;
		if (temp->GetIsEnemy())
			enemyColor = SGD::Color::Yellow;
		else
			enemyColor = SGD::Color::Blue;

		// dispatch a hit marker message only if the other object actually has health
		if (temp->GetCurrHealth() > 0.f)
		{
			CreateHitMarkerMsg* msg = new CreateHitMarkerMsg((int)(GetDamage()), m_ptPosition, m_fRotation - Math::to_radians(180.f), enemyColor);
			SGD::MessageManager::GetInstance()->QueueMessage(msg);
		}
	}

	// avoid shooting yourself unless its a deflected bullet
	if ((owner->GetOwner() != temp && !deflectBullet) || (owner->GetOwner() == temp && deflectBullet))
	{

#pragma region Brawler
		const Character* testCharacter = reinterpret_cast<const Character*>(other);
		Character* testNonConstCharacter = const_cast<Character*>(testCharacter);

		// player hit by bullet 
		if (GameplayState::GetInstance()->player && testCharacter->GetLevel() >= 1)
		{
			if (testCharacter && testCharacter->GetClass() == ClassType::Brawler && testCharacter == GameplayState::GetInstance()->player->GetCharacter())
			{
				// damage player Takes
				GameplayState::GetInstance()->fBaseDamageTaken = GetDamage();
				GameplayState::GetInstance()->fPassiveDamageTaken = testNonConstCharacter->GetWeapon()->GetDamage();
			}
		}

		if (owner->GetGunType() == Weapon::GunType::chainsawLauncher && owner->GetOwner()->GetClass() == ClassType::Brawler)
		{
			if (reinterpret_cast<BuzzsawLauncher*>(owner)->GetisBrawlActive())
			{
				if (owner->GetOwner()->GetLevel() >= 21)
					owner->GetOwner()->SetCurrCooldown(owner->GetOwner()->GetCurrCoolDown() - 0.5f);
				
				if (owner->GetOwner()->GetLevel() >= 11)
					owner->GetOwner()->ModifyHealth(owner->GetOwner()->GetStat(StatType::strength)*0.35f);
			}
		}
#pragma endregion

		if (temp && owner && owner->GetOwner() && owner->GetOwner()->GetClass() == ClassType::Cyborg && owner->GetOwner()->GetLevel() >= 18 && damage >= temp->GetCurrHealth())
		{
			vector<NPC*> hits = GameplayState::GetInstance()->npcs;
			int lightning = 0;
			for (unsigned int x = 0; x < hits.size() && lightning <= 2; x++)
			{
				float length = (hits[x]->getCharacter()->GetPosition() - temp->GetPosition()).ComputeLength();
				if (length < 300.0f && hits[x]->getCharacter()->GetIsEnemy() != owner->GetOwner()->GetIsEnemy() && hits[x]->getCharacter() != temp)
				{
					hits[x]->getCharacter()->ModifyHealth(-owner->GetOwner()->GetStat(StatType::accuracy)*0.5f);
					lightning++;

					if (owner->GetOwner()->GetLevel() >= 24)
					{
						Stun* stun = new Stun(hits[x]->getCharacter());
						stun->SetDuration(1.0f);
						Radiation* rad = new Radiation(hits[x]->getCharacter());
						rad->SetStacks(5);
						hits[x]->getCharacter()->AddStatusAilment(stun);
						hits[x]->getCharacter()->AddStatusAilment(rad);
					}
				}
			}

			if (lightning > 0)
				SGD::AudioManager::GetInstance()->PlayAudio(GameplayState::GetInstance()->chain_lightnin);
		}

		const Character* tempEnemy = dynamic_cast<const Character*>(other);
		Character* newEnemy = const_cast<Character*>(tempEnemy);

		if (tempEnemy && owner && owner->GetOwner() && owner->GetOwner()->GetClass() == ClassType::Gunslinger && owner->GetOwner()->GetLevel() >= 24)
		{
			int theOdds = rand() % 100 + 1;
			// gunslinger passive debug code
			GameplayState::GetInstance()->nRiccochetOdds = theOdds;

			if (theOdds < 45 && tempEnemy->GetIsEnemy() != owner->GetOwner()->GetIsEnemy())
			{
				// adjust angle to aim at another enemy (see chain lightning: cyborg lv 18 - line 120)
				// instead of destroying, redirect to another (and don't destroy)
				// if no other near, destroy this
				Weapon* tempWeapon = newEnemy->GetWeapon();

				// gunslinger debug code
				for (unsigned i = 0; i < GameplayState::GetInstance()->npcs.size(); i++)
				{
					if (GameplayState::GetInstance()->npcs[i]->getCharacter() != tempEnemy)
					{
						SGD::Vector tempDiff = GameplayState::GetInstance()->npcs[i]->getCharacter()->GetPosition() - GetPosition();
						//tempDiff.Normalize();

						float tempDist = tempDiff.ComputeLength();

						if (tempDist < 300)
						{
							// calculate angle to new target
							float toTarget = atan2(tempDiff.y, tempDiff.x);

							SGD::Vector newVelocity = GetVelocity();

							// set the velocity to the newly rotated velocity
							SetVelocity(newVelocity.ComputeRotated(toTarget));
							SetRotation(toTarget);
							SGD::AudioManager::GetInstance()->PlayAudio(GameplayState::GetInstance()->trickShot);
							break;
						}
					}
				}
			}
		}
		if (owner && owner->GetOwner() && owner->GetOwner()->GetClass() == ClassType::Medic && owner->GetOwner()->GetLevel() >= 24 && temp && damage >= temp->GetCurrHealth()*1.2f)
		{
			vector<NPC*> hits = GameplayState::GetInstance()->npcs;
			if ((GameplayState::GetInstance()->player->GetCharacter()->GetPosition() - temp->GetPosition()).ComputeLength() < 300.0f)
			{
				GameplayState::GetInstance()->player->GetCharacter()->ModifyHealth((temp->GetHealth())*0.1f);
				Emitter* heals = GameplayState::GetInstance()->CreateEmitter("heals", (temp != nullptr));
				heals->lifeTime = 0.25f;
			}

			for (unsigned int x = 0; x < hits.size(); x++)
			{
				float length = (hits[x]->getCharacter()->GetPosition() - temp->GetPosition()).ComputeLength();
				if (length < 300.0f && !hits[x]->getCharacter()->GetIsEnemy())
				{
					hits[x]->getCharacter()->ModifyHealth((temp->GetHealth())*0.05f);
					Emitter* heals = GameplayState::GetInstance()->CreateEmitter("heals", (temp != nullptr));
					heals->lifeTime = 0.25f;
					//visual effect
				}
			}
			SGD::AudioManager::GetInstance()->PlayAudio(GameplayState::GetInstance()->tranfusion);
		}
		if (GetOwner()->bulType.size() == 0)
		{
			if (tempEnemy && owner && owner->GetOwner() && (tempEnemy->GetIsEnemy() != owner->GetOwner()->GetIsEnemy()))
			{
				if (critPassive)
					SGD::AudioManager::GetInstance()->PlayAudio(GameplayState::GetInstance()->crit_shot);

				// allocate a message to destroy this instance
				DestroyEntityMsg* msg = new DestroyEntityMsg(this);

				// dispatch destroy message
				SGD::MessageManager::GetInstance()->QueueMessage(msg);
			}
		}
		// allocate a message to destroy this instance if the bullet is not peircing
		for (unsigned int i = 0; i < GetOwner()->bulType.size(); i++)
		{
			//if its a peircing bullet, don't continue to where you delete the bullet
			if (GetOwner()->bulType[i] == BulletType::fmj || GetOwner()->bulType[i] == BulletType::FMJFTW)
			{
				break;
			}

			if (owner && owner->GetOwner() && owner->GetOwner()->GetClass() == ClassType::Gunslinger && owner->GetOwner()->GetLevel() >= 24 && GameplayState::GetInstance()->nTheOdds < 45); // do nothing
			else if (!deflectBullet && i == GetOwner()->bulType.size() - 1)
			{
				// allocate a message to destroy this instance if you make it through the entire vector of bullet types and don't find fmj or fmjftw
				DestroyEntityMsg* msg = new DestroyEntityMsg(this);

				// dispatch destroy message
				SGD::MessageManager::GetInstance()->QueueMessage(msg);
			}
		}
		deflectBullet = false;
	}

}
Пример #5
0
	void Transform2D::SetRotationRad(const glm::float32& rad)
	{
		SetRotation(Angle::FromRadians(rad));
	}
void UKUIMaterialInterfaceComponent::SetRotationStruct( const FRotator& rRotation )
{
	SetRotation( rRotation.Pitch, rRotation.Yaw, rRotation.Yaw );
}
FirstPersonCamera::FirstPersonCamera(float nearClip, float farClip, float fov, float aspect)
    : PerspectiveCamera(nearClip, farClip, fov, aspect)
{
    SetRotation(XMFLOAT2(0.0f, 0.0f), 0.0f);
    UpdateProjection();
}
Пример #8
0
_Use_decl_annotations_ HRESULT WINAPI
DXGISwapChainProxy::SetRotation(DXGI_MODE_ROTATION rotation)
{
    auto const swap_chain = static_cast<IDXGISwapChain1*>(swap_chain_);
    return swap_chain->SetRotation(rotation);
}
Пример #9
0
void RigidBody::HandleTargetRotation(StringHash eventType, VariantMap& eventData)
{
    // Copy the smoothing target rotation to the rigid body
    if (!physicsWorld_ || !physicsWorld_->IsApplyingTransforms())
        SetRotation(static_cast<SmoothedTransform*>(GetEventSender())->GetTargetWorldRotation());
}
Пример #10
0
void CameraClass::SetRotation(D3DXVECTOR3 dr)
{
	SetRotation(dr.x, dr.y, dr.z);
}
Пример #11
0
/////////////////////////////////////////////////////////////////////////////
// CasteroidIGC
HRESULT     CasteroidIGC::Initialize(ImissionIGC* pMission, Time now, const void* data, int dataSize)
{
	ZeroMemory(&m_builderseensides, sizeof(bool) * c_cSidesMax); //Imago 8/10
    TmodelIGC<IasteroidIGC>::Initialize(pMission, now, data, dataSize);

    ZRetailAssert (data && (dataSize == sizeof(DataAsteroidIGC)));
    {
        DataAsteroidIGC*  dataAsteroid = (DataAsteroidIGC*)data;
        m_asteroidDef = dataAsteroid->asteroidDef;
		
        IclusterIGC*    cluster = pMission->GetCluster(dataAsteroid->clusterID);
        ZRetailAssert (cluster);
        {
            HRESULT rc = Load(0,
                              m_asteroidDef.modelName,
                              m_asteroidDef.textureName,
                              m_asteroidDef.iconName,
                              c_mtStatic | c_mtHitable | c_mtDamagable | c_mtSeenBySide | c_mtPredictable);
            assert (SUCCEEDED(rc));

            SetRadius((float)m_asteroidDef.radius);
            SetPosition(dataAsteroid->position);
            {
                Orientation o(dataAsteroid->forward, dataAsteroid->up);
                SetOrientation(o);
            }
			
			// Turkey 01/2014 AME is bugged, rotation axis should be a normalized vector
			Rotation r = dataAsteroid->rotation;
			Vector axis = r.axis().Normalize();
			r.axis(axis);
            SetRotation(r);

            SetSignature(dataAsteroid->signature);

            m_fraction = dataAsteroid->fraction;
			if (m_fraction > 1.0f) m_fraction = 1.0f; // Turkey 01/2014 AME is bugged, gives rocks 100.4% hitpoints (241/240)

            if (dataAsteroid->name[0] != '\0')
                SetName(dataAsteroid->name);
            else
                SetSecondaryName(dataAsteroid->name + 1);

            SetCluster(cluster);

			//Xynth #100 7/2010 Need to initialize oreseenbyside for all sides
			for (SideLinkIGC* psl = this->GetMission()->GetSides()->first(); psl != NULL; psl = psl->next())
			{
				IsideIGC* pside = psl->data();									
				oreSeenBySide.Set(pside, 0.0);									
			}

			m_lastUpdateOre = 0.0;  //Xynth #132 7/2010 Should update first time this is mined
			m_inhibitUpdate = false; //Xynth #225 9/10 		
		    m_inhibitCounter = -1;
#ifdef DEBUG
            {
                //Verify that there is no pre-existing asteroid with the same ID
                for (AsteroidLinkIGC*   pal = pMission->GetAsteroids()->first(); (pal != NULL); pal = pal->next())
                {
                    assert (pal->data()->GetObjectID() != m_asteroidDef.asteroidID);
                }
            }
#endif
            pMission->AddAsteroid(this);
        }
    }

    return S_OK;
}
Пример #12
0
void World::RunWorld()
{
	std::srand(static_cast<unsigned int>(std::time(NULL)));

	uint32 flags = 0;
	flags += b2Draw::e_shapeBit;
	flags += b2Draw::e_jointBit;
	flags += b2Draw::e_aabbBit;
	flags += b2Draw::e_pairBit;
	flags += b2Draw::e_centerOfMassBit;
	WindowManager::I().GetDebugDraw().SetFlags(flags);
	SetDebugDraw(&WindowManager::I().GetDebugDraw());

	// Since the Box2D world is tuned for meters, and works with averagely sized objects,
	//  we'll zoom in with the view.
	sf::View view;
	view.setSize(sf::Vector2f(80, 60));
	view.setCenter(sf::Vector2f(40, 30));
	WindowManager::I().setView(view);

	auto obj = std::make_shared<ObjectBase>(OSTCircle, 1.0f, true);
	auto obj2 = std::make_shared<ObjectBase>(OSTRectangle, 15.0f, false);
	auto obj3 = std::make_shared<ObjectBase>(OSTRectangle, 15.0f, false);
	auto obj4 = std::make_shared<ObjectBase>(OSTRectangle, 15.0f, false);

	obj->SetPosition(40, 10);
	obj2->SetPosition(40, 51.5);
	obj3->SetPosition(70, 43);
	obj3->SetRotation(b2_pi / 4.0f);
	obj4->SetPosition(10, 45);
	obj4->SetRotation(b2_pi / 8.0f + b2_pi);

	while (WindowManager::I().isOpen())
	{
		// Handle events
		sf::Event event;
		while (WindowManager::I().pollEvent(event))
		{
			// Window closed or escape key pressed: exit
			if ((event.type == sf::Event::Closed) ||
				((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Escape)))
			{
				WindowManager::I().close();
				break;
			}
		}

		float32 timeStep = 1.0f / 60.0f;
		int32 velocityIterations = 6;
		int32 positionIterations = 2;

		Step(timeStep, velocityIterations, positionIterations);

		obj->Move();

		WindowManager::I().clear(sf::Color::Black);

		DrawDebugData();

		WindowManager::I().display();
	}
}
Пример #13
0
TInt CNVGCSIcon::DoDrawL(const TSize aSize)
    {
    TInt ret = KErrNone;
    
    vgSetPaint(iFillPaint,   VG_FILL_PATH);
    vgSetPaint(iStrokePaint, VG_STROKE_PATH);
    iLastFillPaintColor     = 0;
    iLastStrkePaintColor    = 0;
    iLastFillPaintType      = 0;
    iLastStrokePaintType    = 0;

    VGfloat lCurrentPathMatrix[9];
    vgGetMatrix(lCurrentPathMatrix);
    
    vgSeti(VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE);  
    vgLoadMatrix(lCurrentPathMatrix);
    SetRotation();
#ifdef __MIRROR_    
    vgScale(1.0f, -1.0f);
    vgTranslate(0, (VGfloat)(-aSize.iHeight) );
#endif
    
    SetViewBoxToViewTransformationL(aSize);
   
    
    vgSeti(VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE);
    
    VGfloat currentMatrix[9];
    
    vgGetMatrix(currentMatrix);
    
    iNVGIconData->BeginRead();

    while (!iNVGIconData->EOF())
        {
        switch (iNVGIconData->ReadInt32L())
            {
            case EPath:
                {
                VGPath path = (VGPath)iNVGIconData->ReadInt32L();
                VGPaintMode paintMode = (VGPaintMode)iNVGIconData->ReadInt32L();

                if (path == VG_INVALID_HANDLE)
                    {
                    vgDrawPath(iPath, paintMode);
                    }
                else
                    {
                    vgDrawPath(path, paintMode);
                    }
                
                break;
                }
            case EPathData:
                {                
                if (iPath != VG_INVALID_HANDLE)
                    {
                    VGint numSegments;
                    VGubyte * pathSegments = 0;
                    VGubyte * pathData = 0;
                    
                    numSegments  = iNVGIconData->ReadInt32L();
                    pathSegments = new (ELeave) VGubyte[numSegments];
                    CleanupStack::PushL(TCleanupItem(CleanupArray, pathSegments));
                    if (pathSegments)
                        {
                        iNVGIconData->ReadL(pathSegments, numSegments);
                        VGint coordinateCount = iNVGIconData->ReadInt32L();
                        pathData = new (ELeave) VGubyte[coordinateCount * 4];
                        if (pathData)
                            {
                            CleanupStack::PushL(TCleanupItem(CleanupArray, pathData));
                            iNVGIconData->ReadL(pathData, coordinateCount * 4);
                            vgClearPath(iPath, VG_PATH_CAPABILITY_APPEND_TO);
                            vgAppendPathData(iPath, numSegments, pathSegments, pathData);
                            CleanupStack::PopAndDestroy();
                            }                        
                        }
                    CleanupStack::PopAndDestroy();
                    }
                break;
                }
            case EPaint:
                {
                DrawPaintL(iFillPaint, VG_MATRIX_FILL_PAINT_TO_USER, iLastFillPaintType, iLastFillPaintColor, VG_FILL_PATH);
                break;
                }
            case EColorRamp:
                {
                iNVGIconData->ReadInt32L();
                break;
                }
            case ETransform:
                {
                TInt flag;
                VGfloat transformMatrix[9];
                
                TPtr8 tmPtr((TUint8 *)transformMatrix, 9 * sizeof(VGfloat));
                
                iNVGIconData->ReadL(tmPtr, 9 * sizeof(VGfloat));
                flag = iNVGIconData->ReadInt32L();
                
                vgLoadMatrix(currentMatrix);
                if (flag)
                    {
                    vgMultMatrix(transformMatrix);
                    }
                }
                break;
            case EStrokeWidth:
                {
                VGfloat strokeWidth = iNVGIconData->ReadReal32L();
                vgSetf(VG_STROKE_LINE_WIDTH, strokeWidth);
                break;
                }
            case EStrokeMiterLimit:
                {
                VGfloat miterLimit = iNVGIconData->ReadReal32L();
                vgSetf(VG_STROKE_MITER_LIMIT, miterLimit);
                break;
                }
            case EStrokeLineJoinCap:
                {
                VGint lineJoin = iNVGIconData->ReadInt32L();
                VGint cap = iNVGIconData->ReadInt32L();
                
                vgSeti(VG_STROKE_JOIN_STYLE, (VGJoinStyle)lineJoin);
                vgSeti(VG_STROKE_CAP_STYLE, (VGCapStyle)cap);
                break;
                }
            case EStrokePaint:
                {
                DrawPaintL(iStrokePaint, VG_MATRIX_STROKE_PAINT_TO_USER, iLastStrokePaintType, iLastStrkePaintColor, VG_STROKE_PATH);
                break;
                }
            case EStrokeColorRamp:
                {
                iNVGIconData->ReadInt32L();
                break;
                }
            default:
                {
                User::Leave(KErrCorrupt);
                break;
                }
            }
        }
    
    iNVGIconData->EndRead();
    
    return ret;
    }
Пример #14
0
TransformObject::TransformObject(Vector3f position, Vector3f eulerRotationAngles, Vector3f scale)
{
	SetPosition(position);
	SetRotation(eulerRotationAngles);
	SetScale(scale);
}
Пример #15
0
void TriggerET::InitializeEntity(
	Entity& entity,
	const EntityModuleParameters* spawnParams) const
{
	auto gameEM = entity.GetModule<GameEM>();
	auto physicsEM = entity.GetModule<PhysicsEM>();
	auto sceneEM = entity.GetModule<SceneEM>();

	const auto params = static_cast<const TriggerEMParams*>(spawnParams);
	auto& timeController = params->m_timeController;
	auto& comboController = params->m_comboController;
	auto& player = params->m_player;
	auto triggerType = params->m_triggerType;

	auto trigger = std::unique_ptr<Trigger>(
		new Trigger(triggerType, player, comboController, timeController));

	auto collisionBox = std::unique_ptr<CollisionBox>(new CollisionBox());
	switch (triggerType)
	{
	case TriggerTypeBoost30:
	case TriggerTypeBoost45:
	case TriggerTypeBoost60:
		collisionBox->SetPosition(Vec3f(0.0f, 100.0f, -1.175f));
		collisionBox->SetDimensions(Vec3f(0.5f, 100.0f, 0.625f));
		break;

	case TriggerTypeSlow:
	case TriggerTypeAngle:
	case TriggerTypeStop:
	case TriggerTypeBlock:
		collisionBox->SetPosition(Vec3f(0.0f, 100.0f, -0.55f));
		collisionBox->SetDimensions(Vec3f(0.5f, 100.0f, 1.25f));
		break;
	}
	physicsEM->AddCollisionShape(std::move(collisionBox));
	physicsEM->SetCollisionListener(trigger.get());
	physicsEM->SetImmovable(true);

	gameEM->SetGameObject(std::move(trigger));

	std::string activeTextureFilePath;
	std::string inactiveTextureFilePath;

	switch(triggerType)
	{
	case TriggerTypeBoost30:
		activeTextureFilePath = "Triggers/Boost30Active.png";
		inactiveTextureFilePath = "Triggers/Boost30Inactive.png";
		break;

	case TriggerTypeBoost45:
		activeTextureFilePath = "Triggers/Boost45Active.png";
		inactiveTextureFilePath = "Triggers/Boost45Inactive.png";
		break;

	case TriggerTypeBoost60:
		activeTextureFilePath = "Triggers/Boost60Active.png";
		inactiveTextureFilePath = "Triggers/Boost60Inactive.png";
		break;

	case TriggerTypeSlow:
		activeTextureFilePath = "Triggers/SlowActive.png";
		inactiveTextureFilePath = "Triggers/SlowInactive.png";
		break;

	case TriggerTypeAngle:
		activeTextureFilePath = "Triggers/Angle.png";
		inactiveTextureFilePath = activeTextureFilePath;
		break;

	case TriggerTypeStop:
		activeTextureFilePath = "Triggers/StopActive.png";
		inactiveTextureFilePath = "Triggers/StopInactive.png";
		break;

	case TriggerTypeBlock:
		activeTextureFilePath = "Triggers/BlockActive.png";
		inactiveTextureFilePath = "Triggers/BlockInactive.png";
		break;
	}

	auto activeModel = Model("nanaka/models/billboard.nmdl");
	Material activeMaterial(activeModel.GetMaterial());
	activeMaterial.SetTexture(Texture(activeTextureFilePath));
	activeModel.SetMaterial(activeMaterial);

	activeModel.SetPosition(Vec3f(0.0f, 0.0f, 0.0f));
	activeModel.SetRotation(Quat::NoRot());
	activeModel.SetScale(Vec3f(2.0f, 1.0f, 4.0f));

	sceneEM->SetAttachment<Model>(s_gfxIdActive, activeModel);

	auto inactiveModel = Model("nanaka/models/billboard.nmdl");
	Material inactiveMaterial(inactiveModel.GetMaterial());
	inactiveMaterial.SetTexture(Texture(inactiveTextureFilePath));
	inactiveModel.SetMaterial(inactiveMaterial);

	inactiveModel.SetPosition(Vec3f(0.0f, 0.0f, 0.0f));
	inactiveModel.SetRotation(Quat::NoRot());
	inactiveModel.SetScale(Vec3f(2.0f, 1.0f, 4.0f));

	sceneEM->SetAttachment<Model>(s_gfxIdInactive, inactiveModel);
}
Пример #16
0
void Graphics_Mesh(bool isOpenGLMode)
{
	StartGraphicsTest();
	SetGLEnable(isOpenGLMode);

	asd::Log* log = asd::Log_Imp::Create(L"graphics.html", L"メッシュ");

	auto window = asd::Window_Imp::Create(640, 480, asd::ToAString(L"メッシュ").c_str());
	ASSERT_TRUE(window != nullptr);

	auto file = asd::File_Imp::Create();
	ASSERT_TRUE(file != nullptr);

	auto graphics = asd::Graphics_Imp::Create(window, isOpenGLMode ? asd::GraphicsDeviceType::OpenGL : asd::GraphicsDeviceType::DirectX11, log, file, false, false);
	ASSERT_TRUE(graphics != nullptr);

	auto renderer3d = new asd::Renderer3D(graphics, asd::RenderSettings());
	ASSERT_TRUE(renderer3d != nullptr);
	renderer3d->SetWindowSize(asd::Vector2DI(640, 480));

	auto mesh1 = CreateMesh(graphics);
	auto mesh2 = CreateMesh(graphics);
	auto deformer = CreateDeformer(graphics);
	auto animation = CreateAnimation();

	SetMeshBone(mesh2);

	mesh1->SendToGPUMemory();
	mesh2->SendToGPUMemory();

	auto cameraObject = new asd::RenderedCameraObject3D(graphics);
	cameraObject->SetPosition(asd::Vector3DF(0, 0, 10));
	cameraObject->SetFocus(asd::Vector3DF(0, 0, 0));
	cameraObject->SetFieldOfView(20.0f);
	cameraObject->SetZNear(1.0f);
	cameraObject->SetZFar(20.0f);
	cameraObject->SetWindowSize(asd::Vector2DI(800, 600));

	auto meshObject1 = new asd::RenderedModelObject3D(graphics);
	meshObject1->AddMesh(mesh1);
	
	meshObject1->SetPosition(asd::Vector3DF(1, 0, 0));
	meshObject1->SetRotation(asd::Vector3DF(20.0f, 20.0f, 0.0f));

	auto meshObject2 = new asd::RenderedModelObject3D(graphics);
	meshObject2->AddMesh(mesh2);
	meshObject2->SetDeformer(deformer.get());
	meshObject2->SetPosition(asd::Vector3DF(-1, 0, 0));
	meshObject2->SetRotation(asd::Vector3DF(20.0f, 20.0f, 0.0f));
	meshObject2->AddAnimationClip(asd::ToAString("anime1").c_str(), animation.get());
	meshObject2->PlayAnimation(0, asd::ToAString("anime1").c_str());

	auto lightObject = new asd::RenderedDirectionalLightObject3D(graphics);
	lightObject->SetRotation(asd::Vector3DF(30, 160, 0));

	renderer3d->AddObject(cameraObject);
	renderer3d->AddObject(meshObject1);
	renderer3d->AddObject(meshObject2);
	renderer3d->AddObject(lightObject);

	int32_t time = 0;
	while (window->DoEvent())
	{
		graphics->Begin();
		graphics->Clear(true, false, asd::Color(0, 0, 0, 255));

		renderer3d->Flip(1);

		renderer3d->BeginRendering(1);
		asd::Sleep(100);
		renderer3d->EndRendering();

		graphics->SetRenderTarget(nullptr, nullptr);
		graphics->Clear(true, false, asd::Color(0, 0, 0, 255));

		renderer3d->RenderResult();

		graphics->Present();

		graphics->End();

		if (time == 10)
		{
			SAVE_SCREEN_SHOT(graphics, 0);
		}

		if (time == 11)
		{
			window->Close();
		}
		time++;
	}

	meshObject1->Release();
	meshObject2->Release();

	cameraObject->Release();
	lightObject->Release();

	delete renderer3d;

	graphics->Release();
	file->Release();

	window->Release();
	delete log;
}
Пример #17
0
CUmbralMap::CUmbralMap(const MapLayoutPtr& mapLayout)
{
	for(const auto& resourceItem : mapLayout->GetResourceItems())
	{
		if(resourceItem.type == '\0trb' || resourceItem.type == '\0txb')
		{
			CResourceManager::GetInstance().LoadResource(resourceItem.resourceId, resourceItem.name);
		}
	}

	const auto& layoutNodes = mapLayout->GetLayoutNodes();

	//Build bg parts
	for(const auto& nodePair : layoutNodes)
	{
		if(auto bgPartObjectNode = std::dynamic_pointer_cast<CMapLayout::BGPARTS_BASE_OBJECT_NODE>(nodePair.second))
		{
			auto bgPartObject = CreateBgPartObject(mapLayout, bgPartObjectNode);
			assert(bgPartObject);
			m_bgPartObjects.insert(std::make_pair(nodePair.first, bgPartObject));
		}
	}

	for(const auto& nodePair : layoutNodes)
	{
		if(auto instanceNode = std::dynamic_pointer_cast<CMapLayout::INSTANCE_OBJECT_NODE>(nodePair.second))
		{
			auto refNodeIterator = layoutNodes.find(instanceNode->refNodePtr);
			if(refNodeIterator == std::end(layoutNodes)) continue;

			CVector3 instancePosition(instanceNode->posX, instanceNode->posY, instanceNode->posZ);
			CQuaternion instanceRotY(CVector3(0, -1, 0), instanceNode->rotY);

			auto refNode = refNodeIterator->second;
			if(auto unitTreeObjectNode = std::dynamic_pointer_cast<CMapLayout::UNIT_TREE_OBJECT_NODE>(refNode))
			{
				for(const auto& item : unitTreeObjectNode->items)
				{
					auto refNodeIterator = layoutNodes.find(item.nodePtr);
					assert(refNodeIterator != std::end(layoutNodes));
					if(refNodeIterator == std::end(layoutNodes)) continue;

					auto refNode = refNodeIterator->second;
					if(auto bgPartsBaseObjectNode = std::dynamic_pointer_cast<CMapLayout::BGPARTS_BASE_OBJECT_NODE>(refNode))
					{
						auto bgPartObjectIterator = m_bgPartObjects.find(item.nodePtr);
						assert(bgPartObjectIterator != std::end(m_bgPartObjects));
						if(bgPartObjectIterator == std::end(m_bgPartObjects)) continue;

						auto tempNode = Palleon::CSceneNode::Create();
						tempNode->AppendChild(bgPartObjectIterator->second);
						tempNode->SetPosition(instancePosition);
						tempNode->SetRotation(instanceRotY);
						tempNode->UpdateTransformations();
						tempNode->TraverseNodes(
							[&] (const Palleon::SceneNodePtr& node)
							{
								if(auto mesh = std::dynamic_pointer_cast<CUmbralMesh>(node))
								{
									auto instance = mesh->CreateInstance();
									m_instances.push_back(instance);
								}
								return true;
							}
						);
					}
				}
			}
			else if(auto bgPartObjectNode = std::dynamic_pointer_cast<CMapLayout::BGPARTS_BASE_OBJECT_NODE>(refNode))
			{
				auto bgPartObjectIterator = m_bgPartObjects.find(refNodeIterator->first);
				assert(bgPartObjectIterator != std::end(m_bgPartObjects));
				if(bgPartObjectIterator == std::end(m_bgPartObjects)) continue;

				auto tempNode = Palleon::CSceneNode::Create();
				tempNode->AppendChild(bgPartObjectIterator->second);
				tempNode->SetPosition(instancePosition);
				tempNode->SetRotation(instanceRotY);
				tempNode->UpdateTransformations();

				tempNode->TraverseNodes(
					[&] (const Palleon::SceneNodePtr& node)
					{
						if(auto mesh = std::dynamic_pointer_cast<CUmbralMesh>(node))
						{
							auto instance = mesh->CreateInstance();
							m_instances.push_back(instance);
						}
						return true;
					}
				);
			}
		}
	}
}
Пример #18
0
void MODEL::DoDryRewet( PROJECT* project, int* dried, int* wetted )
{
  DRYREW *dryRew = &region->dryRew;

  region->Connection( 0L );

  int del = 0;
  int wel = 0;

  if( dryRew->method == 1 )
  {
    // mark nodes and elements to be rewetted ------------------------------------------------------
    wel = region->Rewet( dryRew->rewetLimit, dryRew->rewetPasses, project );

    // mark dry nodes and elements -----------------------------------------------------------------
    del = region->Dry( dryRew->dryLimit, dryRew->countDown );
  }
  else if( dryRew->method == 2 )
  {
    region->DryRewet( dryRew->dryLimit, dryRew->rewetLimit, dryRew->countDown, &del, &wel );
  }
  else if( dryRew->method == 3 )
  {
    region->RewetDry( dryRew->dryLimit, dryRew->rewetLimit, dryRew->countDown, &del, &wel );
  }
/*
  // future work ...
  else if( dryRew->method == 4 )
  {
    // determine dynamic boundary ------------------------------------------------------------------
    region.DynamicBound( np, node, *elem, dryRew->dryLimit, project );
  }
*/

  //////////////////////////////////////////////////////////////////////////////////////////////////

# ifdef _MPI_
  del = project->subdom.Mpi_sum( del );
  wel = project->subdom.Mpi_sum( wel );
# endif

  char text [200];

  sprintf( text, "\n (MODEL::DoDryRewet)     %d elements have got dry\n", del );
  REPORT::rpt.Output( text, 3 );

  sprintf( text, "\n (MODEL::DoDryRewet)     %d elements have got wet\n", wel );
  REPORT::rpt.Output( text, 3 );

  int dryRewFlag = del + wel;

  if( dryRewFlag )
  {
    ////////////////////////////////////////////////////////////////////////////////////////////////
    // exchange information on dry nodes on interfaces
#   ifdef _MPI_
    if( project->subdom.npr > 1 )
    {
      MPI_Comm_Dry( project, true );

      //////////////////////////////////////////////////////////////////////////////////////////////
      // reset wetted area, in case of dry nodes that are not dry in adjacent subdomains
      // added on 20.04.2006, sc

      if( dryRew->method == 2  ||  dryRew->method == 3 )
      {
        int wetted = 0;

        for( int n=0; n<region->Getnp(); n++ )
        {
          NODE* nd = region->Getnode(n);

          nd->mark = false;

          double H = nd->v.S - nd->zor;

          if( H < dryRew->dryLimit )
          {
            SF( nd->flag, NODE::kDry );
          }

          else if( isFS(nd->flag, NODE::kDry) )
          {
            nd->mark = true;

            CF( nd->flag, NODE::kDry );
            wetted++;
          }

          CF( nd->flag, NODE::kMarsh );
          nd->z = nd->zor;
        }


        if( dryRew->method == 2 )
        {
          region->DryRewet( dryRew->dryLimit, dryRew->rewetLimit, dryRew->countDown, &del, &wel );
        }
        else if( dryRew->method == 3 )
        {
          region->RewetDry( dryRew->dryLimit, dryRew->rewetLimit, dryRew->countDown, &del, &wel );
        }

        ////////////////////////////////////////////////////////////////////////////////////////////

        MPI_Comm_Dry( project, false );

        wetted = project->subdom.Mpi_sum( wetted );

        sprintf( text, "\n (MODEL::DoDryRewet)     %d interface nodes have got wet\n", wetted );
        REPORT::rpt.Output( text, 3 );
      }
    }


    ////////////////////////////////////////////////////////////////////////////////////////////////
    // reset interface flags: kInface, kInface_DN and kInface_UP; this is
    // necessary for the correct ordering of equations in EQS::ResetEqOrder()

    project->subdom.SetInface( region );

#   endif  //  #ifdef _MPI_
    ////////////////////////////////////////////////////////////////////////////////////////////////

    // determine 1D boundary elements and ----------------------------------------------------------
    // set up slip velocity boundary conditions

    Initialize();

    SetNormal();
    SetRotation();

    region->SetSlipFlow();

    REPORT::rpt.PrintTime( 3 );

//  ================================================================================================
#   ifdef kDebug_1
    for( int n=0; n<region->Getnp(); n++ )
    {
      NODE* ndbg = region->Getnode(n);

      switch( ndbg->Getname() )
      {
        case 3654:
          REPORT::rpt.Message( "\n" );
          REPORT::rpt.Message( "### NODE %6d: inface    = %d\n", ndbg->Getname(), ndbg->flag&NODE::kInface );
          REPORT::rpt.Message( "###            : inface_dn = %d\n", ndbg->flag&NODE::kInface_DN );
          REPORT::rpt.Message( "###            : inface_up = %d\n", ndbg->flag&NODE::kInface_UP );
          REPORT::rpt.Message( "\n" );
          REPORT::rpt.Message( "###            : dry       = %d\n", ndbg->flag&NODE::kDry );
          REPORT::rpt.Message( "###            : marsh     = %d\n", ndbg->flag&NODE::kMarsh );
          REPORT::rpt.Message( "###            : H         = %f\n", ndbg->v.S - ndbg->zor );
          REPORT::rpt.Message( "\n" );
          REPORT::rpt.Message( "###            : bound     = %d\n", ndbg->flag&NODE::kBound );
          REPORT::rpt.Message( "###            : inflow    = %d\n", ndbg->flag&NODE::kInlet );
          REPORT::rpt.Message( "###            : outflow   = %d\n", ndbg->flag&NODE::kOutlet );
          REPORT::rpt.Message( "###            : rotat     = %d\n", ndbg->flag&NODE::kRotat );
          REPORT::rpt.Message( "###            : noMoment  = %d\n", ndbg->flag&NODE::kNoMoment );
          REPORT::rpt.Message( "\n" );
          REPORT::rpt.Message( "###            : countDown = %d\n", ndbg->countDown );

          {
            SUB* sub = ndbg->sub;
            while( sub )
            {
              REPORT::rpt.Message( "### SUBDOM %4d: dry       = %d\n", sub->no+1, sub->dry );
              sub = sub->next;
            }
          }
          break;
      }
    }
#   endif
//  ================================================================================================
  }

  else
  {
    // set up structure for connection of nodes to elements ----------------------------------------
    // dry elements are not taken into consideration

    region->Connection( ELEM::kDry );
  }

  if( dried )  *dried  = del;
  if( wetted ) *wetted = wel;

  region->firstDryRew = false;
}
Пример #19
0
void CScriptMoveType::SetPhysics(const float3& _pos, const float3& _vel, const float3& _rot)
{
	SetPosition(_pos);
	SetVelocity(_vel);
	SetRotation(_rot);
}
Пример #20
0
extern "C" void Function_GetChainOrientationProbabilityTest(char ** input_string,
                                                            int*_ptCount,
                                                            double*  _separationCutOff,
                                                            int* corr_counts_out,
                                                            double* _systemSize) {
    int ptCount = _ptCount[0];
    double separationCutOff = _separationCutOff[0];
    double systemSize = _systemSize[0];

    std::string input(*input_string);
    std::stringstream in_stream;

    in_stream << "{\"value0\": \"";
    in_stream << input;
    in_stream << "\"}";
    cereal::JSONInputArchive arch(in_stream);
    std::vector<CParticleBase> particles;

    for (int i = 0; i < ptCount; ++i) {
        particles.push_back(CParticleBase());
    }
    arch.loadBinaryValue(&particles[0], sizeof(CParticleBase) * ptCount);

    particles = std::vector<CParticleBase>();

    double displ = 0;
    for(int i = 0; i < 10; i++){
        auto pt = CParticleBase();
        pt.Coordinates = i*0.9 + displ;

        particles.push_back(pt);
    }

//    displ = 12;
//    for(int i = 0; i < 10; i++){
//        auto pt = CParticleBase();
//        pt.Coordinates = i*0.9 + displ;
//
//        particles.push_back(pt);
//    }
//
//    displ = 24;
//    for(int i = 0; i < 10; i++){
//        auto pt = CParticleBase();
//        pt.Coordinates = i*0.9 + displ;
//        pt.Rotation = CQuaternion(M_PI, CVector(0, 1, 0));
//        particles.push_back(pt);
//    }
//
//
    displ = 36;
    for(int i = 0; i < 10; i++){
        auto pt = CParticleBase();
        pt.Coordinates = i*0.9 + displ;
        pt.SetRotation(CQuaternion(M_PI, CVector(0, 1, 0)));
        particles.push_back(pt);
    }

    displ = 48;
    for(int i = 0; i < 10; i++){
        auto pt = CParticleBase();
        pt.Coordinates = i*0.9 + displ;
        pt.SetRotation(CQuaternion(M_PI, CVector(0, 1, 0)));
        particles.push_back(pt);
    }


    bool chain_1 = particles[0].GetOrientation().Z > 0;
    bool chain_2 = true;

    int chainLength = 0;

    for (int i = 0; i < particles.size(); i++) {
        auto& pt = particles[i];
        auto& pt_next = particles[get_next(i, ptCount)];

        auto cosTheta = pt.GetOrientation().Z;
        auto cosTheta_next = pt_next.GetOrientation().Z;

        chain_2 = cosTheta_next > 0;

        if(pt.GetDistanceRight(pt_next, systemSize).GetLength() <= separationCutOff && cosTheta * cosTheta_next >= 0){
            chainLength++;
        }
        else {
            // ll, rl, lr, rr
            if (chain_1 && chain_2) corr_counts_out[3]++;
            if (!chain_1 && chain_2) corr_counts_out[2]++;
            if (chain_1 && !chain_2) corr_counts_out[1]++;
            if (!chain_1 && !chain_2) corr_counts_out[0]++;

            if (chain_1) {
                corr_counts_out[4]++;
            }
            else {
                corr_counts_out[5]++;
            }

            corr_counts_out[6] += chainLength;
            chainLength = 0;

            chain_1 = chain_2;
        }
    }
}
Пример #21
0
FirstPersonCamera::FirstPersonCamera()
    : PerspectiveCamera()
{
    SetRotation(XMFLOAT2(0.0f, 0.0f), 0.0f);
    UpdateProjection();
}
Пример #22
0
void
Snake::Update(float dt)
{
    if(m_isStopped)
    {
        return;
    }
    
    //Update the powerup effects before doing anything
    updatePowerups(dt);
    
    Vector2 pos = m_grid->GetIntermediatePosition(this);
    Vector2 oldPos = pos;
    Vector2 oldGridPos = m_grid->WorldSpaceToGrid(pos);
    
    float rot = 0;
    switch(m_direction)
    {
        case DirectionUp:
            pos.Y += m_movespeed * dt;
            break;
        case DirectionDown:
            pos.Y -= m_movespeed * dt;
            rot = 180;
            break;
        case DirectionLeft:
            pos.X -= m_movespeed * dt;
            rot = 90;
            break;
        case DirectionRight:
            pos.X += m_movespeed * dt;
            rot = 270;
            break;
    }
    
    m_grid->SetIntermediatePosition(this, pos);
    Vector2 newGridPos = m_grid->WorldSpaceToGrid(pos);
    
    if(oldGridPos != newGridPos)
    {
        /** Only update the rotation on positional changes. */
        SetRotation(rot);
        
        if(!m_requestedDirections.empty())
        {
            while(isOppositeDirection(m_requestedDirections.front()))
            {
                m_requestedDirections.pop();
                
                if(m_requestedDirections.empty())
                {
                    break;
                }
            }
            
            if(!m_requestedDirections.empty())
            {
                m_direction = m_requestedDirections.front();
                m_requestedDirections.pop();
            }
        }
        
        if(m_biteTimer > 1)
        {
            SetSprite(getSnakeHeadPath(false));
        }
        
        m_biteTimer++;
        
        /** The snake head has moved a cell. Adjust the tail. */
        std::deque<Actor*>::iterator it = m_tail.begin();
        
        Vector2 prior = oldPos;
        float priorRot = GetRotation();
        
        /** Insert a tailpiece right after the head. */
        if(m_numConsumed != 0)
        {
            addTailPiece(prior);
            m_numConsumed--;
        }
        else
        {
            for(; it != m_tail.end(); ++it)
            {
                /** Shift all tail members to the position of the member prior to itself. */
                Vector2 tmp = m_grid->GetIntermediatePosition(*it);
                m_grid->SetIntermediatePosition(*it, prior);
                
                float tmpRot = (*it)->GetRotation();
                
                bool isCorner = false;
                if(*it != m_tail.back())
                {
                    if(tmpRot != priorRot)
                    {
                        chooseCornerOrientation(*it, priorRot, prior);
                        isCorner = true;
                    }
                    else
                    {
                        (*it)->SetSprite("Resources/Images/snake/snake_body.png");
                    }
                }
                
                (*it)->SetRotation(priorRot);
                
                priorRot = tmpRot;
                prior = tmp;
            }
        }
    }
    m_grid->Update(dt);
}
Пример #23
0
	void Transform2D::SetRotationDeg(const glm::float32& deg)
	{
		SetRotation(Angle::FromDegrees(deg));
	}
Пример #24
0
bool cPlayer::LoadFromDisk()
{
    LoadPermissionsFromDisk();

    // Log player permissions, cause it's what the cool kids do
    LOGINFO("Player %s has permissions:", m_PlayerName.c_str() );
    for( PermissionMap::iterator itr = m_ResolvedPermissions.begin(); itr != m_ResolvedPermissions.end(); ++itr )
    {
        if( itr->second ) LOGINFO("%s", itr->first.c_str() );
    }

    AString SourceFile;
    Printf(SourceFile, "players/%s.json", m_PlayerName.c_str() );

    cFile f;
    if (!f.Open(SourceFile, cFile::fmRead))
    {
        // This is a new player whom we haven't seen yet, bail out, let them have the defaults
        return false;
    }

    AString buffer;
    if (f.ReadRestOfFile(buffer) != f.GetSize())
    {
        LOGWARNING("Cannot read player data from file \"%s\"", SourceFile.c_str());
        return false;
    }
    f.Close(); //cool kids play nice

    Json::Value root;
    Json::Reader reader;
    if (!reader.parse(buffer, root, false))
    {
        LOGWARNING("Cannot parse player data in file \"%s\", player will be reset", SourceFile.c_str());
    }

    Json::Value & JSON_PlayerPosition = root["position"];
    if (JSON_PlayerPosition.size() == 3)
    {
        SetPosX(JSON_PlayerPosition[(unsigned int)0].asDouble());
        SetPosY(JSON_PlayerPosition[(unsigned int)1].asDouble());
        SetPosZ(JSON_PlayerPosition[(unsigned int)2].asDouble());
        m_LastPosX = GetPosX();
        m_LastPosY = GetPosY();
        m_LastPosZ = GetPosZ();
        m_LastFoodPos = GetPosition();
    }

    Json::Value & JSON_PlayerRotation = root["rotation"];
    if (JSON_PlayerRotation.size() == 3)
    {
        SetRotation ((float)JSON_PlayerRotation[(unsigned int)0].asDouble());
        SetPitch    ((float)JSON_PlayerRotation[(unsigned int)1].asDouble());
        SetRoll     ((float)JSON_PlayerRotation[(unsigned int)2].asDouble());
    }

    m_Health              = root.get("health", 0).asInt();
    m_AirLevel            = root.get("air",            MAX_AIR_LEVEL).asInt();
    m_FoodLevel           = root.get("food",           MAX_FOOD_LEVEL).asInt();
    m_FoodSaturationLevel = root.get("foodSaturation", MAX_FOOD_LEVEL).asDouble();
    m_FoodTickTimer       = root.get("foodTickTimer",  0).asInt();
    m_FoodExhaustionLevel = root.get("foodExhaustion", 0).asDouble();
    m_LifetimeTotalXp     = (short) root.get("xpTotal", 0).asInt();
    m_CurrentXp           = (short) root.get("xpCurrent", 0).asInt();

    //SetExperience(root.get("experience", 0).asInt());

    m_GameMode = (eGameMode) root.get("gamemode", eGameMode_NotSet).asInt();

    m_Inventory.LoadFromJson(root["inventory"]);

    m_LoadedWorldName = root.get("world", "world").asString();

    LOGD("Player \"%s\" was read from file, spawning at {%.2f, %.2f, %.2f} in world \"%s\"",
         m_PlayerName.c_str(), GetPosX(), GetPosY(), GetPosZ(), m_LoadedWorldName.c_str()
        );

    return true;
}
Пример #25
0
//=============================================================================
void CTransformComponent2::UpdateRotation (Radian delta)
{
    SetRotation(GetRotation() + delta);
}
Пример #26
0
void Item::Update()
{
	frame++;

	auto engine = STGEngine::GetInstance();

	auto player = engine->GetPlayer();
	auto playerPos = player->GetPosition();

	auto difX = position.x - playerPos.x;
	auto difY = position.y - playerPos.y;

	if (goToPlayer && player->IsDead() == false)
	{
		if (GetSpeed() > 7.0f)
		{
			SetSpeed(7.0f);
			SetAcSpeed(0.0f);
		}
		if (difX*difX + difY*difY < 64)
		{
			OnGot();
			return;
		}
		SetAngle(Math::ToAngle(-difX, -difY));
		SetRotation(GetAngle());
	}

	Sprite::Update();

	if (goToPlayer && player->IsDead() == false)   //Already disposed
	{
		return;
	}

	if (frame > 40)
	{
		SetAngle(270.0f);
		SetAcSpeed(0.05f);
		SetRotation(0.0f);
	}

	if (GetSpeed() > 1.5f)
	{
		SetSpeed(1.5f);
		SetAcSpeed(0.0f);
	}

	if (player->IsDead())
	{
		return;
	}

	float dist;
	if (player->IsHiSpeed())
	{
		dist = hitRange + player->GetHiSpeedItemRange();
		if (difX*difX + difY*difY < dist*dist)
		{
			GoToPlayer();
		}
	}
	else
	{
		dist = hitRange + player->GetLowSpeedItemRange();
		if (difX*difX + difY*difY < dist*dist)
		{
			GoToPlayer();
		}
	}

	if (playerPos.y > player->GetItemGetHeight())
	{
		gotFromHigh = true;
		GoToPlayer();
	}

	if (position.y < -32 || position.y > 480)
	{
		MarkDestroy();
	}
}
Пример #27
0
void GroupNode::CopyAsChildren(Scene* scene, GroupNode* root) {
  const std::vector<SceneNode*>& tocopy_children = root->Children();
  std::deque<SceneNode*>
    to_process(tocopy_children.begin(), tocopy_children.end());

  SetTranslation(root->Translation());
  SetRotation(root->Rotation());
  SetScale(root->Scale());
  SetVisible(root->Visible());

  while (!to_process.empty()) {
    SceneNode* to_copy = to_process.front();
    to_process.pop_front();
    SceneNode* node_copy = nullptr;

    switch (to_copy->NodeType()) {
      case SceneNodeType::kGroupNode:
        {
          GroupNode* child = scene->MakeGroup(this, Scene::kAutoName);
          GroupNode* group_to_copy =
            dynamic_cast<GroupNode*>(to_copy);
          child->CopyAsChildren(scene, group_to_copy);
          node_copy = child;
        }
        break;
      case SceneNodeType::kCameraNode:
        {
          CameraNode* child = scene->MakeCamera(this, Scene::kAutoName);
          const CameraNode* camera_to_copy =
            dynamic_cast<const CameraNode*>(to_copy);
          child->CopyFrom(*camera_to_copy);
          node_copy = child;
        }
        break;
      case SceneNodeType::kLightNode:
        {
          LightNode* child = scene->MakeLight(this, Scene::kAutoName);
          const LightNode* light_to_copy =
            dynamic_cast<const LightNode*>(to_copy);
//          *child = *light_to_copy;
          (void)light_to_copy;
          node_copy = child;
        }
        break;
      case SceneNodeType::kDrawNode:
        {
          DrawNode* node_to_copy =
            dynamic_cast<DrawNode*>(to_copy);
          DrawNode* child = scene->MakeDrawNode(this, Scene::kAutoName);
          for (const Drawable::Ptr& item : node_to_copy->Drawables()) {
            child->Add(item);
          }
          node_copy = child;
        }
        break;
    }

    node_copy->SetTranslation(to_copy->Translation());
    node_copy->SetRotation(to_copy->Rotation());
    node_copy->SetScale(to_copy->Scale());
    node_copy->SetVisible(to_copy->Visible());
  }
}
Пример #28
0
	wrapper.PrepareAccelerometer();

	wrapper.WaitForInitialization();

	//The example...
	CogitareComputing::Pico::Engine picoEngine("LD33", 640, 480, 60, vs, fs, CogitareComputing::Pico::SystemSpecificData(&wrapper));
	picoEngine.PlayOggMusic("trudelutt2.ogg", false);
	auto sound = picoEngine.GetSound("powerup.wav");
	auto msh = picoEngine.LoadMesh("picocube.obj");
	auto gob = std::make_shared<CogitareComputing::Pico::SimpleGameObject>(msh);
	picoEngine.AddGameObject(gob);
	picoEngine.SetCameraPos(CogitareComputing::Pico::Vec3(0.0f, 0.0f, -2.0f));
	gob->SetPosition(CogitareComputing::Pico::Vec3(0.0f, 0.0f, 2.0f));
	picoEngine.SetLight(CogitareComputing::Pico::Vec3(1.0f, 1.0f, 1.0f));
	auto angle = 0.0f;
	sound->Play(false);
	picoEngine.Run([&picoEngine, &gob, &angle](double elapsed)
	{
		glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
		if (picoEngine.IsKeyDown(27))
			return false;

		gob->SetRotation(CogitareComputing::Pico::Vec3(angle, angle, angle));
		angle += 0.1f;
		return true;
	});
	picoEngine.RemoveGameObject(gob->Id());

}
Пример #29
0
void Camera::SetTarget(const core::vector3df &target)
{
	SetRotation( (target - GetAbsolutePosition()).getHorizontalAngle() );
}
Пример #30
0
void Camera::UpdateRotation(float xTurn, float yTurn, float zTurn)
{
	SetRotation(m_rotationX + xTurn, m_rotationY + yTurn, m_rotationZ + zTurn);
}