bool CNSVariable::SetPrimVar_Compressible(double eddy_visc, double turb_ke, CFluidModel *FluidModel) { unsigned short iVar; bool check_dens = false, check_press = false, check_sos = false, check_temp = false, RightVol = true; SetVelocity(); // Computes velocity and velocity^2 double density = GetDensity(); double staticEnergy = GetEnergy()-0.5*Velocity2 - turb_ke; /* check will be moved inside fluid model plus error description strings*/ FluidModel->SetTDState_rhoe(density, staticEnergy); check_dens = SetDensity(); check_press = SetPressure(FluidModel->GetPressure()); check_sos = SetSoundSpeed(FluidModel->GetSoundSpeed2()); check_temp = SetTemperature(FluidModel->GetTemperature()); /*--- Check that the solution has a physical meaning ---*/ if (check_dens || check_press || check_sos || check_temp) { /*--- Copy the old solution ---*/ for (iVar = 0; iVar < nVar; iVar++) Solution[iVar] = Solution_Old[iVar]; /*--- Recompute the primitive variables ---*/ SetVelocity(); // Computes velocity and velocity^2 double density = GetDensity(); double staticEnergy = GetEnergy()-0.5*Velocity2 - turb_ke; /* check will be moved inside fluid model plus error description strings*/ FluidModel->SetTDState_rhoe(density, staticEnergy); check_dens = SetDensity(); check_press = SetPressure(FluidModel->GetPressure()); check_sos = SetSoundSpeed(FluidModel->GetSoundSpeed2()); check_temp = SetTemperature(FluidModel->GetTemperature()); RightVol = false; } /*--- Set enthalpy ---*/ SetEnthalpy(); // Requires pressure computation. /*--- Set laminar viscosity ---*/ SetLaminarViscosity(FluidModel->GetLaminarViscosity(FluidModel->GetTemperature(), GetDensity())); /*--- Set eddy viscosity ---*/ SetEddyViscosity(eddy_visc); return RightVol; }
bool CNSVariable::SetPrimVar_Compressible(double eddy_visc, double turb_ke, CConfig *config) { unsigned short iVar; bool check_dens = false, check_press = false, check_sos = false, check_temp = false, RightVol = true; double Gas_Constant = config->GetGas_ConstantND(); double Gamma = config->GetGamma(); SetVelocity(); // Computes velocity and velocity^2 check_dens = SetDensity(); // Check the density check_press = SetPressure(Gamma, turb_ke); // Requires velocity2 computation. check_sos = SetSoundSpeed(Gamma); // Requires pressure computation. check_temp = SetTemperature(Gas_Constant); // Requires pressure computation. /*--- Check that the solution has a physical meaning ---*/ if (check_dens || check_press || check_sos || check_temp) { /*--- Copy the old solution ---*/ for (iVar = 0; iVar < nVar; iVar++) Solution[iVar] = Solution_Old[iVar]; /*--- Recompute the primitive variables ---*/ SetVelocity(); check_dens = SetDensity(); check_press = SetPressure(Gamma, turb_ke); check_sos = SetSoundSpeed(Gamma); check_temp = SetTemperature(Gas_Constant); RightVol = false; } /*--- Set enthalpy ---*/ SetEnthalpy(); // Requires pressure computation. /*--- Set laminar viscosity ---*/ SetLaminarViscosity(config); // Requires temperature computation. /*--- Set eddy viscosity ---*/ SetEddyViscosity(eddy_visc); return RightVol; }
//----------------------------------------------------------------------------- // SetDensityAll //----------------------------------------------------------------------------- void CPhysicObj::SetDensityAll (float fDensity) { for (int i = 0; i < GetNumParts(); i++) { SetDensity (i, fDensity); } }
CIsoSurface::CIsoSurface(CScreensaverCpBlobs* base) : m_base(base) { SetDensity(24); m_TargetValue = 18.0f; m_pVxs = new glm::vec3[MAXVXS]; m_pNorms = new glm::vec3[MAXVXS]; }
Object::Object(float x, float y , String pathName, float sx, float sy) { SetLayer(3); SetPosition(x, y); SetName("object"); SetSprite(pathName); SetSize(sx, sy); SetDensity(0.0f); SetFriction(0.0f); SetRestitution(0.1f); InitPhysics(); }
static int PSetDensity(int argc, char *argv[], int argt[], ARRAY *variables) { int i; double d; if (argc != 1) return -1; if (argt[0] != NUMBER) return -1; d = atof(argv[0]); i = SetDensity(d); return i; }
static PyObject *PSetDensity(PyObject *self, PyObject *args) { double d; if (spol_file) { SPOLStatement("SetDensity", args, NULL); Py_INCREF(Py_None); return Py_None; } if (!PyArg_ParseTuple(args, "d", &d)) return NULL; SetDensity(d); Py_INCREF(Py_None); return Py_None; }
CharActor::CharActor(const String& maskPath, const Vector2 size) : PhysicsActor() //, m_mask(maskPath) , m_direction(SOUTH) , m_moving(false) , m_movingNorth(false) , m_movingEast(false) , m_movingSouth(false) , m_movingWest(false) , m_movementSpeed(100.0f) //3.0f , m_idleness(0.0f) , m_idleAnim(false) //, m_isKinematic(true) { m_mask = thePixelArthGame.m_collHandler->GetBitmask(maskPath); //SetName("Arth"); //SetColor(1.0f, 1.0f, 1.0f, 1.0f); SetSize(size.X, size.Y); //_mask->setSizeInWorldUnits(size); SetDensity(1.0f); SetFriction(0.0f); SetRestitution(0.0f); SetIsSensor(true); SetFixedRotation(true); InitPhysics(); //_timestampArrowReleased = theWorld.GetCurrentTimeSeconds(); //ClearSpriteInfo(); SetSprite("Resources/Images/animations/chars/arth/stand/lookAroundDown/lookAroundDown_00.png"); theSwitchboard.SubscribeTo(this, "CameraChange"); theSwitchboard.SubscribeTo(this, "UpArrowPressed"); theSwitchboard.SubscribeTo(this, "DownArrowPressed"); theSwitchboard.SubscribeTo(this, "LeftArrowPressed"); theSwitchboard.SubscribeTo(this, "RightArrowPressed"); theSwitchboard.SubscribeTo(this, "UpArrowReleased"); theSwitchboard.SubscribeTo(this, "DownArrowReleased"); theSwitchboard.SubscribeTo(this, "LeftArrowReleased"); theSwitchboard.SubscribeTo(this, "RightArrowReleased"); ///TEST //_world = new Bitmask("Resources/Images/coll.png"); }
BipedDef::BipedDef() { SetMotorTorque(2.0f); SetMotorSpeed(0.0f); SetDensity(20.0f); SetRestitution(0.0f); SetLinearDamping(0.0f); SetAngularDamping(0.005f); SetGroupIndex(--count); EnableMotor(); EnableLimit(); DefaultVertices(); DefaultPositions(); DefaultJoints(); LFootPoly.friction = RFootPoly.friction = 0.85f; }
Cliff_Small::Cliff_Small(Vector2 startingPosition) { int zoom = ((ShapeGameManager*)theWorld.GetGameManager())->WorldZoom * 2; SetSize(zoom); SetPosition(startingPosition); // SetSprite("Resources/Images/sa_cliff_small.png"); SetDensity(0.0f); SetFriction(0.5f); SetRestitution(0.0f); SetShapeType(PhysicsActor::SHAPETYPE_BOX); SetColor(1.0f, 1.0f, 0.5f, 1.0f); InitPhysics(); Tag("ground"); }
FinishLine::FinishLine(Vector2 startingPosition) { int zoom = ((ShapeGameManager*)theWorld.GetGameManager())->WorldZoom; SetSize(zoom * 1.75, zoom * 2); SetPosition(startingPosition); SetSprite("Resources/Images/sa_finish_line.png"); // SetUVs(Vector2(0.0f, 0.0f), Vector2(7.0f, 5.0f)); SetDensity(0.0f); SetFriction(0.5f); SetRestitution(0.0f); SetShapeType(PhysicsActor::SHAPETYPE_BOX); SetColor(1.0f, 1.0f, 1.0f, 1.0f); // InitPhysics(); Tag("ground"); }
void P3DBranchingAlgStd::Load (P3DInputStringFmtStream *SourceStream, const P3DFileVersion *Version) { char StrValue[255 + 1]; float FloatValue; unsigned int UintValue; bool BoolValue; SourceStream->ReadFmtStringTagged("Density","f",&FloatValue); SetDensity(FloatValue); SourceStream->ReadFmtStringTagged("DensityV","f",&FloatValue); SetDensityV(FloatValue); if (Version->Minor > 5) { SourceStream->ReadFmtStringTagged("MinNumber","u",&UintValue); SetMinNumber(UintValue); SourceStream->ReadFmtStringTagged("MaxLimitEnabled","b",&BoolValue); SetMaxLimitEnabled(BoolValue); SourceStream->ReadFmtStringTagged("MaxNumber","u",&UintValue); SetMaxNumber(UintValue); } else { SetMinNumber(0); SetMaxLimitEnabled(false); SetMaxNumber(0); } if (Version->Minor > 1) { SourceStream->ReadFmtStringTagged("Multiplicity","u",&UintValue); SetMultiplicity(UintValue); } else { Multiplicity = 1; } if (Version->Minor > 7) { SourceStream->ReadFmtStringTagged("StartRevAngle","f",&FloatValue); SetStartRevAngle(FloatValue); } else { StartRevAngle = 0.0f; } SourceStream->ReadFmtStringTagged("RevAngle","f",&FloatValue); SetRevAngle(FloatValue); SourceStream->ReadFmtStringTagged("RevAngleV","f",&FloatValue); SetRevAngleV(FloatValue); SourceStream->ReadFmtStringTagged("RotAngle","f",&FloatValue); SetRotationAngle(FloatValue); SourceStream->ReadFmtStringTagged("MinOffset","f",&FloatValue); SetMinOffset(FloatValue); SourceStream->ReadFmtStringTagged("MaxOffset","f",&FloatValue); SetMaxOffset(FloatValue); SourceStream->ReadFmtStringTagged("DeclinationCurve","s",StrValue,sizeof(StrValue)); P3DLoadSplineCurve(&DeclinationCurve,SourceStream,StrValue); SourceStream->ReadFmtStringTagged("DeclinationV","f",&FloatValue); SetDeclinationV(FloatValue); }
Shape::Shape(Vector2 startingPosition) { SetName("Blocky"); SetPosition(startingPosition); _jumpTimeout = -1.0f; _onGround = true; _facingRight = true; _poweringUp = false; // int zoom = ((ShapeGameManager*)theWorld.GetGameManager())->WorldZoom; // SetSize((float)(zoom) * 0.5f, (float)(zoom) * 0.5f); SetSize(3.0f, ((3.0f * 1.1f) * (106.0f / 60.0f)) ); // SetColor(0.0f, 0.0f, 1.0f, 1.0f); SetColor(1.0f, 1.0f, 1.0f, 1.0f); // LoadSpriteFrames("Resources/Images/player_1/p1_01.png", GL_CLAMP, GL_NEAREST); // LoadSpriteFrames("Resources/Images/shapey/Shapey_01.png", GL_CLAMP, GL_NEAREST); LoadSpriteFrames("Resources/Images/Sprite_shapeyV01/Untitled-3_frame_0.png", GL_CLAMP, GL_NEAREST); // LoadSpriteFrames("Resources/Images/patch_01.png", GL_CLAMP, GL_NEAREST); SetSpriteFrame(0); // SetSprite("Resources/Images/red_texture.png"); SetDensity(0.1f); SetFriction(0.1f); SetRestitution(0.0f); SetFixedRotation(true); InitPhysics(); b2PolygonShape sensorShape; b2FixtureDef sensorFixtureDef; sensorFixtureDef.isSensor = true; sensorFixtureDef.shape = &sensorShape; sensorShape.SetAsBox((3.0f / 2), 0.5f, b2Vec2(0.0f, -(GetSize().Y * 0.5f)), 0.0f); _footSensor = GetBody()->CreateFixture(&sensorFixtureDef); _footSensor->SetUserData(this); sensorShape.SetAsBox((3.0f / 2), 0.5f, b2Vec2(0.0f, (GetSize().Y * 0.5f)), 0.0f); _headSensor = GetBody()->CreateFixture(&sensorFixtureDef); _headSensor->SetUserData(this); sensorShape.SetAsBox(0.5f, ((3.0f * 1.39f / 2) - 0.5f), b2Vec2((GetSize().X * 0.5f), 0.0f), 0.0f); _rightSensor = GetBody()->CreateFixture(&sensorFixtureDef); _rightSensor->SetUserData(this); sensorShape.SetAsBox(0.5f, ((3.0f * 1.39f / 2) - 0.5f), b2Vec2(-(GetSize().X * 0.5f), 0.0f), 0.0f); _leftSensor = GetBody()->CreateFixture(&sensorFixtureDef); _leftSensor->SetUserData(this); // SetDrawSize((float)zoom * 0.5f, (float)zoom * 0.5f); _jumpSound = theSound.LoadSample("Resources/Sounds/Jump.wav", false); _powerUpSound = theSound.LoadSample("Resources/Sounds/PowerUp.wav", false); _orbSound = theSound.LoadSample("Resources/Sounds/Picked_Coin_Echo.wav", false); // _bonkSound = theSound.LoadSample("Resources/Sounds/Bonk.wav", false); // Initialize inventory _inventory = new Inventory(); }
void ModelTestScene::Initialize(const GameContext& gameContext) { UNREFERENCED_PARAMETER(gameContext); //GROUND PLANE //************ auto physX = PhysxManager::GetInstance()->GetPhysics(); auto bouncyMaterial = physX->createMaterial(0, 0, 1); auto ground = new GameObject(); ground->AddComponent(new RigidBodyComponent(true)); std::shared_ptr<PxGeometry> geom(new PxPlaneGeometry()); ground->AddComponent(new ColliderComponent(geom, *bouncyMaterial, PxTransform(PxQuat(XM_PIDIV2, PxVec3(0, 0, 1))))); AddChild(ground); //CHAIR OBJECT //************ m_pChair = new GameObject(); //1. Attach a modelcomponent (chair.ovm) auto chairModelComponent = new ModelComponent(L"./Resources/Meshes/chair.ovm"); m_pChair->AddComponent(chairModelComponent); //2. Create a ColorMaterial and add it to the material manager auto chairColorMaterial = new ColorMaterial(); gameContext.pMaterialManager->AddMaterial(chairColorMaterial, 102); //3. Assign the material to the previous created modelcomponent m_pChair->GetComponent<ModelComponent>()->SetMaterial(102); // Build and Run //4. Create a DiffuseMaterial (using PosNormTex3D.fx) // Make sure you are able to set a texture (DiffuseMaterial::SetDiffuseTexture(const wstring& assetFile)) // Load the correct shadervariable and set it during the material variable update auto chairDiffuseMaterial = new DiffuseMaterial(); chairDiffuseMaterial->SetDiffuseTexture(L"./Resources/Textures/Chair_Dark.dds"); gameContext.pMaterialManager->AddMaterial(chairDiffuseMaterial, 104); //5. Assign the material to the modelcomponent m_pChair->GetComponent<ModelComponent>()->SetMaterial(104); // Build and Run //6. Attach a rigidbody component (pure-dynamic) auto chairRigidbody = new RigidBodyComponent(); m_pChair->AddComponent(chairRigidbody); //7. Attach a collider component (Use a PxConvexMeshGeometry [chair.ovpc]) auto defaultMaterial = physX->createMaterial(0.5f, 0.5f, 0.1f); auto chairMesh = ContentManager::Load<PxConvexMesh>(L"./Resources/Meshes/chair.ovpc"); shared_ptr<PxGeometry> chairGeo(new PxConvexMeshGeometry(chairMesh)); auto chairCollider = new ColliderComponent(chairGeo, *defaultMaterial); m_pChair->AddComponent(chairCollider); AddChild(m_pChair); chairRigidbody->SetDensity(300); m_pChair->GetTransform()->Translate(0, 10, 0); // Build and Run }
void CCompound::AddBody(CAbstractBody const & otherbody) { SetWeight(otherbody.GetWeight()); SetVolume(otherbody.GetVolume()); SetDensity(); }