├── LICENSE ├── MyEngine ├── .gitignore ├── BEPUik │ ├── .gitignore │ ├── ActiveSet.cs │ ├── BEPUik.csproj │ ├── Bone.cs │ ├── Control.cs │ ├── DragControl.cs │ ├── IKAngularJoint.cs │ ├── IKBallSocketJoint.cs │ ├── IKConstraint.cs │ ├── IKDistanceJoint.cs │ ├── IKDistanceLimit.cs │ ├── IKJoint.cs │ ├── IKLimit.cs │ ├── IKLinearAxisLimit.cs │ ├── IKPointOnLineJoint.cs │ ├── IKPointOnPlaneJoint.cs │ ├── IKRevoluteJoint.cs │ ├── IKSolver.cs │ ├── IKSwingLimit.cs │ ├── IKSwivelHingeJoint.cs │ ├── IKTwistJoint.cs │ ├── IKTwistLimit.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── SingleBoneAngularMotor.cs │ ├── SingleBoneConstraint.cs │ ├── SingleBoneLinearMotor.cs │ └── StateControl.cs ├── BEPUutilities │ ├── .gitignore │ ├── AffineTransform.cs │ ├── BEPUutilities.csproj │ ├── BoundingBox.cs │ ├── BoundingSphere.cs │ ├── ContainmentType.cs │ ├── ConvexHullHelper.Pruning.cs │ ├── ConvexHullHelper.cs │ ├── DataStructures │ │ ├── ConcurrentDeque.cs │ │ ├── HashSet.cs │ │ ├── ObservableDictionary.cs │ │ ├── ObservableList.cs │ │ ├── RawList.cs │ │ ├── RawValueList.cs │ │ ├── ReadOnlyDictionary.cs │ │ ├── ReadOnlyEnumerable.cs │ │ ├── ReadOnlyList.cs │ │ ├── TinyList.cs │ │ └── TinyStructList.cs │ ├── MathChecker.cs │ ├── MathHelper.cs │ ├── Matrix.cs │ ├── Matrix2x2.cs │ ├── Matrix2x3.cs │ ├── Matrix3x2.cs │ ├── Matrix3x3.cs │ ├── PermutationMapper.cs │ ├── Plane.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── Quaternion.cs │ ├── Ray.cs │ ├── RayHit.cs │ ├── ResourceManagement │ │ ├── CommonResources.cs │ │ ├── LockingResourcePool.cs │ │ ├── ResourcePool.cs │ │ └── UnsafeResourcePool.cs │ ├── RigidTransform.cs │ ├── SpinLock.cs │ ├── Toolbox.cs │ ├── TriangleSidedness.cs │ ├── Vector2.cs │ ├── Vector3.cs │ ├── Vector4.cs │ ├── VoronoiRegion.cs │ ├── packages.config │ └── strongNameKey.snk ├── MyEngine.sln ├── bepuphysics │ ├── .gitignore │ ├── BEPUphysics.csproj │ ├── Background.png │ ├── BroadPhaseEntries │ │ ├── BroadPhaseEntry.cs │ │ ├── Collidable.cs │ │ ├── CollidableCollection.cs │ │ ├── CollidablePair.cs │ │ ├── DetectorVolume.cs │ │ ├── EntityCollidableCollection.cs │ │ ├── Events │ │ │ ├── CollisionEventTypes.cs │ │ │ ├── CompoundEventManager.cs │ │ │ ├── ContactEventManager.cs │ │ │ ├── EntryEventManager.cs │ │ │ ├── IContactEventTriggerer.cs │ │ │ └── IEntryEventTriggerer.cs │ │ ├── InstancedMesh.cs │ │ ├── MobileCollidables │ │ │ ├── CompoundCollidable.cs │ │ │ ├── CompoundHelper.cs │ │ │ ├── CompoundHierarchy.cs │ │ │ ├── ConvexCollidable.cs │ │ │ ├── EntityCollidable.cs │ │ │ ├── MobileCollidable.cs │ │ │ ├── MobileMeshCollidable.cs │ │ │ └── TriangleCollidable.cs │ │ ├── StaticCollidable.cs │ │ ├── StaticGroup.cs │ │ ├── StaticMesh.cs │ │ └── Terrain.cs │ ├── BroadPhaseSystems │ │ ├── BroadPhase.cs │ │ ├── BroadPhaseOverlap.cs │ │ ├── BruteForce.cs │ │ ├── Hierarchies │ │ │ ├── DynamicHierarchy.cs │ │ │ ├── DynamicHierarchyNode.cs │ │ │ └── DynamicHierarchyQueryAccelerator.cs │ │ ├── IBoundingBoxOwner.cs │ │ ├── IBroadPhaseEntryOwner.cs │ │ ├── IQueryAccelerator.cs │ │ └── SortAndSweep │ │ │ ├── Grid2DEntry.cs │ │ │ ├── Grid2DSortAndSweep.cs │ │ │ ├── Grid2DSortAndSweepQueryAccelerator.cs │ │ │ ├── GridCell2D.cs │ │ │ ├── SortAndSweep1D.cs │ │ │ └── SortedGrid2DSet.cs │ ├── CollisionRuleManagement │ │ ├── CollisionGroup.cs │ │ ├── CollisionGroupPair.cs │ │ ├── CollisionRule.cs │ │ ├── CollisionRules.cs │ │ └── ICollisionRulesOwner.cs │ ├── CollisionShapes │ │ ├── CollisionShape.cs │ │ ├── CompoundShape.cs │ │ ├── ConvexShapes │ │ │ ├── BoxShape.cs │ │ │ ├── CapsuleShape.cs │ │ │ ├── ConeShape.cs │ │ │ ├── ConvexHullShape.cs │ │ │ ├── ConvexShape.cs │ │ │ ├── ConvexShapeDescription.cs │ │ │ ├── CylinderShape.cs │ │ │ ├── InertiaHelper.cs │ │ │ ├── MinkowskiSumShape.cs │ │ │ ├── SphereShape.cs │ │ │ ├── TransformableShape.cs │ │ │ ├── TriangleShape.cs │ │ │ └── WrappedShape.cs │ │ ├── EntityShape.cs │ │ ├── EntityShapeVolumeDescription.cs │ │ ├── InstancedMeshShape.cs │ │ ├── MobileMeshShape.cs │ │ ├── ShapeDistributionInformation.cs │ │ ├── StaticGroupShape.cs │ │ ├── StaticMeshShape.cs │ │ └── TerrainShape.cs │ ├── CollisionTests │ │ ├── Contact.cs │ │ ├── ContactData.cs │ │ ├── ContactReducer.cs │ │ ├── ContactRefresher.cs │ │ ├── ContactSupplementData.cs │ │ ├── Manifolds │ │ │ ├── BoxContactManifold.cs │ │ │ ├── BoxSphereContactManifold.cs │ │ │ ├── ContactManifold.cs │ │ │ ├── GeneralConvexContactManifold.cs │ │ │ ├── InstancedMeshContactManifold.cs │ │ │ ├── InstancedMeshConvexContactManifold.cs │ │ │ ├── InstancedMeshSphereContactManifold.cs │ │ │ ├── MobileMeshContactManifold.cs │ │ │ ├── MobileMeshConvexContactManifold.cs │ │ │ ├── MobileMeshSphereContactManifold.cs │ │ │ ├── MobileMeshTriangleContactManifold.cs │ │ │ ├── SphereContactManifold.cs │ │ │ ├── StaticMeshContactManifold.cs │ │ │ ├── StaticMeshConvexContactManifold.cs │ │ │ ├── StaticMeshSphereContactManifold.cs │ │ │ ├── TerrainContactManifold.cs │ │ │ ├── TerrainConvexContactManifold.cs │ │ │ ├── TerrainSphereContactManifold.cs │ │ │ ├── TriangleConvexContactManifold.cs │ │ │ └── TriangleMeshConvexContactManifold.cs │ │ └── collisionalgorithms │ │ │ ├── BoxBoxCollider.cs │ │ │ ├── BoxSphereTester.cs │ │ │ ├── GJK │ │ │ ├── GJKToolbox.cs │ │ │ ├── PairSimplex.cs │ │ │ ├── RaySimplex.cs │ │ │ └── SimpleSimplex.cs │ │ │ ├── GeneralConvexPairTester.cs │ │ │ ├── MPRToolbox.cs │ │ │ ├── MinkowskiToolbox.cs │ │ │ ├── SphereTester.cs │ │ │ ├── TriangleConvexPairTester.cs │ │ │ ├── TrianglePairTester.cs │ │ │ ├── TriangleSpherePairTester.cs │ │ │ └── TriangleTrianglePairTester.cs │ ├── DataStructures │ │ ├── BoundingBoxTree.cs │ │ ├── MeshBoundingBoxTree.cs │ │ ├── MeshBoundingBoxTreeData.cs │ │ ├── StaticMeshData.cs │ │ ├── TransformableMeshData.cs │ │ ├── TreeOverlapPair.cs │ │ └── TriangleMesh.cs │ ├── DeactivationManagement │ │ ├── DeactivationManager.cs │ │ ├── ISimulationIslandConnection.cs │ │ ├── ISimulationIslandConnectionOwner.cs │ │ ├── ISimulationIslandMemberOwner.cs │ │ ├── SimulationIsland.cs │ │ ├── SimulationIslandConnection.cs │ │ ├── SimulationIslandMember.cs │ │ └── SimulationIslandMemberList.cs │ ├── Entities │ │ ├── Entity.cs │ │ ├── EntityBase.cs │ │ ├── EntityConstraintCollection.cs │ │ ├── EntitySolverUpdateableCollection.cs │ │ ├── MorphableEntity.cs │ │ └── Prefabs │ │ │ ├── Box.cs │ │ │ ├── Capsule.cs │ │ │ ├── CompoundBody.cs │ │ │ ├── Cone.cs │ │ │ ├── ConvexHull.cs │ │ │ ├── Cylinder.cs │ │ │ ├── MinkowskiSum.cs │ │ │ ├── MobileMesh.cs │ │ │ ├── Sphere.cs │ │ │ ├── TransformableEntity.cs │ │ │ ├── Triangle.cs │ │ │ └── WrappedBody.cs │ ├── EntityStateManagement │ │ ├── BufferedStatesAccessor.cs │ │ ├── BufferedStatesManager.cs │ │ ├── EntityBufferedStates.cs │ │ ├── EntityStateReadBuffers.cs │ │ ├── EntityStateWriteBuffer.cs │ │ ├── InterpolatedStatesAccessor.cs │ │ ├── InterpolatedStatesManager.cs │ │ └── MotionState.cs │ ├── ISpaceObject.cs │ ├── Materials │ │ ├── IMaterialOwner.cs │ │ ├── InteractionProperties.cs │ │ ├── Material.cs │ │ ├── MaterialManager.cs │ │ └── MaterialPair.cs │ ├── MultithreadedProcessingStage.cs │ ├── OtherSpaceStages │ │ ├── BoundingBoxUpdater.cs │ │ ├── DeferredEventDispatcher.cs │ │ ├── ForceUpdater.cs │ │ ├── IDeferredEventCreator.cs │ │ ├── IDeferredEventCreatorOwner.cs │ │ ├── IForceUpdateable.cs │ │ └── SpaceObjectBuffer.cs │ ├── Paths │ │ ├── CardinalSpline3D.cs │ │ ├── ConstantAngularSpeedCurve.cs │ │ ├── ConstantLinearSpeedCurve.cs │ │ ├── ConstantSpeedCurve.cs │ │ ├── Curve.cs │ │ ├── CurveControlPoint.cs │ │ ├── CurveControlPointList.cs │ │ ├── CurveEndpointBehavior.cs │ │ ├── FiniteDifferenceSpline3D.cs │ │ ├── HermiteCurve3D.cs │ │ ├── LinearInterpolationCurve3D.cs │ │ ├── Path following │ │ │ ├── EntityMover.cs │ │ │ └── EntityRotator.cs │ │ ├── Path.cs │ │ ├── QuaternionSlerpCurve.cs │ │ ├── SpeedControlledCurve.cs │ │ ├── StepCurve1D.cs │ │ ├── VariableAngularSpeedCurve.cs │ │ ├── VariableLinearSpeedCurve.cs │ │ └── VariableSpeedCurve.cs │ ├── PhysicsChecker.cs │ ├── PhysicsResources.cs │ ├── PositionUpdating │ │ ├── ContinuousPositionUpdater.cs │ │ ├── ICCDPositionUpdateable.cs │ │ ├── IPositionUpdateable.cs │ │ └── PositionUpdater.cs │ ├── ProcessingStage.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── RayCastResult.cs │ ├── Settings │ │ ├── CollisionDetectionSettings.cs │ │ ├── CollisionResponseSettings.cs │ │ └── MotionSettings.cs │ ├── Space.cs │ ├── Threading │ │ ├── IParallelLooper.cs │ │ ├── Modified Pool │ │ │ ├── ParallelLoopWorker.cs │ │ │ ├── ParallelLooper.cs │ │ │ ├── SpecializedThreadManager.cs │ │ │ └── ThreadTaskManager.cs │ │ ├── SimpleLooper.cs │ │ └── TPLLoopProvider.cs │ ├── TimeStepSettings.cs │ ├── UpdateableSystems │ │ ├── CombinedUpdateable.cs │ │ ├── FluidVolume.cs │ │ ├── ForceFields │ │ │ ├── BoundingBoxForceFieldShape.cs │ │ │ ├── BoundingSphereForceFieldShape.cs │ │ │ ├── ForceField.cs │ │ │ ├── ForceFieldShape.cs │ │ │ ├── InfiniteForceFieldShape.cs │ │ │ └── VolumeForceFieldShape.cs │ │ ├── IBeforeNarrowPhaseUpdateable.cs │ │ ├── IBeforePositionUpdateUpdateable.cs │ │ ├── IBeforeSolverUpdateable.cs │ │ ├── IDuringForcesUpdateable.cs │ │ ├── IEndOfFrameUpdateable.cs │ │ ├── IEndOfTimeStepUpdateable.cs │ │ ├── ISpaceUpdateable.cs │ │ ├── Updateable.cs │ │ ├── UpdateableManager.cs │ │ └── UpdateableManagers.cs │ ├── Vehicle │ │ ├── CylinderCastWheelShape.cs │ │ ├── RaycastWheelShape.cs │ │ ├── Vehicle.cs │ │ ├── Wheel.cs │ │ ├── WheelBrake.cs │ │ ├── WheelDrivingMotor.cs │ │ ├── WheelFrictionBlender.cs │ │ ├── WheelShape.cs │ │ ├── WheelSlidingFriction.cs │ │ └── WheelSuspension.cs │ ├── constraints │ │ ├── Collision │ │ │ ├── ContactFrictionConstraint.cs │ │ │ ├── ContactManifoldConstraint.cs │ │ │ ├── ContactManifoldConstraintGroup.cs │ │ │ ├── ContactPenetrationConstraint.cs │ │ │ ├── ConvexContactManifoldConstraint.cs │ │ │ ├── NonConvexContactManifoldConstraint.cs │ │ │ ├── SlidingFrictionTwoAxis.cs │ │ │ └── TwistFrictionConstraint.cs │ │ ├── IJacobians.cs │ │ ├── ISolverSettings.cs │ │ ├── ISpringConstraint.cs │ │ ├── IXDImpulseConstraint.cs │ │ ├── JointTransform.cs │ │ ├── SingleEntity │ │ │ ├── MaximumAngularVelocityConstraint.cs │ │ │ ├── MaximumLinearVelocityConstraint.cs │ │ │ ├── SingleEntityAngularMotor.cs │ │ │ ├── SingleEntityConstraint.cs │ │ │ └── SingleEntityLinearMotor.cs │ │ ├── Solver.cs │ │ ├── SolverGroups │ │ │ ├── CustomizableSolverGroup.cs │ │ │ ├── LineSliderJoint.cs │ │ │ ├── PlaneSliderJoint.cs │ │ │ ├── PrismaticJoint.cs │ │ │ ├── RevoluteJoint.cs │ │ │ ├── SolverGroup.cs │ │ │ ├── SwivelHingeJoint.cs │ │ │ ├── UniversalJoint.cs │ │ │ └── WeldJoint.cs │ │ ├── SolverSettings.cs │ │ ├── SolverUpdateable.cs │ │ ├── SolverUpdateableChange.cs │ │ ├── SpringSettings.cs │ │ └── TwoEntity │ │ │ ├── JointLimits │ │ │ ├── DistanceLimit.cs │ │ │ ├── EllipseSwingLimit.cs │ │ │ ├── JointLimit.cs │ │ │ ├── LinearAxisLimit.cs │ │ │ ├── RevoluteLimit.cs │ │ │ ├── SwingLimit.cs │ │ │ └── TwistLimit.cs │ │ │ ├── Joints │ │ │ ├── BallSocketJoint.cs │ │ │ ├── DistanceJoint.cs │ │ │ ├── Joint.cs │ │ │ ├── NoRotationJoint.cs │ │ │ ├── PointOnLineJoint.cs │ │ │ ├── PointOnPlaneJoint.cs │ │ │ ├── RevoluteAngularJoint.cs │ │ │ ├── SwivelHingeAngularJoint.cs │ │ │ └── TwistJoint.cs │ │ │ ├── Motors │ │ │ ├── AngularMotor.cs │ │ │ ├── LinearAxisMotor.cs │ │ │ ├── Motor.cs │ │ │ ├── MotorSettings.cs │ │ │ ├── RevoluteMotor.cs │ │ │ └── TwistMotor.cs │ │ │ └── TwoEntityConstraint.cs │ ├── narrowphasesystems │ │ ├── NarrowPhase.cs │ │ ├── NarrowPhaseHelper.cs │ │ ├── NarrowPhasePairFactory.cs │ │ └── Pairs │ │ │ ├── BoxPairHandler.cs │ │ │ ├── BoxSpherePairHandler.cs │ │ │ ├── CollidablePairHandler.cs │ │ │ ├── CompoundConvexPairHandler.cs │ │ │ ├── CompoundGroupPairHandler.cs │ │ │ ├── CompoundInstancedMeshPairHandler.cs │ │ │ ├── CompoundMobileMeshPairHandler.cs │ │ │ ├── CompoundPairHandler.cs │ │ │ ├── CompoundStaticMeshPairHandler.cs │ │ │ ├── CompoundTerrainPairHandler.cs │ │ │ ├── ContactCollection.cs │ │ │ ├── ContactInformation.cs │ │ │ ├── ConvexConstraintPairHandler.cs │ │ │ ├── ConvexPairHandler.cs │ │ │ ├── DetectorVolumeCompoundPairHandler.cs │ │ │ ├── DetectorVolumeConvexPairHandler.cs │ │ │ ├── DetectorVolumeGroupPairHandler.cs │ │ │ ├── DetectorVolumeMobileMeshPairHandler.cs │ │ │ ├── DetectorVolumePairHandler.cs │ │ │ ├── GeneralConvexPairHandler.cs │ │ │ ├── GroupPairHandler.cs │ │ │ ├── IDetectorVolumePairHandlerParent.cs │ │ │ ├── IPairHandlerParent.cs │ │ │ ├── InstancedMeshConvexPairHandler.cs │ │ │ ├── InstancedMeshPairHandler.cs │ │ │ ├── InstancedMeshSpherePairHandler.cs │ │ │ ├── MeshGroupPairHandler.cs │ │ │ ├── MobileMeshConvexPairHandler.cs │ │ │ ├── MobileMeshInstancedMeshPairHandler.cs │ │ │ ├── MobileMeshMeshPairHandler.cs │ │ │ ├── MobileMeshMobileMeshPairHandler.cs │ │ │ ├── MobileMeshPairHandler.cs │ │ │ ├── MobileMeshSpherePairHandler.cs │ │ │ ├── MobileMeshStaticMeshPairHandler.cs │ │ │ ├── MobileMeshTerrainPairHandler.cs │ │ │ ├── MobileMeshTrianglePairHandler.cs │ │ │ ├── NarrowPhasePair.cs │ │ │ ├── SpherePairHandler.cs │ │ │ ├── StandardPairHandler.cs │ │ │ ├── StaticGroupCompoundPairHandler.cs │ │ │ ├── StaticGroupConvexPairHandler.cs │ │ │ ├── StaticGroupMobileMeshPairHandler.cs │ │ │ ├── StaticGroupPairHandler.cs │ │ │ ├── StaticMeshConvexPairHandler.cs │ │ │ ├── StaticMeshPairHandler.cs │ │ │ ├── StaticMeshSpherePairHandler.cs │ │ │ ├── TerrainConvexPairHandler.cs │ │ │ ├── TerrainPairHandler.cs │ │ │ ├── TerrainSpherePairHandler.cs │ │ │ └── TriangleConvexPairHandler.cs │ ├── packages.config │ └── strongNameKey.snk ├── cudaparticlesimulation │ ├── CudaKernel │ │ ├── CudaKernel.vcxproj │ │ ├── cutil_math.h │ │ └── kernel.cu │ ├── CudaParticleSimulation.sln │ ├── CudaParticleSimulation.v12.suo │ ├── from this project we use only compiled CUDA PTX.txt │ └── kernel.ptx ├── myengine │ ├── .gitignore │ ├── Debug.cs │ ├── DeferredGBuffer.cs │ ├── EngineMain.cs │ ├── ExtensionMethods.cs │ ├── Factory.cs │ ├── IUnloadable.cs │ ├── MaterialPBR.cs │ ├── Math │ │ ├── Matrix4.cs │ │ ├── Quaternion.cs │ │ ├── Vector2.cs │ │ ├── Vector3.cs │ │ └── Vector4.cs │ ├── MyEngine.csproj │ ├── ObjLoader.MaterialLibrary.cs │ ├── ObjLoader.cs │ ├── ParticleSimulation │ │ ├── Manager.cs │ │ ├── ParticleMesh.cs │ │ └── ParticleMeshRenderer.cs │ ├── Physics │ │ ├── ConfigurationHelper.cs │ │ └── PhysicsManager.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── QuaternionUtility.cs │ ├── Resource.cs │ ├── ResourceFolder.cs │ ├── Shader.cs │ ├── ShadowMap.cs │ ├── UniformBlock.cs │ ├── UnityEngine based │ │ ├── Bounds.cs │ │ ├── BoxCollider.cs │ │ ├── Camera.cs │ │ ├── Collider.cs │ │ ├── Collision.cs │ │ ├── Component.cs │ │ ├── Cubemap.cs │ │ ├── FixedJoint.cs │ │ ├── GameObject.cs │ │ ├── GeometryUtility.cs │ │ ├── Input.cs │ │ ├── Joint.cs │ │ ├── Light.cs │ │ ├── Material.cs │ │ ├── Mesh.cs │ │ ├── MeshCollider.cs │ │ ├── MeshRenderer.cs │ │ ├── MonoBehaviour.cs │ │ ├── Physics.cs │ │ ├── Plane.cs │ │ ├── Ray.cs │ │ ├── RaycastHit.cs │ │ ├── Renderer.cs │ │ ├── Rigidbody.cs │ │ ├── Screen.cs │ │ ├── SpringJoint.cs │ │ ├── Texture.cs │ │ ├── Texture2D.cs │ │ └── Transform.cs │ ├── UnloadFactory.cs │ ├── app.config │ └── packages.config ├── mygame │ ├── .gitignore │ ├── CreatePhysicsObject.cs │ ├── DebugShowPlanes.cs │ ├── DragLegoPieces.cs │ ├── DrawBounds.cs │ ├── FirstPersonCamera.cs │ ├── LegoPiece.cs │ ├── LightMovement.cs │ ├── MoveWithArrowKeys.cs │ ├── MyGame.csproj │ ├── Program.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── SSAO.cs │ ├── VisualisePosition.cs │ ├── VisualizeDir.cs │ ├── app.config │ └── packages.config ├── packages │ └── repositories.config └── resources │ ├── box.mtl │ ├── box.obj │ ├── cube.mtl │ ├── cube.obj │ ├── dragon.mtl │ ├── dragon.obj │ ├── internal │ ├── Cloud-particle.png │ ├── black.png │ ├── cube.mtl │ ├── cube.obj │ ├── cube_bigUVs.obj │ ├── cube_center_to_11.mtl │ ├── cube_center_to_11.obj │ ├── cube_x2.obj │ ├── debugDrawTexture.shader │ ├── deferred.gBuffer.particle.shader │ ├── deferred.gBuffer.standart.shader │ ├── deferred.oneLight - Copy (2).shader │ ├── deferred.oneLight - Copy.shader │ ├── deferred.oneLight.shader │ ├── deferred.skybox.shader │ ├── depthGrab.standart.shader │ ├── forward.allLights.shader │ ├── grey.png │ ├── internal backup.rar │ ├── normal.png │ ├── particletexture.jpg │ ├── prependAll.shader │ ├── quad.obj │ ├── skybox.obj │ ├── std.shader │ ├── test.jpg │ └── white.png │ ├── lego │ ├── block_20x20x05.obj │ └── blocks │ │ ├── 73457 - lego lenght-customizable bricks - License.html │ │ ├── block_1x1x1.mtl │ │ ├── block_1x1x1.obj │ │ ├── block_1x2x1.mtl │ │ ├── block_1x2x1.obj │ │ ├── block_1x3x1.mtl │ │ ├── block_1x3x1.obj │ │ ├── block_1x4x1.mtl │ │ ├── block_1x4x1.obj │ │ ├── block_1x5x1.mtl │ │ ├── block_1x5x1.obj │ │ ├── block_1x6x1.mtl │ │ ├── block_1x6x1.obj │ │ ├── block_2x2x1.mtl │ │ ├── block_2x2x1.obj │ │ ├── block_2x3x05.obj │ │ ├── block_2x3x1.mtl │ │ ├── block_2x3x1.obj │ │ ├── block_2x4x1.mtl │ │ ├── block_2x4x1.obj │ │ ├── block_2x5x1.mtl │ │ ├── block_2x5x1.obj │ │ ├── block_2x6x1.mtl │ │ ├── block_2x6x1.obj │ │ └── lego_bs.blend │ ├── postProcessEffects │ └── SSAO.shader │ ├── quad.mtl │ ├── skybox │ └── sunny │ │ ├── back.jpg │ │ ├── bottom.jpg │ │ ├── front.jpg │ │ ├── left.jpg │ │ ├── right.jpg │ │ └── top.jpg │ ├── sphere.mtl │ ├── sphere.obj │ ├── spider.mtl │ ├── spider.obj │ └── textures │ ├── grassDIFFUSE.jpg │ ├── grassDISP.jpg │ ├── grassNORMAL.jpg │ └── pointSprite.png └── README.md /LICENSE: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or 4 | distribute this software, either in source code form or as a compiled 5 | binary, for any purpose, commercial or non-commercial, and by any 6 | means. 7 | 8 | In jurisdictions that recognize copyright laws, the author or authors 9 | of this software dedicate any and all copyright interest in the 10 | software to the public domain. We make this dedication for the benefit 11 | of the public at large and to the detriment of our heirs and 12 | successors. We intend this dedication to be an overt act of 13 | relinquishment in perpetuity of all present and future rights to this 14 | software under copyright law. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | For more information, please refer to 25 | -------------------------------------------------------------------------------- /MyEngine/BEPUik/Control.cs: -------------------------------------------------------------------------------- 1 | namespace BEPUik 2 | { 3 | /// 4 | /// Constrains an individual bone in an attempt to reach some goal. 5 | /// Controls act as groups of single bone constraints. They are used 6 | /// by the solver to determine the active set of body constraints. 7 | /// 8 | public abstract class Control 9 | { 10 | /// 11 | /// Gets or sets the controlled bone. 12 | /// 13 | public abstract Bone TargetBone { get; set; } 14 | 15 | protected internal abstract void Preupdate(float dt, float updateRate); 16 | 17 | protected internal abstract void UpdateJacobiansAndVelocityBias(); 18 | 19 | protected internal abstract void ComputeEffectiveMass(); 20 | 21 | protected internal abstract void WarmStart(); 22 | 23 | protected internal abstract void SolveVelocityIteration(); 24 | 25 | protected internal abstract void ClearAccumulatedImpulses(); 26 | 27 | public abstract float MaximumForce { get; set; } 28 | } 29 | } -------------------------------------------------------------------------------- /MyEngine/BEPUik/DragControl.cs: -------------------------------------------------------------------------------- 1 | namespace BEPUik 2 | { 3 | /// 4 | /// Constrains an individual bone in an attempt to reach some position goal. 5 | /// 6 | public class DragControl : Control 7 | { 8 | /// 9 | /// Gets or sets the controlled bone. 10 | /// 11 | public override Bone TargetBone 12 | { 13 | get { return LinearMotor.TargetBone; } 14 | set 15 | { 16 | LinearMotor.TargetBone = value; 17 | } 18 | } 19 | 20 | /// 21 | /// Gets or sets the linear motor used by the control. 22 | /// 23 | public SingleBoneLinearMotor LinearMotor 24 | { 25 | get; 26 | private set; 27 | } 28 | 29 | public DragControl() 30 | { 31 | LinearMotor = new SingleBoneLinearMotor(); 32 | LinearMotor.Rigidity = 1; 33 | } 34 | 35 | protected internal override void Preupdate(float dt, float updateRate) 36 | { 37 | LinearMotor.Preupdate(dt, updateRate); 38 | } 39 | 40 | protected internal override void UpdateJacobiansAndVelocityBias() 41 | { 42 | LinearMotor.UpdateJacobiansAndVelocityBias(); 43 | } 44 | 45 | protected internal override void ComputeEffectiveMass() 46 | { 47 | LinearMotor.ComputeEffectiveMass(); 48 | } 49 | 50 | protected internal override void WarmStart() 51 | { 52 | LinearMotor.WarmStart(); 53 | } 54 | 55 | protected internal override void SolveVelocityIteration() 56 | { 57 | LinearMotor.SolveVelocityIteration(); 58 | } 59 | 60 | protected internal override void ClearAccumulatedImpulses() 61 | { 62 | LinearMotor.ClearAccumulatedImpulses(); 63 | } 64 | 65 | public override float MaximumForce 66 | { 67 | get { return LinearMotor.MaximumForce; } 68 | set 69 | { 70 | LinearMotor.MaximumForce = value; 71 | } 72 | } 73 | } 74 | } -------------------------------------------------------------------------------- /MyEngine/BEPUik/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("BEPUik")] 9 | [assembly: AssemblyDescription("Simulation-based inverse kinematics solver")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Bepu Entertainment LLC")] 12 | [assembly: AssemblyProduct("BEPUik")] 13 | [assembly: AssemblyCopyright("Copyright © 2013, Bepu Entertainment LLC")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("19bc4d88-94e3-43a4-aefc-a8d441d86b0c")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.3.0.0")] 36 | [assembly: AssemblyFileVersion("0")] 37 | -------------------------------------------------------------------------------- /MyEngine/BEPUik/SingleBoneAngularMotor.cs: -------------------------------------------------------------------------------- 1 | using BEPUutilities; 2 | 3 | namespace BEPUik 4 | { 5 | public class SingleBoneAngularMotor : SingleBoneConstraint 6 | { 7 | /// 8 | /// Gets or sets the target orientation to apply to the target bone. 9 | /// 10 | public Quaternion TargetOrientation; 11 | 12 | protected internal override void UpdateJacobiansAndVelocityBias() 13 | { 14 | linearJacobian = new Matrix3x3(); 15 | angularJacobian = Matrix3x3.Identity; 16 | 17 | //Error is in world space. It gets projected onto the jacobians later. 18 | Quaternion errorQuaternion; 19 | Quaternion.Conjugate(ref TargetBone.Orientation, out errorQuaternion); 20 | Quaternion.Multiply(ref TargetOrientation, ref errorQuaternion, out errorQuaternion); 21 | float angle; 22 | Vector3 angularError; 23 | Quaternion.GetAxisAngleFromQuaternion(ref errorQuaternion, out angularError, out angle); 24 | Vector3.Multiply(ref angularError, angle, out angularError); 25 | 26 | //This is equivalent to projecting the error onto the angular jacobian. The angular jacobian just happens to be the identity matrix! 27 | Vector3.Multiply(ref angularError, errorCorrectionFactor, out velocityBias); 28 | } 29 | 30 | 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /MyEngine/BEPUik/SingleBoneLinearMotor.cs: -------------------------------------------------------------------------------- 1 | using BEPUutilities; 2 | 3 | namespace BEPUik 4 | { 5 | public class SingleBoneLinearMotor : SingleBoneConstraint 6 | { 7 | /// 8 | /// Gets or sets the target position to apply to the target bone. 9 | /// 10 | public Vector3 TargetPosition; 11 | 12 | /// 13 | /// Gets or sets the offset in the bone's local space to the point which will be pulled towards the target position. 14 | /// 15 | public Vector3 LocalOffset; 16 | 17 | 18 | public Vector3 Offset 19 | { 20 | get { return Quaternion.Transform(LocalOffset, TargetBone.Orientation); } 21 | set { LocalOffset = Quaternion.Transform(value, Quaternion.Conjugate(TargetBone.Orientation)); } 22 | } 23 | 24 | protected internal override void UpdateJacobiansAndVelocityBias() 25 | { 26 | linearJacobian = Matrix3x3.Identity; 27 | Vector3 r; 28 | Quaternion.Transform(ref LocalOffset, ref TargetBone.Orientation, out r); 29 | Matrix3x3.CreateCrossProduct(ref r, out angularJacobian); 30 | //Transposing a skew symmetric matrix is equivalent to negating it. 31 | Matrix3x3.Transpose(ref angularJacobian, out angularJacobian); 32 | 33 | Vector3 worldPosition; 34 | Vector3.Add(ref TargetBone.Position, ref r, out worldPosition); 35 | 36 | //Error is in world space. 37 | Vector3 linearError; 38 | Vector3.Subtract(ref TargetPosition, ref worldPosition, out linearError); 39 | //This is equivalent to projecting the error onto the linear jacobian. The linear jacobian just happens to be the identity matrix! 40 | Vector3.Multiply(ref linearError, errorCorrectionFactor, out velocityBias); 41 | } 42 | 43 | 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /MyEngine/BEPUutilities/BoundingSphere.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace BEPUutilities 7 | { 8 | /// 9 | /// Provides XNA-like bounding sphere functionality. 10 | /// 11 | public struct BoundingSphere 12 | { 13 | /// 14 | /// Radius of the sphere. 15 | /// 16 | public float Radius; 17 | /// 18 | /// Location of the center of the sphere. 19 | /// 20 | public Vector3 Center; 21 | 22 | /// 23 | /// Constructs a new bounding sphere. 24 | /// 25 | /// Location of the center of the sphere. 26 | /// Radius of the sphere. 27 | public BoundingSphere(Vector3 center, float radius) 28 | { 29 | this.Center = center; 30 | this.Radius = radius; 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /MyEngine/BEPUutilities/ContainmentType.cs: -------------------------------------------------------------------------------- 1 | namespace BEPUutilities 2 | { 3 | /// 4 | /// The current containment state of two objects. 5 | /// 6 | public enum ContainmentType 7 | { 8 | /// 9 | /// The objects are separate. 10 | /// 11 | Disjoint, 12 | /// 13 | /// One object fully contains the other. 14 | /// 15 | Contains, 16 | /// 17 | /// The objects are intersecting, but neither object fully contains the other. 18 | /// 19 | Intersects 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /MyEngine/BEPUutilities/DataStructures/ReadOnlyEnumerable.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | 4 | namespace BEPUutilities.DataStructures 5 | { 6 | /// 7 | /// WRaps an enumerable in a temporary enumeration struct. 8 | /// 9 | ///Type of the enumerable being iterated. 10 | public struct ReadOnlyEnumerable : IEnumerable 11 | { 12 | private readonly IEnumerable enumerable; 13 | 14 | /// 15 | /// Constructs a new read only enumerable. 16 | /// 17 | ///Enumerable to wrap. 18 | public ReadOnlyEnumerable(IEnumerable enumerable) 19 | { 20 | this.enumerable = enumerable; 21 | } 22 | 23 | #region IEnumerable Members 24 | 25 | /// 26 | /// Returns an enumerator that iterates through the collection. 27 | /// 28 | /// 29 | /// A that can be used to iterate through the collection. 30 | /// 31 | /// 1 32 | public IEnumerator GetEnumerator() 33 | { 34 | return enumerable.GetEnumerator(); 35 | } 36 | 37 | IEnumerator IEnumerable.GetEnumerator() 38 | { 39 | return enumerable.GetEnumerator(); 40 | } 41 | 42 | #endregion 43 | } 44 | } -------------------------------------------------------------------------------- /MyEngine/BEPUutilities/Plane.cs: -------------------------------------------------------------------------------- 1 | namespace BEPUutilities 2 | { 3 | /// 4 | /// Provides XNA-like plane functionality. 5 | /// 6 | public struct Plane 7 | { 8 | /// 9 | /// Normal of the plane. 10 | /// 11 | public Vector3 Normal; 12 | /// 13 | /// Negative distance to the plane from the origin along the normal. 14 | /// 15 | public float D; 16 | 17 | /// 18 | /// Constructs a new plane. 19 | /// 20 | /// Normal of the plane. 21 | /// Negative distance to the plane from the origin along the normal 22 | public Plane(Vector3 normal, float d) 23 | { 24 | this.Normal = normal; 25 | this.D = d; 26 | } 27 | 28 | /// 29 | /// Gets the dot product of the position offset from the plane along the plane's normal. 30 | /// 31 | /// Position to compute the dot product of. 32 | /// Dot product. 33 | public void DotCoordinate(ref Vector3 v, out float dot) 34 | { 35 | dot = Normal.X * v.X + Normal.Y * v.Y + Normal.Z * v.Z + D; 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /MyEngine/BEPUutilities/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("BEPUutilities")] 9 | [assembly: AssemblyDescription("Extensions and helpers used by various bepu things.")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Bepu Entertainment LLC")] 12 | [assembly: AssemblyProduct("BEPUutilities")] 13 | [assembly: AssemblyCopyright("Copyright © 2013, Bepu Entertainment LLC")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("c8431ed4-209d-4c02-9328-ca225b760ea6")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.3.0.0")] 36 | [assembly: AssemblyFileVersion("1.3.0.0")] 37 | -------------------------------------------------------------------------------- /MyEngine/BEPUutilities/RayHit.cs: -------------------------------------------------------------------------------- 1 | namespace BEPUutilities 2 | { 3 | /// 4 | /// Contains ray hit data. 5 | /// 6 | public struct RayHit 7 | { 8 | /// 9 | /// Location of the ray hit. 10 | /// 11 | public Vector3 Location; 12 | /// 13 | /// Normal of the ray hit. 14 | /// 15 | public Vector3 Normal; 16 | /// 17 | /// T parameter of the ray hit. 18 | /// The ray hit location is equal to the ray origin added to the ray direction multiplied by T. 19 | /// 20 | public float T; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /MyEngine/BEPUutilities/ResourceManagement/ResourcePool.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace BEPUutilities.ResourceManagement 4 | { 5 | /// 6 | /// Manages a cache of a type of resource. 7 | /// 8 | /// Type of object to pool. 9 | public abstract class ResourcePool where T : class, new() 10 | { 11 | /// 12 | /// Gets the number of resources in the pool. 13 | /// Even if the resource count hits 0, resources 14 | /// can still be requested; they will be allocated 15 | /// dynamically. 16 | /// 17 | public abstract int Count { get; } 18 | 19 | /// 20 | /// Gets or sets the function that configures new instances. 21 | /// This is only called once per object created for the resource pool. 22 | /// 23 | public Action InstanceInitializer { get; set; } 24 | 25 | /// 26 | /// Gives an item back to the resource pool. 27 | /// 28 | /// Item to return. 29 | public abstract void GiveBack(T item); 30 | 31 | /// 32 | /// Initializes the pool with some resources. 33 | /// Throws away excess resources. 34 | /// 35 | /// Number of resources to include. 36 | public abstract void Initialize(int initialResourceCount); 37 | 38 | /// 39 | /// Takes an item from the resource pool. 40 | /// 41 | /// Item to take. 42 | public abstract T Take(); 43 | 44 | /// 45 | /// Creates and returns a new resource. 46 | /// 47 | /// New resource. 48 | protected T CreateNewResource() 49 | { 50 | var toReturn = new T(); 51 | if (InstanceInitializer != null) 52 | InstanceInitializer(toReturn); 53 | return toReturn; 54 | } 55 | 56 | /// 57 | /// Removes all elements from the pool. 58 | /// 59 | public abstract void Clear(); 60 | 61 | } 62 | } -------------------------------------------------------------------------------- /MyEngine/BEPUutilities/TriangleSidedness.cs: -------------------------------------------------------------------------------- 1 | namespace BEPUutilities 2 | { 3 | /// 4 | /// Sidedness of a triangle or mesh. 5 | /// A triangle can be double sided, or allow one of its sides to let interacting objects through. 6 | /// 7 | public enum TriangleSidedness 8 | { 9 | /// 10 | /// The triangle will interact with objects coming from both directions. 11 | /// 12 | DoubleSided, 13 | /// 14 | /// The triangle will interact with objects from which the winding of the triangle appears to be clockwise. 15 | /// 16 | Clockwise, 17 | /// 18 | /// The triangle will interact with objects from which the winding of the triangle appears to be counterclockwise.. 19 | /// 20 | Counterclockwise 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /MyEngine/BEPUutilities/VoronoiRegion.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace BEPUphysics.CollisionTests 7 | { 8 | public enum VoronoiRegion 9 | { 10 | A, 11 | B, 12 | C, 13 | AB, 14 | AC, 15 | BC, 16 | ABC 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /MyEngine/BEPUutilities/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /MyEngine/BEPUutilities/strongNameKey.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JakubNei/lego-game-and-Unity-like-engine/949b0c60fa674272b1905bdb47d8a37d8fde9fc1/MyEngine/BEPUutilities/strongNameKey.snk -------------------------------------------------------------------------------- /MyEngine/bepuphysics/Background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JakubNei/lego-game-and-Unity-like-engine/949b0c60fa674272b1905bdb47d8a37d8fde9fc1/MyEngine/bepuphysics/Background.png -------------------------------------------------------------------------------- /MyEngine/bepuphysics/BroadPhaseEntries/Events/CompoundEventManager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using BEPUphysics.BroadPhaseEntries.MobileCollidables; 6 | using BEPUphysics.OtherSpaceStages; 7 | 8 | namespace BEPUphysics.BroadPhaseEntries.Events 9 | { 10 | /// 11 | /// Event manager for use with the CompoundCollidable. 12 | /// It's possible to use the ContactEventManager directly with a compound, 13 | /// but without using this class, any child event managers will fail to dispatch 14 | /// deferred events. 15 | /// 16 | public class CompoundEventManager : ContactEventManager 17 | { 18 | 19 | //TODO: This class can be generalized if there is ever another collidable which has similar requirements to the compound body. 20 | protected override void DispatchEvents() 21 | { 22 | //Go through all children and dispatch events. 23 | //They won't be touched by the primary event manager otherwise. 24 | var compound = this.owner as CompoundCollidable; 25 | if (compound != null) 26 | { 27 | foreach (var child in compound.children) 28 | { 29 | var deferredEventCreator = child.CollisionInformation.events as IDeferredEventCreator; 30 | if (deferredEventCreator.IsActive) 31 | deferredEventCreator.DispatchEvents(); 32 | } 33 | } 34 | else 35 | { 36 | throw new InvalidOperationException("Cannot use a CompoundEventManager with anything but a CompoundCollidable."); 37 | } 38 | base.DispatchEvents(); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /MyEngine/bepuphysics/BroadPhaseEntries/Events/IEntryEventTriggerer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using BEPUphysics.BroadPhaseEntries; 6 | using BEPUphysics.BroadPhaseSystems; 7 | using BEPUphysics.NarrowPhaseSystems.Pairs; 8 | 9 | namespace BEPUphysics.BroadPhaseEntries.Events 10 | { 11 | /// 12 | /// Manages triggers for events in an EntryEventManager. 13 | /// 14 | public interface IEntryEventTriggerer 15 | { 16 | /// 17 | /// Fires the event manager's pair creation events. 18 | /// 19 | /// Other entry involved in the pair. 20 | /// Narrow phase pair governing the two objects. 21 | void OnPairCreated(BroadPhaseEntry other, NarrowPhasePair collisionPair); 22 | 23 | /// 24 | /// Fires the event manager's pair removal events. 25 | /// 26 | /// Other entry involved in the pair. 27 | void OnPairRemoved(BroadPhaseEntry other); 28 | 29 | /// 30 | /// Fires the event manager's pair updated events. 31 | /// 32 | /// Other entry involved in the pair. 33 | /// Narrow phase pair governing the two objects. 34 | void OnPairUpdated(BroadPhaseEntry other, NarrowPhasePair collisionPair); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /MyEngine/bepuphysics/BroadPhaseEntries/MobileCollidables/CompoundHierarchy.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using BEPUphysics.DataStructures; 3 | 4 | namespace BEPUphysics.BroadPhaseEntries.MobileCollidables 5 | { 6 | /// 7 | /// Hierarchy of children used to accelerate queries and tests for compound collidables. 8 | /// 9 | public class CompoundHierarchy 10 | { 11 | private BoundingBoxTree tree; 12 | /// 13 | /// Gets the bounding box tree of the hierarchy. 14 | /// 15 | public BoundingBoxTree Tree 16 | { 17 | get 18 | { 19 | return tree; 20 | } 21 | } 22 | 23 | private CompoundCollidable owner; 24 | /// 25 | /// Gets the CompoundCollidable that owns this hierarchy. 26 | /// 27 | public CompoundCollidable Owner 28 | { 29 | get 30 | { 31 | return owner; 32 | } 33 | } 34 | 35 | /// 36 | /// Constructs a new compound hierarchy. 37 | /// 38 | ///Owner of the hierarchy. 39 | public CompoundHierarchy(CompoundCollidable owner) 40 | { 41 | this.owner = owner; 42 | var children = new CompoundChild[owner.children.Count]; 43 | Array.Copy(owner.children.Elements, children, owner.children.Count); 44 | //In order to initialize a good tree, the local space bounding boxes should first be computed. 45 | //Otherwise, the tree would try to create a hierarchy based on a bunch of zeroed out bounding boxes! 46 | for (int i = 0; i < children.Length; i++) 47 | { 48 | children[i].CollisionInformation.worldTransform = owner.Shape.shapes.Elements[i].LocalTransform; 49 | children[i].CollisionInformation.UpdateBoundingBoxInternal(0); 50 | } 51 | tree = new BoundingBoxTree(children); 52 | } 53 | 54 | 55 | 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /MyEngine/bepuphysics/BroadPhaseEntries/MobileCollidables/MobileCollidable.cs: -------------------------------------------------------------------------------- 1 | namespace BEPUphysics.BroadPhaseEntries.MobileCollidables 2 | { 3 | //This is implemented by anything which wants the engine to update its bounding box every frame (so long as it is 'active'). 4 | /// 5 | /// Superclass of all collidables which are capable of movement, and thus need bounding box updates every frame. 6 | /// 7 | public abstract class MobileCollidable : Collidable 8 | { 9 | //TODO: Imagine needing to calculate the bounding box for a data structure that is not axis-aligned. Being able to return BB without 'setting' would be helpful. 10 | //Possibly require second method. The parameterless one uses 'self data' to do the calculation, as a sort of convenience. The parameterful would return without setting. 11 | /// 12 | /// Updates the bounding box of the mobile collidable. 13 | /// 14 | ///Timestep with which to update the bounding box. 15 | public abstract void UpdateBoundingBox(float dt); 16 | 17 | 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /MyEngine/bepuphysics/BroadPhaseEntries/MobileCollidables/TriangleCollidable.cs: -------------------------------------------------------------------------------- 1 | using BEPUphysics.CollisionShapes.ConvexShapes; 2 | using BEPUutilities; 3 | 4 | 5 | namespace BEPUphysics.BroadPhaseEntries.MobileCollidables 6 | { 7 | /// 8 | /// Special case collidable for reuseable triangles. 9 | /// 10 | public class TriangleCollidable : ConvexCollidable 11 | { 12 | /// 13 | /// Constructs a new shapeless collidable. 14 | /// 15 | public TriangleCollidable() 16 | : base(new TriangleShape()) 17 | { 18 | } 19 | 20 | /// 21 | /// Constructs the triangle collidable using the given shape. 22 | /// 23 | ///TriangleShape to use in the collidable. 24 | public TriangleCollidable(TriangleShape shape) 25 | : base(shape) 26 | { 27 | } 28 | 29 | /// 30 | /// Initializes the collidable using the new triangle shape, but does NOT 31 | /// fire any shape-changed events. 32 | /// 33 | ///First vertex in the triangle. 34 | ///Second vertex in the triangle. 35 | ///Third vertex in the triangle. 36 | public void Initialize(ref Vector3 a, ref Vector3 b, ref Vector3 c) 37 | { 38 | var shape = Shape; 39 | shape.collisionMargin = 0; 40 | shape.sidedness = TriangleSidedness.DoubleSided; 41 | shape.vA = a; 42 | shape.vB = b; 43 | shape.vC = c; 44 | } 45 | 46 | /// 47 | /// Cleans up the collidable by removing all events. 48 | /// 49 | public void CleanUp() 50 | { 51 | events.RemoveAllEvents(); 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /MyEngine/bepuphysics/BroadPhaseSystems/BruteForce.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using BEPUphysics.BroadPhaseEntries; 6 | 7 | namespace BEPUphysics.BroadPhaseSystems 8 | { 9 | public class BruteForce : BroadPhase 10 | { 11 | public List entries = new List(); 12 | 13 | public override void Add(BroadPhaseEntry entry) 14 | { 15 | entries.Add(entry); 16 | } 17 | 18 | public override void Remove(BroadPhaseEntry entry) 19 | { 20 | entries.Remove(entry); 21 | } 22 | 23 | protected override void UpdateMultithreaded() 24 | { 25 | UpdateSingleThreaded(); 26 | } 27 | 28 | protected override void UpdateSingleThreaded() 29 | { 30 | Overlaps.Clear(); 31 | for (int i = 0; i < entries.Count; i++) 32 | { 33 | for (int j = i + 1; j < entries.Count; j++) 34 | { 35 | if (entries[i].boundingBox.Intersects(entries[j].boundingBox)) 36 | base.TryToAddOverlap(entries[i], entries[j]); 37 | } 38 | } 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /MyEngine/bepuphysics/BroadPhaseSystems/IBoundingBoxOwner.cs: -------------------------------------------------------------------------------- 1 |  2 | 3 | using BEPUutilities; 4 | namespace BEPUphysics.BroadPhaseSystems 5 | { 6 | /// 7 | /// Requires that a class have a BoundingBox. 8 | /// 9 | public interface IBoundingBoxOwner 10 | { 11 | /// 12 | /// Gets the bounding box of the object. 13 | /// 14 | BoundingBox BoundingBox { get; } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /MyEngine/bepuphysics/BroadPhaseSystems/IBroadPhaseEntryOwner.cs: -------------------------------------------------------------------------------- 1 | using BEPUphysics.BroadPhaseEntries; 2 | 3 | namespace BEPUphysics.BroadPhaseSystems 4 | { 5 | /// 6 | /// Requires that a class own a BroadPhaseEntry. 7 | /// 8 | public interface IBroadPhaseEntryOwner 9 | { 10 | /// 11 | /// Gets the broad phase entry associated with this object. 12 | /// 13 | BroadPhaseEntry Entry { get; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /MyEngine/bepuphysics/BroadPhaseSystems/SortAndSweep/Grid2DEntry.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using BEPUphysics.BroadPhaseEntries; 6 | 7 | namespace BEPUphysics.BroadPhaseSystems.SortAndSweep 8 | { 9 | class Grid2DEntry 10 | { 11 | internal void Initialize(BroadPhaseEntry entry) 12 | { 13 | this.item = entry; 14 | Grid2DSortAndSweep.ComputeCell(ref entry.boundingBox.Min, out previousMin); 15 | Grid2DSortAndSweep.ComputeCell(ref entry.boundingBox.Max, out previousMax); 16 | } 17 | 18 | 19 | internal BroadPhaseEntry item; 20 | internal Int2 previousMin; 21 | internal Int2 previousMax; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /MyEngine/bepuphysics/CollisionRuleManagement/CollisionRule.cs: -------------------------------------------------------------------------------- 1 | namespace BEPUphysics.CollisionRuleManagement 2 | { 3 | /// 4 | /// Defines a set of rules that collisions can adhere to. 5 | /// 6 | public enum CollisionRule 7 | { 8 | /// 9 | /// Yields the interaction type's determination to a later stage. 10 | /// 11 | Defer, 12 | /// 13 | /// Uses all of collision detection, including creating a collision pair, creating contacts when appropriate, and responding to those contacts physically. 14 | /// If a collision pair is forced to use a 'normal' interaction but both entities in the pair are kinematic, the collision response will be skipped. 15 | /// 16 | Normal, 17 | /// 18 | /// Creates a collision pair and undergoes narrow phase testing, but does not collision response in the solver. 19 | /// 20 | NoSolver, 21 | /// 22 | /// Creates a broad phase overlap and narrow phase pair but the collision is never updated. It cannot generate contacts nor undergo solving. 23 | /// 24 | NoNarrowPhaseUpdate, 25 | /// 26 | /// Creates a broad phase overlap but does not create any narrow phase pairs. It cannot generate contacts nor undergo solving. 27 | /// 28 | NoNarrowPhasePair, 29 | /// 30 | /// Does not create a broad phase overlap. No further collision detection or response takes place. 31 | /// 32 | NoBroadPhase 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /MyEngine/bepuphysics/CollisionRuleManagement/ICollisionRulesOwner.cs: -------------------------------------------------------------------------------- 1 | namespace BEPUphysics.CollisionRuleManagement 2 | { 3 | /// 4 | /// Defines a class which must own CollisionRules. 5 | /// 6 | public interface ICollisionRulesOwner 7 | { 8 | /// 9 | /// Collision rules owned by the object. 10 | /// 11 | CollisionRules CollisionRules { get; set; } 12 | } 13 | } -------------------------------------------------------------------------------- /MyEngine/bepuphysics/CollisionShapes/CollisionShape.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace BEPUphysics.CollisionShapes 4 | { 5 | /// 6 | /// Superclass of all collision shapes. 7 | /// Collision shapes are composed entirely of local space information. 8 | /// Collidables provide the world space information needed to use the shapes to do collision detection. 9 | /// 10 | public abstract class CollisionShape 11 | { 12 | /// 13 | /// Fires when some of the local space information in the shape changes. 14 | /// 15 | public event Action ShapeChanged; 16 | 17 | protected virtual void OnShapeChanged() 18 | { 19 | if (ShapeChanged != null) 20 | ShapeChanged(this); 21 | } 22 | 23 | 24 | 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /MyEngine/bepuphysics/CollisionShapes/ConvexShapes/ConvexShapeDescription.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace BEPUphysics.CollisionShapes.ConvexShapes 7 | { 8 | /// 9 | /// Stores information needed by all convex shapes. 10 | /// 11 | public struct ConvexShapeDescription 12 | { 13 | /// 14 | /// EntityShape information for this convex shape. 15 | /// 16 | public EntityShapeVolumeDescription EntityShapeVolume; 17 | 18 | /// 19 | /// Minimum radius of the convex shape. 20 | /// Must be contained fully by the shape when centered at the origin. 21 | /// 22 | public float MinimumRadius; 23 | 24 | /// 25 | /// Maximum radius of the convex shape. 26 | /// Must contain the shape fully when centered at the origin. 27 | /// 28 | public float MaximumRadius; 29 | 30 | /// 31 | /// Collision margin of the convex shape. 32 | /// 33 | public float CollisionMargin; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /MyEngine/bepuphysics/CollisionShapes/EntityShapeVolumeDescription.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using BEPUutilities; 6 | 7 | namespace BEPUphysics.CollisionShapes 8 | { 9 | public struct EntityShapeVolumeDescription 10 | { 11 | public Matrix3x3 VolumeDistribution; 12 | public float Volume; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /MyEngine/bepuphysics/CollisionShapes/ShapeDistributionInformation.cs: -------------------------------------------------------------------------------- 1 | using BEPUutilities; 2 | 3 | 4 | namespace BEPUphysics.CollisionShapes 5 | { 6 | /// 7 | /// Contains data about the distribution of volume in a shape. 8 | /// 9 | public struct ShapeDistributionInformation 10 | { 11 | /// 12 | /// The distribution of volume in a shape. 13 | /// This can be scaled to create an inertia tensor for a shape. 14 | /// 15 | public Matrix3x3 VolumeDistribution; 16 | /// 17 | /// The center of a shape. 18 | /// 19 | public Vector3 Center; 20 | /// 21 | /// The volume of a shape. 22 | /// 23 | public float Volume; 24 | 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /MyEngine/bepuphysics/CollisionShapes/StaticMeshShape.cs: -------------------------------------------------------------------------------- 1 | using BEPUutilities; 2 | 3 | using BEPUphysics.DataStructures; 4 | 5 | namespace BEPUphysics.CollisionShapes 6 | { 7 | /// 8 | /// The local space information needed by a StaticMesh. 9 | /// Since the hierarchy is in world space and owned by the StaticMesh collidable, 10 | /// this is a pretty lightweight object. 11 | /// 12 | public class StaticMeshShape : CollisionShape 13 | { 14 | TransformableMeshData triangleMeshData; 15 | /// 16 | /// Gets the triangle mesh data composing the StaticMeshShape. 17 | /// 18 | public TransformableMeshData TriangleMeshData 19 | { 20 | get 21 | { 22 | return triangleMeshData; 23 | } 24 | } 25 | 26 | 27 | 28 | 29 | 30 | 31 | /// 32 | /// Constructs a new StaticMeshShape. 33 | /// 34 | ///Vertices of the mesh. 35 | ///Indices of the mesh. 36 | ///World transform to use in the local space data. 37 | public StaticMeshShape(Vector3[] vertices, int[] indices, AffineTransform worldTransform) 38 | { 39 | triangleMeshData = new TransformableMeshData(vertices, indices, worldTransform); 40 | } 41 | 42 | 43 | 44 | /// 45 | /// Constructs a new StaticMeshShape. 46 | /// 47 | ///Vertices of the mesh. 48 | ///Indices of the mesh. 49 | public StaticMeshShape(Vector3[] vertices, int[] indices) 50 | { 51 | triangleMeshData = new TransformableMeshData(vertices, indices); 52 | } 53 | 54 | 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /MyEngine/bepuphysics/CollisionTests/Contact.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using BEPUutilities; 3 | 4 | 5 | namespace BEPUphysics.CollisionTests 6 | { 7 | /// 8 | /// Handles information about a contact point during a collision between two bodies. 9 | /// 10 | public class Contact 11 | { 12 | /// 13 | /// Amount of penetration between the two objects. 14 | /// 15 | public float PenetrationDepth; 16 | 17 | /// 18 | /// Identifier used to link contact data with existing contacts and categorize members of a manifold. 19 | /// 20 | public int Id = -1; 21 | 22 | /// 23 | /// Normal direction of the surface at the contact point. 24 | /// 25 | public Vector3 Normal; 26 | 27 | 28 | /// 29 | /// Position of the contact point. 30 | /// 31 | public Vector3 Position; 32 | 33 | 34 | 35 | 36 | /// 37 | /// Sets up the contact with new information. 38 | /// 39 | ///Contact data to initialize the contact with. 40 | public void Setup(ref ContactData candidate) 41 | { 42 | candidate.Validate(); 43 | Position = candidate.Position; 44 | Normal = candidate.Normal; 45 | PenetrationDepth = candidate.PenetrationDepth; 46 | Id = candidate.Id; 47 | } 48 | 49 | /// 50 | /// Outputs the position, normal, and depth information of the contact into a string. 51 | /// 52 | /// Position, normal, and depth information of the contact in a string. 53 | public override string ToString() 54 | { 55 | return "Position: " + Position + " Normal: " + Normal + " Depth: " + PenetrationDepth; 56 | } 57 | 58 | 59 | 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /MyEngine/bepuphysics/CollisionTests/ContactData.cs: -------------------------------------------------------------------------------- 1 |  2 | using System; 3 | using BEPUutilities; 4 | 5 | namespace BEPUphysics.CollisionTests 6 | { 7 | /// 8 | /// Contact data created by collision detection. 9 | /// 10 | public struct ContactData :IEquatable 11 | { 12 | /// 13 | /// Amount of penetration between the two objects. 14 | /// 15 | public float PenetrationDepth; 16 | 17 | /// 18 | /// Feature-based id used to match contacts from the previous frame to their current versions. 19 | /// 20 | public int Id; 21 | 22 | /// 23 | /// Normal direction of the surface at the contact point. 24 | /// 25 | public Vector3 Normal; 26 | 27 | /// 28 | /// Position of the contact point. 29 | /// 30 | public Vector3 Position; 31 | 32 | /// 33 | /// Returns the fully qualified type name of this instance. 34 | /// 35 | /// 36 | /// A containing a fully qualified type name. 37 | /// 38 | /// 2 39 | public override string ToString() 40 | { 41 | return Position + ", " + Normal; 42 | } 43 | 44 | 45 | 46 | public bool Equals(ContactData other) 47 | { 48 | return other.PenetrationDepth == PenetrationDepth && 49 | other.Id == Id && 50 | other.Normal == Normal && 51 | other.Position == Position; 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /MyEngine/bepuphysics/CollisionTests/ContactSupplementData.cs: -------------------------------------------------------------------------------- 1 |  2 | 3 | using BEPUutilities; 4 | namespace BEPUphysics.CollisionTests 5 | { 6 | /// 7 | /// Extra data associated with a contact point used to refresh contacts each frame. 8 | /// 9 | public struct ContactSupplementData 10 | { 11 | /// 12 | /// Offset from the center of the first object to the contact point in the object's local space. 13 | /// 14 | public Vector3 LocalOffsetA; 15 | 16 | /// 17 | /// Offset from the center of the second object to the contact point in the object's local space. 18 | /// 19 | public Vector3 LocalOffsetB; 20 | /// 21 | /// Original penetration depth computed at the associatd contact. 22 | /// 23 | public float BasePenetrationDepth; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /MyEngine/bepuphysics/CollisionTests/Manifolds/InstancedMeshConvexContactManifold.cs: -------------------------------------------------------------------------------- 1 | using BEPUphysics.CollisionTests.CollisionAlgorithms; 2 | using BEPUutilities.ResourceManagement; 3 | 4 | namespace BEPUphysics.CollisionTests.Manifolds 5 | { 6 | /// 7 | /// Manages persistent contacts between a convex and an instanced mesh. 8 | /// 9 | public class InstancedMeshConvexContactManifold : InstancedMeshContactManifold 10 | { 11 | 12 | UnsafeResourcePool testerPool = new UnsafeResourcePool(); 13 | protected override void GiveBackTester(CollisionAlgorithms.TrianglePairTester tester) 14 | { 15 | testerPool.GiveBack((TriangleConvexPairTester)tester); 16 | } 17 | 18 | protected override CollisionAlgorithms.TrianglePairTester GetTester() 19 | { 20 | return testerPool.Take(); 21 | } 22 | 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /MyEngine/bepuphysics/CollisionTests/Manifolds/InstancedMeshSphereContactManifold.cs: -------------------------------------------------------------------------------- 1 | using BEPUphysics.CollisionTests.CollisionAlgorithms; 2 | using BEPUutilities.ResourceManagement; 3 | 4 | namespace BEPUphysics.CollisionTests.Manifolds 5 | { 6 | /// 7 | /// Manages persistent contacts between a convex and an instanced mesh. 8 | /// 9 | public class InstancedMeshSphereContactManifold : InstancedMeshContactManifold 10 | { 11 | 12 | UnsafeResourcePool testerPool = new UnsafeResourcePool(); 13 | protected override void GiveBackTester(TrianglePairTester tester) 14 | { 15 | testerPool.GiveBack((TriangleSpherePairTester)tester); 16 | } 17 | 18 | protected override TrianglePairTester GetTester() 19 | { 20 | return testerPool.Take(); 21 | } 22 | 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /MyEngine/bepuphysics/CollisionTests/Manifolds/MobileMeshConvexContactManifold.cs: -------------------------------------------------------------------------------- 1 | using BEPUphysics.CollisionTests.CollisionAlgorithms; 2 | using BEPUutilities.ResourceManagement; 3 | 4 | namespace BEPUphysics.CollisionTests.Manifolds 5 | { 6 | /// 7 | /// Manages persistent contacts between a convex and an instanced mesh. 8 | /// 9 | public class MobileMeshConvexContactManifold : MobileMeshContactManifold 10 | { 11 | 12 | UnsafeResourcePool testerPool = new UnsafeResourcePool(); 13 | protected override void GiveBackTester(TrianglePairTester tester) 14 | { 15 | testerPool.GiveBack((TriangleConvexPairTester)tester); 16 | } 17 | 18 | protected override TrianglePairTester GetTester() 19 | { 20 | return testerPool.Take(); 21 | } 22 | 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /MyEngine/bepuphysics/CollisionTests/Manifolds/MobileMeshSphereContactManifold.cs: -------------------------------------------------------------------------------- 1 | using BEPUphysics.CollisionTests.CollisionAlgorithms; 2 | using BEPUutilities.ResourceManagement; 3 | 4 | namespace BEPUphysics.CollisionTests.Manifolds 5 | { 6 | /// 7 | /// Manages persistent contacts between a convex and an instanced mesh. 8 | /// 9 | public class MobileMeshSphereContactManifold : MobileMeshContactManifold 10 | { 11 | 12 | UnsafeResourcePool testerPool = new UnsafeResourcePool(); 13 | protected override void GiveBackTester(TrianglePairTester tester) 14 | { 15 | testerPool.GiveBack((TriangleSpherePairTester)tester); 16 | } 17 | 18 | protected override TrianglePairTester GetTester() 19 | { 20 | return testerPool.Take(); 21 | } 22 | 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /MyEngine/bepuphysics/CollisionTests/Manifolds/MobileMeshTriangleContactManifold.cs: -------------------------------------------------------------------------------- 1 | using BEPUphysics.CollisionTests.CollisionAlgorithms; 2 | using BEPUutilities.ResourceManagement; 3 | 4 | namespace BEPUphysics.CollisionTests.Manifolds 5 | { 6 | /// 7 | /// Manages persistent contacts between a convex and an instanced mesh. 8 | /// 9 | public class MobileMeshTriangleContactManifold : MobileMeshContactManifold 10 | { 11 | 12 | UnsafeResourcePool testerPool = new UnsafeResourcePool(); 13 | protected override void GiveBackTester(TrianglePairTester tester) 14 | { 15 | testerPool.GiveBack((TriangleTrianglePairTester)tester); 16 | } 17 | 18 | protected override TrianglePairTester GetTester() 19 | { 20 | return testerPool.Take(); 21 | } 22 | 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /MyEngine/bepuphysics/CollisionTests/Manifolds/StaticMeshConvexContactManifold.cs: -------------------------------------------------------------------------------- 1 | using BEPUphysics.CollisionTests.CollisionAlgorithms; 2 | using BEPUutilities.ResourceManagement; 3 | 4 | namespace BEPUphysics.CollisionTests.Manifolds 5 | { 6 | /// 7 | /// Manages persistent contacts between a static mesh and a convex. 8 | /// 9 | public class StaticMeshConvexContactManifold : StaticMeshContactManifold 10 | { 11 | 12 | 13 | UnsafeResourcePool testerPool = new UnsafeResourcePool(); 14 | protected override void GiveBackTester(CollisionAlgorithms.TrianglePairTester tester) 15 | { 16 | testerPool.GiveBack((TriangleConvexPairTester)tester); 17 | } 18 | 19 | protected override CollisionAlgorithms.TrianglePairTester GetTester() 20 | { 21 | return testerPool.Take(); 22 | } 23 | 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /MyEngine/bepuphysics/CollisionTests/Manifolds/StaticMeshSphereContactManifold.cs: -------------------------------------------------------------------------------- 1 | using BEPUphysics.CollisionTests.CollisionAlgorithms; 2 | using BEPUutilities.ResourceManagement; 3 | 4 | namespace BEPUphysics.CollisionTests.Manifolds 5 | { 6 | /// 7 | /// Manages persistent contacts between a static mesh and a convex. 8 | /// 9 | public class StaticMeshSphereContactManifold : StaticMeshContactManifold 10 | { 11 | 12 | 13 | UnsafeResourcePool testerPool = new UnsafeResourcePool(); 14 | protected override void GiveBackTester(TrianglePairTester tester) 15 | { 16 | testerPool.GiveBack((TriangleSpherePairTester)tester); 17 | } 18 | 19 | protected override TrianglePairTester GetTester() 20 | { 21 | return testerPool.Take(); 22 | } 23 | 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /MyEngine/bepuphysics/CollisionTests/Manifolds/TerrainConvexContactManifold.cs: -------------------------------------------------------------------------------- 1 | using BEPUphysics.CollisionTests.CollisionAlgorithms; 2 | using BEPUutilities.ResourceManagement; 3 | 4 | namespace BEPUphysics.CollisionTests.Manifolds 5 | { 6 | public class TerrainConvexContactManifold : TerrainContactManifold 7 | { 8 | UnsafeResourcePool testerPool = new UnsafeResourcePool(); 9 | protected override TrianglePairTester GetTester() 10 | { 11 | return testerPool.Take(); 12 | } 13 | 14 | protected override void GiveBackTester(TrianglePairTester tester) 15 | { 16 | testerPool.GiveBack((TriangleConvexPairTester)tester); 17 | } 18 | 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /MyEngine/bepuphysics/CollisionTests/Manifolds/TerrainSphereContactManifold.cs: -------------------------------------------------------------------------------- 1 | using BEPUphysics.CollisionTests.CollisionAlgorithms; 2 | using BEPUutilities.ResourceManagement; 3 | 4 | namespace BEPUphysics.CollisionTests.Manifolds 5 | { 6 | public class TerrainSphereContactManifold : TerrainContactManifold 7 | { 8 | UnsafeResourcePool testerPool = new UnsafeResourcePool(); 9 | protected override TrianglePairTester GetTester() 10 | { 11 | return testerPool.Take(); 12 | } 13 | 14 | protected override void GiveBackTester(TrianglePairTester tester) 15 | { 16 | testerPool.GiveBack((TriangleSpherePairTester)tester); 17 | } 18 | 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /MyEngine/bepuphysics/CollisionTests/collisionalgorithms/TrianglePairTester.cs: -------------------------------------------------------------------------------- 1 | using BEPUphysics.CollisionShapes.ConvexShapes; 2 | using BEPUutilities.DataStructures; 3 | 4 | namespace BEPUphysics.CollisionTests.CollisionAlgorithms 5 | { 6 | /// 7 | /// Persistent tester that compares triangles against convex objects. 8 | /// 9 | public abstract class TrianglePairTester 10 | { 11 | internal TriangleShape triangle; 12 | 13 | /// 14 | /// Whether or not the pair tester was updated during the last attempt. 15 | /// 16 | public bool Updated; 17 | 18 | //Relies on the triangle being located in the local space of the convex object. The convex transform is used to transform the 19 | //contact points back from the convex's local space into world space. 20 | /// 21 | /// Generates a contact between the triangle and convex. 22 | /// 23 | ///Contact between the shapes, if any. 24 | ///Whether or not the shapes are colliding. 25 | public abstract bool GenerateContactCandidate(out TinyStructList contactList); 26 | 27 | /// 28 | /// Gets the triangle region in which the contact resides. 29 | /// 30 | /// Contact to check. 31 | /// Region in which the contact resides. 32 | public abstract VoronoiRegion GetRegion(ref ContactData contact); 33 | 34 | /// 35 | /// Whether or not the last found contact should have its normal corrected. 36 | /// 37 | public abstract bool ShouldCorrectContactNormal { get; } 38 | 39 | /// 40 | /// Initializes the pair tester. 41 | /// 42 | ///Convex shape to use. 43 | ///Triangle shape to use. 44 | public abstract void Initialize(ConvexShape convex, TriangleShape triangle); 45 | 46 | /// 47 | /// Cleans up the pair tester. 48 | /// 49 | public abstract void CleanUp(); 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /MyEngine/bepuphysics/DataStructures/StaticMeshData.cs: -------------------------------------------------------------------------------- 1 |  2 | 3 | using BEPUutilities; 4 | namespace BEPUphysics.DataStructures 5 | { 6 | /// 7 | /// Collection of triangle mesh data that directly returns vertices from its vertex buffer instead of transforming them first. 8 | /// 9 | public class StaticMeshData : MeshBoundingBoxTreeData 10 | { 11 | /// 12 | /// Constructs the triangle mesh data. 13 | /// 14 | ///Vertices to use in the data. 15 | ///Indices to use in the data. 16 | public StaticMeshData(Vector3[] vertices, int[] indices) 17 | { 18 | Vertices = vertices; 19 | Indices = indices; 20 | } 21 | 22 | 23 | /// 24 | /// Gets the triangle vertex positions at a given index. 25 | /// 26 | ///First index of a triangle's vertices in the index buffer. 27 | ///First vertex of the triangle. 28 | ///Second vertex of the triangle. 29 | ///Third vertex of the triangle. 30 | public override void GetTriangle(int triangleIndex, out Vector3 v1, out Vector3 v2, out Vector3 v3) 31 | { 32 | v1 = vertices[indices[triangleIndex]]; 33 | v2 = vertices[indices[triangleIndex + 1]]; 34 | v3 = vertices[indices[triangleIndex + 2]]; 35 | } 36 | 37 | 38 | /// 39 | /// Gets the position of a vertex in the data. 40 | /// 41 | ///Index of the vertex. 42 | ///Position of the vertex. 43 | public override void GetVertexPosition(int i, out Vector3 vertex) 44 | { 45 | vertex = vertices[i]; 46 | } 47 | 48 | 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /MyEngine/bepuphysics/DataStructures/TreeOverlapPair.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace BEPUphysics.DataStructures 7 | { 8 | /// 9 | /// Result of an overlap test between two trees of specified type. 10 | /// 11 | ///Type of elements in the first tree. 12 | ///Type of elements in the second tree. 13 | public struct TreeOverlapPair 14 | { 15 | /// 16 | /// Overlap owned by the first tree. 17 | /// 18 | public T1 OverlapA; 19 | /// 20 | /// Overlap owned by the second tree. 21 | /// 22 | public T2 OverlapB; 23 | 24 | /// 25 | /// Constructs a new overlap pair. 26 | /// 27 | /// Overlap owned by the first tree. 28 | /// Overlap owned by the second tree. 29 | public TreeOverlapPair(T1 overlapA, T2 overlapB) 30 | { 31 | OverlapA = overlapA; 32 | OverlapB = overlapB; 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /MyEngine/bepuphysics/DeactivationManagement/ISimulationIslandConnectionOwner.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace BEPUphysics.DeactivationManagement 7 | { 8 | /// 9 | /// Denotes a class which owns a simulation island connection. 10 | /// 11 | public interface ISimulationIslandConnectionOwner 12 | { 13 | /// 14 | /// Gets the connection associated with the object. 15 | /// 16 | SimulationIslandConnection SimulationIslandConnection 17 | { 18 | get; 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /MyEngine/bepuphysics/DeactivationManagement/ISimulationIslandMemberOwner.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace BEPUphysics.DeactivationManagement 7 | { 8 | /// 9 | /// Defines an object which owns a SimulationIslandMember. 10 | /// 11 | public interface ISimulationIslandMemberOwner 12 | { 13 | /// 14 | /// Gets the simulation island member associated with the object. 15 | /// 16 | SimulationIslandMember ActivityInformation { get; } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /MyEngine/bepuphysics/Entities/Entity.cs: -------------------------------------------------------------------------------- 1 | using BEPUphysics.BroadPhaseEntries.MobileCollidables; 2 | using BEPUutilities; 3 | 4 | namespace BEPUphysics.Entities 5 | { 6 | /// 7 | /// Superclass of all entities which have a defined collidable type. 8 | /// After construction, the collidable on this sort of Entity cannot be changed. 9 | /// It can be constructed directly, or one of its prefab children (Box, Sphere, etc.) can be used. 10 | /// 11 | /// If the collidable needs to be changed after construction, consider using the MorphableEntity. 12 | ///Type of EntityCollidable to use for the entity. 13 | public class Entity : Entity where T : EntityCollidable 14 | { 15 | /// 16 | /// Gets the collidable used by the entity. 17 | /// 18 | public new T CollisionInformation 19 | { 20 | get { return (T)collisionInformation; } 21 | } 22 | 23 | protected internal Entity() 24 | { 25 | 26 | } 27 | 28 | /// 29 | /// Constructs a kinematic Entity. 30 | /// 31 | ///Collidable for the entity. 32 | public Entity(T collisionInformation) 33 | { 34 | Initialize(collisionInformation); 35 | } 36 | 37 | 38 | /// 39 | /// Constructs a dynamic Entity. 40 | /// 41 | ///Collidable for the entity. 42 | /// Mass of the entity. 43 | public Entity(T collisionInformation, float mass) 44 | { 45 | Initialize(collisionInformation, mass); 46 | } 47 | /// 48 | /// Constructs a dynamic Entity. 49 | /// 50 | ///Collidable for the entity. 51 | /// Mass of the entity. 52 | /// Inertia of the entity. 53 | public Entity(T collisionInformation, float mass, Matrix3x3 inertiaTensor) 54 | { 55 | Initialize(collisionInformation, mass, inertiaTensor); 56 | } 57 | 58 | 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /MyEngine/bepuphysics/EntityStateManagement/EntityBufferedStates.cs: -------------------------------------------------------------------------------- 1 | using BEPUphysics.Entities; 2 | 3 | namespace BEPUphysics.EntityStateManagement 4 | { 5 | /// 6 | /// Contains a single entity's buffered states. 7 | /// 8 | public class EntityBufferedStates 9 | { 10 | /// 11 | /// Gets the buffered states manager that owns this entry. 12 | /// 13 | public BufferedStatesManager BufferedStatesManager { get; internal set; } 14 | 15 | /// 16 | /// Gets the buffered states accessor for this entity. 17 | /// Contains the current snapshot of the entity's states. 18 | /// 19 | public BufferedStatesAccessor States { get; private set; } 20 | /// 21 | /// Gets the interpolated states accessor for this entity. 22 | /// Contains a blended snapshot between the previous and current states based on the 23 | /// internal timestepping remainder. 24 | /// 25 | public InterpolatedStatesAccessor InterpolatedStates { get; private set; } 26 | 27 | internal int motionStateIndex; 28 | /// 29 | /// Gets the motion state index of this entity. 30 | /// 31 | public int MotionStateIndex { get { return motionStateIndex; } internal set { motionStateIndex = value; } } 32 | 33 | /// 34 | /// Constructs a new buffered states entry. 35 | /// 36 | ///Owning entity. 37 | public EntityBufferedStates(Entity entity) 38 | { 39 | Entity = entity; 40 | States = new BufferedStatesAccessor(this); 41 | InterpolatedStates = new InterpolatedStatesAccessor(this); 42 | } 43 | 44 | /// 45 | /// Gets the entity owning this entry. 46 | /// 47 | public Entity Entity { get; private set; } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /MyEngine/bepuphysics/EntityStateManagement/MotionState.cs: -------------------------------------------------------------------------------- 1 |  2 | using System; 3 | using BEPUutilities; 4 | 5 | namespace BEPUphysics.EntityStateManagement 6 | { 7 | /// 8 | /// State describing the position, orientation, and velocity of an entity. 9 | /// 10 | public struct MotionState : IEquatable 11 | { 12 | /// 13 | /// Position of an entity. 14 | /// 15 | public Vector3 Position; 16 | /// 17 | /// Orientation of an entity. 18 | /// 19 | public Quaternion Orientation; 20 | /// 21 | /// Orientation matrix of an entity. 22 | /// 23 | public Matrix OrientationMatrix 24 | { 25 | get 26 | { 27 | Matrix toReturn; 28 | Matrix.CreateFromQuaternion(ref Orientation, out toReturn); 29 | return toReturn; 30 | } 31 | } 32 | /// 33 | /// World transform of an entity. 34 | /// 35 | public Matrix WorldTransform 36 | { 37 | get 38 | { 39 | Matrix toReturn; 40 | Matrix.CreateFromQuaternion(ref Orientation, out toReturn); 41 | toReturn.Translation = Position; 42 | return toReturn; 43 | } 44 | } 45 | /// 46 | /// Linear velocity of an entity. 47 | /// 48 | public Vector3 LinearVelocity; 49 | /// 50 | /// Angular velocity of an entity. 51 | /// 52 | public Vector3 AngularVelocity; 53 | 54 | 55 | public bool Equals(MotionState other) 56 | { 57 | return other.AngularVelocity == AngularVelocity && 58 | other.LinearVelocity == LinearVelocity && 59 | other.Position == Position && 60 | other.Orientation == Orientation; 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /MyEngine/bepuphysics/ISpaceObject.cs: -------------------------------------------------------------------------------- 1 | namespace BEPUphysics 2 | { 3 | /// 4 | /// Defines an object which can be managed by an Space. 5 | /// 6 | public interface ISpaceObject 7 | { 8 | /// 9 | /// Gets the Space to which the object belongs. 10 | /// 11 | Space Space { get; set; } 12 | /// 13 | /// Called after the object is added to a space. 14 | /// 15 | /// Space to which the object was added. 16 | void OnAdditionToSpace(Space newSpace); 17 | /// 18 | /// Called before an object is removed from its space. 19 | /// 20 | /// Space from which the object was removed. 21 | void OnRemovalFromSpace(Space oldSpace); 22 | /// 23 | /// Gets or sets the user data associated with this object. 24 | /// 25 | object Tag { get; set; } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /MyEngine/bepuphysics/Materials/IMaterialOwner.cs: -------------------------------------------------------------------------------- 1 | namespace BEPUphysics.Materials 2 | { 3 | /// 4 | /// Defines an object that has a material. 5 | /// 6 | public interface IMaterialOwner 7 | { 8 | /// 9 | /// Gets or sets the material of the object. 10 | /// 11 | Material Material { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /MyEngine/bepuphysics/Materials/InteractionProperties.cs: -------------------------------------------------------------------------------- 1 | namespace BEPUphysics.Materials 2 | { 3 | /// 4 | /// Contains the blended friction and bounciness of a pair of objects. 5 | /// 6 | public struct InteractionProperties 7 | { 8 | /// 9 | /// Kinetic friction between the pair of objects. 10 | /// 11 | public float KineticFriction; 12 | /// 13 | /// Static friction between the pair of objects. 14 | /// 15 | public float StaticFriction; 16 | /// 17 | /// Bounciness between the pair of objects. 18 | /// 19 | public float Bounciness; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /MyEngine/bepuphysics/Materials/MaterialPair.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | namespace BEPUphysics.Materials 3 | { 4 | /// 5 | /// A pair of materials. 6 | /// 7 | public struct MaterialPair :IEquatable 8 | { 9 | /// 10 | /// First material in the pair. 11 | /// 12 | public Material MaterialA; 13 | /// 14 | /// Second material in the pair. 15 | /// 16 | public Material MaterialB; 17 | /// 18 | /// Constructs a new material pair. 19 | /// 20 | ///First material in the pair. 21 | ///Second material in the pair. 22 | public MaterialPair(Material a, Material b) 23 | { 24 | MaterialA = a; 25 | MaterialB = b; 26 | } 27 | 28 | /// 29 | /// Returns the hash code for this instance. 30 | /// 31 | /// 32 | /// A 32-bit signed integer that is the hash code for this instance. 33 | /// 34 | /// 2 35 | public override int GetHashCode() 36 | { 37 | return MaterialA.GetHashCode() + MaterialB.GetHashCode(); 38 | } 39 | 40 | 41 | /// 42 | /// Determines if the two material pairs have the same materials. 43 | /// 44 | /// Other pair to compare against. 45 | /// Whether or not the two pairs have the same materials. 46 | public bool Equals(MaterialPair other) 47 | { 48 | return (other.MaterialA == MaterialA && other.MaterialB == MaterialB) || (other.MaterialA == MaterialB && other.MaterialB == MaterialA); 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /MyEngine/bepuphysics/OtherSpaceStages/IDeferredEventCreator.cs: -------------------------------------------------------------------------------- 1 | namespace BEPUphysics.OtherSpaceStages 2 | { 3 | /// 4 | /// Defines an object which can create deferred events. 5 | /// 6 | public interface IDeferredEventCreator 7 | { 8 | //Needs backreference in order to add/remove itself to the dispatcher when deferred event handlers are added/removed. 9 | /// 10 | /// Gets or sets the deferred event dispatcher that owns this creator. 11 | /// 12 | DeferredEventDispatcher DeferredEventDispatcher { get; set; } 13 | 14 | /// 15 | /// Gets or sets the activity state of this creator. 16 | /// 17 | bool IsActive { get; set; } 18 | 19 | /// 20 | /// Dispatches the events created by this creator. 21 | /// 22 | void DispatchEvents(); 23 | 24 | /// 25 | /// Gets or sets the number of child deferred event creators. 26 | /// 27 | int ChildDeferredEventCreators { get; set; } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /MyEngine/bepuphysics/OtherSpaceStages/IDeferredEventCreatorOwner.cs: -------------------------------------------------------------------------------- 1 | namespace BEPUphysics.OtherSpaceStages 2 | { 3 | /// 4 | /// Defines an object that owns a deferred event creator. 5 | /// 6 | public interface IDeferredEventCreatorOwner 7 | { 8 | /// 9 | /// Gets the event creator owned by the object. 10 | /// 11 | IDeferredEventCreator EventCreator { get; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /MyEngine/bepuphysics/OtherSpaceStages/IForceUpdateable.cs: -------------------------------------------------------------------------------- 1 | namespace BEPUphysics.OtherSpaceStages 2 | { 3 | /// 4 | /// Defines an object which can be updated using forces by the ForceUpdater. 5 | /// 6 | public interface IForceUpdateable 7 | { 8 | /// 9 | /// Applies forces to the object. 10 | /// 11 | ///Time step duration. 12 | void UpdateForForces(float dt); 13 | 14 | /// 15 | /// Force updater that owns this object. 16 | /// 17 | ForceUpdater ForceUpdater { get; set; } 18 | 19 | /// 20 | /// Gets whether or not this object is dynamic. 21 | /// Only dynamic objects are updated by the force updater. 22 | /// 23 | bool IsDynamic { get; } 24 | 25 | /// 26 | /// Gets whether or not this object is active. Only active objects are updated by the force updater. 27 | /// 28 | bool IsActive { get; } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /MyEngine/bepuphysics/Paths/ConstantAngularSpeedCurve.cs: -------------------------------------------------------------------------------- 1 | using BEPUutilities; 2 | 3 | 4 | namespace BEPUphysics.Paths 5 | { 6 | /// 7 | /// Wrapper around an orientation curve that specifies a specific velocity at which to travel. 8 | /// 9 | public class ConstantAngularSpeedCurve : ConstantSpeedCurve 10 | { 11 | /// 12 | /// Constructs a new constant speed curve. 13 | /// 14 | /// Speed to maintain while traveling around a curve. 15 | /// Curve to wrap. 16 | public ConstantAngularSpeedCurve(float speed, Curve curve) 17 | : base(speed, curve) 18 | { 19 | } 20 | 21 | /// 22 | /// Constructs a new constant speed curve. 23 | /// 24 | /// Speed to maintain while traveling around a curve. 25 | /// Curve to wrap. 26 | /// Number of samples to use when constructing the wrapper curve. 27 | /// More samples increases the accuracy of the speed requirement at the cost of performance. 28 | public ConstantAngularSpeedCurve(float speed, Curve curve, int sampleCount) 29 | : base(speed, curve, sampleCount) 30 | { 31 | } 32 | 33 | protected override float GetDistance(Quaternion start, Quaternion end) 34 | { 35 | Quaternion.Conjugate(ref end, out end); 36 | Quaternion.Multiply(ref end, ref start, out end); 37 | return Quaternion.GetAngleFromQuaternion(ref end); 38 | } 39 | } 40 | } -------------------------------------------------------------------------------- /MyEngine/bepuphysics/Paths/ConstantLinearSpeedCurve.cs: -------------------------------------------------------------------------------- 1 |  2 | 3 | using BEPUutilities; 4 | namespace BEPUphysics.Paths 5 | { 6 | /// 7 | /// Wrapper around a 3d position curve that specifies a specific velocity at which to travel. 8 | /// 9 | public class ConstantLinearSpeedCurve : ConstantSpeedCurve 10 | { 11 | /// 12 | /// Constructs a new constant speed curve. 13 | /// 14 | /// Speed to maintain while traveling around a curve. 15 | /// Curve to wrap. 16 | public ConstantLinearSpeedCurve(float speed, Curve curve) 17 | : base(speed, curve) 18 | { 19 | } 20 | 21 | /// 22 | /// Constructs a new constant speed curve. 23 | /// 24 | /// Speed to maintain while traveling around a curve. 25 | /// Curve to wrap. 26 | /// Number of samples to use when constructing the wrapper curve. 27 | /// More samples increases the accuracy of the speed requirement at the cost of performance. 28 | public ConstantLinearSpeedCurve(float speed, Curve curve, int sampleCount) 29 | : base(speed, curve, sampleCount) 30 | { 31 | } 32 | 33 | protected override float GetDistance(Vector3 start, Vector3 end) 34 | { 35 | float distance; 36 | Vector3.Distance(ref start, ref end, out distance); 37 | return distance; 38 | } 39 | } 40 | } -------------------------------------------------------------------------------- /MyEngine/bepuphysics/Paths/ConstantSpeedCurve.cs: -------------------------------------------------------------------------------- 1 | namespace BEPUphysics.Paths 2 | { 3 | /// 4 | /// Superclass of speed-controlled curves that have a constant speed. 5 | /// 6 | /// Type of the values in the curve. 7 | public abstract class ConstantSpeedCurve : SpeedControlledCurve 8 | { 9 | /// 10 | /// Constructs a new constant speed curve. 11 | /// 12 | /// Speed to maintain while traveling around a curve. 13 | /// Curve to wrap. 14 | protected ConstantSpeedCurve(float speed, Curve curve) 15 | : base(curve) 16 | { 17 | Speed = speed; 18 | ResampleCurve(); 19 | } 20 | 21 | /// 22 | /// Constructs a new constant speed curve. 23 | /// 24 | /// Speed to maintain while traveling around a curve. 25 | /// Curve to wrap. 26 | /// Number of samples to use when constructing the wrapper curve. 27 | /// More samples increases the accuracy of the speed requirement at the cost of performance. 28 | protected ConstantSpeedCurve(float speed, Curve curve, int sampleCount) 29 | : base(curve, sampleCount) 30 | { 31 | Speed = speed; 32 | ResampleCurve(); 33 | } 34 | 35 | /// 36 | /// Gets or sets the speed of the curve. 37 | /// 38 | public float Speed { get; set; } 39 | 40 | /// 41 | /// Gets the desired speed at a given time. 42 | /// 43 | /// Time to check for speed. 44 | /// Speed at the given time. 45 | public override float GetSpeedAtCurveTime(double time) 46 | { 47 | return Speed; 48 | } 49 | } 50 | } -------------------------------------------------------------------------------- /MyEngine/bepuphysics/Paths/CurveEndpointBehavior.cs: -------------------------------------------------------------------------------- 1 | namespace BEPUphysics.Paths 2 | { 3 | /// 4 | /// Defines how a curve behaves beyond an endpoint. 5 | /// 6 | public enum CurveEndpointBehavior 7 | { 8 | /// 9 | /// When the time exceeds the endpoint, it wraps around to the other end of the curve. 10 | /// 11 | Wrap, 12 | /// 13 | /// Times exceeding the endpoint are clamped to the endpoint's value. 14 | /// 15 | Clamp, 16 | /// 17 | /// Times exceeding the endpoint will reverse direction and sample backwards. 18 | /// 19 | Mirror 20 | } 21 | } -------------------------------------------------------------------------------- /MyEngine/bepuphysics/Paths/Path.cs: -------------------------------------------------------------------------------- 1 | namespace BEPUphysics.Paths 2 | { 3 | /// 4 | /// Superclass of a variety of classes that can be evaluated at a time to retrieve a value associated with that time. 5 | /// 6 | /// Type of the value of the path. 7 | public abstract class Path 8 | { 9 | /// 10 | /// Computes the value of the path at a given time. 11 | /// 12 | /// Time at which to evaluate the path. 13 | /// Path value at the given time. 14 | public abstract void Evaluate(double time, out TValue value); 15 | 16 | /// 17 | /// Gets the starting and ending times of the path. 18 | /// 19 | /// Beginning time of the path. 20 | /// Ending time of the path. 21 | public abstract void GetPathBoundsInformation(out double startingTime, out double endingTime); 22 | 23 | /// 24 | /// Computes the value of the path at a given time. 25 | /// 26 | /// Time at which to evaluate the path. 27 | /// Path value at the given time. 28 | public TValue Evaluate(double time) 29 | { 30 | TValue toReturn; 31 | Evaluate(time, out toReturn); 32 | return toReturn; 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /MyEngine/bepuphysics/Paths/StepCurve1D.cs: -------------------------------------------------------------------------------- 1 | namespace BEPUphysics.Paths 2 | { 3 | /// 4 | /// One dimensional-valued curve that does not interpolate values. 5 | /// Instead, it just picks the value from the previous control point. 6 | /// 7 | public class StepCurve1D : Curve 8 | { 9 | /// 10 | /// Evaluates the curve at a given time using linear interpolation. 11 | /// 12 | /// Index of the control point at the beginning of the evaluation interval. 13 | /// Value of 0 to 1 representing how far along the interval to sample. 14 | /// Value of the curve at the given location. 15 | public override void Evaluate(int controlPointIndex, float weight, out float value) 16 | { 17 | value = ControlPoints[controlPointIndex].Value; 18 | } 19 | 20 | /// 21 | /// Computes the bounds of the curve. 22 | /// 23 | /// Minimum index of the curve. 24 | /// Maximum index of the curve. 25 | public override void GetCurveIndexBoundsInformation(out int minIndex, out int maxIndex) 26 | { 27 | maxIndex = ControlPoints.Count - 1; 28 | if (maxIndex < 0) 29 | minIndex = -1; 30 | else 31 | minIndex = 0; 32 | } 33 | 34 | protected internal override void ControlPointAdded(CurveControlPoint curveControlPoint, int index) 35 | { 36 | } 37 | 38 | protected internal override void ControlPointRemoved(CurveControlPoint curveControlPoint, int oldIndex) 39 | { 40 | } 41 | 42 | protected internal override void ControlPointTimeChanged(CurveControlPoint curveControlPoint, int oldIndex, int newIndex) 43 | { 44 | } 45 | 46 | protected internal override void ControlPointValueChanged(CurveControlPoint curveControlPoint) 47 | { 48 | } 49 | } 50 | } -------------------------------------------------------------------------------- /MyEngine/bepuphysics/Paths/VariableAngularSpeedCurve.cs: -------------------------------------------------------------------------------- 1 | using BEPUutilities; 2 | 3 | 4 | namespace BEPUphysics.Paths 5 | { 6 | /// 7 | /// Wraps a curve that is traveled along with arbitrary defined angular speed. 8 | /// 9 | /// 10 | /// The speed curve should be designed with the wrapped curve's times in mind. 11 | /// Speeds will be sampled based on the wrapped curve's interval. 12 | public class VariableAngularSpeedCurve : VariableSpeedCurve 13 | { 14 | /// 15 | /// Constructs a new variable speed curve. 16 | /// 17 | /// Curve defining speeds to use. 18 | /// Curve to wrap. 19 | public VariableAngularSpeedCurve(Path speedCurve, Curve curve) 20 | : base(speedCurve, curve) 21 | { 22 | } 23 | 24 | /// 25 | /// Constructs a new variable speed curve. 26 | /// 27 | /// Curve defining speeds to use. 28 | /// Curve to wrap. 29 | /// Number of samples to use when constructing the wrapper curve. 30 | /// More samples increases the accuracy of the speed requirement at the cost of performance. 31 | public VariableAngularSpeedCurve(Path speedCurve, Curve curve, int sampleCount) 32 | : base(speedCurve, curve, sampleCount) 33 | { 34 | } 35 | 36 | protected override float GetDistance(Quaternion start, Quaternion end) 37 | { 38 | Quaternion.Conjugate(ref end, out end); 39 | Quaternion.Multiply(ref end, ref start, out end); 40 | return Quaternion.GetAngleFromQuaternion(ref end); 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /MyEngine/bepuphysics/Paths/VariableLinearSpeedCurve.cs: -------------------------------------------------------------------------------- 1 |  2 | 3 | using BEPUutilities; 4 | namespace BEPUphysics.Paths 5 | { 6 | /// 7 | /// Wraps a curve that is traveled along with arbitrary defined linear speed. 8 | /// 9 | /// 10 | /// The speed curve should be designed with the wrapped curve's times in mind. 11 | /// Speeds will be sampled based on the wrapped curve's interval. 12 | public class VariableLinearSpeedCurve : VariableSpeedCurve 13 | { 14 | /// 15 | /// Constructs a new variable speed curve. 16 | /// 17 | /// Curve defining speeds to use. 18 | /// Curve to wrap. 19 | public VariableLinearSpeedCurve(Path speedCurve, Curve curve) 20 | : base(speedCurve, curve) 21 | { 22 | } 23 | 24 | /// 25 | /// Constructs a new variable speed curve. 26 | /// 27 | /// Curve defining speeds to use. 28 | /// Curve to wrap. 29 | /// Number of samples to use when constructing the wrapper curve. 30 | /// More samples increases the accuracy of the speed requirement at the cost of performance. 31 | public VariableLinearSpeedCurve(Path speedCurve, Curve curve, int sampleCount) 32 | : base(speedCurve, curve, sampleCount) 33 | { 34 | } 35 | 36 | protected override float GetDistance(Vector3 start, Vector3 end) 37 | { 38 | float distance; 39 | Vector3.Distance(ref start, ref end, out distance); 40 | return distance; 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /MyEngine/bepuphysics/Paths/VariableSpeedCurve.cs: -------------------------------------------------------------------------------- 1 | namespace BEPUphysics.Paths 2 | { 3 | /// 4 | /// Curve that wraps another curve and travels along it with specified speeds. 5 | /// 6 | /// Type of the value of the wrapped curve. 7 | public abstract class VariableSpeedCurve : SpeedControlledCurve 8 | { 9 | /// 10 | /// Constructs a new constant speed curve. 11 | /// 12 | /// Curve defining speeds to use. 13 | /// Curve to wrap. 14 | protected VariableSpeedCurve(Path speedCurve, Curve curve) 15 | : base(curve) 16 | { 17 | SpeedCurve = speedCurve; 18 | ResampleCurve(); 19 | } 20 | 21 | /// 22 | /// Constructs a new constant speed curve. 23 | /// 24 | /// Curve defining speeds to use. 25 | /// Curve to wrap. 26 | /// Number of samples to use when constructing the wrapper curve. 27 | /// More samples increases the accuracy of the speed requirement at the cost of performance. 28 | protected VariableSpeedCurve(Path speedCurve, Curve curve, int sampleCount) 29 | : base(curve, sampleCount) 30 | { 31 | SpeedCurve = speedCurve; 32 | ResampleCurve(); 33 | } 34 | 35 | /// 36 | /// Gets or sets the path that defines the speeds at given locations. 37 | /// The speed curve will be sampled at times associated with the wrapped curve. 38 | /// 39 | public Path SpeedCurve { get; set; } 40 | 41 | /// 42 | /// Gets the speed at a given time on the wrapped curve. 43 | /// 44 | /// Time to evaluate. 45 | /// Speed at the given time. 46 | public override float GetSpeedAtCurveTime(double time) 47 | { 48 | return SpeedCurve.Evaluate(time); 49 | } 50 | } 51 | } -------------------------------------------------------------------------------- /MyEngine/bepuphysics/PhysicsChecker.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using BEPUphysics.CollisionTests; 4 | using BEPUutilities; 5 | 6 | namespace BEPUphysics 7 | { 8 | /// 9 | /// Contains conditional extensions to check for bad values in various structures. 10 | /// 11 | public static class PhysicsChecker 12 | { 13 | 14 | /// 15 | /// Checks the contact to see if it contains NaNs or infinities. If it is, an exception is thrown. 16 | /// This is only run when the CHECKMATH symbol is defined. 17 | /// 18 | [Conditional("CHECKMATH")] 19 | public static void Validate(this Contact contact) 20 | { 21 | contact.Normal.Validate(); 22 | if (contact.Normal.LengthSquared() < 0.9f) 23 | throw new ArithmeticException("Invalid contact normal."); 24 | contact.Position.Validate(); 25 | contact.PenetrationDepth.Validate(); 26 | } 27 | 28 | 29 | /// 30 | /// Checks the contact to see if it contains NaNs or infinities. If it is, an exception is thrown. 31 | /// This is only run when the CHECKMATH symbol is defined. 32 | /// 33 | [Conditional("CHECKMATH")] 34 | public static void Validate(this ContactData contact) 35 | { 36 | contact.Normal.Validate(); 37 | contact.Position.Validate(); 38 | contact.PenetrationDepth.Validate(); 39 | } 40 | 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /MyEngine/bepuphysics/PositionUpdating/ICCDPositionUpdateable.cs: -------------------------------------------------------------------------------- 1 | namespace BEPUphysics.PositionUpdating 2 | { 3 | /// 4 | /// Update modes for position updateables. 5 | /// 6 | public enum PositionUpdateMode : byte 7 | { 8 | /// 9 | /// Updates position discretely regardless of its collision pairs. 10 | /// 11 | Discrete, 12 | /// 13 | /// Updates position discretely in isolation; when a Continuous object collides with it, 14 | /// its position update will be bounded by the time of impact. 15 | /// 16 | Passive, 17 | /// 18 | /// Updates position continuously. Continuous objects will integrate up to their earliest collision time. 19 | /// 20 | Continuous 21 | } 22 | 23 | /// 24 | /// A position updateable that can be updated continuously. 25 | /// 26 | public interface ICCDPositionUpdateable : IPositionUpdateable 27 | { 28 | /// 29 | /// Updates the time of impacts associated with the updateable. 30 | /// 31 | ///Time step duration. 32 | void UpdateTimesOfImpact(float dt); 33 | 34 | /// 35 | /// Updates the updateable using its continuous nature. 36 | /// 37 | /// Time step duration. 38 | void UpdatePositionContinuously(float dt); 39 | 40 | /// 41 | /// Gets or sets the position update mode of the object. 42 | /// The position update mode defines the way the object 43 | /// interacts with continuous collision detection. 44 | /// 45 | PositionUpdateMode PositionUpdateMode { get; set; } 46 | 47 | /// 48 | /// Resets the times of impact for pairs associated with this position updateable. 49 | /// 50 | void ResetTimesOfImpact(); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /MyEngine/bepuphysics/PositionUpdating/IPositionUpdateable.cs: -------------------------------------------------------------------------------- 1 | namespace BEPUphysics.PositionUpdating 2 | { 3 | /// 4 | /// Defines an object capable of a position update. 5 | /// 6 | public interface IPositionUpdateable 7 | { 8 | /// 9 | /// Gets whether or not the object is active. 10 | /// Only active objects will be updated. 11 | /// 12 | bool IsActive { get; } 13 | 14 | /// 15 | /// Gets or sets the position updater that owns this updateable. 16 | /// 17 | PositionUpdater PositionUpdater { get; set; } 18 | 19 | /// 20 | /// Updates the position state of the object. 21 | /// 22 | ///Time step duration. 23 | void PreUpdatePosition(float dt); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /MyEngine/bepuphysics/PositionUpdating/PositionUpdater.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using BEPUphysics.Threading; 3 | 4 | namespace BEPUphysics.PositionUpdating 5 | { 6 | /// 7 | /// Superclass of updaters which manage the position of objects. 8 | /// 9 | public abstract class PositionUpdater : MultithreadedProcessingStage 10 | { 11 | protected TimeStepSettings timeStepSettings; 12 | /// 13 | /// Gets or sets the time step settings used by the updater. 14 | /// 15 | public TimeStepSettings TimeStepSettings 16 | { 17 | get 18 | { 19 | return timeStepSettings; 20 | } 21 | set 22 | { 23 | timeStepSettings = value; 24 | } 25 | } 26 | 27 | protected PositionUpdater(TimeStepSettings timeStepSettings, IParallelLooper parallelLooper) 28 | :this(timeStepSettings) 29 | { 30 | ParallelLooper = parallelLooper; 31 | AllowMultithreading = true; 32 | } 33 | 34 | protected PositionUpdater(TimeStepSettings timeStepSettings) 35 | { 36 | this.timeStepSettings = timeStepSettings; 37 | Enabled = true; 38 | } 39 | /// 40 | /// Adds an object to the position updater. 41 | /// 42 | ///Updateable to add. 43 | ///Thrown if the updateable already belongs to a position updater. 44 | public abstract void Add(IPositionUpdateable updateable); 45 | /// 46 | /// Removes an updateable from the updater. 47 | /// 48 | ///Item to remove. 49 | ///Thrown if the updater does not own the updateable. 50 | public abstract void Remove(IPositionUpdateable updateable); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /MyEngine/bepuphysics/ProcessingStage.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | 4 | namespace BEPUphysics 5 | { 6 | /// 7 | /// Superclass of singlethreaded update systems. 8 | /// 9 | public abstract class ProcessingStage 10 | { 11 | /// 12 | /// Gets or sets whether or not the stage should update. 13 | /// 14 | public virtual bool Enabled { get; set; } 15 | 16 | /// 17 | /// Fires when the stage starts working. 18 | /// 19 | public event Action Starting; 20 | 21 | /// 22 | /// Fires when the stage finishes working. 23 | /// 24 | public event Action Finishing; 25 | 26 | #if PROFILE 27 | /// 28 | /// Gets the time elapsed in the previous execution of this stage, not including any hooked Starting or Finishing events. 29 | /// 30 | public double Time 31 | { 32 | get 33 | { 34 | return (end - start) / (double)Stopwatch.Frequency; 35 | } 36 | } 37 | 38 | long start, end; 39 | 40 | 41 | #endif 42 | /// 43 | /// Updates the stage. 44 | /// 45 | public void Update() 46 | { 47 | if (!Enabled) 48 | return; 49 | if (Starting != null) 50 | Starting(); 51 | #if PROFILE 52 | start = Stopwatch.GetTimestamp(); 53 | #endif 54 | 55 | UpdateStage(); 56 | 57 | #if PROFILE 58 | end = Stopwatch.GetTimestamp(); 59 | #endif 60 | if (Finishing != null) 61 | Finishing(); 62 | } 63 | protected abstract void UpdateStage(); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /MyEngine/bepuphysics/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("BEPUphysics")] 9 | [assembly: AssemblyProduct("BEPUphysics")] 10 | [assembly: AssemblyDescription("Real time physics simulation library")] 11 | [assembly: AssemblyCompany("Bepu Entertainment LLC")] 12 | [assembly: AssemblyCopyright("Copyright © 2013, Bepu Entertainment LLC")] 13 | [assembly: AssemblyTrademark("")] 14 | [assembly: AssemblyCulture("")] 15 | 16 | // Setting ComVisible to false makes the types in this assembly not visible 17 | // to COM components. If you need to access a type in this assembly from 18 | // COM, set the ComVisible attribute to true on that type. Only Windows 19 | // assemblies support COM. 20 | [assembly: ComVisible(false)] 21 | 22 | // On Windows, the following GUID is for the ID of the typelib if this 23 | // project is exposed to COM. On other platforms, it unique identifies the 24 | // title storage container when deploying this assembly to the device. 25 | [assembly: Guid("ab0c58ea-ef42-46d7-b180-2baedc61ce9b")] 26 | 27 | // Version information for an assembly consists of the following four values: 28 | // 29 | // Major Version 30 | // Minor Version 31 | // Build Number 32 | // Revision 33 | // 34 | [assembly: AssemblyVersion("1.3.0.0")] 35 | #if WINDOWS_PHONE 36 | [assembly: CodeGeneration(CodeGenerationFlags.EnableFPIntrinsicsUsingSIMD)] 37 | #endif 38 | [assembly: AssemblyFileVersionAttribute("0")] 39 | -------------------------------------------------------------------------------- /MyEngine/bepuphysics/RayCastResult.cs: -------------------------------------------------------------------------------- 1 | using BEPUphysics.BroadPhaseEntries; 2 | using BEPUutilities; 3 | 4 | namespace BEPUphysics 5 | { 6 | /// 7 | /// Contains information about a ray cast hit. 8 | /// 9 | public struct RayCastResult 10 | { 11 | /// 12 | /// Position, normal, and t paramater of the hit. 13 | /// 14 | public RayHit HitData; 15 | /// 16 | /// Object hit by the ray. 17 | /// 18 | public BroadPhaseEntry HitObject; 19 | 20 | /// 21 | /// Constructs a new ray cast result. 22 | /// 23 | ///Ray cast hit data. 24 | ///Object hit by the ray. 25 | public RayCastResult(RayHit hitData, BroadPhaseEntry hitObject) 26 | { 27 | HitData = hitData; 28 | HitObject = hitObject; 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /MyEngine/bepuphysics/Settings/CollisionResponseSettings.cs: -------------------------------------------------------------------------------- 1 | namespace BEPUphysics.Settings 2 | { 3 | /// 4 | /// Contains global settings relating to the collision response system. 5 | /// 6 | public static class CollisionResponseSettings 7 | { 8 | /// 9 | /// Impact velocity above which the full bounciness of a material pair is taken into account. Below the threshold, the extra energy introduced by the bounce is reduced. The lower the velocity is relative to the threshold, the lower the effective bounciness. 10 | /// Defaults to 1. 11 | /// 12 | public static float BouncinessVelocityThreshold = 1; 13 | 14 | /// 15 | /// Maximum speed at which interpenetrating objects will attempt to undo any overlap. 16 | /// Defaults to 2. 17 | /// 18 | public static float MaximumPenetrationRecoverySpeed = 2; 19 | 20 | /// 21 | /// Fraction of position error to convert into corrective momentum. 22 | /// Defaults to 0.2. 23 | /// 24 | public static float PenetrationRecoveryStiffness = 0.2f; 25 | 26 | /// 27 | /// Magnitude of relative velocity at a contact point below which staticFriction is used. 28 | /// dynamicFriction is used when velocity exceeds this threshold. 29 | /// Defaults to 0.2. 30 | /// 31 | public static float StaticFrictionVelocityThreshold = 0.2f; 32 | 33 | /// 34 | /// Value by which a collision pair's friction coefficient will be multiplied to get the twist friction coefficient. 35 | /// Defaults to 1. 36 | /// 37 | public static float TwistFrictionFactor = 1f; 38 | 39 | /// 40 | /// Softness multiplier used by collision penetration constraints. Higher softness values allow more velocity error and make things look 'squishier'. Defaults to 0.001. 41 | /// Note that this value is not used directly by constraints; it is first scaled by the raw inverse effective mass. This allows consistent behavior across objects with different masses. 42 | /// 43 | public static float Softness = .001f; 44 | 45 | 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /MyEngine/bepuphysics/Threading/IParallelLooper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace BEPUphysics.Threading 4 | { 5 | 6 | /// 7 | /// Provides a multithreaded for loop interface. 8 | /// 9 | public interface IParallelLooper 10 | { 11 | 12 | /// 13 | /// Loops from the starting index (inclusive) to the ending index (exclusive), calling the loopBody at each iteration. 14 | /// The forLoop function will not return until all iterations are complete. 15 | /// This is meant to be used in a 'fork-join' model; only a single thread should be running a forLoop 16 | /// at any time. 17 | /// 18 | /// Inclusive starting index. 19 | /// Exclusive ending index. 20 | /// Function that handles an individual iteration of the loop. 21 | void ForLoop(int startIndex, int endIndex, Action loopBody); 22 | 23 | /// 24 | /// Gets the number of threads available to the loop. 25 | /// This is used to configure job sizes where applicable. 26 | /// It does not have to be exactly correct; an estimate will work. 27 | /// Better estimates should result in better performance. 28 | /// 29 | int ThreadCount { get; } 30 | } 31 | } -------------------------------------------------------------------------------- /MyEngine/bepuphysics/Threading/TPLLoopProvider.cs: -------------------------------------------------------------------------------- 1 | #if WINDOWS 2 | using System; 3 | using System.Threading.Tasks; 4 | 5 | namespace BEPUphysics.Threading 6 | { 7 | /// 8 | /// Uses the .NET Task Parallel library to provide multithreaded loops. 9 | /// 10 | public class TPLLoopProvider : IParallelLooper 11 | { 12 | /// 13 | /// Gets the number of threads available to the loop. 14 | /// This is used to configure job sizes where applicable. 15 | /// It does not have to be exactly correct; an estimate will work. 16 | /// Better estimates should result in better performance. 17 | /// 18 | public int ThreadCount { get; private set; } 19 | 20 | public TPLLoopProvider() 21 | { 22 | ThreadCount = Environment.ProcessorCount; 23 | } 24 | 25 | /// 26 | /// Loops from the starting index (inclusive) to the ending index (exclusive), calling the loopBody at each iteration. 27 | /// The forLoop function will not return until all iterations are complete. 28 | /// This is meant to be used in a 'fork-join' model; only a single thread should be running a forLoop 29 | /// at any time. 30 | /// 31 | /// Inclusive starting index. 32 | /// Exclusive ending index. 33 | /// Function that handles an individual iteration of the loop. 34 | public void ForLoop(int startIndex, int endIndex, Action loopBody) 35 | { 36 | Parallel.For(startIndex, endIndex, loopBody); 37 | } 38 | 39 | 40 | } 41 | } 42 | 43 | #endif -------------------------------------------------------------------------------- /MyEngine/bepuphysics/TimeStepSettings.cs: -------------------------------------------------------------------------------- 1 | namespace BEPUphysics 2 | { 3 | /// 4 | /// Contains settings for the instance's time step. 5 | /// 6 | public class TimeStepSettings 7 | { 8 | /// 9 | /// Maximum number of timesteps to perform during a given frame when Space.Update(float) is used. The unsimulated time will be accumulated for subsequent calls to Space.Update(float). 10 | /// Defaults to 3. 11 | /// 12 | public int MaximumTimeStepsPerFrame = 3; 13 | 14 | /// 15 | /// Length of each integration step. Calling a Space's Update() method moves time forward this much. 16 | /// The other method, Space.Update(float), will try to move time forward by the amount specified in the parameter by taking steps of TimeStepDuration size. 17 | /// Defaults to 1/60. 18 | /// 19 | public float TimeStepDuration = 1f / 60; 20 | 21 | /// 22 | /// Amount of time accumulated by previous calls to Space.Update(float) that has not yet been simulated. 23 | /// 24 | public float AccumulatedTime; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /MyEngine/bepuphysics/UpdateableSystems/CombinedUpdateable.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using BEPUphysics.Constraints; 3 | 4 | namespace BEPUphysics.UpdateableSystems 5 | { 6 | /// 7 | /// A class which is both a space updateable and a Solver Updateable. 8 | /// 9 | public abstract class CombinedUpdateable : SolverUpdateable, ISpaceUpdateable 10 | { 11 | private bool isSequentiallyUpdated = true; 12 | 13 | protected CombinedUpdateable() 14 | { 15 | IsUpdating = true; 16 | } 17 | 18 | #region ISpaceUpdateable Members 19 | 20 | List managers = new List(); 21 | List ISpaceUpdateable.Managers 22 | { 23 | get 24 | { 25 | return managers; 26 | } 27 | } 28 | 29 | /// 30 | /// Gets and sets whether or not the updateable should be updated sequentially even in a multithreaded space. 31 | /// If this is true, the updateable can make use of the space's ParallelLooper for internal multithreading. 32 | /// 33 | public bool IsUpdatedSequentially 34 | { 35 | get { return isSequentiallyUpdated; } 36 | set 37 | { 38 | bool oldValue = isSequentiallyUpdated; 39 | isSequentiallyUpdated = value; 40 | if (value != oldValue) 41 | for (int i = 0; i < managers.Count; i++) 42 | { 43 | managers[i].SequentialUpdatingStateChanged(this); 44 | } 45 | } 46 | } 47 | 48 | 49 | /// 50 | /// Gets and sets whether or not the updateable should be updated by the space. 51 | /// 52 | public bool IsUpdating 53 | { 54 | get; 55 | set; 56 | } 57 | 58 | 59 | Space ISpaceObject.Space 60 | { 61 | get; 62 | set; 63 | } 64 | 65 | /// 66 | /// Gets or sets the user data associated with this object. 67 | /// 68 | public new object Tag { get; set; } 69 | 70 | #endregion 71 | 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /MyEngine/bepuphysics/UpdateableSystems/ForceFields/ForceFieldShape.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using BEPUphysics.Entities; 3 | using BEPUutilities.DataStructures; 4 | 5 | namespace BEPUphysics.UpdateableSystems.ForceFields 6 | { 7 | /// 8 | /// Superclass of force field shapes that test whether or not entities are affected by a forcefield. 9 | /// 10 | public abstract class ForceFieldShape 11 | { 12 | /// 13 | /// Force field associated with this shape. 14 | /// 15 | public ForceField ForceField { get; internal set; } 16 | 17 | 18 | /// 19 | /// Uses an efficient query to see what entities may be affected. 20 | /// Usually uses a broadphase bounding box query. 21 | /// 22 | /// Possibly affected entities. 23 | public abstract IList GetPossiblyAffectedEntities(); 24 | 25 | /// 26 | /// Performs a narrow-phase test to see if an entity is affected by the force field. 27 | /// 28 | /// Entity to test. 29 | /// Whether or not the entity is affected. 30 | public abstract bool IsEntityAffected(Entity entity); 31 | } 32 | } -------------------------------------------------------------------------------- /MyEngine/bepuphysics/UpdateableSystems/ForceFields/InfiniteForceFieldShape.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using BEPUphysics.Entities; 3 | using BEPUutilities.DataStructures; 4 | 5 | namespace BEPUphysics.UpdateableSystems.ForceFields 6 | { 7 | /// 8 | /// Defines the area in which a force field works using an entity's shape. 9 | /// 10 | public class InfiniteForceFieldShape : ForceFieldShape 11 | { 12 | private IList boxedList; 13 | /// 14 | /// Determines the possibly involved entities. 15 | /// 16 | /// Possibly involved entities. 17 | public override IList GetPossiblyAffectedEntities() 18 | { 19 | return boxedList ?? (boxedList = (ForceField as ISpaceObject).Space.Entities); 20 | } 21 | 22 | /// 23 | /// Determines if the entity is affected by the force field. 24 | /// 25 | /// Entity to test. 26 | /// Whether the entity is affected. 27 | public override bool IsEntityAffected(Entity testEntity) 28 | { 29 | return true; 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /MyEngine/bepuphysics/UpdateableSystems/ForceFields/VolumeForceFieldShape.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using BEPUphysics.BroadPhaseEntries; 3 | using BEPUphysics.Entities; 4 | using BEPUutilities.DataStructures; 5 | 6 | namespace BEPUphysics.UpdateableSystems.ForceFields 7 | { 8 | /// 9 | /// Defines the area in which a force field works using an entity's shape. 10 | /// 11 | public class VolumeForceFieldShape : ForceFieldShape 12 | { 13 | private readonly RawList affectedEntities = new RawList(); 14 | 15 | /// 16 | /// Constructs a new force field shape using a detector volume. 17 | /// 18 | /// Volume to use. 19 | public VolumeForceFieldShape(DetectorVolume volume) 20 | { 21 | Volume = volume; 22 | } 23 | 24 | /// 25 | /// Gets or sets the volume used by the shape. 26 | /// 27 | public DetectorVolume Volume { get; set; } 28 | 29 | /// 30 | /// Determines the possibly involved entities. 31 | /// 32 | /// Possibly involved entities. 33 | public override IList GetPossiblyAffectedEntities() 34 | { 35 | affectedEntities.Clear(); 36 | foreach (var entity in Volume.pairs.Keys) 37 | { 38 | affectedEntities.Add(entity); 39 | } 40 | return affectedEntities; 41 | } 42 | 43 | /// 44 | /// Determines if the entity is affected by the force field. 45 | /// 46 | /// Entity to test. 47 | /// Whether the entity is affected. 48 | public override bool IsEntityAffected(Entity testEntity) 49 | { 50 | return Volume.pairs[testEntity].Touching; 51 | } 52 | } 53 | } -------------------------------------------------------------------------------- /MyEngine/bepuphysics/UpdateableSystems/IBeforeNarrowPhaseUpdateable.cs: -------------------------------------------------------------------------------- 1 | namespace BEPUphysics.UpdateableSystems 2 | { 3 | /// 4 | /// Defines an object which is updated by the space before the narrow phase runs. 5 | /// 6 | public interface IBeforeNarrowPhaseUpdateable : ISpaceUpdateable 7 | { 8 | /// 9 | /// Updates the updateable before the narrow phase. 10 | /// 11 | ///Time step duration. 12 | void Update(float dt); 13 | 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /MyEngine/bepuphysics/UpdateableSystems/IBeforePositionUpdateUpdateable.cs: -------------------------------------------------------------------------------- 1 | namespace BEPUphysics.UpdateableSystems 2 | { 3 | /// 4 | /// Defines an object which is updated by the space at the end of a time step. 5 | /// 6 | public interface IBeforePositionUpdateUpdateable : ISpaceUpdateable 7 | { 8 | 9 | /// 10 | /// Updates the object at the end of a time step. 11 | /// 12 | ///Time step duration. 13 | void Update(float dt); 14 | 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /MyEngine/bepuphysics/UpdateableSystems/IBeforeSolverUpdateable.cs: -------------------------------------------------------------------------------- 1 | namespace BEPUphysics.UpdateableSystems 2 | { 3 | /// 4 | /// Defines an object which is updated by the space before the solver runs. 5 | /// 6 | public interface IBeforeSolverUpdateable : ISpaceUpdateable 7 | { 8 | /// 9 | /// Updates the updateable before the solver. 10 | /// 11 | ///Time step duration. 12 | void Update(float dt); 13 | 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /MyEngine/bepuphysics/UpdateableSystems/IDuringForcesUpdateable.cs: -------------------------------------------------------------------------------- 1 | namespace BEPUphysics.UpdateableSystems 2 | { 3 | /// 4 | /// Defines an object which is updated by a space during force application. 5 | /// 6 | public interface IDuringForcesUpdateable : ISpaceUpdateable 7 | { 8 | 9 | /// 10 | /// Updates the object during force application. 11 | /// 12 | ///Time step duration. 13 | void Update(float dt); 14 | 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /MyEngine/bepuphysics/UpdateableSystems/IEndOfFrameUpdateable.cs: -------------------------------------------------------------------------------- 1 | namespace BEPUphysics.UpdateableSystems 2 | { 3 | /// 4 | /// Defines an object which is updated by the space at the end of the frame. 5 | /// 6 | public interface IEndOfFrameUpdateable : ISpaceUpdateable 7 | { 8 | /// 9 | /// Updates the object at the end of the frame. 10 | /// 11 | /// Time step duration. 12 | void Update(float dt); 13 | 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /MyEngine/bepuphysics/UpdateableSystems/IEndOfTimeStepUpdateable.cs: -------------------------------------------------------------------------------- 1 | namespace BEPUphysics.UpdateableSystems 2 | { 3 | /// 4 | /// Defines an object which is updated by the space at the end of a time step. 5 | /// 6 | public interface IEndOfTimeStepUpdateable : ISpaceUpdateable 7 | { 8 | 9 | /// 10 | /// Updates the object at the end of a time step. 11 | /// 12 | ///Time step duration. 13 | void Update(float dt); 14 | 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /MyEngine/bepuphysics/UpdateableSystems/ISpaceUpdateable.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace BEPUphysics.UpdateableSystems 4 | { 5 | /// 6 | /// Defines an object which is updated by the space. 7 | /// These refer to the special Updateable types which 8 | /// allow for easier integration into the update flow of the space. 9 | /// 10 | public interface ISpaceUpdateable : ISpaceObject 11 | { 12 | /// 13 | /// Gets and sets whether or not the updateable should be updated sequentially even in a multithreaded space. 14 | /// If this is true, the updateable can make use of the space's ParallelLooper for internal multithreading. 15 | /// 16 | bool IsUpdatedSequentially { get; set; } 17 | 18 | /// 19 | /// Gets and sets whether or not the updateable should be updated by the space. 20 | /// 21 | bool IsUpdating { get; set; } 22 | 23 | /// 24 | /// List of managers owning the updateable. 25 | /// 26 | List Managers { get; } 27 | 28 | 29 | 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /MyEngine/bepuphysics/Vehicle/WheelFrictionBlender.cs: -------------------------------------------------------------------------------- 1 | using BEPUphysics.Materials; 2 | namespace BEPUphysics.Vehicle 3 | { 4 | /// 5 | /// Function which takes the friction values from a wheel and a supporting material and computes the blended friction. 6 | /// 7 | /// Friction coefficient associated with the wheel. 8 | /// Friction coefficient associated with the support material. 9 | /// True if the friction coefficients passed into the blender are kinetic coefficients, false otherwise. 10 | /// Wheel being blended. 11 | /// Blended friction coefficient. 12 | public delegate float WheelFrictionBlender(float wheelFriction, float materialFriction, bool usingKineticFriction, Wheel wheel); 13 | 14 | 15 | } -------------------------------------------------------------------------------- /MyEngine/bepuphysics/constraints/ISolverSettings.cs: -------------------------------------------------------------------------------- 1 | namespace BEPUphysics.Constraints 2 | { 3 | /// 4 | /// Implemented by classes which have solver settings. 5 | /// 6 | public interface ISolverSettings 7 | { 8 | /// 9 | /// Gets the solver settings for this constraint. 10 | /// 11 | SolverSettings SolverSettings { get; } 12 | } 13 | } -------------------------------------------------------------------------------- /MyEngine/bepuphysics/constraints/ISpringConstraint.cs: -------------------------------------------------------------------------------- 1 | namespace BEPUphysics.Constraints 2 | { 3 | /// 4 | /// Implemented by constraints that support springlike behavior. 5 | /// 6 | public interface ISpringSettings 7 | { 8 | /// 9 | /// Gets the spring settings used by the constraint. 10 | /// 11 | SpringSettings SpringSettings { get; } 12 | } 13 | } -------------------------------------------------------------------------------- /MyEngine/bepuphysics/constraints/SingleEntity/SingleEntityConstraint.cs: -------------------------------------------------------------------------------- 1 | using BEPUphysics.Entities; 2 | using BEPUutilities.DataStructures; 3 | 4 | namespace BEPUphysics.Constraints.SingleEntity 5 | { 6 | /// 7 | /// Abstract superclass of constraints which control a single entity. 8 | /// 9 | public abstract class SingleEntityConstraint : SolverUpdateable 10 | { 11 | /// 12 | /// Number of frames so far at effectively zero corrective impulse. 13 | /// Set to zero during every preStep(float dt) call and incremented by checkForEarlyOutIterations(Vector3 impulse). 14 | /// 15 | protected int iterationsAtZeroImpulse; 16 | 17 | /// 18 | /// Entity affected by the constraint. 19 | /// 20 | protected internal Entity entity; 21 | 22 | /// 23 | /// Gets or sets the entity affected by the constraint. 24 | /// 25 | public virtual Entity Entity 26 | { 27 | get { return entity; } 28 | set 29 | { 30 | //TODO: Should this clear accumulated impulses? 31 | //For constraints too... 32 | entity = value; 33 | OnInvolvedEntitiesChanged(); 34 | } 35 | } 36 | 37 | 38 | /// 39 | /// Adds entities associated with the solver item to the involved entities list. 40 | /// Ensure that sortInvolvedEntities() is called at the end of the function. 41 | /// This allows the non-batched multithreading system to lock properly. 42 | /// 43 | protected internal override void CollectInvolvedEntities(RawList outputInvolvedEntities) 44 | { 45 | if (entity != null) //sometimes, the entity is set to null to 'deactivate' it. Don't add null to the involved entities list. 46 | outputInvolvedEntities.Add(entity); 47 | } 48 | 49 | } 50 | } -------------------------------------------------------------------------------- /MyEngine/bepuphysics/constraints/SolverGroups/CustomizableSolverGroup.cs: -------------------------------------------------------------------------------- 1 | namespace BEPUphysics.Constraints.SolverGroups 2 | { 3 | /// 4 | /// Constraint made from other constraints. 5 | /// Putting constraints into a solver group can help with organization and, in some cases, performance. 6 | /// 7 | /// If you have multiple constraints between the same two entities, putting the constraints into a 8 | /// CustomizableSolverGroup can lower lock contention. 9 | /// 10 | /// Be careful about overloading a single solvergroup; it should be kept relatively small to ensure that the multithreading loads stay balanced. 11 | /// 12 | public class CustomizableSolverGroup : SolverGroup 13 | { 14 | /// 15 | /// Adds a new solver updateable to the solver group. 16 | /// 17 | /// Solver updateable to add. 18 | public new void Add(SolverUpdateable solverUpdateable) 19 | { 20 | base.Add(solverUpdateable); 21 | } 22 | 23 | /// 24 | /// Removes a solver updateable from the solver group. 25 | /// 26 | /// Solver updateable to remove. 27 | public new void Remove(SolverUpdateable solverUpdateable) 28 | { 29 | base.Remove(solverUpdateable); 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /MyEngine/bepuphysics/constraints/SolverUpdateableChange.cs: -------------------------------------------------------------------------------- 1 | namespace BEPUphysics.Constraints 2 | { 3 | /// 4 | /// Stores an enqueued solver updateable addition or removal. 5 | /// 6 | public struct SolverUpdateableChange 7 | { 8 | 9 | /// 10 | /// Whether the item is going to be added or removed. 11 | /// 12 | public bool ShouldAdd; 13 | /// 14 | /// Item being added or removed. 15 | /// 16 | public SolverUpdateable Item; 17 | 18 | /// 19 | /// Constructs a new solver updateable change. 20 | /// 21 | ///Whether the item is going to be added or removed. 22 | ///Item to add or remove. 23 | public SolverUpdateableChange(bool shouldAdd, SolverUpdateable item) 24 | { 25 | ShouldAdd = shouldAdd; 26 | Item = item; 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /MyEngine/bepuphysics/constraints/TwoEntity/Joints/Joint.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace BEPUphysics.Constraints.TwoEntity.Joints 4 | { 5 | /// 6 | /// Superclass of position-based constraints. 7 | /// 8 | public abstract class Joint : TwoEntityConstraint, ISpringSettings 9 | { 10 | /// 11 | /// Maximum extra velocity that the constraint will apply in an effort to correct constraint error. 12 | /// 13 | protected float maxCorrectiveVelocity = float.MaxValue; 14 | 15 | /// 16 | /// Squared maximum extra velocity that the constraint will apply in an effort to correct constraint error. 17 | /// 18 | protected float maxCorrectiveVelocitySquared = float.MaxValue; 19 | 20 | protected float softness; 21 | 22 | /// 23 | /// Spring settings define how a constraint responds to velocity and position error. 24 | /// 25 | protected SpringSettings springSettings = new SpringSettings(); 26 | 27 | /// 28 | /// Gets or sets the maximum extra velocity that the constraint will apply in an effort to correct any constraint error. 29 | /// 30 | public float MaxCorrectiveVelocity 31 | { 32 | get { return maxCorrectiveVelocity; } 33 | set 34 | { 35 | maxCorrectiveVelocity = Math.Max(0, value); 36 | if (maxCorrectiveVelocity >= float.MaxValue) 37 | { 38 | maxCorrectiveVelocitySquared = float.MaxValue; 39 | } 40 | else 41 | { 42 | maxCorrectiveVelocitySquared = maxCorrectiveVelocity * maxCorrectiveVelocity; 43 | } 44 | } 45 | } 46 | 47 | #region ISpringSettings Members 48 | 49 | /// 50 | /// Gets the spring settings used by the constraint. 51 | /// Spring settings define how a constraint responds to velocity and position error. 52 | /// 53 | public SpringSettings SpringSettings 54 | { 55 | get { return springSettings; } 56 | } 57 | 58 | #endregion 59 | } 60 | } -------------------------------------------------------------------------------- /MyEngine/bepuphysics/constraints/TwoEntity/Motors/Motor.cs: -------------------------------------------------------------------------------- 1 | namespace BEPUphysics.Constraints.TwoEntity.Motors 2 | { 3 | /// 4 | /// Superclass of constraints which do work and change the velocity of connected entities, but have no specific position target. 5 | /// 6 | public abstract class Motor : TwoEntityConstraint 7 | { 8 | protected float maxForceDt = float.MaxValue; 9 | protected float maxForceDtSquared = float.MaxValue; 10 | 11 | /// 12 | /// Softness divided by the timestep to maintain timestep independence. 13 | /// 14 | internal float usedSoftness; 15 | 16 | /// 17 | /// Computes the maxForceDt and maxForceDtSquared fields. 18 | /// 19 | protected void ComputeMaxForces(float maxForce, float dt) 20 | { 21 | //Determine maximum force 22 | if (maxForce < float.MaxValue) 23 | { 24 | maxForceDt = maxForce * dt; 25 | maxForceDtSquared = maxForceDt * maxForceDt; 26 | } 27 | else 28 | { 29 | maxForceDt = float.MaxValue; 30 | maxForceDtSquared = float.MaxValue; 31 | } 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /MyEngine/bepuphysics/narrowphasesystems/Pairs/CompoundGroupPairHandler.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using BEPUphysics.BroadPhaseEntries; 3 | using BEPUphysics.BroadPhaseEntries.MobileCollidables; 4 | 5 | namespace BEPUphysics.NarrowPhaseSystems.Pairs 6 | { 7 | /// 8 | /// Handles a compound and group collision pair. 9 | /// 10 | public abstract class CompoundGroupPairHandler : GroupPairHandler 11 | { 12 | protected CompoundCollidable compoundInfo; 13 | 14 | public override Collidable CollidableA 15 | { 16 | get { return compoundInfo; } 17 | } 18 | public override Entities.Entity EntityA 19 | { 20 | get { return compoundInfo.entity; } 21 | } 22 | 23 | 24 | 25 | /// 26 | /// Initializes the pair handler. 27 | /// 28 | ///First entry in the pair. 29 | ///Second entry in the pair. 30 | public override void Initialize(BroadPhaseEntry entryA, BroadPhaseEntry entryB) 31 | { 32 | //Other member of the pair is initialized by the child. 33 | compoundInfo = entryA as CompoundCollidable; 34 | if (compoundInfo == null) 35 | { 36 | compoundInfo = entryB as CompoundCollidable; 37 | if (compoundInfo == null) 38 | { 39 | throw new ArgumentException("Inappropriate types used to initialize pair."); 40 | } 41 | } 42 | 43 | base.Initialize(entryA, entryB); 44 | } 45 | 46 | /// 47 | /// Cleans up the pair handler. 48 | /// 49 | public override void CleanUp() 50 | { 51 | base.CleanUp(); 52 | 53 | compoundInfo = null; 54 | //Child type needs to null out other reference. 55 | } 56 | 57 | 58 | 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /MyEngine/bepuphysics/narrowphasesystems/Pairs/ContactInformation.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using BEPUphysics.CollisionTests; 3 | using BEPUutilities; 4 | 5 | 6 | namespace BEPUphysics.NarrowPhaseSystems.Pairs 7 | { 8 | /// 9 | /// Contact and some associated data used by the convenience ContactCollection. 10 | /// 11 | public struct ContactInformation : IEquatable 12 | { 13 | /// 14 | /// Contact point in the pair. 15 | /// 16 | public Contact Contact; 17 | 18 | /// 19 | /// Pair that most directly generated the contact. 20 | /// The pair may have parents, accessible through the pair's Parent property. 21 | /// 22 | public CollidablePairHandler Pair; 23 | 24 | /// 25 | /// Normal impulse applied between the objects at the contact point. 26 | /// 27 | public float NormalImpulse; 28 | 29 | /// 30 | /// Friction impulse applied between the objects at the contact point. 31 | /// This is sometimes an approximation due to the varying ways in which 32 | /// friction is calculated. 33 | /// 34 | public float FrictionImpulse; 35 | 36 | /// 37 | /// Relative velocity of the colliding objects at the position of the contact. 38 | /// 39 | public Vector3 RelativeVelocity; 40 | 41 | 42 | public override string ToString() 43 | { 44 | return Contact + " NormalImpulse: " + NormalImpulse + " FrictionImpulse: " + FrictionImpulse + " RelativeVelocity: " + RelativeVelocity; 45 | } 46 | 47 | 48 | public bool Equals(ContactInformation other) 49 | { 50 | return other.Contact == Contact; 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /MyEngine/bepuphysics/narrowphasesystems/Pairs/IDetectorVolumePairHandlerParent.cs: -------------------------------------------------------------------------------- 1 | namespace BEPUphysics.NarrowPhaseSystems.Pairs 2 | { 3 | /// 4 | /// Implemented by detector volume pair handlers with children. 5 | /// 6 | public interface IDetectorVolumePairHandlerParent 7 | { 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /MyEngine/bepuphysics/narrowphasesystems/Pairs/IPairHandlerParent.cs: -------------------------------------------------------------------------------- 1 | using BEPUphysics.Constraints; 2 | using BEPUphysics.CollisionTests; 3 | 4 | namespace BEPUphysics.NarrowPhaseSystems.Pairs 5 | { 6 | /// 7 | /// Defines a pair handler which can have children. 8 | /// 9 | public interface IPairHandlerParent 10 | { 11 | /// 12 | /// Called when a child adds a contact. 13 | /// 14 | ///Contact added. 15 | void OnContactAdded(Contact contact); 16 | 17 | /// 18 | /// Called when a child removes a contact. 19 | /// 20 | /// Contact removed. 21 | void OnContactRemoved(Contact contact); 22 | 23 | /// 24 | /// Called when a child attempts to add a solver updateable to the solver. 25 | /// 26 | ///Item to add. 27 | void AddSolverUpdateable(SolverUpdateable addedItem); 28 | 29 | 30 | /// 31 | /// Called when a child attempts to remove a solver updateable from the solver. 32 | /// 33 | ///Item to remove. 34 | void RemoveSolverUpdateable(SolverUpdateable removedItem); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /MyEngine/bepuphysics/narrowphasesystems/Pairs/InstancedMeshConvexPairHandler.cs: -------------------------------------------------------------------------------- 1 | using BEPUphysics.CollisionTests.Manifolds; 2 | 3 | namespace BEPUphysics.NarrowPhaseSystems.Pairs 4 | { 5 | /// 6 | /// Handles a instanced mesh-convex collision pair. 7 | /// 8 | public class InstancedMeshConvexPairHandler : InstancedMeshPairHandler 9 | { 10 | 11 | InstancedMeshConvexContactManifold contactManifold = new InstancedMeshConvexContactManifold(); 12 | protected override InstancedMeshContactManifold MeshManifold 13 | { 14 | get { return contactManifold; } 15 | } 16 | 17 | 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /MyEngine/bepuphysics/narrowphasesystems/Pairs/InstancedMeshSpherePairHandler.cs: -------------------------------------------------------------------------------- 1 | using BEPUphysics.CollisionTests.Manifolds; 2 | 3 | namespace BEPUphysics.NarrowPhaseSystems.Pairs 4 | { 5 | /// 6 | /// Handles a instanced mesh-convex collision pair. 7 | /// 8 | public class InstancedMeshSpherePairHandler : InstancedMeshPairHandler 9 | { 10 | InstancedMeshSphereContactManifold contactManifold = new InstancedMeshSphereContactManifold(); 11 | protected override InstancedMeshContactManifold MeshManifold 12 | { 13 | get { return contactManifold; } 14 | } 15 | 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /MyEngine/bepuphysics/narrowphasesystems/Pairs/MobileMeshConvexPairHandler.cs: -------------------------------------------------------------------------------- 1 | using BEPUphysics.CollisionTests.Manifolds; 2 | 3 | namespace BEPUphysics.NarrowPhaseSystems.Pairs 4 | { 5 | /// 6 | /// Handles a mobile mesh-convex collision pair. 7 | /// 8 | public class MobileMeshConvexPairHandler : MobileMeshPairHandler 9 | { 10 | MobileMeshConvexContactManifold contactManifold = new MobileMeshConvexContactManifold(); 11 | protected internal override MobileMeshContactManifold MeshManifold 12 | { 13 | get { return contactManifold; } 14 | } 15 | 16 | 17 | 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /MyEngine/bepuphysics/narrowphasesystems/Pairs/MobileMeshMeshPairHandler.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using BEPUphysics.BroadPhaseEntries; 3 | using BEPUphysics.BroadPhaseEntries.MobileCollidables; 4 | 5 | namespace BEPUphysics.NarrowPhaseSystems.Pairs 6 | { 7 | /// 8 | /// Handles a mobile mesh and mesh collision pair. 9 | /// 10 | public abstract class MobileMeshMeshPairHandler : MeshGroupPairHandler 11 | { 12 | public MobileMeshCollidable mobileMesh; 13 | 14 | public override Collidable CollidableA 15 | { 16 | get { return mobileMesh; } 17 | } 18 | public override Entities.Entity EntityA 19 | { 20 | get { return mobileMesh.entity; } 21 | } 22 | protected override Materials.Material MaterialA 23 | { 24 | get { return mobileMesh.entity.material; } 25 | } 26 | 27 | 28 | /// 29 | /// Initializes the pair handler. 30 | /// 31 | ///First entry in the pair. 32 | ///Second entry in the pair. 33 | public override void Initialize(BroadPhaseEntry entryA, BroadPhaseEntry entryB) 34 | { 35 | //Other member of the pair is initialized by the child. 36 | mobileMesh = entryA as MobileMeshCollidable; 37 | if (mobileMesh == null) 38 | { 39 | mobileMesh = entryB as MobileMeshCollidable; 40 | if (mobileMesh == null) 41 | { 42 | throw new ArgumentException("Inappropriate types used to initialize pair."); 43 | } 44 | } 45 | 46 | base.Initialize(entryA, entryB); 47 | } 48 | 49 | /// 50 | /// Cleans up the pair handler. 51 | /// 52 | public override void CleanUp() 53 | { 54 | base.CleanUp(); 55 | 56 | mobileMesh = null; 57 | //Child type needs to null out other reference. 58 | } 59 | 60 | 61 | 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /MyEngine/bepuphysics/narrowphasesystems/Pairs/MobileMeshSpherePairHandler.cs: -------------------------------------------------------------------------------- 1 | using BEPUphysics.CollisionTests.Manifolds; 2 | 3 | namespace BEPUphysics.NarrowPhaseSystems.Pairs 4 | { 5 | /// 6 | /// Handles a mobile mesh-sphere collision pair. 7 | /// 8 | public class MobileMeshSpherePairHandler : MobileMeshPairHandler 9 | { 10 | MobileMeshSphereContactManifold contactManifold = new MobileMeshSphereContactManifold(); 11 | protected internal override MobileMeshContactManifold MeshManifold 12 | { 13 | get { return contactManifold; } 14 | } 15 | 16 | 17 | 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /MyEngine/bepuphysics/narrowphasesystems/Pairs/MobileMeshTrianglePairHandler.cs: -------------------------------------------------------------------------------- 1 | using BEPUphysics.CollisionTests.Manifolds; 2 | 3 | namespace BEPUphysics.NarrowPhaseSystems.Pairs 4 | { 5 | /// 6 | /// Handles a mobile mesh-convex collision pair. 7 | /// 8 | public class MobileMeshTrianglePairHandler : MobileMeshPairHandler 9 | { 10 | MobileMeshTriangleContactManifold contactManifold = new MobileMeshTriangleContactManifold(); 11 | protected internal override MobileMeshContactManifold MeshManifold 12 | { 13 | get { return contactManifold; } 14 | } 15 | 16 | 17 | 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /MyEngine/bepuphysics/narrowphasesystems/Pairs/StaticGroupPairHandler.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using BEPUphysics.BroadPhaseEntries; 3 | 4 | namespace BEPUphysics.NarrowPhaseSystems.Pairs 5 | { 6 | /// 7 | /// Handles a compound and group collision pair. 8 | /// 9 | public abstract class StaticGroupPairHandler : GroupPairHandler 10 | { 11 | protected StaticGroup staticGroup; 12 | 13 | public override Collidable CollidableA 14 | { 15 | get { return staticGroup; } 16 | } 17 | public override Entities.Entity EntityA 18 | { 19 | get { return null; } 20 | } 21 | 22 | 23 | 24 | /// 25 | /// Initializes the pair handler. 26 | /// 27 | ///First entry in the pair. 28 | ///Second entry in the pair. 29 | public override void Initialize(BroadPhaseEntry entryA, BroadPhaseEntry entryB) 30 | { 31 | //Other member of the pair is initialized by the child. 32 | staticGroup = entryA as StaticGroup; 33 | if (staticGroup == null) 34 | { 35 | staticGroup = entryB as StaticGroup; 36 | if (staticGroup == null) 37 | { 38 | throw new ArgumentException("Inappropriate types used to initialize pair."); 39 | } 40 | } 41 | 42 | base.Initialize(entryA, entryB); 43 | } 44 | 45 | /// 46 | /// Cleans up the pair handler. 47 | /// 48 | public override void CleanUp() 49 | { 50 | base.CleanUp(); 51 | 52 | staticGroup = null; 53 | //Child type needs to null out other reference. 54 | } 55 | 56 | 57 | 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /MyEngine/bepuphysics/narrowphasesystems/Pairs/StaticMeshConvexPairHandler.cs: -------------------------------------------------------------------------------- 1 | using BEPUphysics.CollisionTests.Manifolds; 2 | 3 | namespace BEPUphysics.NarrowPhaseSystems.Pairs 4 | { 5 | /// 6 | /// Handles a static mesh-convex collision pair. 7 | /// 8 | public class StaticMeshConvexPairHandler : StaticMeshPairHandler 9 | { 10 | 11 | StaticMeshConvexContactManifold contactManifold = new StaticMeshConvexContactManifold(); 12 | protected override StaticMeshContactManifold MeshManifold 13 | { 14 | get { return contactManifold; } 15 | } 16 | 17 | 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /MyEngine/bepuphysics/narrowphasesystems/Pairs/StaticMeshSpherePairHandler.cs: -------------------------------------------------------------------------------- 1 | using BEPUphysics.CollisionTests.Manifolds; 2 | 3 | namespace BEPUphysics.NarrowPhaseSystems.Pairs 4 | { 5 | /// 6 | /// Handles a static mesh-sphere collision pair. 7 | /// 8 | public class StaticMeshSpherePairHandler : StaticMeshPairHandler 9 | { 10 | 11 | StaticMeshSphereContactManifold contactManifold = new StaticMeshSphereContactManifold(); 12 | protected override StaticMeshContactManifold MeshManifold 13 | { 14 | get { return contactManifold; } 15 | } 16 | 17 | 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /MyEngine/bepuphysics/narrowphasesystems/Pairs/TerrainConvexPairHandler.cs: -------------------------------------------------------------------------------- 1 | using BEPUphysics.CollisionTests.Manifolds; 2 | 3 | namespace BEPUphysics.NarrowPhaseSystems.Pairs 4 | { 5 | /// 6 | /// Handles a terrain-convex collision pair. 7 | /// 8 | public sealed class TerrainConvexPairHandler : TerrainPairHandler 9 | { 10 | private TerrainConvexContactManifold contactManifold = new TerrainConvexContactManifold(); 11 | protected override TerrainContactManifold TerrainManifold 12 | { 13 | get { return contactManifold; } 14 | } 15 | 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /MyEngine/bepuphysics/narrowphasesystems/Pairs/TerrainSpherePairHandler.cs: -------------------------------------------------------------------------------- 1 | using BEPUphysics.CollisionTests.Manifolds; 2 | 3 | namespace BEPUphysics.NarrowPhaseSystems.Pairs 4 | { 5 | /// 6 | /// Handles a terrain-sphere collision pair. 7 | /// 8 | public sealed class TerrainSpherePairHandler : TerrainPairHandler 9 | { 10 | private TerrainSphereContactManifold contactManifold = new TerrainSphereContactManifold(); 11 | protected override TerrainContactManifold TerrainManifold 12 | { 13 | get { return contactManifold; } 14 | } 15 | 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /MyEngine/bepuphysics/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /MyEngine/bepuphysics/strongNameKey.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JakubNei/lego-game-and-Unity-like-engine/949b0c60fa674272b1905bdb47d8a37d8fde9fc1/MyEngine/bepuphysics/strongNameKey.snk -------------------------------------------------------------------------------- /MyEngine/cudaparticlesimulation/CudaParticleSimulation.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.21005.1 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CudaKernel", "CudaKernel\CudaKernel.vcxproj", "{BB3C1CCF-4AF1-4E28-A3BA-A9C58F287CB7}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Debug|Mixed Platforms = Debug|Mixed Platforms 12 | Debug|Win32 = Debug|Win32 13 | Debug|x64 = Debug|x64 14 | Release|Any CPU = Release|Any CPU 15 | Release|Mixed Platforms = Release|Mixed Platforms 16 | Release|Win32 = Release|Win32 17 | Release|x64 = Release|x64 18 | EndGlobalSection 19 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 20 | {BB3C1CCF-4AF1-4E28-A3BA-A9C58F287CB7}.Debug|Any CPU.ActiveCfg = Debug|Win32 21 | {BB3C1CCF-4AF1-4E28-A3BA-A9C58F287CB7}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 22 | {BB3C1CCF-4AF1-4E28-A3BA-A9C58F287CB7}.Debug|Mixed Platforms.Build.0 = Debug|Win32 23 | {BB3C1CCF-4AF1-4E28-A3BA-A9C58F287CB7}.Debug|Win32.ActiveCfg = Debug|Win32 24 | {BB3C1CCF-4AF1-4E28-A3BA-A9C58F287CB7}.Debug|Win32.Build.0 = Debug|Win32 25 | {BB3C1CCF-4AF1-4E28-A3BA-A9C58F287CB7}.Debug|x64.ActiveCfg = Debug|x64 26 | {BB3C1CCF-4AF1-4E28-A3BA-A9C58F287CB7}.Debug|x64.Build.0 = Debug|x64 27 | {BB3C1CCF-4AF1-4E28-A3BA-A9C58F287CB7}.Release|Any CPU.ActiveCfg = Release|Win32 28 | {BB3C1CCF-4AF1-4E28-A3BA-A9C58F287CB7}.Release|Mixed Platforms.ActiveCfg = Release|Win32 29 | {BB3C1CCF-4AF1-4E28-A3BA-A9C58F287CB7}.Release|Mixed Platforms.Build.0 = Release|Win32 30 | {BB3C1CCF-4AF1-4E28-A3BA-A9C58F287CB7}.Release|Win32.ActiveCfg = Release|Win32 31 | {BB3C1CCF-4AF1-4E28-A3BA-A9C58F287CB7}.Release|Win32.Build.0 = Release|Win32 32 | {BB3C1CCF-4AF1-4E28-A3BA-A9C58F287CB7}.Release|x64.ActiveCfg = Release|x64 33 | {BB3C1CCF-4AF1-4E28-A3BA-A9C58F287CB7}.Release|x64.Build.0 = Release|x64 34 | EndGlobalSection 35 | GlobalSection(SolutionProperties) = preSolution 36 | HideSolutionNode = FALSE 37 | EndGlobalSection 38 | EndGlobal 39 | -------------------------------------------------------------------------------- /MyEngine/cudaparticlesimulation/CudaParticleSimulation.v12.suo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JakubNei/lego-game-and-Unity-like-engine/949b0c60fa674272b1905bdb47d8a37d8fde9fc1/MyEngine/cudaparticlesimulation/CudaParticleSimulation.v12.suo -------------------------------------------------------------------------------- /MyEngine/cudaparticlesimulation/from this project we use only compiled CUDA PTX.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JakubNei/lego-game-and-Unity-like-engine/949b0c60fa674272b1905bdb47d8a37d8fde9fc1/MyEngine/cudaparticlesimulation/from this project we use only compiled CUDA PTX.txt -------------------------------------------------------------------------------- /MyEngine/myengine/Debug.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Diagnostics; 4 | using System.Text; 5 | 6 | namespace MyEngine 7 | { 8 | public static class Debug 9 | { 10 | static List alreadyShown = new List(); 11 | 12 | 13 | static void Log(object obj, bool canRepeat) 14 | { 15 | var s = obj.ToString(); 16 | if (canRepeat || !alreadyShown.Contains(s)) 17 | { 18 | var t=new StackTrace(2); 19 | var f = t.GetFrame(0); 20 | var m = f.GetMethod(); 21 | 22 | if(!canRepeat) alreadyShown.Add(s); 23 | Console.WriteLine("["+m.DeclaringType.Name+"."+m.Name+"] "+s); 24 | } 25 | } 26 | 27 | public static void Info(object obj, bool canRepeat = true, bool pause = false) 28 | { 29 | Console.ForegroundColor = ConsoleColor.Gray; 30 | Console.BackgroundColor = ConsoleColor.Black; 31 | Log(obj, canRepeat); 32 | if (pause) Pause(); 33 | } 34 | 35 | 36 | public static void Warning(object obj, bool canRepeat = true, bool pause = false) 37 | { 38 | Console.ForegroundColor = ConsoleColor.Yellow; 39 | Console.BackgroundColor = ConsoleColor.Black; 40 | Log(obj, canRepeat); 41 | if (pause) Pause(); 42 | } 43 | public static void Error(object obj, bool canRepeat = true, bool pause = false) 44 | { 45 | Console.ForegroundColor = ConsoleColor.Red; 46 | Console.BackgroundColor = ConsoleColor.Black; 47 | Log(obj, canRepeat); 48 | if (pause) Pause(); 49 | } 50 | public static void Pause() 51 | { 52 | Console.ForegroundColor = ConsoleColor.Gray; 53 | Console.BackgroundColor = ConsoleColor.Black; 54 | Console.WriteLine("Press any key to continue ..."); 55 | Console.ReadKey(); 56 | } 57 | 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /MyEngine/myengine/ExtensionMethods.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | using OpenTK; 7 | 8 | namespace MyEngine 9 | { 10 | public static class ExtensionMethods 11 | { 12 | public static Vector3 RotateBy(this Vector3 vector, Quaternion rotation) 13 | { 14 | Matrix4 rot = Matrix4.CreateFromQuaternion(rotation); 15 | Vector3 newDirection; 16 | Vector3.TransformVector(ref vector, ref rot, out newDirection); 17 | return newDirection; 18 | } 19 | 20 | public static Vector3 CompomentWiseMult(this Vector3 a, Vector3 b) 21 | { 22 | return new Vector3(a.X * b.X, a.Y * b.Y, a.Z * b.Z); 23 | } 24 | public static float Distance(this Vector3 a, Vector3 b) 25 | { 26 | return (a - b).Length; 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /MyEngine/myengine/IUnloadable.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace MyEngine 6 | { 7 | public interface IUnloadable 8 | { 9 | void Unload(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /MyEngine/myengine/ParticleSimulation/ParticleMeshRenderer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace MyEngine.ParticleSimulation 8 | { 9 | public class ParticleMeshRenderer : Renderer 10 | { 11 | 12 | override internal bool shouldRenderGeometry { get { return base.shouldRenderGeometry && material.gBufferShader != null; } } 13 | override internal bool castsShadows { get { return base.castsShadows && material.depthGrabShader != null; } } 14 | 15 | MaterialPBR _material; 16 | public new MaterialPBR material 17 | { 18 | set 19 | { 20 | base.material = value; 21 | _material = value; 22 | } 23 | 24 | get 25 | { 26 | return _material; 27 | } 28 | } 29 | 30 | internal ParticleMesh particleMesh; 31 | 32 | public ParticleMeshRenderer() 33 | { 34 | material = new MaterialPBR() 35 | { 36 | gBufferShader = Factory.GetShader("internal/deferred.gBuffer.particle.shader"), 37 | depthGrabShader = null, 38 | }; 39 | } 40 | 41 | override internal void UploadUBOandDraw(Camera camera, UniformBlock ubo) 42 | { 43 | var modelMat = this.gameObject.transform.localToWorldMatrix; 44 | var modelViewMat = modelMat * camera.GetViewMat(); 45 | ubo.model.modelMatrix = modelMat; 46 | ubo.model.modelViewMatrix = modelViewMat; 47 | ubo.model.modelViewProjectionMatrix = modelViewMat * camera.GetProjectionMat(); 48 | ubo.modelUBO.UploadData(); 49 | particleMesh.Draw(); 50 | } 51 | 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /MyEngine/myengine/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("MyEngine")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("MyEngine")] 13 | [assembly: AssemblyCopyright("Copyright © 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("f4ac0b2b-98f7-4045-a6de-1882ecb065f7")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /MyEngine/myengine/QuaternionUtility.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | using OpenTK; 8 | 9 | namespace MyEngine 10 | { 11 | public static class QuaternionUtility 12 | { 13 | public static Quaternion LookRotation(Vector3 direction) 14 | { 15 | var up = Vector3.UnitY; 16 | if (up == direction) up = Vector3.UnitX; 17 | Matrix4 rot = Matrix4.LookAt(Vector3.Zero, direction, up); 18 | return rot.ExtractRotation(); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /MyEngine/myengine/ResourceFolder.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using System.IO; 4 | using System.Collections.Generic; 5 | using System.Text; 6 | 7 | namespace MyEngine 8 | { 9 | public class ResourceFolder 10 | { 11 | public string originalPath; 12 | public string realPath; 13 | 14 | private ResourceFolder() 15 | { 16 | 17 | } 18 | 19 | public static implicit operator string(ResourceFolder r) 20 | { 21 | return r.realPath; 22 | } 23 | public static implicit operator ResourceFolder(string originalPath) 24 | { 25 | return MakeResource(originalPath); 26 | } 27 | 28 | static string defaultResourcesFolder; 29 | public static string GetDefaultResourcesFolder() 30 | { 31 | if (defaultResourcesFolder != null) 32 | return defaultResourcesFolder; 33 | 34 | Debug.Info("root path: " + Path.GetFullPath(".")); 35 | 36 | defaultResourcesFolder = "resources/"; 37 | for (int i = 0; i < 10; i++) 38 | { 39 | if (Directory.Exists("./" + defaultResourcesFolder)) 40 | { 41 | defaultResourcesFolder = "./" + defaultResourcesFolder; 42 | return defaultResourcesFolder; 43 | } 44 | 45 | defaultResourcesFolder = "../" + defaultResourcesFolder; 46 | } 47 | 48 | return defaultResourcesFolder; 49 | } 50 | 51 | private static string MakeRealPath(string originalPath) 52 | { 53 | return GetDefaultResourcesFolder() + originalPath; 54 | } 55 | 56 | private static ResourceFolder MakeResource(string originalPath) 57 | { 58 | var realPath = MakeRealPath(originalPath); 59 | if (Directory.Exists(realPath)) 60 | { 61 | return new ResourceFolder() { originalPath = originalPath, realPath = realPath }; 62 | } 63 | else 64 | { 65 | Debug.Error("Directory " + originalPath + " doesnt exits"); 66 | Debug.Pause(); 67 | return null; 68 | } 69 | } 70 | 71 | } 72 | } -------------------------------------------------------------------------------- /MyEngine/myengine/UnityEngine based/Collision.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | using OpenTK; 7 | 8 | namespace MyEngine 9 | { 10 | // http://docs.unity3d.com/ScriptReference/Collision.html 11 | public class Collision 12 | { 13 | 14 | 15 | public class ContactPoint { 16 | public Vector3 normal; 17 | public Collider otherCollider; 18 | public Vector3 point; 19 | public Collider thisCollider; 20 | 21 | } 22 | public ContactPoint[] contacts; 23 | public GameObject gameObject; 24 | 25 | public Vector3 relativeVelocity; 26 | 27 | 28 | public Collider collider { get { return gameObject.GetComponent(); } } 29 | public Rigidbody rigidbody { get { return gameObject.GetComponent(); } } 30 | public Transform transform { get { return gameObject.transform; } } 31 | 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /MyEngine/myengine/UnityEngine based/Component.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using System.Diagnostics; 5 | using OpenTK; 6 | using OpenTK.Graphics; 7 | using OpenTK.Graphics.OpenGL; 8 | 9 | namespace MyEngine 10 | { 11 | public class Component 12 | { 13 | 14 | 15 | 16 | public Transform transform 17 | { 18 | get 19 | { 20 | return gameObject.transform; 21 | } 22 | } 23 | public GameObject gameObject 24 | { 25 | get; 26 | internal set; 27 | } 28 | public T GetComponent() where T : Component 29 | { 30 | return gameObject.GetComponent(); 31 | } 32 | 33 | public T[] GetComponents() where T : Component 34 | { 35 | return gameObject.GetComponents(); 36 | } 37 | internal Component() 38 | { 39 | } 40 | internal virtual void OnCreated() 41 | { 42 | } 43 | internal virtual void OnDestroyed() { 44 | 45 | } 46 | 47 | 48 | 49 | public static implicit operator bool (Component c) 50 | { 51 | return c != null; 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /MyEngine/myengine/UnityEngine based/FixedJoint.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace MyEngine 7 | { 8 | public class FixedJoint : Joint 9 | { 10 | Rigidbody m_connectedTo; 11 | public Rigidbody connectedTo 12 | { 13 | set 14 | { 15 | if (physicsJoint!=null) 16 | { 17 | PhysicsUsage.PhysicsManager.instance.Remove(physicsJoint); 18 | physicsJoint = null; 19 | } 20 | 21 | m_connectedTo = value; 22 | 23 | if (value) 24 | { 25 | 26 | var a = this.GetComponent(); 27 | if (!a) return; 28 | 29 | var b = connectedTo.GetComponent(); 30 | if (!b) return; 31 | 32 | physicsJoint = new BEPUphysics.Constraints.SolverGroups.WeldJoint(a.collisionEntity_generic, b.collisionEntity_generic); 33 | physicsJoint.BallSocketJoint.SpringSettings.Stiffness = 10000000; 34 | physicsJoint.NoRotationJoint.SpringSettings.Stiffness = physicsJoint.BallSocketJoint.SpringSettings.Stiffness; 35 | 36 | PhysicsUsage.PhysicsManager.instance.Add(physicsJoint); 37 | } 38 | } 39 | get 40 | { 41 | return m_connectedTo; 42 | } 43 | } 44 | 45 | BEPUphysics.Constraints.SolverGroups.WeldJoint physicsJoint; 46 | 47 | 48 | internal override void OnDestroyed() 49 | { 50 | connectedTo = null; 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /MyEngine/myengine/UnityEngine based/GameObject.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using System.Diagnostics; 5 | using OpenTK; 6 | using OpenTK.Graphics; 7 | using OpenTK.Graphics.OpenGL; 8 | 9 | namespace MyEngine 10 | { 11 | public class GameObject : Component 12 | { 13 | 14 | public Transform transform { get; private set; } 15 | 16 | public GameObject(string name = "") 17 | { 18 | Factory.allGameObjects.Add(this); 19 | transform = this.AddComponent(); 20 | } 21 | 22 | public List components = new List(); 23 | public T GetComponent() where T : Component 24 | { 25 | foreach (var c in components) 26 | { 27 | if (c is T) 28 | { 29 | return c as T; 30 | } 31 | } 32 | return null; 33 | } 34 | 35 | public T[] GetComponents() where T : Component 36 | { 37 | List ret = new List(); 38 | foreach (var c in components) 39 | { 40 | if (c is T) 41 | { 42 | ret.Add(c as T); 43 | } 44 | } 45 | return ret.ToArray(); 46 | } 47 | 48 | public T AddComponent() where T : Component, new() 49 | { 50 | T c = new T(); 51 | c.gameObject = this; 52 | c.OnCreated(); 53 | components.Add(c); 54 | return c; 55 | } 56 | 57 | public void DestroyComponent(T component) where T : Component { 58 | if (component) component.OnDestroyed(); 59 | } 60 | 61 | 62 | public Action OnChanged; 63 | 64 | internal void RaiseOnChanged(ChangedFlags flags) 65 | { 66 | if (OnChanged != null) OnChanged(flags); 67 | } 68 | } 69 | 70 | public enum ChangedFlags 71 | { 72 | Position = 1<<0, 73 | Roltation = 1 << 1, 74 | Scale = 1 << 2, 75 | Bounds = 1 << 3, 76 | VisualRepresentation = 1 << 4, 77 | PhysicsSettings = 1 << 5, 78 | PhysicalShape = 1 << 6, 79 | All = 0xffff 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /MyEngine/myengine/UnityEngine based/Joint.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace MyEngine 7 | { 8 | public abstract class Joint : Component 9 | { 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /MyEngine/myengine/UnityEngine based/MonoBehaviour.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace MyEngine 6 | { 7 | public abstract class MonoBehaviour : Component 8 | { 9 | public int updatePerFrame = 1; 10 | public virtual void Start() 11 | { 12 | //Debug.Info(this.GetType()); 13 | } 14 | public virtual void Update(double deltaTime) 15 | { 16 | //Debug.Info(this.GetType()); 17 | } 18 | 19 | public virtual void OnCollisionEnter(Collision collision) 20 | { 21 | } 22 | public virtual void OnCollisionExit(Collision collision) 23 | { 24 | } 25 | 26 | private bool shouldRunStart = true; 27 | internal void Update_Internal(double deltaTime) 28 | { 29 | if(shouldRunStart) 30 | { 31 | shouldRunStart = false; 32 | //Debug.Info("start "+this.GetType()); 33 | Start(); 34 | } 35 | Update(deltaTime); 36 | } 37 | 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /MyEngine/myengine/UnityEngine based/Physics.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace MyEngine 7 | { 8 | public static class Physics 9 | { 10 | public static bool Raycast(Ray ray, out RaycastHit raycastHit, float maxDistance = float.MaxValue) 11 | { 12 | BEPUphysics.RayCastResult result; 13 | BEPUutilities.Ray r = new BEPUutilities.Ray() 14 | { 15 | Direction = ray.direction, 16 | Position = ray.origin, 17 | }; 18 | bool ret = PhysicsUsage.PhysicsManager.instance.Space.RayCast(r, maxDistance, out result); 19 | if (ret) 20 | { 21 | var other = result.HitObject; 22 | var otherEntity = other as BEPUphysics.BroadPhaseEntries.MobileCollidables.EntityCollidable; 23 | var otherCollider = otherEntity.Entity.Tag as Collider; 24 | raycastHit = new RaycastHit() 25 | { 26 | m_Collider = otherCollider, 27 | m_Point = result.HitData.Location, 28 | m_Normal = result.HitData.Normal, 29 | m_Distance = result.HitData.T, 30 | }; 31 | } 32 | else 33 | { 34 | raycastHit = new RaycastHit(); 35 | } 36 | return ret; 37 | } 38 | 39 | public static void IgnoreCollision(Collider collider1, Collider collider2, bool ignore = true) 40 | { 41 | PhysicsUsage.PhysicsManager.instance.IgnoreCollision(collider1, collider2, ignore); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /MyEngine/myengine/UnityEngine based/Plane.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | using OpenTK; 8 | 9 | namespace MyEngine 10 | { 11 | public struct Plane 12 | { 13 | public Vector3 normal; 14 | public float distance; 15 | 16 | /* 17 | public Plane(Vector3 inNormal, Vector3 inPoint) 18 | { 19 | SetNormalAndPosition(inNormal, inPoint); 20 | } 21 | public Plane(Vector3 a, Vector3 b, Vector3 c) 22 | { 23 | Set3Points(a, b, c); 24 | } 25 | public void SetNormalAndPosition(Vector3 inNormal, Vector3 inPoint) { 26 | 27 | } 28 | public void Set3Points(Vector3 a, Vector3 b, Vector3 c) 29 | { 30 | 31 | }*/ 32 | 33 | // http://www.youtube.com/watch?v=4p-E_31XOPM 34 | public float GetDistanceToPoint(Vector3 point) 35 | { 36 | return Vector3.Dot(point, normal) + distance; 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /MyEngine/myengine/UnityEngine based/Ray.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | using OpenTK; 7 | 8 | 9 | namespace MyEngine 10 | { 11 | 12 | public struct Ray 13 | { 14 | private Vector3 m_Origin; 15 | private Vector3 m_Direction; 16 | public Vector3 origin 17 | { 18 | get 19 | { 20 | return this.m_Origin; 21 | } 22 | set 23 | { 24 | this.m_Origin = value; 25 | } 26 | } 27 | public Vector3 direction 28 | { 29 | get 30 | { 31 | return this.m_Direction; 32 | } 33 | set 34 | { 35 | this.m_Direction = value.Normalized(); 36 | } 37 | } 38 | public Ray(Vector3 origin, Vector3 direction) 39 | { 40 | this.m_Origin = origin; 41 | this.m_Direction = direction.Normalized(); 42 | } 43 | public Vector3 GetPoint(float distance) 44 | { 45 | return this.m_Origin + this.m_Direction * distance; 46 | } 47 | public override string ToString() 48 | { 49 | return String.Format("Origin: {0}, Dir: {1}", new object[] 50 | { 51 | this.m_Origin, 52 | this.m_Direction 53 | }); 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /MyEngine/myengine/UnityEngine based/Renderer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace MyEngine 7 | { 8 | public enum ShadowCastingMode 9 | { 10 | Off, //No shadows are cast from this object. 11 | On, //Shadows are cast from this object. 12 | TwoSided, //Shadows are cast from this object, treating it as two-sided. 13 | ShadowsOnly, //Object casts shadows, but is otherwise invisible in the scene. 14 | }; 15 | public abstract class Renderer : Component 16 | { 17 | public ShadowCastingMode shadowCastingMode = ShadowCastingMode.On; 18 | 19 | virtual internal bool shouldRenderGeometry { get { return shadowCastingMode != ShadowCastingMode.ShadowsOnly; } } 20 | virtual internal bool castsShadows { get { return shadowCastingMode != ShadowCastingMode.Off; } } 21 | 22 | public Material material; 23 | public virtual Bounds bounds { set; get; } 24 | public bool canBeFrustumCulled = true; 25 | virtual internal void UploadUBOandDraw(Camera camera, UniformBlock ubo) 26 | { 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /MyEngine/myengine/UnityEngine based/Screen.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace MyEngine 7 | { 8 | public class Screen 9 | { 10 | public static bool lockCursor 11 | { 12 | set 13 | { 14 | EngineMain.instance.CursorVisible = value; 15 | } 16 | get 17 | { 18 | return EngineMain.instance.CursorVisible; 19 | } 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /MyEngine/myengine/UnityEngine based/SpringJoint.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace MyEngine 8 | { 9 | public class SpringJoint : Joint 10 | { 11 | /*Rigidbody m_connectedTo; 12 | public Rigidbody connectedTo 13 | { 14 | set 15 | { 16 | m_connectedTo = value; 17 | 18 | var a = this.GetComponent(); 19 | if(!a) return; 20 | 21 | var b = connectedTo.GetComponent(); 22 | if(!b) return; 23 | 24 | physicsJoint = new BEPUphysics.Constraints.TwoEntity.Joints.DistanceJoint(a.collisionEntity_generic, b.collisionEntity_generic, a.transform.position, b.transform.position); 25 | 26 | PhysicsUsage.PhysicsManager.instance.Add(physicsJoint); 27 | } 28 | get 29 | { 30 | return m_connectedTo; 31 | } 32 | } 33 | 34 | BEPUphysics.Constraints.TwoEntity.Joints.DistanceJoint physicsJoint; 35 | 36 | internal override void OnCreated(GameObject gameObject) 37 | { 38 | base.OnCreated(gameObject); 39 | }*/ 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /MyEngine/myengine/UnityEngine based/Texture.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using System.Diagnostics; 5 | using OpenTK; 6 | using OpenTK.Graphics; 7 | using OpenTK.Graphics.OpenGL; 8 | 9 | namespace MyEngine 10 | { 11 | // http://docs.unity3d.com/ScriptReference/Texture.html 12 | 13 | public enum TextureWrapMode 14 | { 15 | Repeat, 16 | Clamp, 17 | } 18 | public enum FilterMode 19 | { 20 | Bilinear, 21 | Trilinear, 22 | Point, 23 | } 24 | public class Texture 25 | { 26 | public int anisoLevel; 27 | public FilterMode filterMode = FilterMode.Bilinear; 28 | public float mipMapBias; 29 | public TextureWrapMode wrapMode = TextureWrapMode.Repeat; 30 | 31 | public virtual int GetNativeTextureID() { return 0; } 32 | 33 | 34 | internal TextureMinFilter GetTextureMinFilter(bool withMipMaps = false) 35 | { 36 | if (withMipMaps) 37 | { 38 | if (filterMode == FilterMode.Point) return TextureMinFilter.NearestMipmapNearest; 39 | else return TextureMinFilter.LinearMipmapLinear; 40 | } 41 | else 42 | { 43 | if (filterMode == FilterMode.Point) return TextureMinFilter.Nearest; 44 | else return TextureMinFilter.Linear; 45 | } 46 | } 47 | internal TextureMagFilter GetTextureMagFilter(bool withMipMaps = false) 48 | { 49 | if (filterMode == FilterMode.Point) return TextureMagFilter.Nearest; 50 | else return TextureMagFilter.Linear; 51 | } 52 | internal TextureWrapMode GetTextureWrapMode() 53 | { 54 | if (wrapMode == TextureWrapMode.Repeat) return TextureWrapMode.Repeat; 55 | else return TextureWrapMode.Clamp; 56 | } 57 | } 58 | 59 | 60 | } 61 | -------------------------------------------------------------------------------- /MyEngine/myengine/UnloadFactory.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace MyEngine 6 | { 7 | public class UnloadFactory 8 | { 9 | static internal List unloadables = new List(); 10 | public static void Set(ref T oldObj, T newObj) where T : class 11 | { 12 | if (oldObj is IUnloadable) 13 | { 14 | if (oldObj != null) 15 | { 16 | (oldObj as IUnloadable).Unload(); 17 | unloadables.Remove((oldObj as IUnloadable)); 18 | } 19 | if (newObj != null) unloadables.Add((newObj as IUnloadable)); 20 | } 21 | 22 | oldObj = newObj; 23 | } 24 | public static void Add(object obj) 25 | { 26 | var u = obj as IUnloadable; 27 | if (u!=null && !unloadables.Contains(u)) 28 | { 29 | unloadables.Add(u); 30 | } 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /MyEngine/myengine/app.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /MyEngine/myengine/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /MyEngine/mygame/DebugShowPlanes.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | using OpenTK; 8 | using MyEngine; 9 | 10 | namespace MyGame 11 | { 12 | public class DebugShowPlanes : MonoBehaviour 13 | { 14 | List gos = new List(); 15 | public override void Start() 16 | { 17 | for (int i = 0; i < 6; i++) 18 | { 19 | var go = new GameObject(); 20 | gos.Add(go); 21 | var r = go.AddComponent(); 22 | r.mesh = Factory.GetMesh("internal/cube.obj"); 23 | go.transform.scale = new Vector3(10, 10, 1); 24 | } 25 | } 26 | public override void Update(double deltaTime) 27 | { 28 | var p = GeometryUtility.CalculateFrustumPlanes(GetComponent()); 29 | 30 | for (int i = 0; i < 6; i++) 31 | { 32 | // is broken maybe, furstum culling works but this doesnt make much sense 33 | //gos[i].transform.position = p[i].normal * p[i].distance; 34 | gos[i].transform.rotation = QuaternionUtility.LookRotation(p[i].normal); 35 | } 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /MyEngine/mygame/DrawBounds.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | using MyEngine; 7 | 8 | namespace MyGame 9 | { 10 | public class DrawBounds : MonoBehaviour 11 | { 12 | public Transform drawForThisTransform; 13 | 14 | public static void ForGameObject(GameObject go) 15 | { 16 | var bb = new GameObject(); 17 | var ft = bb.AddComponent(); 18 | ft.drawForThisTransform = go.transform; 19 | var mr = bb.AddComponent(); 20 | mr.mesh = Factory.GetMesh("internal/cube.obj"); 21 | } 22 | public override void Update(double deltaTime) 23 | { 24 | var r = drawForThisTransform.GetComponent(); 25 | if (r) 26 | { 27 | this.transform.scale = r.mesh.bounds.extents; 28 | 29 | this.transform.rotation = drawForThisTransform.rotation; 30 | this.transform.position = drawForThisTransform.position + r.mesh.bounds.center.RotateBy(transform.rotation); 31 | } 32 | else 33 | { 34 | this.transform.position = drawForThisTransform.position; 35 | this.transform.rotation = drawForThisTransform.rotation; 36 | } 37 | } 38 | 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /MyEngine/mygame/LightMovement.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | using MyEngine; 6 | using OpenTK; 7 | 8 | namespace MyGame 9 | { 10 | class LightMovement : MonoBehaviour 11 | { 12 | 13 | public Vector3 offset = new Vector3(0, 10, 0); 14 | public Vector3 dir = new Vector3(0, 0, 1); 15 | public float start = 0f; 16 | public float end = 20.0f; 17 | public float current = 0.0f; 18 | public bool goingToEnd = true; 19 | public float speed = 10f; 20 | 21 | 22 | public override void Update(double deltaTime) 23 | { 24 | 25 | var p=this.gameObject.transform.position; 26 | 27 | p = offset + dir * current; 28 | 29 | 30 | var s = -speed; 31 | if(goingToEnd) s=speed; 32 | 33 | current += (float)deltaTime * s; 34 | 35 | if (current > end) goingToEnd = false; 36 | if (current < start) goingToEnd = true; 37 | 38 | 39 | this.gameObject.transform.position = p; 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /MyEngine/mygame/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("MyGame")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("MyGame")] 13 | [assembly: AssemblyCopyright("Copyright © 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("260bd686-3cfb-4adf-8137-29d0815a9af8")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /MyEngine/mygame/SSAO.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | using OpenTK; 7 | using OpenTK.Input; 8 | using OpenTK.Graphics; 9 | using OpenTK.Graphics.OpenGL; 10 | 11 | using MyEngine; 12 | 13 | namespace MyGame 14 | { 15 | class SSAO : MonoBehaviour 16 | { 17 | public override void Start() 18 | { 19 | //var shader = Factory.GetShader("postProcessEffects/SSAO.shader"); 20 | 21 | //shader.SetUniform("testColor", new Vector3(0, 1, 0)); 22 | 23 | //Camera.main.AddPostProcessEffect(shader); 24 | } 25 | 26 | public override void Update(double deltaTime) 27 | { 28 | 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /MyEngine/mygame/VisualisePosition.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | using MyEngine; 6 | using OpenTK; 7 | 8 | namespace MyGame 9 | { 10 | class VisualizePosition : MonoBehaviour 11 | { 12 | 13 | 14 | GameObject target; 15 | Vector3 targetsLocalPosition; 16 | 17 | public static void Create(GameObject target, Vector3 targetsLocalPosition) 18 | { 19 | var go = new GameObject(); 20 | var renderer = go.AddComponent(); 21 | renderer.mesh = Factory.GetMesh("sphere.obj"); 22 | renderer.material.albedo = new Vector4(0, 0, 1, 1); 23 | go.transform.scale *= 0.5f; 24 | 25 | var vp=go.AddComponent(); 26 | vp.target = target; 27 | vp.targetsLocalPosition = targetsLocalPosition; 28 | 29 | } 30 | 31 | public override void Update(double deltaTime) 32 | { 33 | transform.position = target.transform.position + targetsLocalPosition.RotateBy(target.transform.rotation); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /MyEngine/mygame/VisualizeDir.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | using MyEngine; 6 | using OpenTK; 7 | 8 | namespace MyGame 9 | { 10 | class VisualizeDir : MonoBehaviour 11 | { 12 | 13 | public Vector3 offset = new Vector3(0, 10, 0); 14 | 15 | GameObject dirVisualize; 16 | 17 | public override void Start() 18 | { 19 | var go = new GameObject(); 20 | var renderer = go.AddComponent(); 21 | renderer.mesh = Factory.GetMesh("sphere.obj"); 22 | renderer.material.albedo = new Vector4(0, 0, 1, 1); 23 | go.transform.scale *= 0.5f; 24 | 25 | dirVisualize = go; 26 | } 27 | 28 | public override void Update(double deltaTime) 29 | { 30 | 31 | dirVisualize.transform.position = this.gameObject.transform.position + this.gameObject.transform.forward*2; 32 | 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /MyEngine/mygame/app.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /MyEngine/mygame/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /MyEngine/packages/repositories.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /MyEngine/resources/box.mtl: -------------------------------------------------------------------------------- 1 | # Blender MTL File: '' 2 | # Material Count: 1 3 | newmtl Material 4 | Ns 96.078431 5 | Ka 0.000000 0.000000 0.000000 6 | Kd 0.640000 0.640000 0.640000 7 | Ks 0.500000 0.500000 0.500000 8 | Ni 1.000000 9 | d 1.000000 10 | illum 2 11 | map_Kd bricks.jpg 12 | 13 | 14 | -------------------------------------------------------------------------------- /MyEngine/resources/box.obj: -------------------------------------------------------------------------------- 1 | # Blender v2.57 (sub 0) OBJ File: '' 2 | # www.blender.org 3 | mtllib box.mtl 4 | o Cube 5 | v 1.000000 -1.000000 -1.000000 6 | v 1.000000 -1.000000 1.000000 7 | v -1.000000 -1.000000 1.000000 8 | v -1.000000 -1.000000 -1.000000 9 | v 1.000000 1.000000 -1.000000 10 | v 0.999999 1.000000 1.000001 11 | v -1.000000 1.000000 1.000000 12 | v -1.000000 1.000000 -1.000000 13 | vt 2.094305 1.396205 14 | vt 1.396205 2.094305 15 | vt 0.698100 1.396205 16 | vt 1.396205 0.698100 17 | vt 5.000000 5.000000 18 | vt 2.792410 5.000000 19 | vt 2.792410 2.792410 20 | vt 5.000000 2.792410 21 | vt 2.792410 2.094305 22 | vt 2.094305 2.792410 23 | vt 0.698100 2.792410 24 | vt 0.000000 2.094305 25 | vt 0.000000 0.698100 26 | vt 0.698100 0.000000 27 | vt 2.792410 0.698100 28 | vt 2.094305 0.000000 29 | usemtl Material 30 | s off 31 | f 1/1 2/2 3/3 32 | f 1/1 3/3 4/4 33 | f 5/5 8/6 7/7 34 | f 5/5 7/7 6/8 35 | f 1/1 5/9 6/10 36 | f 1/1 6/10 2/2 37 | f 2/2 6/11 7/12 38 | f 2/2 7/12 3/3 39 | f 3/3 7/13 8/14 40 | f 3/3 8/14 4/4 41 | f 5/15 1/1 4/4 42 | f 5/15 4/4 8/16 43 | -------------------------------------------------------------------------------- /MyEngine/resources/cube.mtl: -------------------------------------------------------------------------------- 1 | # Blender MTL File: 'None' 2 | # Material Count: 1 3 | 4 | newmtl None 5 | Ns 0 6 | Ka 0.000000 0.000000 0.000000 7 | Kd 0.8 0.8 0.8 8 | Ks 0.8 0.8 0.8 9 | d 1 10 | illum 2 11 | -------------------------------------------------------------------------------- /MyEngine/resources/cube.obj: -------------------------------------------------------------------------------- 1 | # Blender v2.71 (sub 0) OBJ File: '' 2 | # www.blender.org 3 | mtllib cube.mtl 4 | o Cube 5 | v -1.000000 -1.000000 1.000000 6 | v -1.000000 -1.000000 -1.000000 7 | v 1.000000 -1.000000 -1.000000 8 | v 1.000000 -1.000000 1.000000 9 | v -1.000000 1.000000 1.000000 10 | v -1.000000 1.000000 -1.000000 11 | v 1.000000 1.000000 -1.000000 12 | v 1.000000 1.000000 1.000000 13 | vt 1.000000 0.000000 14 | vt 1.000000 1.000000 15 | vt 0.000000 1.000000 16 | vt 0.000000 0.000000 17 | vn -1.000000 0.000000 0.000000 18 | vn 0.000000 0.000000 -1.000000 19 | vn 1.000000 0.000000 0.000000 20 | vn 0.000000 0.000000 1.000000 21 | vn 0.000000 -1.000000 0.000000 22 | vn 0.000000 1.000000 0.000000 23 | usemtl None 24 | s off 25 | f 6/1/1 2/2/1 1/3/1 26 | f 7/1/2 3/2/2 2/3/2 27 | f 8/1/3 4/2/3 3/3/3 28 | f 5/1/4 1/2/4 4/3/4 29 | f 2/1/5 3/2/5 4/3/5 30 | f 7/1/6 6/2/6 5/3/6 31 | f 5/4/1 6/1/1 1/3/1 32 | f 6/4/2 7/1/2 2/3/2 33 | f 7/4/3 8/1/3 3/3/3 34 | f 8/4/4 5/1/4 4/3/4 35 | f 1/4/5 2/1/5 4/3/5 36 | f 8/4/6 7/1/6 5/3/6 37 | -------------------------------------------------------------------------------- /MyEngine/resources/dragon.mtl: -------------------------------------------------------------------------------- 1 | # 3ds Max Wavefront OBJ Exporter v0.94b - (c)2007 guruware 2 | # File Created: 04.07.2010 10:41:39 3 | 4 | newmtl wire_087224198 5 | Ns 32 6 | d 1 7 | Tr 1 8 | Tf 1 1 1 9 | illum 2 10 | Ka 0.0000 0.0000 0.0000 11 | Kd 0.3412 0.8784 0.7765 12 | Ks 0.3500 0.3500 0.3500 13 | -------------------------------------------------------------------------------- /MyEngine/resources/internal/Cloud-particle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JakubNei/lego-game-and-Unity-like-engine/949b0c60fa674272b1905bdb47d8a37d8fde9fc1/MyEngine/resources/internal/Cloud-particle.png -------------------------------------------------------------------------------- /MyEngine/resources/internal/black.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JakubNei/lego-game-and-Unity-like-engine/949b0c60fa674272b1905bdb47d8a37d8fde9fc1/MyEngine/resources/internal/black.png -------------------------------------------------------------------------------- /MyEngine/resources/internal/cube.mtl: -------------------------------------------------------------------------------- 1 | # Blender MTL File: 'None' 2 | # Material Count: 1 3 | 4 | newmtl None 5 | Ns 0 6 | Ka 0.000000 0.000000 0.000000 7 | Kd 0.8 0.8 0.8 8 | Ks 0.8 0.8 0.8 9 | d 1 10 | illum 2 11 | -------------------------------------------------------------------------------- /MyEngine/resources/internal/cube.obj: -------------------------------------------------------------------------------- 1 | # Blender v2.69 (sub 0) OBJ File: '' 2 | # www.blender.org 3 | o Cube 4 | v -1.000000 -1.000000 -1.000000 5 | v -1.000000 1.000000 -1.000000 6 | v 1.000000 1.000000 -1.000000 7 | v 1.000000 -1.000000 -1.000000 8 | v -1.000000 -0.999999 1.000000 9 | v -0.999999 1.000001 1.000000 10 | v 1.000000 1.000000 1.000000 11 | v 1.000000 -1.000000 1.000000 12 | vt 0.000000 0.000000 13 | vt 1.000000 0.000000 14 | vt 0.000000 1.000000 15 | vt 1.000000 1.000000 16 | vn 0.000000 0.000000 -1.000000 17 | vn 0.000000 0.000000 1.000000 18 | vn -1.000000 0.000000 -0.000000 19 | vn 0.000000 1.000000 -0.000000 20 | vn 1.000000 -0.000000 -0.000000 21 | vn -0.000000 -1.000000 0.000000 22 | vn -1.000000 0.000001 0.000000 23 | s off 24 | f 1/1/1 2/2/1 4/3/1 25 | f 5/1/2 8/2/2 6/3/2 26 | f 1/1/3 5/2/3 2/3/3 27 | f 2/1/4 6/2/4 3/3/4 28 | f 3/1/5 7/2/5 4/3/5 29 | f 5/1/6 1/2/6 8/3/6 30 | f 2/2/1 3/4/1 4/3/1 31 | f 8/2/2 7/4/2 6/3/2 32 | f 5/2/7 6/4/7 2/3/7 33 | f 6/2/4 7/4/4 3/3/4 34 | f 7/2/5 8/4/5 4/3/5 35 | f 1/2/6 4/4/6 8/3/6 36 | -------------------------------------------------------------------------------- /MyEngine/resources/internal/cube_bigUVs.obj: -------------------------------------------------------------------------------- 1 | # Blender v2.63 (sub 0) OBJ File: '' 2 | # www.blender.org 3 | mtllib untitled.mtl 4 | v 1.000000 -1.000000 -1.000000 5 | v 1.000000 -1.000000 1.000000 6 | v -1.000000 -1.000000 1.000000 7 | v -1.000000 -1.000000 -1.000000 8 | v 1.000000 1.000000 -1.000000 9 | v 1.000000 1.000000 1.000001 10 | v -1.000000 1.000000 1.000000 11 | v -1.000000 1.000000 -1.000000 12 | vt 0.000000 0.000000 13 | vt 100.000000 0.000000 14 | vt 100.000000 100.000000 15 | vt 0.000000 100.000000 16 | vn 0.000000 -1.000000 0.000000 17 | vn 0.000000 1.000000 0.000000 18 | vn 1.000000 0.000000 0.000000 19 | vn -0.000000 -0.000000 1.000000 20 | vn -1.000000 -0.000000 -0.000000 21 | vn 0.000000 0.000000 -1.000000 22 | usemtl Material 23 | s off 24 | f 1/1/1 2/2/1 3/3/1 25 | f 1/1/1 3/3/1 4/4/1 26 | f 5/1/2 8/2/2 7/3/2 27 | f 5/1/2 7/3/2 6/4/2 28 | f 1/1/3 5/2/3 6/3/3 29 | f 1/1/3 6/3/3 2/4/3 30 | f 2/1/4 6/2/4 7/3/4 31 | f 2/1/4 7/3/4 3/4/4 32 | f 3/1/5 7/2/5 8/3/5 33 | f 3/1/5 8/3/5 4/4/5 34 | f 5/1/6 1/2/6 4/3/6 35 | f 5/1/6 4/3/6 8/4/6 36 | -------------------------------------------------------------------------------- /MyEngine/resources/internal/cube_center_to_11.mtl: -------------------------------------------------------------------------------- 1 | # Blender MTL File: 'None' 2 | # Material Count: 1 3 | 4 | newmtl None 5 | Ns 0 6 | Ka 0.000000 0.000000 0.000000 7 | Kd 0.8 0.8 0.8 8 | Ks 0.8 0.8 0.8 9 | d 1 10 | illum 2 11 | -------------------------------------------------------------------------------- /MyEngine/resources/internal/cube_center_to_11.obj: -------------------------------------------------------------------------------- 1 | # Blender v2.71 (sub 0) OBJ File: '' 2 | # www.blender.org 3 | mtllib cube.mtl 4 | v 0.000000 0.000000 0.000000 5 | v 0.000000 0.000000 -1.000000 6 | v 1.000000 0.000000 -1.000000 7 | v 1.000000 0.000000 0.000000 8 | v 0.000000 1.000000 0.000000 9 | v 0.000000 1.000000 -1.000000 10 | v 1.000000 1.000000 -1.000000 11 | v 1.000000 1.000000 0.000000 12 | vt 1.000000 0.000000 13 | vt 1.000000 1.000000 14 | vt 0.000000 1.000000 15 | vt 0.000000 0.000000 16 | vn -1.000000 0.000000 0.000000 17 | vn 0.000000 0.000000 -1.000000 18 | vn 1.000000 0.000000 0.000000 19 | vn 0.000000 0.000000 1.000000 20 | vn 0.000000 -1.000000 0.000000 21 | vn 0.000000 1.000000 0.000000 22 | usemtl None 23 | s off 24 | f 6/1/1 2/2/1 1/3/1 25 | f 7/1/2 3/2/2 2/3/2 26 | f 8/1/3 4/2/3 3/3/3 27 | f 5/1/4 1/2/4 4/3/4 28 | f 2/1/5 3/2/5 4/3/5 29 | f 7/1/6 6/2/6 5/3/6 30 | f 5/4/1 6/1/1 1/3/1 31 | f 6/4/2 7/1/2 2/3/2 32 | f 7/4/3 8/1/3 3/3/3 33 | f 8/4/4 5/1/4 4/3/4 34 | f 1/4/5 2/1/5 4/3/5 35 | f 8/4/6 7/1/6 5/3/6 36 | -------------------------------------------------------------------------------- /MyEngine/resources/internal/cube_x2.obj: -------------------------------------------------------------------------------- 1 | # Blender v2.63 (sub 0) OBJ File: '' 2 | # www.blender.org 3 | mtllib cube_x2.mtl 4 | o Cube.001 5 | v 1.000000 -1.000000 -1.000000 6 | v 1.000000 -1.000000 1.000000 7 | v -1.000000 -1.000000 1.000000 8 | v -1.000000 -1.000000 -1.000000 9 | v 1.000000 1.000000 -0.999999 10 | v 0.999999 1.000000 1.000001 11 | v -1.000000 1.000000 1.000000 12 | v -1.000000 1.000000 -1.000000 13 | usemtl Material 14 | s off 15 | f 1 2 3 4 16 | f 5 8 7 6 17 | f 1 5 6 2 18 | f 2 6 7 3 19 | f 3 7 8 4 20 | f 5 1 4 8 21 | o Cube 22 | v 1.000000 -1.000000 -1.000000 23 | v 1.000000 -1.000000 1.000000 24 | v -1.000000 -1.000000 1.000000 25 | v -1.000000 -1.000000 -1.000000 26 | v 1.000000 1.000000 -0.999999 27 | v 0.999999 1.000000 1.000001 28 | v -1.000000 1.000000 1.000000 29 | v -1.000000 1.000000 -1.000000 30 | usemtl Material 31 | s off 32 | f 9 10 11 12 33 | f 13 16 15 14 34 | f 9 13 14 10 35 | f 10 14 15 11 36 | f 11 15 16 12 37 | f 13 9 12 16 38 | -------------------------------------------------------------------------------- /MyEngine/resources/internal/debugDrawTexture.shader: -------------------------------------------------------------------------------- 1 | 2 | 3 | [VertexShader] 4 | 5 | layout(location = 0) in vec3 in_position; 6 | layout(location = 1) in vec3 in_normal; 7 | layout(location = 2) in vec3 in_tangent; 8 | layout(location = 3) in vec2 in_uv; 9 | // in mat4 in_modelMatrix; // instanced rendering 10 | 11 | 12 | uniform vec4 debugDrawTexturePositionScale; 13 | uniform vec4 debugDrawTexturePositionOffset; 14 | 15 | void main() 16 | { 17 | 18 | gl_Position = debugDrawTexturePositionOffset + vec4(in_position,1) * debugDrawTexturePositionScale; 19 | 20 | } 21 | 22 | 23 | [FragmentShader] 24 | 25 | 26 | uniform sampler2D debugDrawTexture; 27 | 28 | uniform float debugDrawTextureScale = 1; 29 | uniform float debugDrawTextureOffset = 0; 30 | 31 | layout(location = 0) out vec4 out_color; 32 | 33 | void main() 34 | { 35 | 36 | vec2 screenCoord = gl_FragCoord.xy / engine.screenSize; 37 | 38 | out_color = debugDrawTextureOffset + texture(debugDrawTexture, screenCoord) * debugDrawTextureScale ; 39 | 40 | } 41 | 42 | -------------------------------------------------------------------------------- /MyEngine/resources/internal/deferred.skybox.shader: -------------------------------------------------------------------------------- 1 | 2 | 3 | [VertexShader] 4 | 5 | layout(location = 0) in vec3 in_position; 6 | layout(location = 1) in vec3 in_normal; 7 | layout(location = 2) in vec3 in_tangent; 8 | layout(location = 3) in vec2 in_uv; 9 | 10 | out data { 11 | vec3 uv; 12 | } o; 13 | 14 | void main() 15 | { 16 | gl_Position = engine.viewProjectionMatrix * vec4(in_position + engine.cameraPosition , 1); 17 | 18 | o.uv = in_position; 19 | } 20 | 21 | 22 | [FragmentShader] 23 | 24 | uniform samplerCube skyboxCubeMap; 25 | 26 | in data { 27 | vec3 uv; 28 | } i; 29 | 30 | layout(location = 0) out vec4 out_color; 31 | layout(location = 1) out vec3 out_position; 32 | layout(location = 2) out vec3 out_normal; 33 | layout(location = 3) out vec4 out_uv; 34 | 35 | void main() 36 | { 37 | 38 | //out_color = vec4(i.uv/2+0.5, 1); 39 | out_color = texture(skyboxCubeMap, i.uv); 40 | 41 | out_position = vec3(0); 42 | out_normal = vec3(0); 43 | out_uv = vec4(0); 44 | 45 | } 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /MyEngine/resources/internal/depthGrab.standart.shader: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | [VertexShader] 5 | 6 | layout(location = 0) in vec3 in_position; 7 | 8 | void main() 9 | { 10 | 11 | gl_Position = model.modelViewProjectionMatrix * vec4(in_position,1); 12 | 13 | } 14 | 15 | 16 | [FragmentShader] 17 | 18 | 19 | 20 | layout(location = 0) out float out_depth; 21 | 22 | 23 | void main() 24 | { 25 | out_depth = gl_FragCoord.z; 26 | } 27 | 28 | -------------------------------------------------------------------------------- /MyEngine/resources/internal/grey.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JakubNei/lego-game-and-Unity-like-engine/949b0c60fa674272b1905bdb47d8a37d8fde9fc1/MyEngine/resources/internal/grey.png -------------------------------------------------------------------------------- /MyEngine/resources/internal/internal backup.rar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JakubNei/lego-game-and-Unity-like-engine/949b0c60fa674272b1905bdb47d8a37d8fde9fc1/MyEngine/resources/internal/internal backup.rar -------------------------------------------------------------------------------- /MyEngine/resources/internal/normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JakubNei/lego-game-and-Unity-like-engine/949b0c60fa674272b1905bdb47d8a37d8fde9fc1/MyEngine/resources/internal/normal.png -------------------------------------------------------------------------------- /MyEngine/resources/internal/particletexture.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JakubNei/lego-game-and-Unity-like-engine/949b0c60fa674272b1905bdb47d8a37d8fde9fc1/MyEngine/resources/internal/particletexture.jpg -------------------------------------------------------------------------------- /MyEngine/resources/internal/quad.obj: -------------------------------------------------------------------------------- 1 | # Blender v2.57 (sub 0) OBJ File: '' 2 | # www.blender.org 3 | o Cube_Cube.001 4 | v -1.000000 1.000000 0.000000 5 | v 1.000000 1.000000 0.000000 6 | v -1.000000 -1.000000 0.000000 7 | v 1.000000 -1.000000 0.000000 8 | vt 1.000000 1.000000 9 | vt 0.000000 1.000000 10 | vt 0.000000 0.000000 11 | vt 1.000000 0.000000 12 | usemtl (null) 13 | s off 14 | f 4/4 3/3 1/2 15 | f 2/1 4/4 1/2 16 | -------------------------------------------------------------------------------- /MyEngine/resources/internal/skybox.obj: -------------------------------------------------------------------------------- 1 | # Blender v2.73 (sub 0) OBJ File: '' 2 | # www.blender.org 3 | o Cube 4 | v 1.000000 -1.000000 -1.000000 5 | v 1.000000 -1.000000 1.000000 6 | v -1.000000 -1.000000 1.000000 7 | v -1.000000 -1.000000 -1.000000 8 | v 1.000000 1.000000 -1.000000 9 | v 1.000000 1.000000 1.000000 10 | v -1.000000 1.000000 1.000000 11 | v -1.000000 1.000000 -1.000000 12 | vn 0.000000 1.000000 0.000000 13 | vn 0.000000 -1.000000 0.000000 14 | vn -1.000000 -0.000000 -0.000000 15 | vn 0.000000 0.000000 -1.000000 16 | vn 1.000000 0.000000 0.000000 17 | vn -0.000000 -0.000000 1.000000 18 | s off 19 | f 1//1 4//1 3//1 2//1 20 | f 5//2 6//2 7//2 8//2 21 | f 1//3 2//3 6//3 5//3 22 | f 2//4 3//4 7//4 6//4 23 | f 3//5 4//5 8//5 7//5 24 | f 5//6 8//6 4//6 1//6 25 | -------------------------------------------------------------------------------- /MyEngine/resources/internal/test.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JakubNei/lego-game-and-Unity-like-engine/949b0c60fa674272b1905bdb47d8a37d8fde9fc1/MyEngine/resources/internal/test.jpg -------------------------------------------------------------------------------- /MyEngine/resources/internal/white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JakubNei/lego-game-and-Unity-like-engine/949b0c60fa674272b1905bdb47d8a37d8fde9fc1/MyEngine/resources/internal/white.png -------------------------------------------------------------------------------- /MyEngine/resources/lego/blocks/block_1x1x1.mtl: -------------------------------------------------------------------------------- 1 | # Blender MTL File: 'lego_bs.blend' 2 | # Material Count: 2 3 | 4 | newmtl yellow 5 | Ns 96.078431 6 | Ka 0.000000 0.000000 0.000000 7 | Kd 0.640000 0.640000 0.640000 8 | Ks 0.500000 0.500000 0.500000 9 | Ni 1.000000 10 | d 1.000000 11 | illum 2 12 | map_Kd C:\Users\Neitri\Downloads\OLD\73812_legodeadpool_blend\512px-Lego_dimensions.jpg 13 | 14 | newmtl yellow_NONE 15 | Ns 96.078431 16 | Ka 0.000000 0.000000 0.000000 17 | Kd 0.640000 0.640000 0.640000 18 | Ks 0.500000 0.500000 0.500000 19 | Ni 1.000000 20 | d 1.000000 21 | illum 2 22 | -------------------------------------------------------------------------------- /MyEngine/resources/lego/blocks/block_1x2x1.mtl: -------------------------------------------------------------------------------- 1 | # Blender MTL File: 'lego_bs.blend' 2 | # Material Count: 2 3 | 4 | newmtl red 5 | Ns 96.078431 6 | Ka 0.000000 0.000000 0.000000 7 | Kd 0.640000 0.640000 0.640000 8 | Ks 0.500000 0.500000 0.500000 9 | Ni 1.000000 10 | d 1.000000 11 | illum 2 12 | map_Kd C:\Users\Neitri\Downloads\OLD\73812_legodeadpool_blend\512px-Lego_dimensions.jpg 13 | 14 | newmtl red_NONE 15 | Ns 96.078431 16 | Ka 0.000000 0.000000 0.000000 17 | Kd 0.640000 0.640000 0.640000 18 | Ks 0.500000 0.500000 0.500000 19 | Ni 1.000000 20 | d 1.000000 21 | illum 2 22 | -------------------------------------------------------------------------------- /MyEngine/resources/lego/blocks/block_1x3x1.mtl: -------------------------------------------------------------------------------- 1 | # Blender MTL File: 'lego_bs.blend' 2 | # Material Count: 2 3 | 4 | newmtl green 5 | Ns 96.078431 6 | Ka 0.000000 0.000000 0.000000 7 | Kd 0.640000 0.640000 0.640000 8 | Ks 0.500000 0.500000 0.500000 9 | Ni 1.000000 10 | d 1.000000 11 | illum 2 12 | map_Kd C:\Users\Neitri\Downloads\OLD\73812_legodeadpool_blend\512px-Lego_dimensions.jpg 13 | 14 | newmtl green_NONE 15 | Ns 96.078431 16 | Ka 0.000000 0.000000 0.000000 17 | Kd 0.640000 0.640000 0.640000 18 | Ks 0.500000 0.500000 0.500000 19 | Ni 1.000000 20 | d 1.000000 21 | illum 2 22 | -------------------------------------------------------------------------------- /MyEngine/resources/lego/blocks/block_1x4x1.mtl: -------------------------------------------------------------------------------- 1 | # Blender MTL File: 'lego_bs.blend' 2 | # Material Count: 2 3 | 4 | newmtl green 5 | Ns 96.078431 6 | Ka 0.000000 0.000000 0.000000 7 | Kd 0.640000 0.640000 0.640000 8 | Ks 0.500000 0.500000 0.500000 9 | Ni 1.000000 10 | d 1.000000 11 | illum 2 12 | map_Kd C:\Users\Neitri\Downloads\OLD\73812_legodeadpool_blend\512px-Lego_dimensions.jpg 13 | 14 | newmtl green_NONE 15 | Ns 96.078431 16 | Ka 0.000000 0.000000 0.000000 17 | Kd 0.640000 0.640000 0.640000 18 | Ks 0.500000 0.500000 0.500000 19 | Ni 1.000000 20 | d 1.000000 21 | illum 2 22 | -------------------------------------------------------------------------------- /MyEngine/resources/lego/blocks/block_1x5x1.mtl: -------------------------------------------------------------------------------- 1 | # Blender MTL File: 'lego_bs.blend' 2 | # Material Count: 2 3 | 4 | newmtl green 5 | Ns 96.078431 6 | Ka 0.000000 0.000000 0.000000 7 | Kd 0.640000 0.640000 0.640000 8 | Ks 0.500000 0.500000 0.500000 9 | Ni 1.000000 10 | d 1.000000 11 | illum 2 12 | map_Kd C:\Users\Neitri\Downloads\OLD\73812_legodeadpool_blend\512px-Lego_dimensions.jpg 13 | 14 | newmtl green_NONE 15 | Ns 96.078431 16 | Ka 0.000000 0.000000 0.000000 17 | Kd 0.640000 0.640000 0.640000 18 | Ks 0.500000 0.500000 0.500000 19 | Ni 1.000000 20 | d 1.000000 21 | illum 2 22 | -------------------------------------------------------------------------------- /MyEngine/resources/lego/blocks/block_1x6x1.mtl: -------------------------------------------------------------------------------- 1 | # Blender MTL File: 'lego_bs.blend' 2 | # Material Count: 2 3 | 4 | newmtl green 5 | Ns 96.078431 6 | Ka 0.000000 0.000000 0.000000 7 | Kd 0.640000 0.640000 0.640000 8 | Ks 0.500000 0.500000 0.500000 9 | Ni 1.000000 10 | d 1.000000 11 | illum 2 12 | map_Kd C:\Users\Neitri\Downloads\OLD\73812_legodeadpool_blend\512px-Lego_dimensions.jpg 13 | 14 | newmtl green_NONE 15 | Ns 96.078431 16 | Ka 0.000000 0.000000 0.000000 17 | Kd 0.640000 0.640000 0.640000 18 | Ks 0.500000 0.500000 0.500000 19 | Ni 1.000000 20 | d 1.000000 21 | illum 2 22 | -------------------------------------------------------------------------------- /MyEngine/resources/lego/blocks/block_2x2x1.mtl: -------------------------------------------------------------------------------- 1 | # Blender MTL File: 'lego_bs.blend' 2 | # Material Count: 2 3 | 4 | newmtl blue 5 | Ns 96.078431 6 | Ka 0.000000 0.000000 0.000000 7 | Kd 0.640000 0.640000 0.640000 8 | Ks 0.500000 0.500000 0.500000 9 | Ni 1.000000 10 | d 1.000000 11 | illum 2 12 | map_Kd C:\Users\Neitri\Downloads\OLD\73812_legodeadpool_blend\512px-Lego_dimensions.jpg 13 | 14 | newmtl blue_NONE 15 | Ns 96.078431 16 | Ka 0.000000 0.000000 0.000000 17 | Kd 0.640000 0.640000 0.640000 18 | Ks 0.500000 0.500000 0.500000 19 | Ni 1.000000 20 | d 1.000000 21 | illum 2 22 | -------------------------------------------------------------------------------- /MyEngine/resources/lego/blocks/block_2x3x1.mtl: -------------------------------------------------------------------------------- 1 | # Blender MTL File: 'lego_bs.blend' 2 | # Material Count: 2 3 | 4 | newmtl green 5 | Ns 96.078431 6 | Ka 0.000000 0.000000 0.000000 7 | Kd 0.640000 0.640000 0.640000 8 | Ks 0.500000 0.500000 0.500000 9 | Ni 1.000000 10 | d 1.000000 11 | illum 2 12 | map_Kd C:\Users\Neitri\Downloads\OLD\73812_legodeadpool_blend\512px-Lego_dimensions.jpg 13 | 14 | newmtl green_NONE 15 | Ns 96.078431 16 | Ka 0.000000 0.000000 0.000000 17 | Kd 0.640000 0.640000 0.640000 18 | Ks 0.500000 0.500000 0.500000 19 | Ni 1.000000 20 | d 1.000000 21 | illum 2 22 | -------------------------------------------------------------------------------- /MyEngine/resources/lego/blocks/block_2x4x1.mtl: -------------------------------------------------------------------------------- 1 | # Blender MTL File: 'lego_bs.blend' 2 | # Material Count: 2 3 | 4 | newmtl green 5 | Ns 96.078431 6 | Ka 0.000000 0.000000 0.000000 7 | Kd 0.640000 0.640000 0.640000 8 | Ks 0.500000 0.500000 0.500000 9 | Ni 1.000000 10 | d 1.000000 11 | illum 2 12 | map_Kd C:\Users\Neitri\Downloads\OLD\73812_legodeadpool_blend\512px-Lego_dimensions.jpg 13 | 14 | newmtl green_NONE 15 | Ns 96.078431 16 | Ka 0.000000 0.000000 0.000000 17 | Kd 0.640000 0.640000 0.640000 18 | Ks 0.500000 0.500000 0.500000 19 | Ni 1.000000 20 | d 1.000000 21 | illum 2 22 | -------------------------------------------------------------------------------- /MyEngine/resources/lego/blocks/block_2x5x1.mtl: -------------------------------------------------------------------------------- 1 | # Blender MTL File: 'lego_bs.blend' 2 | # Material Count: 2 3 | 4 | newmtl green 5 | Ns 96.078431 6 | Ka 0.000000 0.000000 0.000000 7 | Kd 0.640000 0.640000 0.640000 8 | Ks 0.500000 0.500000 0.500000 9 | Ni 1.000000 10 | d 1.000000 11 | illum 2 12 | map_Kd C:\Users\Neitri\Downloads\OLD\73812_legodeadpool_blend\512px-Lego_dimensions.jpg 13 | 14 | newmtl green_NONE 15 | Ns 96.078431 16 | Ka 0.000000 0.000000 0.000000 17 | Kd 0.640000 0.640000 0.640000 18 | Ks 0.500000 0.500000 0.500000 19 | Ni 1.000000 20 | d 1.000000 21 | illum 2 22 | -------------------------------------------------------------------------------- /MyEngine/resources/lego/blocks/block_2x6x1.mtl: -------------------------------------------------------------------------------- 1 | # Blender MTL File: 'lego_bs.blend' 2 | # Material Count: 2 3 | 4 | newmtl green 5 | Ns 96.078431 6 | Ka 0.000000 0.000000 0.000000 7 | Kd 0.640000 0.640000 0.640000 8 | Ks 0.500000 0.500000 0.500000 9 | Ni 1.000000 10 | d 1.000000 11 | illum 2 12 | map_Kd C:\Users\Neitri\Downloads\OLD\73812_legodeadpool_blend\512px-Lego_dimensions.jpg 13 | 14 | newmtl green_NONE 15 | Ns 96.078431 16 | Ka 0.000000 0.000000 0.000000 17 | Kd 0.640000 0.640000 0.640000 18 | Ks 0.500000 0.500000 0.500000 19 | Ni 1.000000 20 | d 1.000000 21 | illum 2 22 | -------------------------------------------------------------------------------- /MyEngine/resources/lego/blocks/lego_bs.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JakubNei/lego-game-and-Unity-like-engine/949b0c60fa674272b1905bdb47d8a37d8fde9fc1/MyEngine/resources/lego/blocks/lego_bs.blend -------------------------------------------------------------------------------- /MyEngine/resources/postProcessEffects/SSAO.shader: -------------------------------------------------------------------------------- 1 | 2 | [VertexShader] // pass thru vertex shader 3 | 4 | layout(location = 0) in vec3 in_position; 5 | 6 | void main() 7 | { 8 | gl_Position = vec4(in_position,1); 9 | } 10 | 11 | 12 | 13 | 14 | 15 | [FragmentShader] 16 | 17 | uniform vec3 testColor; 18 | 19 | layout(location = 0) out vec4 out_color; 20 | 21 | void main() 22 | { 23 | 24 | 25 | vec2 screenCoord = gl_FragCoord.xy / engine.screenSize; 26 | 27 | GBufferPerPixel gBuffer = GetGBufferPerPixel(); 28 | 29 | // skybox, just pass thru color 30 | if (gBuffer.normal == vec3(0, 0, 0)) { 31 | out_color = vec4(gBuffer.color, 1); 32 | return; 33 | } 34 | 35 | //out_color = vec4(pow(gBuffer.final,vec3(gBuffer.depth)), 1); 36 | out_color = vec4(gBuffer.final, 1); 37 | out_color = vec4(testColor, 1); 38 | 39 | //out_color = vec4(vec3(gBuffer.depth*100), 1); 40 | 41 | } 42 | 43 | 44 | -------------------------------------------------------------------------------- /MyEngine/resources/quad.mtl: -------------------------------------------------------------------------------- 1 | # Blender MTL File: '' 2 | # Material Count: 0 3 | -------------------------------------------------------------------------------- /MyEngine/resources/skybox/sunny/back.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JakubNei/lego-game-and-Unity-like-engine/949b0c60fa674272b1905bdb47d8a37d8fde9fc1/MyEngine/resources/skybox/sunny/back.jpg -------------------------------------------------------------------------------- /MyEngine/resources/skybox/sunny/bottom.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JakubNei/lego-game-and-Unity-like-engine/949b0c60fa674272b1905bdb47d8a37d8fde9fc1/MyEngine/resources/skybox/sunny/bottom.jpg -------------------------------------------------------------------------------- /MyEngine/resources/skybox/sunny/front.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JakubNei/lego-game-and-Unity-like-engine/949b0c60fa674272b1905bdb47d8a37d8fde9fc1/MyEngine/resources/skybox/sunny/front.jpg -------------------------------------------------------------------------------- /MyEngine/resources/skybox/sunny/left.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JakubNei/lego-game-and-Unity-like-engine/949b0c60fa674272b1905bdb47d8a37d8fde9fc1/MyEngine/resources/skybox/sunny/left.jpg -------------------------------------------------------------------------------- /MyEngine/resources/skybox/sunny/right.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JakubNei/lego-game-and-Unity-like-engine/949b0c60fa674272b1905bdb47d8a37d8fde9fc1/MyEngine/resources/skybox/sunny/right.jpg -------------------------------------------------------------------------------- /MyEngine/resources/skybox/sunny/top.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JakubNei/lego-game-and-Unity-like-engine/949b0c60fa674272b1905bdb47d8a37d8fde9fc1/MyEngine/resources/skybox/sunny/top.jpg -------------------------------------------------------------------------------- /MyEngine/resources/sphere.mtl: -------------------------------------------------------------------------------- 1 | # Blender MTL File: 'None' 2 | # Material Count: 1 3 | 4 | newmtl None 5 | Ns 0 6 | Ka 0.000000 0.000000 0.000000 7 | Kd 0.8 0.8 0.8 8 | Ks 0.8 0.8 0.8 9 | d 1 10 | illum 2 11 | -------------------------------------------------------------------------------- /MyEngine/resources/spider.mtl: -------------------------------------------------------------------------------- 1 | # 2 | # spider.mtl 3 | # 4 | 5 | newmtl Skin 6 | Ka 0.200000 0.200000 0.200000 7 | Kd 0.827451 0.792157 0.772549 8 | Ks 0.000000 0.000000 0.000000 9 | Ns 0.000000 10 | map_Kd .\wal67ar_small.jpg 11 | 12 | newmtl Brusttex 13 | Ka 0.200000 0.200000 0.200000 14 | Kd 0.800000 0.800000 0.800000 15 | Ks 0.000000 0.000000 0.000000 16 | Ns 0.000000 17 | map_Kd .\wal69ar_small.jpg 18 | 19 | newmtl HLeibTex 20 | Ka 0.200000 0.200000 0.200000 21 | Kd 0.690196 0.639216 0.615686 22 | Ks 0.000000 0.000000 0.000000 23 | Ns 0.000000 24 | map_Kd .\SpiderTex.jpg 25 | 26 | newmtl BeinTex 27 | Ka 0.200000 0.200000 0.200000 28 | Kd 0.800000 0.800000 0.800000 29 | Ks 0.000000 0.000000 0.000000 30 | Ns 0.000000 31 | map_Kd .\drkwood2.jpg 32 | 33 | newmtl Augentex 34 | Ka 0.200000 0.200000 0.200000 35 | Kd 0.800000 0.800000 0.800000 36 | Ks 0.000000 0.000000 0.000000 37 | Ns 0.000000 38 | map_Kd .\engineflare1.jpg -------------------------------------------------------------------------------- /MyEngine/resources/textures/grassDIFFUSE.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JakubNei/lego-game-and-Unity-like-engine/949b0c60fa674272b1905bdb47d8a37d8fde9fc1/MyEngine/resources/textures/grassDIFFUSE.jpg -------------------------------------------------------------------------------- /MyEngine/resources/textures/grassDISP.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JakubNei/lego-game-and-Unity-like-engine/949b0c60fa674272b1905bdb47d8a37d8fde9fc1/MyEngine/resources/textures/grassDISP.jpg -------------------------------------------------------------------------------- /MyEngine/resources/textures/grassNORMAL.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JakubNei/lego-game-and-Unity-like-engine/949b0c60fa674272b1905bdb47d8a37d8fde9fc1/MyEngine/resources/textures/grassNORMAL.jpg -------------------------------------------------------------------------------- /MyEngine/resources/textures/pointSprite.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JakubNei/lego-game-and-Unity-like-engine/949b0c60fa674272b1905bdb47d8a37d8fde9fc1/MyEngine/resources/textures/pointSprite.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Lego like game + Unity inspired engine 2 | Simple lego game made along with simple Unity inspired game engine. 3 | 4 | One semester we had a Computer Graphics, everyone did their projects in in C++, but I set out to create it in C# and make the scripting API exactly the same as Unity's scripting API. 5 | 6 | If someone ever thinks of creating and switching to their own proprietary engine with same scripting API (for smooth transition), this project might be a good start. 7 | 8 | Uses OpenTK as OpenGL wrapper for rendering and C# physics engine BEPUphysics. 9 | 10 | It is a simple lego game, with: physics, deferred rendering, directional soft shadows, any number of lights (any type), parallax mapping and very very lame CUDA 'accelerated' particles. 11 | 12 | Not everything works properly, still needs plenty of work. It is separated into MyEngine and MyGame projects, in theory MyGame will require minimal effort to port over to Unity (same API, resource management is different). 13 | 14 | [Unity forum thread](https://forum.unity3d.com/threads/beginnings-of-clone-of-unity-engine-scripting-api.326255) 15 | 16 | ![](http://i.imgur.com/O2gSs9E.jpg) 17 | 18 | ![](http://i.imgur.com/kWN0aXg.png) 19 | --------------------------------------------------------------------------------