bool GetCurShadowLightInfo(ShadowHelper.Shadower shadower, out Matrix shadowerTransform, out float intensity, out Vector3 lightPos, out Vector3 lightDir, out bool bDirectional) { Vector4 col0, col1, col2; if (shadower.mContext is StaticMeshComp) { StaticMeshComp smc = shadower.mContext as StaticMeshComp; shadowerTransform = smc.mPO.GetMatrix(); if (!mVisibleSMC.Contains(smc)) { intensity = 0f; lightPos = lightDir = Vector3.Zero; bDirectional = true; return(false); } MeshLighting ml = smc.mOwner.GetComponent( typeof(MeshLighting)) as MeshLighting; if (ml == null || !ml.NeedsShadow()) { intensity = 0f; lightPos = lightDir = Vector3.Zero; bDirectional = true; return(false); } ml.GetCurrentValues(out col0, out col1, out col2, out intensity, out lightPos, out lightDir, out bDirectional); return(true); } if (shadower.mChar == mPChar) { shadowerTransform = mPChar.GetTransform(); } else { intensity = 0f; lightPos = Vector3.Zero; lightDir = Vector3.Zero; bDirectional = false; shadowerTransform = Matrix.Identity; return(false); } return(mPMeshLighting.GetCurrentValues(out col0, out col1, out col2, out intensity, out lightPos, out lightDir, out bDirectional)); }
void PickUpThing(ConvexVolume cv) { PickUp pu = cv.mOwner.GetComponent(typeof(PickUp)) as PickUp; pu.StateChange(PickUp.State.WaitingRespawn, 1); StaticMeshComp smc = pu.mOwner.GetComponent(typeof(StaticMeshComp)) as StaticMeshComp; StaticMesh sm = smc.mDrawObject as StaticMesh; int numParts = sm.GetNumParts(); for (int i = 0; i < numParts; i++) { sm.SetPartVisible(i, false); } }
void SetTriLightForSMC(StaticMeshComp smc) { MeshLighting ml = smc.mOwner.GetComponent( typeof(MeshLighting)) as MeshLighting; StaticMesh sm = smc.mDrawObject as StaticMesh; if (ml == null || sm == null) { return; } Vector4 lightCol0, lightCol1, lightCol2; Vector3 lightPos, lightDir; bool bDir; float intensity; ml.GetCurrentValues( out lightCol0, out lightCol1, out lightCol2, out intensity, out lightPos, out lightDir, out bDir); sm.SetTriLightValues(lightCol0, lightCol1, lightCol2, lightDir); }
//if running on a fixed timestep, this might be called //more often with a smaller delta time than RenderUpdate() internal void Update(UpdateTimer time, List <Input.InputAction> actions, PlayerSteering ps) { //Thread.Sleep(30); float secDelta = time.GetUpdateDeltaSeconds(); mZone.ClearPushableVelocities(secDelta); //update model movers foreach (Component c in mBModelMovers) { c.Update(time); } Vector3 pos = Vector3.Zero; bool bGroundMove = false; UInt32 contents = mPCamMob.GetWorldContents(); if (mbFly) { pos = UpdateFly(secDelta, actions, ps); } else if (Misc.bFlagSet(contents, (UInt32)GameContents.Lava) || Misc.bFlagSet(contents, (UInt32)GameContents.Water) || Misc.bFlagSet(contents, (UInt32)GameContents.Slime)) { pos = UpdateSwimming(secDelta, actions, ps); } else { pos = UpdateGround(secDelta, actions, ps, out bGroundMove); //flip ground move as it returns as a jump bool bGroundMove = !bGroundMove; } UpdateMiscKeys(actions, ps); UpdateDynamicLights(actions); Vector3 camPos = Vector3.Zero; Vector3 endPos = pos; float msDelta = time.GetUpdateDeltaMilliSeconds(); mPCamMob.Move(endPos, msDelta, false, mbFly, bGroundMove, true, out endPos, out camPos); //check resulting move against triggers / pickups if (!mbFly) { foreach (Trigger t in mTriggers) { t.BoxTriggerCheck(mPCamMob, mPCamMob.GetBounds(), pos, endPos, msDelta); } foreach (ConvexVolume cv in mPickUpCVs) { if (!cv.Active) { continue; } if (cv.SphereMotionIntersects(PlayerBoxWidth, pos, endPos)) { PickUpThing(cv); cv.StateChange(ConvexVolume.State.Active, 0); } } } //check a slightly expanded box to see if any interactives are being touched mModelsHit.Clear(); if (!mbFly) { if (mZone.TraceStaticBoxVsModels(mFatBox, endPos, mModelsHit)) { //do stuff foreach (int model in mModelsHit) { foreach (BModelMover bmm in mBModelMovers) { if (bmm.GetModelIndex() == model) { bmm.StateChange(BModelMover.States.Forward, 1); bmm.StateChange(BModelMover.States.Moving, 1); } } } } } mGD.GCam.Update(camPos, ps.Pitch, ps.Yaw, ps.Roll); if (!mbFly) { if (mPCamMob.IsOnGround()) { //kill downward velocity so previous //falling momentum doesn't contribute to //a new jump if (mCamVelocity.Y < 0f) { mCamVelocity.Y = 0f; } } if (mPCamMob.IsBadFooting()) { //reduce downward velocity to avoid //getting stuck in V shaped floors if (mCamVelocity.Y < 0f) { mCamVelocity.Y -= (StumbleFriction * mCamVelocity.Y * secDelta); } } } //update pickup entities foreach (PickUp pu in mPickUps) { pu.Update(time); StaticMeshComp smc = pu.GetSMC(); if (smc == null) { continue; } StaticMesh sm = smc.mDrawObject as StaticMesh; if (sm == null) { continue; } float yaw = pu.GetYaw(); Matrix mat = smc.mPO.GetMatrix(); if (pu.mSpinningPart == -1) { smc.mPO.SetYaw(yaw); sm.SetTransform(mat); } else { sm.SetTransform(mat); sm.SetPartTransform(pu.mSpinningPart, Matrix.RotationY(yaw) * mat); } } mPB.Update(mGD.DC, time.GetUpdateDeltaMilliSeconds()); mAudio.Update(mGD.GCam); mST.ModifyStringText(mFonts[0], "ModelOn: " + mPCamMob.GetModelOn() + " : " + (int)mGD.GCam.Position.X + ", " + (int)mGD.GCam.Position.Y + ", " + (int)mGD.GCam.Position.Z + " (F)lyMode: " + mbFly + (mPCamMob.IsBadFooting()? " BadFooting!" : "") + " ModelsHit: " + mModelsHit.Count, "PosStatus"); mST.Update(mGD.DC); }