protected virtual void SetPhysics(idPhysics phys) { // clear any contacts the current physics object has if (_physics != null) { _physics.ClearContacts(); } // set new physics object or set the default physics if NULL if (phys != null) { _defaultPhysicsObject.SetClipModel(null, 1.0f); _physics = phys; _physics.Activate(); } else { _physics = _defaultPhysicsObject; } _physics.UpdateTime(idR.Game.Time); idConsole.Warning("TODO: _physics.SetMaster(bindMaster, fl.bindOrientated);"); }
private void InitDefaultPhysics(Vector3 origin, Matrix axis) { string temp = _spawnArgs.GetString("clipmodel", ""); idClipModel clipModel = null; // check if a clipmodel key/value pair is set if (temp != string.Empty) { if (idClipModel.CheckModel(temp) != null) { clipModel = new idClipModel(temp); } } if (_spawnArgs.GetBool("noclipmodel", false) == false) { // check if mins/maxs or size key/value pairs are set if (clipModel == null) { idBounds bounds = idBounds.Zero; bool setClipModel = false; if ((_spawnArgs.ContainsKey("mins") == true) && (_spawnArgs.ContainsKey("maxs") == true)) { bounds = new idBounds(_spawnArgs.GetVector3("mins"), _spawnArgs.GetVector3("maxs")); setClipModel = true; if ((bounds.Min.X > bounds.Max.X) || (bounds.Min.Y > bounds.Max.Y) || (bounds.Min.Z > bounds.Max.Z)) { idConsole.Error("Invalid bounds '{0}'-'{1}' on entity '{2}'", bounds.Min, bounds.Max, this.Name); } } else if (_spawnArgs.ContainsKey("size") == true) { Vector3 size = _spawnArgs.GetVector3("size"); if ((size.X < 0.0f) || (size.Y < 0.0f) || (size.Z < 0.0f)) { idConsole.Error("Invalid size '{0}' on entity '{1}'", size, this.Name); } setClipModel = true; bounds = new idBounds( new Vector3(size.X * -0.5f, size.Y * -0.5f, 0.0f), new Vector3(size.X * 0.5f, size.Y * 0.5f, size.Z) ); } if (setClipModel == true) { int sideCount = _spawnArgs.GetInteger("cyclinder", 0); idTraceModel traceModel = new idTraceModel(); if (sideCount > 0) { idConsole.Warning("TODO: traceModel.SetupCyclinder(bounds, (sideCount < 3) ? 3 : sideCount);"); } else if ((sideCount = _spawnArgs.GetInteger("cone", 0)) > 0) { idConsole.Warning("TODO: traceModel.SetupCone(bounds, (sideCount < 3) ? 3 : sideCount);"); } else { traceModel.SetupBox(bounds); } clipModel = new idClipModel(traceModel); } } // check if the visual model can be used as collision model if (clipModel == null) { temp = _spawnArgs.GetString("model"); if (temp != string.Empty) { if (idClipModel.CheckModel(temp) != null) { clipModel = new idClipModel(temp); } } } } _defaultPhysicsObject.Self = this; _defaultPhysicsObject.SetClipModel(clipModel, 1.0f); _defaultPhysicsObject.SetOrigin(origin); _defaultPhysicsObject.SetAxis(axis); _physics = _defaultPhysicsObject; }