├── .gitattributes
├── .gitignore
├── GeonBit.nuspec
├── GeonBit.sln
├── GeonBit
├── Content
│ ├── Content.mgcb
│ ├── GeonBit.Core
│ │ ├── BasicMeshes
│ │ │ ├── Cone.fbx
│ │ │ ├── Cube.fbx
│ │ │ ├── Cylinder.fbx
│ │ │ ├── Plane.fbx
│ │ │ ├── Skybox.fbx
│ │ │ ├── Sphere.fbx
│ │ │ ├── SphereLowPoly.fbx
│ │ │ └── SphereSmooth.fbx
│ │ ├── Effects
│ │ │ ├── LitEffect.fx
│ │ │ ├── LitEffectAlphaTest.fx
│ │ │ └── NormalMapLitEffect.fx
│ │ └── Textures
│ │ │ └── Skybox.png
│ └── README.md
├── GeonBit.csproj
├── Icon.bmp
├── Icon.ico
├── Libs
│ ├── Content.Pipeline
│ │ ├── AnimationImporters
│ │ │ ├── Animation
│ │ │ │ ├── AnimationsContent.cs
│ │ │ │ ├── ClipContent.cs
│ │ │ │ ├── CpuAnimatedVertexBufferContent.cs
│ │ │ │ └── KeyframeContent.cs
│ │ │ ├── AnimationImporters.csproj
│ │ │ ├── Processors
│ │ │ │ ├── AnimationsProcessor.cs
│ │ │ │ ├── CpuAnimatedModelProcessor.cs
│ │ │ │ └── GpuAnimatedModelProcessor.cs
│ │ │ ├── Properties
│ │ │ │ └── AssemblyInfo.cs
│ │ │ └── Serialization
│ │ │ │ ├── AnimationsWriter.cs
│ │ │ │ ├── ClipWriter.cs
│ │ │ │ └── CpuAnimatedVertexBufferWriter.cs
│ │ └── GraphicsImporters
│ │ │ ├── Graphics
│ │ │ ├── DynamicIndexBufferContent.cs
│ │ │ ├── DynamicModelContent.cs
│ │ │ ├── DynamicModelMeshContent.cs
│ │ │ ├── DynamicModelMeshPartContent.cs
│ │ │ └── DynamicVertexBufferContent.cs
│ │ │ ├── GraphicsImporters.csproj
│ │ │ ├── Processors
│ │ │ └── DynamicModelProcessor.cs
│ │ │ ├── Properties
│ │ │ └── AssemblyInfo.cs
│ │ │ └── Serialization
│ │ │ ├── DynamicIndexBufferWriter.cs
│ │ │ ├── DynamicModelWriter.cs
│ │ │ └── DynamicVertexBufferWriter.cs
│ ├── Extend
│ │ └── Animations
│ │ │ ├── Animations.csproj
│ │ │ ├── Properties
│ │ │ └── AssemblyInfo.cs
│ │ │ ├── README.md
│ │ │ └── Source
│ │ │ ├── Animation
│ │ │ ├── Animations.cs
│ │ │ ├── Clip.cs
│ │ │ ├── CpuAnimatedVertexBuffer.Unsafe.cs
│ │ │ ├── CpuAnimatedVertexBuffer.cs
│ │ │ ├── Extensions.cs
│ │ │ ├── Keyframe.cs
│ │ │ └── NativeExtensions.cs
│ │ │ ├── ContentReaders
│ │ │ ├── AnimationsReader.cs
│ │ │ ├── ClipReader.cs
│ │ │ └── CpuAnimatedVertexBufferReader.cs
│ │ │ └── Graphics
│ │ │ └── VertexTypes
│ │ │ └── VertexIndicesWeightsPositionNormal.cs
│ └── README.md
├── Logo
│ ├── GeonBitLogo-simple.psd
│ ├── GeonBitLogo.psd
│ ├── README.md
│ ├── icon.ico
│ ├── main-simple.png
│ ├── main.png
│ ├── nuget.png
│ ├── square-simple-with-bg.png
│ ├── square-simple.ico
│ ├── square-simple.png
│ └── square.png
├── Program.cs
├── Properties
│ └── AssemblyInfo.cs
├── README.md
├── Source
│ ├── Core
│ │ ├── CoreManager.cs
│ │ ├── Exceptions.cs
│ │ ├── Graphics
│ │ │ ├── Entities
│ │ │ │ ├── BaseRenderableEntity.cs
│ │ │ │ ├── BoundingBoxEntity.cs
│ │ │ │ ├── CombinedMeshesEntity.cs
│ │ │ │ ├── CompositeModelEntity.cs
│ │ │ │ ├── IEntity.cs
│ │ │ │ ├── MaterialOverrides.cs
│ │ │ │ ├── MeshEntity.cs
│ │ │ │ ├── ModelEntity.cs
│ │ │ │ ├── SimpleModelEntity.cs
│ │ │ │ ├── SkinnedModelEntity.cs
│ │ │ │ ├── SpriteEntity.cs
│ │ │ │ └── SpriteSheet.cs
│ │ │ ├── GraphicsManager.cs
│ │ │ ├── Lights
│ │ │ │ ├── DeferredLighting.cs
│ │ │ │ ├── ILightsManager.cs
│ │ │ │ ├── LightSource.cs
│ │ │ │ └── LightsManager.cs
│ │ │ ├── Materials
│ │ │ │ ├── AlphaTestMaterial.cs
│ │ │ │ ├── BasicMaterial.cs
│ │ │ │ ├── DefaultMaterialsFactory.cs
│ │ │ │ ├── LitMaterial.cs
│ │ │ │ ├── LitMaterialAlphaTest.cs
│ │ │ │ ├── MaterialAPI.cs
│ │ │ │ ├── NormalMapLitMaterial.cs
│ │ │ │ ├── SkinnedMaterial.cs
│ │ │ │ ├── SkyboxMaterial.cs
│ │ │ │ └── SpriteMaterial.cs
│ │ │ ├── Misc
│ │ │ │ ├── CameraEntity.cs
│ │ │ │ ├── ExtendedVertices.cs
│ │ │ │ └── ModelUtils.cs
│ │ │ ├── Nodes
│ │ │ │ ├── BoundingBoxCullingNode.cs
│ │ │ │ ├── BoundingSphereCullingNode.cs
│ │ │ │ ├── CullingNode.cs
│ │ │ │ ├── Node.cs
│ │ │ │ ├── NodesManager.cs
│ │ │ │ ├── OctreeCullingNode.cs
│ │ │ │ └── ParticlesNode.cs
│ │ │ └── RenderingQueues.cs
│ │ ├── Input
│ │ │ ├── GameKeys.cs
│ │ │ ├── Keys.cs
│ │ │ └── Mouse.cs
│ │ ├── Physics
│ │ │ ├── BasicPhysicalBody.cs
│ │ │ ├── CollisionGroups.cs
│ │ │ ├── CollisionShapes
│ │ │ │ ├── CollisionBox.cs
│ │ │ │ ├── CollisionBox2d.cs
│ │ │ │ ├── CollisionCapsule.cs
│ │ │ │ ├── CollisionCompoundShape.cs
│ │ │ │ ├── CollisionCone.cs
│ │ │ │ ├── CollisionConvexHull.cs
│ │ │ │ ├── CollisionCylinder.cs
│ │ │ │ ├── CollisionEndlessPlane.cs
│ │ │ │ ├── CollisionHeightMap.cs
│ │ │ │ ├── CollisionSphere.cs
│ │ │ │ ├── CollisionTriangle.cs
│ │ │ │ └── ICollisionShape.cs
│ │ │ ├── Convert.cs
│ │ │ ├── DebugDrawer.cs
│ │ │ ├── KinematicBody.cs
│ │ │ ├── RigidBody.cs
│ │ │ ├── StaticBody.cs
│ │ │ └── World.cs
│ │ ├── README.md
│ │ ├── Resources
│ │ │ └── ResourcesManager.cs
│ │ ├── Sound
│ │ │ └── SoundPlayer.cs
│ │ ├── Transformations
│ │ │ └── Transformations.cs
│ │ └── Utils
│ │ │ ├── CountAndAlert.cs
│ │ │ ├── ExtendedMath.cs
│ │ │ └── ResizeableArray.cs
│ ├── ECS
│ │ ├── Components
│ │ │ ├── BaseComponent.cs
│ │ │ ├── Graphics
│ │ │ │ ├── Backgrounds
│ │ │ │ │ ├── SceneBackground.cs
│ │ │ │ │ └── SkyBox.cs
│ │ │ │ ├── Camera.cs
│ │ │ │ ├── Docs.cs
│ │ │ │ ├── Light.cs
│ │ │ │ └── Renderers
│ │ │ │ │ ├── BaseRenderer.cs
│ │ │ │ │ ├── BaseRendererWithOverrideMaterial.cs
│ │ │ │ │ ├── BillboardRenderer.cs
│ │ │ │ │ ├── BoundingBoxRenderer.cs
│ │ │ │ │ ├── CombinedMeshesRenderer.cs
│ │ │ │ │ ├── CompositeModelRenderer.cs
│ │ │ │ │ ├── ModelMeshRenderer.cs
│ │ │ │ │ ├── ModelRenderer.cs
│ │ │ │ │ ├── ShapeRenderer.cs
│ │ │ │ │ ├── SimpleModelRenderer.cs
│ │ │ │ │ ├── SkinnedModelRenderer.cs
│ │ │ │ │ └── SpriteRenderer.cs
│ │ │ ├── IComponent.cs
│ │ │ ├── Misc
│ │ │ │ ├── CameraEditorController.cs
│ │ │ │ ├── Docs.cs
│ │ │ │ ├── TileMap.cs
│ │ │ │ └── TimeToLive.cs
│ │ │ ├── Particles
│ │ │ │ ├── Animators
│ │ │ │ │ ├── AnimatorUtils.cs
│ │ │ │ │ ├── BaseAnimator.cs
│ │ │ │ │ ├── Color.cs
│ │ │ │ │ ├── Fade.cs
│ │ │ │ │ ├── Motion.cs
│ │ │ │ │ ├── Rotation.cs
│ │ │ │ │ ├── Scale.cs
│ │ │ │ │ └── SpawnRandomizer.cs
│ │ │ │ ├── Docs.cs
│ │ │ │ └── ParticleSystem.cs
│ │ │ ├── Physics
│ │ │ │ ├── BasePhysicsComponent.cs
│ │ │ │ ├── BodyShapesInfo.cs
│ │ │ │ ├── Docs.cs
│ │ │ │ ├── KinematicBody.cs
│ │ │ │ ├── RigidBody.cs
│ │ │ │ └── StaticBody.cs
│ │ │ └── Sound
│ │ │ │ ├── BackgroundMusic.cs
│ │ │ │ ├── Docs.cs
│ │ │ │ └── SoundEffect.cs
│ │ ├── GameObject.cs
│ │ ├── GameScene.cs
│ │ └── README.md
│ ├── Main
│ │ ├── GeonBitGame.cs
│ │ ├── GeonBitMain.cs
│ │ ├── MonoGameWrapper.cs
│ │ └── README.md
│ ├── Managers
│ │ ├── Application.cs
│ │ ├── ConfigStorage.cs
│ │ ├── Diagnostic.cs
│ │ ├── EasyManagersGetters.cs
│ │ ├── GameFiles.cs
│ │ ├── GameInput.cs
│ │ ├── GraphicsManager.cs
│ │ ├── IManager.cs
│ │ ├── Plugins.cs
│ │ ├── Prototypes.cs
│ │ ├── README.md
│ │ ├── SoundManager.cs
│ │ └── TimeManager.cs
│ └── README.md
├── app.manifest
└── packages.config
├── LICENSE
├── PluginTemplate
├── GeonBitPluginTemplate.zip
└── README.md
├── README.md
├── Template
├── GeonBit Desktop Application.zip
└── README.md
├── docs
├── CNAME
├── Documentation.chm
├── README.md
├── _config.yml
├── assets
│ ├── GeonBit-sm.png
│ ├── UI-example1.png
│ ├── ecs-explained.pptx
│ ├── ecs-model.png
│ ├── ecs-vs-non-ecs.png
│ ├── example1.png
│ ├── examples.jpg
│ ├── non-ecs-model.png
│ ├── octree.png
│ ├── overview.jpg
│ ├── overview.pptx
│ ├── physics.png
│ ├── spaceship-demo.png
│ ├── sprite.png
│ ├── template-project.png
│ └── template-window.png
├── build.py
├── changes.md
├── chapters
│ ├── (alternative)_manual_setup.md
│ ├── advanced_topics.md
│ ├── cookbook.md
│ ├── demos.md
│ ├── geonbit_overview.md
│ ├── glossary.md
│ ├── intro.md
│ ├── misc.md
│ ├── plugins.md
│ ├── setup.md
│ └── using_geonbit.md
└── index.md
├── geonbit.shfbproj
└── readme.txt
/.gitattributes:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # Set default behavior to automatically normalize line endings.
3 | ###############################################################################
4 | * text=auto
5 |
6 | ###############################################################################
7 | # Set default behavior for command prompt diff.
8 | #
9 | # This is need for earlier builds of msysgit that does not have it on by
10 | # default for csharp files.
11 | # Note: This is only used by command line
12 | ###############################################################################
13 | #*.cs diff=csharp
14 |
15 | ###############################################################################
16 | # Set the merge driver for project and solution files
17 | #
18 | # Merging from the command prompt will add diff markers to the files if there
19 | # are conflicts (Merging from VS is not affected by the settings below, in VS
20 | # the diff markers are never inserted). Diff markers may cause the following
21 | # file extensions to fail to load in VS. An alternative would be to treat
22 | # these files as binary and thus will always conflict and require user
23 | # intervention with every merge. To do so, just uncomment the entries below
24 | ###############################################################################
25 | #*.sln merge=binary
26 | #*.csproj merge=binary
27 | #*.vbproj merge=binary
28 | #*.vcxproj merge=binary
29 | #*.vcproj merge=binary
30 | #*.dbproj merge=binary
31 | #*.fsproj merge=binary
32 | #*.lsproj merge=binary
33 | #*.wixproj merge=binary
34 | #*.modelproj merge=binary
35 | #*.sqlproj merge=binary
36 | #*.wwaproj merge=binary
37 |
38 | ###############################################################################
39 | # behavior for image files
40 | #
41 | # image files are treated as binary by default.
42 | ###############################################################################
43 | #*.jpg binary
44 | #*.png binary
45 | #*.gif binary
46 |
47 | ###############################################################################
48 | # diff behavior for common document formats
49 | #
50 | # Convert binary document formats to text before diffing them. This feature
51 | # is only available from the command line. Turn it on by uncommenting the
52 | # entries below.
53 | ###############################################################################
54 | #*.doc diff=astextplain
55 | #*.DOC diff=astextplain
56 | #*.docx diff=astextplain
57 | #*.DOCX diff=astextplain
58 | #*.dot diff=astextplain
59 | #*.DOT diff=astextplain
60 | #*.pdf diff=astextplain
61 | #*.PDF diff=astextplain
62 | #*.rtf diff=astextplain
63 | #*.RTF diff=astextplain
64 |
--------------------------------------------------------------------------------
/GeonBit.nuspec:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | GeonBit
5 | 0.1.0.8
6 | Ronen Ness
7 | RonenNess
8 | GeonBit.Core
9 | GeonBit is a 3D Entity-Component-System engine, powered by MonoGame for C# games.
10 | https://github.com/RonenNess/GeonBit/blob/master/LICENSE
11 | https://github.com/RonenNess/GeonBit
12 | https://raw.githubusercontent.com/RonenNess/GeonBit/master/GeonBit/Logo/nuget.png
13 | Ronen Ness
14 | true
15 | Updated GeonBit.UI version, lots of misc improvements and bug fixes.
16 | ECS game engine in MonoGame and C#.
17 | monogame gamedev game-engine games ecs entity-component
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/GeonBit/Content/GeonBit.Core/BasicMeshes/Cone.fbx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RonenNess/GeonBit/988989b71e3ea695778d12cee264f0f849ab06c7/GeonBit/Content/GeonBit.Core/BasicMeshes/Cone.fbx
--------------------------------------------------------------------------------
/GeonBit/Content/GeonBit.Core/BasicMeshes/Cube.fbx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RonenNess/GeonBit/988989b71e3ea695778d12cee264f0f849ab06c7/GeonBit/Content/GeonBit.Core/BasicMeshes/Cube.fbx
--------------------------------------------------------------------------------
/GeonBit/Content/GeonBit.Core/BasicMeshes/Cylinder.fbx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RonenNess/GeonBit/988989b71e3ea695778d12cee264f0f849ab06c7/GeonBit/Content/GeonBit.Core/BasicMeshes/Cylinder.fbx
--------------------------------------------------------------------------------
/GeonBit/Content/GeonBit.Core/BasicMeshes/Plane.fbx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RonenNess/GeonBit/988989b71e3ea695778d12cee264f0f849ab06c7/GeonBit/Content/GeonBit.Core/BasicMeshes/Plane.fbx
--------------------------------------------------------------------------------
/GeonBit/Content/GeonBit.Core/BasicMeshes/Skybox.fbx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RonenNess/GeonBit/988989b71e3ea695778d12cee264f0f849ab06c7/GeonBit/Content/GeonBit.Core/BasicMeshes/Skybox.fbx
--------------------------------------------------------------------------------
/GeonBit/Content/GeonBit.Core/BasicMeshes/Sphere.fbx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RonenNess/GeonBit/988989b71e3ea695778d12cee264f0f849ab06c7/GeonBit/Content/GeonBit.Core/BasicMeshes/Sphere.fbx
--------------------------------------------------------------------------------
/GeonBit/Content/GeonBit.Core/BasicMeshes/SphereLowPoly.fbx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RonenNess/GeonBit/988989b71e3ea695778d12cee264f0f849ab06c7/GeonBit/Content/GeonBit.Core/BasicMeshes/SphereLowPoly.fbx
--------------------------------------------------------------------------------
/GeonBit/Content/GeonBit.Core/BasicMeshes/SphereSmooth.fbx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RonenNess/GeonBit/988989b71e3ea695778d12cee264f0f849ab06c7/GeonBit/Content/GeonBit.Core/BasicMeshes/SphereSmooth.fbx
--------------------------------------------------------------------------------
/GeonBit/Content/GeonBit.Core/Textures/Skybox.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RonenNess/GeonBit/988989b71e3ea695778d12cee264f0f849ab06c7/GeonBit/Content/GeonBit.Core/Textures/Skybox.png
--------------------------------------------------------------------------------
/GeonBit/Content/README.md:
--------------------------------------------------------------------------------
1 | # Content
2 |
3 | Built-in content that comes with GeonBit.
--------------------------------------------------------------------------------
/GeonBit/Icon.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RonenNess/GeonBit/988989b71e3ea695778d12cee264f0f849ab06c7/GeonBit/Icon.bmp
--------------------------------------------------------------------------------
/GeonBit/Icon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RonenNess/GeonBit/988989b71e3ea695778d12cee264f0f849ab06c7/GeonBit/Icon.ico
--------------------------------------------------------------------------------
/GeonBit/Libs/Content.Pipeline/AnimationImporters/Animation/AnimationsContent.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | /// -------------------------------------------------------------------------------------
3 | /// Notice: This file had been edited to integrate as core inside GeonBit.
4 | /// Original license and attributes below. The license and copyright notice below affect
5 | /// this file and this file only. https://github.com/tainicom/Aether.Extras
6 | /// -------------------------------------------------------------------------------------
7 | // Copyright 2011-2016 Kastellanos Nikolaos
8 | //
9 | // Licensed under the Apache License, Version 2.0 (the "License");
10 | // you may not use this file except in compliance with the License.
11 | // You may obtain a copy of the License at
12 | //
13 | // http://www.apache.org/licenses/LICENSE-2.0
14 | //
15 | // Unless required by applicable law or agreed to in writing, software
16 | // distributed under the License is distributed on an "AS IS" BASIS,
17 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 | // See the License for the specific language governing permissions and
19 | // limitations under the License.
20 | #endregion
21 |
22 | using System.Collections.Generic;
23 | using Microsoft.Xna.Framework;
24 |
25 | namespace GeonBit.Content.Pipeline.Animation
26 | {
27 | public class AnimationsContent
28 | {
29 | public List BindPose { get; private set; }
30 | public List InvBindPose { get; private set; }
31 | public List SkeletonHierarchy { get; private set; }
32 | public List BoneNames { get; private set; }
33 | public Dictionary Clips { get; private set; }
34 |
35 |
36 | internal AnimationsContent(List bindPose, List invBindPose, List skeletonHierarchy, List boneNames, Dictionary clips)
37 | {
38 | BindPose = bindPose;
39 | InvBindPose = invBindPose;
40 | SkeletonHierarchy = skeletonHierarchy;
41 | BoneNames = boneNames;
42 | Clips = clips;
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/GeonBit/Libs/Content.Pipeline/AnimationImporters/Animation/ClipContent.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | /// -------------------------------------------------------------------------------------
3 | /// Notice: This file had been edited to integrate as core inside GeonBit.
4 | /// Original license and attributes below. The license and copyright notice below affect
5 | /// this file and this file only. https://github.com/tainicom/Aether.Extras
6 | /// -------------------------------------------------------------------------------------
7 | // Copyright 2011-2016 Kastellanos Nikolaos
8 | //
9 | // Licensed under the Apache License, Version 2.0 (the "License");
10 | // you may not use this file except in compliance with the License.
11 | // You may obtain a copy of the License at
12 | //
13 | // http://www.apache.org/licenses/LICENSE-2.0
14 | //
15 | // Unless required by applicable law or agreed to in writing, software
16 | // distributed under the License is distributed on an "AS IS" BASIS,
17 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 | // See the License for the specific language governing permissions and
19 | // limitations under the License.
20 | #endregion
21 |
22 | using System;
23 |
24 | namespace GeonBit.Content.Pipeline.Animation
25 | {
26 | public class ClipContent
27 | {
28 | public TimeSpan Duration { get; internal set; }
29 | public KeyframeContent[] Keyframes { get; private set; }
30 |
31 | internal ClipContent(TimeSpan duration, KeyframeContent[] keyframes)
32 | {
33 | Duration = duration;
34 | Keyframes = keyframes;
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/GeonBit/Libs/Content.Pipeline/AnimationImporters/Animation/CpuAnimatedVertexBufferContent.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | /// -------------------------------------------------------------------------------------
3 | /// Notice: This file had been edited to integrate as core inside GeonBit.
4 | /// Original license and attributes below. The license and copyright notice below affect
5 | /// this file and this file only. https://github.com/tainicom/Aether.Extras
6 | /// -------------------------------------------------------------------------------------
7 | // Copyright 2011-2016 Kastellanos Nikolaos
8 | //
9 | // Licensed under the Apache License, Version 2.0 (the "License");
10 | // you may not use this file except in compliance with the License.
11 | // You may obtain a copy of the License at
12 | //
13 | // http://www.apache.org/licenses/LICENSE-2.0
14 | //
15 | // Unless required by applicable law or agreed to in writing, software
16 | // distributed under the License is distributed on an "AS IS" BASIS,
17 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 | // See the License for the specific language governing permissions and
19 | // limitations under the License.
20 | #endregion
21 |
22 | using Microsoft.Xna.Framework.Content.Pipeline.Processors;
23 | using GeonBit.Content.Pipeline.Graphics;
24 |
25 | namespace GeonBit.Content.Pipeline.Animation
26 | {
27 | public class CpuAnimatedVertexBufferContent : DynamicVertexBufferContent
28 | {
29 | public CpuAnimatedVertexBufferContent(VertexBufferContent source) : base(source)
30 | {
31 | }
32 |
33 |
34 | }
35 | }
--------------------------------------------------------------------------------
/GeonBit/Libs/Content.Pipeline/AnimationImporters/Animation/KeyframeContent.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | /// -------------------------------------------------------------------------------------
3 | /// Notice: This file had been edited to integrate as core inside GeonBit.
4 | /// Original license and attributes below. The license and copyright notice below affect
5 | /// this file and this file only. https://github.com/tainicom/Aether.Extras
6 | /// -------------------------------------------------------------------------------------
7 | // Copyright 2011-2016 Kastellanos Nikolaos
8 | //
9 | // Licensed under the Apache License, Version 2.0 (the "License");
10 | // you may not use this file except in compliance with the License.
11 | // You may obtain a copy of the License at
12 | //
13 | // http://www.apache.org/licenses/LICENSE-2.0
14 | //
15 | // Unless required by applicable law or agreed to in writing, software
16 | // distributed under the License is distributed on an "AS IS" BASIS,
17 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 | // See the License for the specific language governing permissions and
19 | // limitations under the License.
20 | #endregion
21 |
22 | using System;
23 | using Microsoft.Xna.Framework;
24 |
25 | namespace GeonBit.Content.Pipeline.Animation
26 | {
27 | public struct KeyframeContent
28 | {
29 | public int Bone;
30 | public TimeSpan Time;
31 | public Matrix Transform;
32 |
33 | public KeyframeContent(int bone, TimeSpan time, Matrix transform)
34 | {
35 | this.Bone = bone;
36 | this.Time = time;
37 | this.Transform = transform;
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/GeonBit/Libs/Content.Pipeline/AnimationImporters/Processors/GpuAnimatedModelProcessor.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | /// -------------------------------------------------------------------------------------
3 | /// Notice: This file had been edited to integrate as core inside GeonBit.
4 | /// Original license and attributes below. The license and copyright notice below affect
5 | /// this file and this file only. https://github.com/tainicom/Aether.Extras
6 | /// -------------------------------------------------------------------------------------
7 | // Copyright 2011-2016 Kastellanos Nikolaos
8 | //
9 | // Licensed under the Apache License, Version 2.0 (the "License");
10 | // you may not use this file except in compliance with the License.
11 | // You may obtain a copy of the License at
12 | //
13 | // http://www.apache.org/licenses/LICENSE-2.0
14 | //
15 | // Unless required by applicable law or agreed to in writing, software
16 | // distributed under the License is distributed on an "AS IS" BASIS,
17 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 | // See the License for the specific language governing permissions and
19 | // limitations under the License.
20 | #endregion
21 |
22 | using System.ComponentModel;
23 | using Microsoft.Xna.Framework.Content.Pipeline;
24 | using Microsoft.Xna.Framework.Content.Pipeline.Graphics;
25 | using Microsoft.Xna.Framework.Content.Pipeline.Processors;
26 | using Microsoft.Xna.Framework.Graphics;
27 |
28 | namespace GeonBit.Content.Pipeline.Processors
29 | {
30 | [ContentProcessor(DisplayName = "GPU AnimatedModel - GeonBit")]
31 | public class GpuAnimatedModelProcessor : ModelProcessor
32 | {
33 | private int _maxBones = SkinnedEffect.MaxBones;
34 | private int _generateKeyframesFrequency = 0;
35 | private bool _fixRealBoneRoot = false;
36 |
37 | #if !PORTABLE
38 | [DisplayName("MaxBones")]
39 | #endif
40 | [DefaultValue(SkinnedEffect.MaxBones)]
41 | public virtual int MaxBones
42 | {
43 | get { return _maxBones; }
44 | set { _maxBones = value; }
45 | }
46 |
47 | #if !PORTABLE
48 | [DisplayName("Generate Keyframes Frequency")]
49 | #endif
50 | [DefaultValue(0)] // (0=no, 30=30fps, 60=60fps)
51 | public virtual int GenerateKeyframesFrequency
52 | {
53 | get { return _generateKeyframesFrequency; }
54 | set { _generateKeyframesFrequency = value; }
55 | }
56 |
57 | #if !PORTABLE
58 | [DisplayName("Fix BoneRoot from MG importer")]
59 | #endif
60 | [DefaultValue(false)]
61 | public virtual bool FixRealBoneRoot
62 | {
63 | get { return _fixRealBoneRoot; }
64 | set { _fixRealBoneRoot = value; }
65 | }
66 |
67 | [DefaultValue(MaterialProcessorDefaultEffect.SkinnedEffect)]
68 | public override MaterialProcessorDefaultEffect DefaultEffect
69 | {
70 | get { return base.DefaultEffect; }
71 | set { base.DefaultEffect = value; }
72 | }
73 |
74 | public GpuAnimatedModelProcessor()
75 | {
76 | DefaultEffect = MaterialProcessorDefaultEffect.SkinnedEffect;
77 | }
78 |
79 | public override ModelContent Process(NodeContent input, ContentProcessorContext context)
80 | {
81 | var animationProcessor = new AnimationsProcessor();
82 | animationProcessor.MaxBones = this.MaxBones;
83 | animationProcessor.GenerateKeyframesFrequency = this.GenerateKeyframesFrequency;
84 | animationProcessor.FixRealBoneRoot = this._fixRealBoneRoot;
85 | var animation = animationProcessor.Process(input, context);
86 |
87 | ModelContent model = base.Process(input, context);
88 | model.Tag = animation;
89 | return model;
90 | }
91 | }
92 | }
93 |
--------------------------------------------------------------------------------
/GeonBit/Libs/Content.Pipeline/AnimationImporters/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("AnimationImporters")]
9 | [assembly: AssemblyProduct("AnimationImporters")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyDescription("")]
12 | [assembly: AssemblyCompany("")]
13 | [assembly: AssemblyCopyright("Copyright © 2017")]
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("0e4ed2dc-0dfc-4b68-93d5-a317b461e264")]
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 |
--------------------------------------------------------------------------------
/GeonBit/Libs/Content.Pipeline/AnimationImporters/Serialization/AnimationsWriter.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | /// -------------------------------------------------------------------------------------
3 | /// Notice: This file had been edited to integrate as core inside GeonBit.
4 | /// Original license and attributes below. The license and copyright notice below affect
5 | /// this file and this file only. https://github.com/tainicom/Aether.Extras
6 | /// -------------------------------------------------------------------------------------
7 | // Copyright 2011-2016 Kastellanos Nikolaos
8 | //
9 | // Licensed under the Apache License, Version 2.0 (the "License");
10 | // you may not use this file except in compliance with the License.
11 | // You may obtain a copy of the License at
12 | //
13 | // http://www.apache.org/licenses/LICENSE-2.0
14 | //
15 | // Unless required by applicable law or agreed to in writing, software
16 | // distributed under the License is distributed on an "AS IS" BASIS,
17 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 | // See the License for the specific language governing permissions and
19 | // limitations under the License.
20 | #endregion
21 |
22 | using System;
23 | using System.Collections.Generic;
24 | using Microsoft.Xna.Framework.Content.Pipeline;
25 | using Microsoft.Xna.Framework.Content.Pipeline.Serialization.Compiler;
26 | using GeonBit.Content.Pipeline.Animation;
27 |
28 | namespace GeonBit.Content.Pipeline.Serialization
29 | {
30 | [ContentTypeWriter]
31 | class AnimationsDataWriter : ContentTypeWriter
32 | {
33 | protected override void Write(ContentWriter output, AnimationsContent value)
34 | {
35 | WriteClips(output, value.Clips);
36 | WriteBindPose(output, value.BindPose);
37 | WriteInvBindPose(output, value.InvBindPose);
38 | WriteSkeletonHierarchy(output, value.SkeletonHierarchy);
39 | WriteBoneNames(output, value.BoneNames);
40 | }
41 |
42 | private void WriteClips(ContentWriter output, Dictionary clips)
43 | {
44 | Int32 count = clips.Count;
45 | output.Write((Int32)count);
46 |
47 | foreach (var clip in clips)
48 | {
49 | output.Write(clip.Key);
50 | output.WriteObject(clip.Value);
51 | }
52 |
53 | return;
54 | }
55 |
56 | private void WriteBindPose(ContentWriter output, List bindPoses)
57 | {
58 | Int32 count = bindPoses.Count;
59 | output.Write((Int32)count);
60 |
61 | for (int i = 0; i < count; i++)
62 | output.Write(bindPoses[i]);
63 |
64 | return;
65 | }
66 |
67 | private void WriteInvBindPose(ContentWriter output, List invBindPoses)
68 | {
69 | Int32 count = invBindPoses.Count;
70 | output.Write((Int32)count);
71 |
72 | for (int i = 0; i < count; i++)
73 | output.Write(invBindPoses[i]);
74 |
75 | return;
76 | }
77 |
78 | private void WriteSkeletonHierarchy(ContentWriter output, List skeletonHierarchy)
79 | {
80 | Int32 count = skeletonHierarchy.Count;
81 | output.Write((Int32)count);
82 |
83 | for (int i = 0; i < count; i++)
84 | output.Write((Int32)skeletonHierarchy[i]);
85 |
86 | return;
87 | }
88 |
89 | private void WriteBoneNames(ContentWriter output, List boneNames)
90 | {
91 | Int32 count = boneNames.Count;
92 | output.Write((Int32)count);
93 |
94 | for (int boneIndex = 0; boneIndex < count; boneIndex++)
95 | {
96 | var boneName = boneNames[boneIndex];
97 | output.Write(boneName);
98 | }
99 |
100 | return;
101 | }
102 |
103 | public override string GetRuntimeType(TargetPlatform targetPlatform)
104 | {
105 | return "GeonBit.Extend.Animation.Animations, " +
106 | typeof(GeonBit.Extend.Animation.Animations).Assembly.FullName;
107 | }
108 |
109 | public override string GetRuntimeReader(TargetPlatform targetPlatform)
110 | {
111 | return "GeonBit.Extend.Animation.Content.AnimationsReader, " +
112 | typeof(GeonBit.Extend.Animation.Content.AnimationsReader).Assembly.FullName;
113 | }
114 | }
115 |
116 | }
117 |
--------------------------------------------------------------------------------
/GeonBit/Libs/Content.Pipeline/AnimationImporters/Serialization/ClipWriter.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | /// -------------------------------------------------------------------------------------
3 | /// Notice: This file had been edited to integrate as core inside GeonBit.
4 | /// Original license and attributes below. The license and copyright notice below affect
5 | /// this file and this file only. https://github.com/tainicom/Aether.Extras
6 | /// -------------------------------------------------------------------------------------
7 | // Copyright 2011-2016 Kastellanos Nikolaos
8 | //
9 | // Licensed under the Apache License, Version 2.0 (the "License");
10 | // you may not use this file except in compliance with the License.
11 | // You may obtain a copy of the License at
12 | //
13 | // http://www.apache.org/licenses/LICENSE-2.0
14 | //
15 | // Unless required by applicable law or agreed to in writing, software
16 | // distributed under the License is distributed on an "AS IS" BASIS,
17 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 | // See the License for the specific language governing permissions and
19 | // limitations under the License.
20 | #endregion
21 |
22 | using System;
23 | using System.Collections.Generic;
24 | using Microsoft.Xna.Framework.Content.Pipeline;
25 | using Microsoft.Xna.Framework.Content.Pipeline.Serialization.Compiler;
26 | using GeonBit.Content.Pipeline.Animation;
27 |
28 |
29 | namespace GeonBit.Content.Pipeline.Serialization
30 | {
31 | [ContentTypeWriter]
32 | class ClipWriter : ContentTypeWriter
33 | {
34 | protected override void Write(ContentWriter output, ClipContent value)
35 | {
36 | WriteDuration(output, value.Duration);
37 | WriteKeyframes(output, value.Keyframes);
38 | }
39 |
40 | private void WriteDuration(ContentWriter output, TimeSpan duration)
41 | {
42 | output.Write(duration.Ticks);
43 | }
44 |
45 | private void WriteKeyframes(ContentWriter output, IList keyframes)
46 | {
47 | Int32 count = keyframes.Count;
48 | output.Write((Int32)count);
49 |
50 | for (int i = 0; i < count; i++)
51 | {
52 | KeyframeContent keyframe = keyframes[i];
53 | output.Write(keyframe.Bone);
54 | output.Write(keyframe.Time.Ticks);
55 | output.Write(keyframe.Transform.M11);
56 | output.Write(keyframe.Transform.M12);
57 | output.Write(keyframe.Transform.M13);
58 | output.Write(keyframe.Transform.M21);
59 | output.Write(keyframe.Transform.M22);
60 | output.Write(keyframe.Transform.M23);
61 | output.Write(keyframe.Transform.M31);
62 | output.Write(keyframe.Transform.M32);
63 | output.Write(keyframe.Transform.M33);
64 | output.Write(keyframe.Transform.M41);
65 | output.Write(keyframe.Transform.M42);
66 | output.Write(keyframe.Transform.M43);
67 | }
68 |
69 | return;
70 | }
71 |
72 | public override string GetRuntimeType(TargetPlatform targetPlatform)
73 | {
74 | return "GeonBit.Extend.Animation.Clip, " +
75 | typeof(GeonBit.Extend.Animation.Clip).Assembly.FullName;
76 | }
77 |
78 | public override string GetRuntimeReader(TargetPlatform targetPlatform)
79 | {
80 | return "GeonBit.Extend.Animation.Content.ClipReader, " +
81 | typeof(GeonBit.Extend.Animation.Content.ClipReader).Assembly.FullName;
82 | }
83 | }
84 |
85 | }
86 |
--------------------------------------------------------------------------------
/GeonBit/Libs/Content.Pipeline/AnimationImporters/Serialization/CpuAnimatedVertexBufferWriter.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | /// -------------------------------------------------------------------------------------
3 | /// Notice: This file had been edited to integrate as core inside GeonBit.
4 | /// Original license and attributes below. The license and copyright notice below affect
5 | /// this file and this file only. https://github.com/tainicom/Aether.Extras
6 | /// -------------------------------------------------------------------------------------
7 | // Copyright 2011-2016 Kastellanos Nikolaos
8 | //
9 | // Licensed under the Apache License, Version 2.0 (the "License");
10 | // you may not use this file except in compliance with the License.
11 | // You may obtain a copy of the License at
12 | //
13 | // http://www.apache.org/licenses/LICENSE-2.0
14 | //
15 | // Unless required by applicable law or agreed to in writing, software
16 | // distributed under the License is distributed on an "AS IS" BASIS,
17 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 | // See the License for the specific language governing permissions and
19 | // limitations under the License.
20 | #endregion
21 |
22 | using System;
23 | using Microsoft.Xna.Framework.Content.Pipeline;
24 | using Microsoft.Xna.Framework.Content.Pipeline.Serialization.Compiler;
25 | using GeonBit.Content.Pipeline.Animation;
26 | using GeonBit.Content.Pipeline.Graphics;
27 |
28 | namespace GeonBit.Content.Pipeline.Serialization
29 | {
30 | [ContentTypeWriter]
31 | public class CpuAnimatedVertexBufferWriter : ContentTypeWriter
32 | {
33 | protected override void Write(ContentWriter output, CpuAnimatedVertexBufferContent buffer)
34 | {
35 | WriteVertexBuffer(output, buffer);
36 |
37 | output.Write(buffer.IsWriteOnly);
38 | }
39 |
40 | private void WriteVertexBuffer(ContentWriter output, DynamicVertexBufferContent buffer)
41 | {
42 | var vertexCount = buffer.VertexData.Length / buffer.VertexDeclaration.VertexStride;
43 | output.WriteRawObject(buffer.VertexDeclaration);
44 | output.Write((UInt32)vertexCount);
45 | output.Write(buffer.VertexData);
46 | }
47 |
48 | public override string GetRuntimeReader(TargetPlatform targetPlatform)
49 | {
50 | return "GeonBit.Extend.Animation.Content.CpuAnimatedVertexBufferReader, " +
51 | typeof(GeonBit.Extend.Animation.Content.CpuAnimatedVertexBufferReader).Assembly.FullName;
52 | }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/GeonBit/Libs/Content.Pipeline/GraphicsImporters/Graphics/DynamicIndexBufferContent.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | // Copyright 2016 Kastellanos Nikolaos
3 | //
4 | // Licensed under the Apache License, Version 2.0 (the "License");
5 | // you may not use this file except in compliance with the License.
6 | // You may obtain a copy of the License at
7 | //
8 | // http://www.apache.org/licenses/LICENSE-2.0
9 | //
10 | // Unless required by applicable law or agreed to in writing, software
11 | // distributed under the License is distributed on an "AS IS" BASIS,
12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | // See the License for the specific language governing permissions and
14 | // limitations under the License.
15 | #endregion
16 |
17 | using System.Collections.Generic;
18 | using System.Collections.ObjectModel;
19 |
20 | namespace GeonBit.Content.Pipeline.Graphics
21 | {
22 | public class DynamicIndexBufferContent: Collection
23 | {
24 | protected internal Collection Source { get; protected set; }
25 |
26 | public bool IsWriteOnly = false;
27 |
28 | new public int Count { get { return Source.Count; } }
29 |
30 | public DynamicIndexBufferContent(Collection source)
31 | {
32 | Source = source;
33 | }
34 |
35 | public new IEnumerator GetEnumerator()
36 | {
37 | return Source.GetEnumerator();
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/GeonBit/Libs/Content.Pipeline/GraphicsImporters/Graphics/DynamicModelContent.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | // Copyright 2016 Kastellanos Nikolaos
3 | //
4 | // Licensed under the Apache License, Version 2.0 (the "License");
5 | // you may not use this file except in compliance with the License.
6 | // You may obtain a copy of the License at
7 | //
8 | // http://www.apache.org/licenses/LICENSE-2.0
9 | //
10 | // Unless required by applicable law or agreed to in writing, software
11 | // distributed under the License is distributed on an "AS IS" BASIS,
12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | // See the License for the specific language governing permissions and
14 | // limitations under the License.
15 | #endregion
16 |
17 | using System;
18 | using System.Collections.Generic;
19 | using Microsoft.Xna.Framework.Content;
20 | using Microsoft.Xna.Framework.Content.Pipeline.Processors;
21 |
22 | namespace GeonBit.Content.Pipeline.Graphics
23 | {
24 | public class DynamicModelContent
25 | {
26 | [Flags]
27 | public enum BufferType : int
28 | {
29 | ///
30 | /// Use the default BufferReader
31 | ///
32 | Default = int.MinValue,
33 |
34 | ///
35 | /// Deserialize a Dynamic Buffer
36 | ///
37 | Dynamic = 0,
38 |
39 | ///
40 | /// Deserialize a Dynamic Buffer with BufferUsage.WriteOnly
41 | ///
42 | DynamicWriteOnly = 0x01,
43 | }
44 |
45 | protected internal ModelContent Source { get; protected set; }
46 | public BufferType VertexBufferType = BufferType.Dynamic;
47 | public BufferType IndexBufferType = BufferType.Dynamic;
48 |
49 | // Summary:
50 | // Gets the collection of bones that are referenced by this model.
51 | public ModelBoneContentCollection Bones { get { return Source.Bones; } }
52 |
53 | // Summary:
54 | // Gets the collection of meshes that are associated with this model.
55 | [ContentSerializerIgnore]
56 | public List Meshes { get; private set; }
57 |
58 | // Summary:
59 | // Gets the root bone of this model
60 | [ContentSerializerIgnore]
61 | public ModelBoneContent Root { get { return Source.Root; } }
62 |
63 | // Summary:
64 | // Gets a user defined tag object.
65 | [ContentSerializer(SharedResource = true)]
66 | public object Tag { get { return Source.Tag; } set { Source.Tag = value; } }
67 |
68 | public DynamicModelContent(ModelContent source)
69 | {
70 | this.Source = source;
71 |
72 | //deep clone Meshes
73 | Meshes = new List(source.Meshes.Count);
74 | foreach(var mesh in source.Meshes)
75 | Meshes.Add(new DynamicModelMeshContent(mesh));
76 | }
77 |
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/GeonBit/Libs/Content.Pipeline/GraphicsImporters/Graphics/DynamicModelMeshContent.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | // Copyright 2016 Kastellanos Nikolaos
3 | //
4 | // Licensed under the Apache License, Version 2.0 (the "License");
5 | // you may not use this file except in compliance with the License.
6 | // You may obtain a copy of the License at
7 | //
8 | // http://www.apache.org/licenses/LICENSE-2.0
9 | //
10 | // Unless required by applicable law or agreed to in writing, software
11 | // distributed under the License is distributed on an "AS IS" BASIS,
12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | // See the License for the specific language governing permissions and
14 | // limitations under the License.
15 | #endregion
16 |
17 | using System.Collections.Generic;
18 | using Microsoft.Xna.Framework;
19 | using Microsoft.Xna.Framework.Content;
20 | using Microsoft.Xna.Framework.Content.Pipeline.Processors;
21 |
22 | namespace GeonBit.Content.Pipeline.Graphics
23 | {
24 | public class DynamicModelMeshContent
25 | {
26 | protected internal ModelMeshContent Source { get; protected set; }
27 |
28 | // Summary:
29 | // Gets the mesh name.
30 | public string Name { get { return Source.Name; } }
31 |
32 | // Summary:
33 | // Gets the parent bone.
34 | [ContentSerializerIgnore]
35 | public ModelBoneContent ParentBone { get { return Source.ParentBone; } }
36 |
37 | // Summary:
38 | // Gets the bounding sphere for this mesh.
39 | public BoundingSphere BoundingSphere { get { return Source.BoundingSphere; } }
40 |
41 | // Summary:
42 | // Gets the children mesh parts associated with this mesh.
43 | [ContentSerializerIgnore]
44 | public List MeshParts { get; private set; }
45 |
46 | // Summary:
47 | // Gets a user defined tag object.
48 | [ContentSerializer(SharedResource = true)]
49 | public object Tag { get { return Source.Tag; } set { Source.Tag = value; } }
50 |
51 |
52 | public DynamicModelMeshContent(ModelMeshContent source)
53 | {
54 | this.Source = source;
55 |
56 | //deep clone MeshParts
57 | MeshParts = new List(source.MeshParts.Count);
58 | foreach (var mesh in source.MeshParts)
59 | MeshParts.Add(new DynamicModelMeshPartContent(mesh));
60 | }
61 |
62 | }
63 | }
--------------------------------------------------------------------------------
/GeonBit/Libs/Content.Pipeline/GraphicsImporters/Graphics/DynamicModelMeshPartContent.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | // Copyright 2016 Kastellanos Nikolaos
3 | //
4 | // Licensed under the Apache License, Version 2.0 (the "License");
5 | // you may not use this file except in compliance with the License.
6 | // You may obtain a copy of the License at
7 | //
8 | // http://www.apache.org/licenses/LICENSE-2.0
9 | //
10 | // Unless required by applicable law or agreed to in writing, software
11 | // distributed under the License is distributed on an "AS IS" BASIS,
12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | // See the License for the specific language governing permissions and
14 | // limitations under the License.
15 | #endregion
16 |
17 | using System.Collections.ObjectModel;
18 | using Microsoft.Xna.Framework.Content;
19 | using Microsoft.Xna.Framework.Content.Pipeline.Graphics;
20 | using Microsoft.Xna.Framework.Content.Pipeline.Processors;
21 |
22 | namespace GeonBit.Content.Pipeline.Graphics
23 | {
24 | public class DynamicModelMeshPartContent
25 | {
26 | protected internal ModelMeshPartContent Source { get; protected set; }
27 |
28 | // Summary:
29 | // Gets the offset, in bytes, from the first index of the of vertex buffer for this mesh part.
30 | public int VertexOffset { get; set; }
31 |
32 | // Summary:
33 | // Gets the number of vertices used in this mesh part.
34 | public int NumVertices { get; set; }
35 |
36 | // Summary:
37 | // Gets the location in the index buffer at which to start reading vertices.
38 | public int StartIndex { get; set; }
39 |
40 | // Summary:
41 | // Gets the number of primitives to render for this mesh part.
42 | public int PrimitiveCount { get; set; }
43 |
44 |
45 | // Summary:
46 | // Gets the vertex buffer associated with this mesh part.
47 | [ContentSerializerIgnore]
48 | public VertexBufferContent VertexBuffer { get; set; }
49 |
50 | // Summary:
51 | // Gets the index buffer associated with this mesh part.
52 | [ContentSerializerIgnore]
53 | public Collection IndexBuffer { get; set; }
54 |
55 | // Summary:
56 | // Gets the material of this mesh part.
57 | [ContentSerializer(SharedResource = true)]
58 | public MaterialContent Material { get; set; }
59 |
60 | // Summary:
61 | // Gets a user defined tag object.
62 | [ContentSerializer(SharedResource = true)]
63 | public object Tag { get; set; }
64 |
65 |
66 | public DynamicModelMeshPartContent(ModelMeshPartContent source)
67 | {
68 | this.Source = source;
69 | this.VertexOffset = source.VertexOffset;
70 | this.NumVertices = source.NumVertices;
71 | this.StartIndex = source.StartIndex;
72 | this.PrimitiveCount = source.PrimitiveCount;
73 | this.VertexBuffer = source.VertexBuffer;
74 | this.IndexBuffer = source.IndexBuffer;
75 | this.Material = source.Material;
76 | this.Tag = Tag;
77 | }
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/GeonBit/Libs/Content.Pipeline/GraphicsImporters/Graphics/DynamicVertexBufferContent.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | // Copyright 2016 Kastellanos Nikolaos
3 | //
4 | // Licensed under the Apache License, Version 2.0 (the "License");
5 | // you may not use this file except in compliance with the License.
6 | // You may obtain a copy of the License at
7 | //
8 | // http://www.apache.org/licenses/LICENSE-2.0
9 | //
10 | // Unless required by applicable law or agreed to in writing, software
11 | // distributed under the License is distributed on an "AS IS" BASIS,
12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | // See the License for the specific language governing permissions and
14 | // limitations under the License.
15 | #endregion
16 |
17 | using Microsoft.Xna.Framework.Content.Pipeline.Processors;
18 |
19 | namespace GeonBit.Content.Pipeline.Graphics
20 | {
21 | public class DynamicVertexBufferContent: VertexBufferContent
22 | {
23 | protected internal VertexBufferContent Source { get; protected set; }
24 |
25 | public bool IsWriteOnly = false;
26 |
27 | new public VertexDeclarationContent VertexDeclaration { get { return Source.VertexDeclaration; } }
28 |
29 | new public byte[] VertexData { get { return Source.VertexData; } }
30 |
31 | public DynamicVertexBufferContent(VertexBufferContent source):base()
32 | {
33 | Source = source;
34 | }
35 |
36 | public DynamicVertexBufferContent(VertexBufferContent source, int size):base(size)
37 | {
38 | Source = source;
39 | }
40 |
41 |
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/GeonBit/Libs/Content.Pipeline/GraphicsImporters/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("GraphicsImporters")]
9 | [assembly: AssemblyProduct("GraphicsImporters")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyDescription("")]
12 | [assembly: AssemblyCompany("")]
13 | [assembly: AssemblyCopyright("Copyright © 2017")]
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("039da872-5391-444c-a14b-451f60acdc15")]
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 |
--------------------------------------------------------------------------------
/GeonBit/Libs/Content.Pipeline/GraphicsImporters/Serialization/DynamicIndexBufferWriter.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | // Copyright 2016 Kastellanos Nikolaos
3 | //
4 | // Licensed under the Apache License, Version 2.0 (the "License");
5 | // you may not use this file except in compliance with the License.
6 | // You may obtain a copy of the License at
7 | //
8 | // http://www.apache.org/licenses/LICENSE-2.0
9 | //
10 | // Unless required by applicable law or agreed to in writing, software
11 | // distributed under the License is distributed on an "AS IS" BASIS,
12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | // See the License for the specific language governing permissions and
14 | // limitations under the License.
15 | #endregion
16 |
17 | using System;
18 | using Microsoft.Xna.Framework.Content.Pipeline;
19 | using Microsoft.Xna.Framework.Content.Pipeline.Serialization.Compiler;
20 | using GeonBit.Content.Pipeline.Graphics;
21 |
22 | namespace GeonBit.Content.Pipeline.Serialization
23 | {
24 | [ContentTypeWriter]
25 | class DynamicIndexBufferWriter : ContentTypeWriter
26 | {
27 | protected override void Write(ContentWriter output, DynamicIndexBufferContent buffer)
28 | {
29 | WriteIndexBuffer(output, buffer);
30 |
31 | output.Write(buffer.IsWriteOnly);
32 |
33 | return;
34 | }
35 |
36 | private static void WriteIndexBuffer(ContentWriter output, DynamicIndexBufferContent buffer)
37 | {
38 | // check if the buffer contains values greater than UInt16.MaxValue
39 | var is16Bit = true;
40 | foreach(var index in buffer)
41 | {
42 | if(index > UInt16.MaxValue)
43 | {
44 | is16Bit = false;
45 | break;
46 | }
47 | }
48 |
49 | var stride = (is16Bit) ? 2 : 4;
50 |
51 | output.Write(is16Bit); // Is 16 bit
52 | output.Write((UInt32)(buffer.Count*stride)); // Data size
53 | if (is16Bit)
54 | {
55 | foreach (var item in buffer)
56 | output.Write((UInt16)item);
57 | }
58 | else
59 | {
60 | foreach (var item in buffer)
61 | output.Write(item);
62 | }
63 | }
64 |
65 | public override string GetRuntimeReader(TargetPlatform targetPlatform)
66 | {
67 | return "GeonBit.Graphics.Content.DynamicIndexBufferReader, Aether.Graphics";
68 | }
69 |
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/GeonBit/Libs/Content.Pipeline/GraphicsImporters/Serialization/DynamicVertexBufferWriter.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | // Copyright 2016 Kastellanos Nikolaos
3 | //
4 | // Licensed under the Apache License, Version 2.0 (the "License");
5 | // you may not use this file except in compliance with the License.
6 | // You may obtain a copy of the License at
7 | //
8 | // http://www.apache.org/licenses/LICENSE-2.0
9 | //
10 | // Unless required by applicable law or agreed to in writing, software
11 | // distributed under the License is distributed on an "AS IS" BASIS,
12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | // See the License for the specific language governing permissions and
14 | // limitations under the License.
15 | #endregion
16 |
17 | using System;
18 | using Microsoft.Xna.Framework.Content.Pipeline;
19 | using Microsoft.Xna.Framework.Content.Pipeline.Serialization.Compiler;
20 | using GeonBit.Content.Pipeline.Graphics;
21 |
22 | namespace GeonBit.Content.Pipeline.Serialization
23 | {
24 | [ContentTypeWriter]
25 | public class DynamicVertexBufferWriter : ContentTypeWriter
26 | {
27 | protected override void Write(ContentWriter output, DynamicVertexBufferContent buffer)
28 | {
29 | WriteVertexBuffer(output, buffer);
30 |
31 | output.Write(buffer.IsWriteOnly);
32 |
33 | return;
34 | }
35 |
36 | private void WriteVertexBuffer(ContentWriter output, DynamicVertexBufferContent buffer)
37 | {
38 | var vertexCount = buffer.VertexData.Length / buffer.VertexDeclaration.VertexStride;
39 | output.WriteRawObject(buffer.VertexDeclaration);
40 | output.Write((UInt32)vertexCount);
41 | output.Write(buffer.VertexData);
42 | }
43 |
44 | public override string GetRuntimeReader(TargetPlatform targetPlatform)
45 | {
46 | return "GeonBit.Graphics.Content.DynamicVertexBufferReader, Aether.Graphics";
47 | }
48 |
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/GeonBit/Libs/Extend/Animations/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("Animations")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("Animations")]
13 | [assembly: AssemblyCopyright("Copyright © 2017")]
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("775b85f8-1a9a-4766-9b1b-db3f1da33631")]
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 |
--------------------------------------------------------------------------------
/GeonBit/Libs/Extend/Animations/README.md:
--------------------------------------------------------------------------------
1 |
2 | # GeonBit.Extend.Animation.*
3 |
4 | Play animated 3D models and support for CPU animation.
5 | CPU animation is optimized using unsafe code, writing directly to mapped VertexBuffer memory using reflection (DirectX) and unmanaged/C++ code (WP8.0).
6 |
7 | ## Importers
8 |
9 | * 'Animation' - Import animations from a Model.
10 | * 'GPU AnimatedModel' - Import an animated Model.
11 | * 'CPU AnimatedModel' - Import an animated Model to be animated by the CPU. Based on DynamicModelProcessor, the imported asset is of type Microsoft.Xna.Framework.Graphics.Model where the VertexBuffer is replaced by a CpuAnimatedVertexBuffer. CpuAnimatedVertexBuffer inherits from DynamicVertexBuffer.
12 |
13 | ## Example
14 |
15 | -Import 3D model with GPU AnimatedModel or GPU AnimatedModel Processor. Use SkinnedEffect for GPU and BasicEffect for CPU based animation.
16 |
17 | -Load as any 3D Model:
18 |
19 | _model = Content.Load("animatedModel");
20 |
21 | -Load the Animations from model:
22 |
23 | _animations = _model.GetAnimations();
24 | var clip = _animations.Clips["ClipName"];
25 | _animations.SetClip(clip);
26 |
27 | -Update animation on every frame:
28 |
29 | _animations.Update(gameTime.ElapsedGameTime, true, Matrix.Identity);
30 |
31 | -Draw GPU animation:
32 |
33 | foreach (ModelMesh mesh in _model.Meshes)
34 | {
35 | foreach (var meshPart in mesh.MeshParts)
36 | {
37 | meshPart.effect.SetBoneTransforms(_animations.AnimationTransforms);
38 | // set effect parameters, lights, etc
39 | }
40 | mesh.Draw();
41 | }
42 |
43 | -Draw CPU animation:
44 |
45 | foreach (ModelMesh mesh in _model.Meshes)
46 | {
47 | foreach (var meshPart in mesh.MeshParts)
48 | {
49 | meshPart.UpdateVertices(animationPlayer.AnimationTransforms);
50 | // set effect parameters, lights, etc
51 | }
52 | mesh.Draw();
53 | }
54 |
55 |
56 |
57 |
58 |
--------------------------------------------------------------------------------
/GeonBit/Libs/Extend/Animations/Source/Animation/Clip.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | /// -------------------------------------------------------------------------------------
3 | /// Notice: This file had been edited to integrate as core inside GeonBit.
4 | /// Original license and attributes below. The license and copyright notice below affect
5 | /// this file and this file only. https://github.com/tainicom/Aether.Extras
6 | /// -------------------------------------------------------------------------------------
7 | // Copyright 2011-2016 Kastellanos Nikolaos
8 | //
9 | // Licensed under the Apache License, Version 2.0 (the "License");
10 | // you may not use this file except in compliance with the License.
11 | // You may obtain a copy of the License at
12 | //
13 | // http://www.apache.org/licenses/LICENSE-2.0
14 | //
15 | // Unless required by applicable law or agreed to in writing, software
16 | // distributed under the License is distributed on an "AS IS" BASIS,
17 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 | // See the License for the specific language governing permissions and
19 | // limitations under the License.
20 | #endregion
21 |
22 | using System;
23 |
24 | namespace GeonBit.Extend.Animation
25 | {
26 | public class Clip
27 | {
28 | public TimeSpan Duration { get; internal set; }
29 | public Keyframe[] Keyframes { get; private set; }
30 |
31 | internal Clip(TimeSpan duration, Keyframe[] keyframes)
32 | {
33 | Duration = duration;
34 | Keyframes = keyframes;
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/GeonBit/Libs/Extend/Animations/Source/Animation/Extensions.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | /// -------------------------------------------------------------------------------------
3 | /// Notice: This file had been edited to integrate as core inside GeonBit.
4 | /// Original license and attributes below. The license and copyright notice below affect
5 | /// this file and this file only. https://github.com/tainicom/Aether.Extras
6 | /// -------------------------------------------------------------------------------------
7 | // Copyright 2011-2016 Kastellanos Nikolaos
8 | //
9 | // Licensed under the Apache License, Version 2.0 (the "License");
10 | // you may not use this file except in compliance with the License.
11 | // You may obtain a copy of the License at
12 | //
13 | // http://www.apache.org/licenses/LICENSE-2.0
14 | //
15 | // Unless required by applicable law or agreed to in writing, software
16 | // distributed under the License is distributed on an "AS IS" BASIS,
17 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 | // See the License for the specific language governing permissions and
19 | // limitations under the License.
20 | #endregion
21 |
22 | using Microsoft.Xna.Framework;
23 | using Microsoft.Xna.Framework.Graphics;
24 | using GeonBit.Extend.Graphics;
25 |
26 | namespace GeonBit.Extend.Animation
27 | {
28 | public static class Extensions
29 | {
30 | ///
31 | /// Get the animations of this model, if loaded.
32 | ///
33 | /// Model to get animations for.
34 | /// If true, will return a clone of the animations.
35 | ///
36 | public static Animations GetAnimations(this Model model, bool cloned)
37 | {
38 | var animations = model.Tag as Animations;
39 | if (animations == null) { throw new System.Exception("No animations data found on model. Make sure the model processor is set to an animated model in the content manager."); }
40 | if (cloned) { animations = animations.Clone(); }
41 | return animations;
42 | }
43 |
44 | ///
45 | /// Update mesh vertices based on animation (animate in CPU).
46 | ///
47 | /// Mesh part to animate.
48 | /// Bone transformations.
49 | public static void UpdateVertices(this ModelMeshPart meshPart, Matrix[] boneTransforms)
50 | {
51 | var animatedVertexBuffer = meshPart.VertexBuffer as CpuAnimatedVertexBuffer;
52 | if (animatedVertexBuffer == null) { throw new System.Exception("Cannot find CPU-animated data. Make sure the model processor is set to CPU-animated model in the content manager."); }
53 | animatedVertexBuffer.UpdateVertices(boneTransforms, meshPart.VertexOffset, meshPart.NumVertices);
54 | }
55 |
56 | ///
57 | /// Get if a given model is CPU-animated.
58 | ///
59 | public static bool IsCpuAnimated(this Model model)
60 | {
61 | var animatedVertexBuffer = model.Meshes[0].MeshParts[0].VertexBuffer as CpuAnimatedVertexBuffer;
62 | return animatedVertexBuffer != null;
63 | }
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/GeonBit/Libs/Extend/Animations/Source/Animation/Keyframe.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | /// -------------------------------------------------------------------------------------
3 | /// Notice: This file had been edited to integrate as core inside GeonBit.
4 | /// Original license and attributes below. The license and copyright notice below affect
5 | /// this file and this file only. https://github.com/tainicom/Aether.Extras
6 | /// -------------------------------------------------------------------------------------
7 | // Copyright 2011-2016 Kastellanos Nikolaos
8 | //
9 | // Licensed under the Apache License, Version 2.0 (the "License");
10 | // you may not use this file except in compliance with the License.
11 | // You may obtain a copy of the License at
12 | //
13 | // http://www.apache.org/licenses/LICENSE-2.0
14 | //
15 | // Unless required by applicable law or agreed to in writing, software
16 | // distributed under the License is distributed on an "AS IS" BASIS,
17 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 | // See the License for the specific language governing permissions and
19 | // limitations under the License.
20 | #endregion
21 |
22 | using System;
23 | using Microsoft.Xna.Framework;
24 | using Microsoft.Xna.Framework.Content;
25 |
26 | namespace GeonBit.Extend.Animation
27 | {
28 | public struct Keyframe
29 | {
30 | internal int _bone;
31 | internal TimeSpan _time;
32 | internal Matrix _transform;
33 |
34 | public int Bone
35 | {
36 | get {return _bone;}
37 | internal set { _bone = value; }
38 | }
39 |
40 | public TimeSpan Time
41 | {
42 | get { return _time; }
43 | internal set { _time = value; }
44 | }
45 |
46 | public Matrix Transform
47 | {
48 | get { return _transform; }
49 | internal set { _transform = value; }
50 | }
51 |
52 | public Keyframe(int bone, TimeSpan time, Matrix transform)
53 | {
54 | this._bone = bone;
55 | this._time = time;
56 | this._transform = transform;
57 | }
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/GeonBit/Libs/Extend/Animations/Source/Animation/NativeExtensions.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | /// -------------------------------------------------------------------------------------
3 | /// Notice: This file had been edited to integrate as core inside GeonBit.
4 | /// Original license and attributes below. The license and copyright notice below affect
5 | /// this file and this file only. https://github.com/tainicom/Aether.Extras
6 | /// -------------------------------------------------------------------------------------
7 | // Copyright 2015-2016 Kastellanos Nikolaos
8 | //
9 | // Licensed under the Apache License, Version 2.0 (the "License");
10 | // you may not use this file except in compliance with the License.
11 | // You may obtain a copy of the License at
12 | //
13 | // http://www.apache.org/licenses/LICENSE-2.0
14 | //
15 | // Unless required by applicable law or agreed to in writing, software
16 | // distributed under the License is distributed on an "AS IS" BASIS,
17 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 | // See the License for the specific language governing permissions and
19 | // limitations under the License.
20 | #endregion
21 |
22 | using Microsoft.Xna.Framework;
23 | using GeonBit.Extend.Graphics;
24 |
25 | namespace GeonBit.Extend.Animation
26 | {
27 | internal static class NativeExtensions
28 | {
29 | #if USE_NATIVE_ANIMATION
30 |
31 | internal static Native.Animation.VertexTypes.VertexIndicesWeightsPositionNormal ToNativeCpuVertex(this VertexIndicesWeightsPositionNormal source)
32 | {
33 | Native.Animation.VertexTypes.VertexIndicesWeightsPositionNormal result;
34 | //result.BlendIndices = source.BlendIndices.ToInt4Data();
35 | result.BlendIndices = new Native.Animation.Data.Int4Data()
36 | {
37 | X = source.BlendIndex0,
38 | Y = source.BlendIndex1,
39 | Z = source.BlendIndex2,
40 | W = source.BlendIndex3,
41 | };
42 | result.BlendWeights = source.BlendWeights.ToNativeVector4Data();
43 | result.Position = source.Position.ToNativeVector3Data();
44 | result.Normal = source.Normal.ToNativeVector3Data();
45 |
46 | return result;
47 | }
48 |
49 | internal static Native.Animation.Data.Vector4Data ToNativeVector4Data(this Vector4 source)
50 | {
51 | Native.Animation.Data.Vector4Data result;
52 | result.X = source.X;
53 | result.Y = source.Y;
54 | result.Z = source.Z;
55 | result.W = source.W;
56 | return result;
57 | }
58 |
59 | internal static Native.Animation.Data.Vector3Data ToNativeVector3Data(this Vector3 source)
60 | {
61 | Native.Animation.Data.Vector3Data result;
62 | result.X = source.X;
63 | result.Y = source.Y;
64 | result.Z = source.Z;
65 | return result;
66 | }
67 |
68 | internal static Native.Animation.Data.Vector2Data ToNativeVector2Data(this Vector2 source)
69 | {
70 | Native.Animation.Data.Vector2Data result;
71 | result.X = source.X;
72 | result.Y = source.Y;
73 | return result;
74 | }
75 |
76 | #endif
77 | }
78 | }
79 |
80 |
--------------------------------------------------------------------------------
/GeonBit/Libs/Extend/Animations/Source/ContentReaders/ClipReader.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | /// -------------------------------------------------------------------------------------
3 | /// Notice: This file had been edited to integrate as core inside GeonBit.
4 | /// Original license and attributes below. The license and copyright notice below affect
5 | /// this file and this file only. https://github.com/tainicom/Aether.Extras
6 | /// -------------------------------------------------------------------------------------
7 | // Copyright 2011-2016 Kastellanos Nikolaos
8 | //
9 | // Licensed under the Apache License, Version 2.0 (the "License");
10 | // you may not use this file except in compliance with the License.
11 | // You may obtain a copy of the License at
12 | //
13 | // http://www.apache.org/licenses/LICENSE-2.0
14 | //
15 | // Unless required by applicable law or agreed to in writing, software
16 | // distributed under the License is distributed on an "AS IS" BASIS,
17 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 | // See the License for the specific language governing permissions and
19 | // limitations under the License.
20 | #endregion
21 |
22 | using System;
23 | using Microsoft.Xna.Framework.Content;
24 |
25 | namespace GeonBit.Extend.Animation.Content
26 | {
27 | public class ClipReader : ContentTypeReader
28 | {
29 | protected override Clip Read(ContentReader input, Clip existingInstance)
30 | {
31 | Clip animationClip = existingInstance;
32 |
33 | if (existingInstance == null)
34 | {
35 | TimeSpan duration = ReadDuration(input);
36 | Keyframe[] keyframes = ReadKeyframes(input, null);
37 | animationClip = new Clip(duration, keyframes);
38 | }
39 | else
40 | {
41 | animationClip.Duration = ReadDuration(input);
42 | ReadKeyframes(input, animationClip.Keyframes);
43 | }
44 |
45 | return animationClip;
46 | }
47 |
48 | private TimeSpan ReadDuration(ContentReader input)
49 | {
50 | return new TimeSpan(input.ReadInt64());
51 | }
52 |
53 | private Keyframe[] ReadKeyframes(ContentReader input, Keyframe[] existingInstance)
54 | {
55 | Keyframe[] keyframes = existingInstance;
56 |
57 | int count = input.ReadInt32();
58 | if (keyframes == null)
59 | keyframes = new Keyframe[count];
60 |
61 | for (int i = 0; i < count; i++)
62 | {
63 | keyframes[i]._bone = input.ReadInt32();
64 | keyframes[i]._time = new TimeSpan(input.ReadInt64());
65 | keyframes[i]._transform.M11 = input.ReadSingle();
66 | keyframes[i]._transform.M12 = input.ReadSingle();
67 | keyframes[i]._transform.M13 = input.ReadSingle();
68 | keyframes[i]._transform.M14 = 0;
69 | keyframes[i]._transform.M21 = input.ReadSingle();
70 | keyframes[i]._transform.M22 = input.ReadSingle();
71 | keyframes[i]._transform.M23 = input.ReadSingle();
72 | keyframes[i]._transform.M24 = 0;
73 | keyframes[i]._transform.M31 = input.ReadSingle();
74 | keyframes[i]._transform.M32 = input.ReadSingle();
75 | keyframes[i]._transform.M33 = input.ReadSingle();
76 | keyframes[i]._transform.M34 = 0;
77 | keyframes[i]._transform.M41 = input.ReadSingle();
78 | keyframes[i]._transform.M42 = input.ReadSingle();
79 | keyframes[i]._transform.M43 = input.ReadSingle();
80 | keyframes[i]._transform.M44 = 1;
81 | }
82 |
83 | return keyframes;
84 | }
85 |
86 | }
87 |
88 | }
89 |
--------------------------------------------------------------------------------
/GeonBit/Libs/Extend/Animations/Source/Graphics/VertexTypes/VertexIndicesWeightsPositionNormal.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | /// -------------------------------------------------------------------------------------
3 | /// Notice: This file had been edited to integrate as core inside GeonBit.
4 | /// Original license and attributes below. The license and copyright notice below affect
5 | /// this file and this file only. https://github.com/tainicom/Aether.Extras
6 | /// -------------------------------------------------------------------------------------
7 | // Copyright 2011-2016 Kastellanos Nikolaos
8 | //
9 | // Licensed under the Apache License, Version 2.0 (the "License");
10 | // you may not use this file except in compliance with the License.
11 | // You may obtain a copy of the License at
12 | //
13 | // http://www.apache.org/licenses/LICENSE-2.0
14 | //
15 | // Unless required by applicable law or agreed to in writing, software
16 | // distributed under the License is distributed on an "AS IS" BASIS,
17 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 | // See the License for the specific language governing permissions and
19 | // limitations under the License.
20 | #endregion
21 |
22 | using System.Runtime.InteropServices;
23 | using Microsoft.Xna.Framework;
24 | using Microsoft.Xna.Framework.Graphics;
25 |
26 | namespace GeonBit.Extend.Graphics
27 | {
28 | [StructLayout(LayoutKind.Explicit)]
29 | public struct VertexIndicesWeightsPositionNormal : IVertexType
30 | {
31 | [FieldOffset( 0)] public byte BlendIndex0;
32 | [FieldOffset( 1)] public byte BlendIndex1;
33 | [FieldOffset( 2)] public byte BlendIndex2;
34 | [FieldOffset( 3)] public byte BlendIndex3;
35 | [FieldOffset( 4)] public Vector4 BlendWeights;
36 | [FieldOffset(20)] public Vector3 Position;
37 | [FieldOffset(32)] public Vector3 Normal;
38 |
39 |
40 | #region IVertexType Members
41 | public readonly static VertexDeclaration VertexDeclaration = new VertexDeclaration(
42 | new VertexElement[]
43 | {
44 | new VertexElement( 0, VertexElementFormat.Byte4, VertexElementUsage.BlendIndices, 0),
45 | new VertexElement( 4, VertexElementFormat.Vector4, VertexElementUsage.BlendWeight, 0),
46 | new VertexElement(20, VertexElementFormat.Vector3, VertexElementUsage.Position, 0),
47 | new VertexElement(32, VertexElementFormat.Vector3, VertexElementUsage.Normal, 0),
48 | });
49 |
50 | VertexDeclaration IVertexType.VertexDeclaration { get { return VertexDeclaration; } }
51 | #endregion
52 |
53 |
54 | public VertexIndicesWeightsPositionNormal(Vector3 position, Vector3 normal, Vector4 blendWeights, byte blendIndex0, byte blendIndex1, byte blendIndex2, byte blendIndex3)
55 | {
56 | this.BlendIndex0 = blendIndex0;
57 | this.BlendIndex1 = blendIndex1;
58 | this.BlendIndex2 = blendIndex2;
59 | this.BlendIndex3 = blendIndex3;
60 | this.BlendWeights = blendWeights;
61 | this.Position = position;
62 | this.Normal = normal;
63 | }
64 |
65 | public override string ToString()
66 | {
67 | return string.Format("{{Position:{0} Normal:{1} BlendWeights:{2} BlendIndices:{3},{4},{5},{6} }}",
68 | new object[] { Position, Normal, BlendWeights, BlendIndex0, BlendIndex1, BlendIndex2, BlendIndex3 });
69 | }
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/GeonBit/Libs/README.md:
--------------------------------------------------------------------------------
1 | # Libs
2 |
3 | Additional projects that act as external libs but are part of GeonBit.
--------------------------------------------------------------------------------
/GeonBit/Logo/GeonBitLogo-simple.psd:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RonenNess/GeonBit/988989b71e3ea695778d12cee264f0f849ab06c7/GeonBit/Logo/GeonBitLogo-simple.psd
--------------------------------------------------------------------------------
/GeonBit/Logo/GeonBitLogo.psd:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RonenNess/GeonBit/988989b71e3ea695778d12cee264f0f849ab06c7/GeonBit/Logo/GeonBitLogo.psd
--------------------------------------------------------------------------------
/GeonBit/Logo/README.md:
--------------------------------------------------------------------------------
1 | # Logos
2 |
3 | GeonBit official logos and banners. Feel free to use them for GeonBit related stuff.
--------------------------------------------------------------------------------
/GeonBit/Logo/icon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RonenNess/GeonBit/988989b71e3ea695778d12cee264f0f849ab06c7/GeonBit/Logo/icon.ico
--------------------------------------------------------------------------------
/GeonBit/Logo/main-simple.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RonenNess/GeonBit/988989b71e3ea695778d12cee264f0f849ab06c7/GeonBit/Logo/main-simple.png
--------------------------------------------------------------------------------
/GeonBit/Logo/main.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RonenNess/GeonBit/988989b71e3ea695778d12cee264f0f849ab06c7/GeonBit/Logo/main.png
--------------------------------------------------------------------------------
/GeonBit/Logo/nuget.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RonenNess/GeonBit/988989b71e3ea695778d12cee264f0f849ab06c7/GeonBit/Logo/nuget.png
--------------------------------------------------------------------------------
/GeonBit/Logo/square-simple-with-bg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RonenNess/GeonBit/988989b71e3ea695778d12cee264f0f849ab06c7/GeonBit/Logo/square-simple-with-bg.png
--------------------------------------------------------------------------------
/GeonBit/Logo/square-simple.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RonenNess/GeonBit/988989b71e3ea695778d12cee264f0f849ab06c7/GeonBit/Logo/square-simple.ico
--------------------------------------------------------------------------------
/GeonBit/Logo/square-simple.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RonenNess/GeonBit/988989b71e3ea695778d12cee264f0f849ab06c7/GeonBit/Logo/square-simple.png
--------------------------------------------------------------------------------
/GeonBit/Logo/square.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RonenNess/GeonBit/988989b71e3ea695778d12cee264f0f849ab06c7/GeonBit/Logo/square.png
--------------------------------------------------------------------------------
/GeonBit/Program.cs:
--------------------------------------------------------------------------------
1 | // This file shows an example of a Program.cs file and allow us to execute GeonBit as binary.
2 | // This project should be build as a lib, this file is for testing only.
3 | using System;
4 | using Microsoft.Xna.Framework;
5 |
6 | namespace GeonBit
7 | {
8 | ///
9 | /// Empty GeonBitGame implementation just so we can execute binary.
10 | ///
11 | internal class EmptyGeonBitMain : GeonBitGame
12 | {
13 | // create the game class
14 | public EmptyGeonBitMain()
15 | {
16 | // disable ui, since this project don't contain geonbit ui content
17 | InitParams.UiTheme = null;
18 | }
19 |
20 | ///
21 | /// Allows the game to run logic such as updating the world,
22 | /// checking for collisions, gathering input, and playing audio.
23 | ///
24 | /// Provides a snapshot of timing values.
25 | override public void Update(GameTime gameTime)
26 | {
27 | }
28 |
29 | ///
30 | /// Initialize to implement per main type.
31 | ///
32 | override public void Initialize()
33 | {
34 | }
35 |
36 | ///
37 | /// Draw function to implement per main type.
38 | ///
39 | /// Provides a snapshot of timing values.
40 | override public void Draw(GameTime gameTime)
41 | {
42 | }
43 | }
44 |
45 | ///
46 | /// Program to execute GeonBit as a binary file, for test purposes.
47 | /// Don't use this class.
48 | ///
49 | public static class Program
50 | {
51 | ///
52 | /// The main entry point for the application.
53 | ///
54 | [STAThread]
55 | static void Main()
56 | {
57 | GeonBitMain.Instance.Run(new EmptyGeonBitMain());
58 | }
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/GeonBit/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("GeonBit")]
9 | [assembly: AssemblyProduct("GeonBit")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyDescription("")]
12 | [assembly: AssemblyCompany("")]
13 | [assembly: AssemblyCopyright("Copyright © 2017")]
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("87db1171-c617-46b6-80dd-7e8529c90a6b")]
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 |
--------------------------------------------------------------------------------
/GeonBit/README.md:
--------------------------------------------------------------------------------
1 | # GeonBit
2 |
3 | This folder contains GeonBit source code and projects.
--------------------------------------------------------------------------------
/GeonBit/Source/Core/CoreManager.cs:
--------------------------------------------------------------------------------
1 | #region LICENSE
2 | //-----------------------------------------------------------------------------
3 | // For the purpose of making video games, educational projects or gamification,
4 | // GeonBit is distributed under the MIT license and is totally free to use.
5 | // To use this source code or GeonBit as a whole for other purposes, please seek
6 | // permission from the library author, Ronen Ness.
7 | //
8 | // Copyright (c) 2017 Ronen Ness [ronenness@gmail.com].
9 | // Do not remove this license notice.
10 | //-----------------------------------------------------------------------------
11 | #endregion
12 | #region File Description
13 | //-----------------------------------------------------------------------------
14 | // Core components global manager.
15 | //
16 | // Author: Ronen Ness.
17 | // Since: 2017.
18 | //-----------------------------------------------------------------------------
19 | #endregion
20 | using Microsoft.Xna.Framework;
21 | using Microsoft.Xna.Framework.Content;
22 |
23 | namespace GeonBit.Core
24 | {
25 | ///
26 | /// GeonBit.Core contains implementation of core components and integration with external libraries.
27 | /// This layer implements most of the engine stuff.
28 | ///
29 | [System.Runtime.CompilerServices.CompilerGenerated]
30 | class NamespaceDoc
31 | {
32 | }
33 |
34 | ///
35 | /// General 'Core' manager.
36 | ///
37 | public static class CoreManager
38 | {
39 | ///
40 | /// Init all core components.
41 | ///
42 | /// Graphic device manager.
43 | /// Content manager.
44 | public static void Initialize(GraphicsDeviceManager graphics, ContentManager content)
45 | {
46 | // init resources manager
47 | ResourcesManager.Instance.Initialize(content);
48 |
49 | // init physics callbacks
50 | Physics.PhysicsWorld.Initialize();
51 |
52 | // init graphics
53 | Graphics.GraphicsManager.Initialize(graphics);
54 | }
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/GeonBit/Source/Core/Graphics/Entities/IEntity.cs:
--------------------------------------------------------------------------------
1 | #region LICENSE
2 | //-----------------------------------------------------------------------------
3 | // For the purpose of making video games, educational projects or gamification,
4 | // GeonBit is distributed under the MIT license and is totally free to use.
5 | // To use this source code or GeonBit as a whole for other purposes, please seek
6 | // permission from the library author, Ronen Ness.
7 | //
8 | // Copyright (c) 2017 Ronen Ness [ronenness@gmail.com].
9 | // Do not remove this license notice.
10 | //-----------------------------------------------------------------------------
11 | #endregion
12 | #region File Description
13 | //-----------------------------------------------------------------------------
14 | // An entity is something you can draw, eg actual objects and not nodes.
15 | // Entities don't have transformations of their own; instead, you put them inside
16 | // a node which handle matrices and transformations for them.
17 | //
18 | // Author: Ronen Ness.
19 | // Since: 2017.
20 | //-----------------------------------------------------------------------------
21 | #endregion
22 | using Microsoft.Xna.Framework;
23 |
24 |
25 | namespace GeonBit.Core.Graphics
26 | {
27 | ///
28 | /// A basic renderable entity.
29 | ///
30 | public interface IEntity
31 | {
32 | ///
33 | /// Draw this entity.
34 | ///
35 | /// Parent node that's currently drawing this entity.
36 | /// Local transformations from the direct parent node.
37 | /// World transformations to apply on this entity (this is what you should use to draw this entity).
38 | void Draw(Node parent, ref Matrix localTransformations, ref Matrix worldTransformations);
39 |
40 | ///
41 | /// Get the bounding box of this entity (in world space).
42 | ///
43 | /// Parent node that's currently drawing this entity.
44 | /// Local transformations from the direct parent node.
45 | /// World transformations to apply on this entity (this is what you should use to draw this entity).
46 | /// Bounding box of the entity, in world space.
47 | BoundingBox GetBoundingBox(Node parent, ref Matrix localTransformations, ref Matrix worldTransformations);
48 |
49 | ///
50 | /// Get the bounding sphere of this entity (in world space).
51 | ///
52 | /// Parent node that's currently drawing this entity.
53 | /// Local transformations from the direct parent node.
54 | /// World transformations to apply on this entity (this is what you should use to draw this entity).
55 | /// Bounding sphere of the entity, in world space.
56 | BoundingSphere GetBoundingSphere(Node parent, ref Matrix localTransformations, ref Matrix worldTransformations);
57 |
58 | ///
59 | /// Return if the entity is currently visible.
60 | ///
61 | /// If the entity is visible or not.
62 | bool Visible { get; set; }
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/GeonBit/Source/Core/Graphics/Lights/ILightsManager.cs:
--------------------------------------------------------------------------------
1 | #region LICENSE
2 | //-----------------------------------------------------------------------------
3 | // For the purpose of making video games, educational projects or gamification,
4 | // GeonBit is distributed under the MIT license and is totally free to use.
5 | // To use this source code or GeonBit as a whole for other purposes, please seek
6 | // permission from the library author, Ronen Ness.
7 | //
8 | // Copyright (c) 2017 Ronen Ness [ronenness@gmail.com].
9 | // Do not remove this license notice.
10 | //-----------------------------------------------------------------------------
11 | #endregion
12 | #region File Description
13 | //-----------------------------------------------------------------------------
14 | // Define the interface for lights manager.
15 | //
16 | // Author: Ronen Ness.
17 | // Since: 2017.
18 | //-----------------------------------------------------------------------------
19 | #endregion
20 | using System.Collections.Generic;
21 | using Microsoft.Xna.Framework;
22 |
23 | namespace GeonBit.Core.Graphics.Lights
24 | {
25 | ///
26 | /// Interface for lights manager.
27 | /// These objects manage lights and provide them to materials when trying to render.
28 | ///
29 | public interface ILightsManager
30 | {
31 | ///
32 | /// Get / set ambient light.
33 | ///
34 | ///
35 | Color AmbientLight { get; set; }
36 |
37 | ///
38 | /// Add a light source to the lights manager.
39 | ///
40 | /// Light to add.
41 | void AddLight(LightSource light);
42 |
43 | ///
44 | /// Remove a light source from the lights manager.
45 | ///
46 | /// Light to remove.
47 | void RemoveLight(LightSource light);
48 |
49 | ///
50 | /// Enable / disable all lights.
51 | ///
52 | bool Enabled { get; set; }
53 |
54 | ///
55 | /// Get all lights for a given bounding sphere and material.
56 | ///
57 | /// Material to get lights for.
58 | /// Rendering bounding sphere.
59 | /// Maximum lights count to return.
60 | /// Array of lights to apply on this material and drawing. Note: directional lights must always come first!
61 | LightSource[] GetLights(Materials.MaterialAPI material, ref BoundingSphere boundingSphere, int maxLights);
62 |
63 | ///
64 | /// Update the transformations of a light inside this manager.
65 | ///
66 | /// Light to update.
67 | void UpdateLightTransform(LightSource light);
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/GeonBit/Source/Core/Graphics/Materials/LitMaterialAlphaTest.cs:
--------------------------------------------------------------------------------
1 | #region LICENSE
2 | //-----------------------------------------------------------------------------
3 | // For the purpose of making video games, educational projects or gamification,
4 | // GeonBit is distributed under the MIT license and is totally free to use.
5 | // To use this source code or GeonBit as a whole for other purposes, please seek
6 | // permission from the library author, Ronen Ness.
7 | //
8 | // Copyright (c) 2017 Ronen Ness [ronenness@gmail.com].
9 | // Do not remove this license notice.
10 | //-----------------------------------------------------------------------------
11 | #endregion
12 | #region File Description
13 | //-----------------------------------------------------------------------------
14 | // A basic one-pass lit material with alpha test.
15 | //
16 | // Author: Ronen Ness.
17 | // Since: 2017.
18 | //-----------------------------------------------------------------------------
19 | #endregion
20 | using Microsoft.Xna.Framework;
21 | using Microsoft.Xna.Framework.Graphics;
22 | using System.Collections.Generic;
23 | using System;
24 |
25 | namespace GeonBit.Core.Graphics.Materials
26 | {
27 | ///
28 | /// A material that support ambient + several point / directional lights.
29 | /// In addition, it support alpha test (transparent pixels).
30 | ///
31 | public class LitMaterialAlphaTest : LitMaterial
32 | {
33 | // effect path
34 | private static readonly string _effectPath = EffectsPath + "LitEffectAlphaTest";
35 |
36 | ///
37 | /// Create new lit effect instance.
38 | ///
39 | /// New lit effect instance.
40 | public override Effect CreateEffect()
41 | {
42 | return ResourcesManager.Instance.GetEffect(_effectPath).Clone();
43 | }
44 |
45 | ///
46 | /// Create the lit material from an empty effect.
47 | ///
48 | public LitMaterialAlphaTest() : base()
49 | {
50 | }
51 |
52 | ///
53 | /// Create the material from another material instance.
54 | ///
55 | /// Other material to clone.
56 | public LitMaterialAlphaTest(LitMaterial other) : base(other)
57 | {
58 | }
59 |
60 | ///
61 | /// Create the lit material.
62 | ///
63 | /// Effect to create material from.
64 | public LitMaterialAlphaTest(Effect fromEffect) : base(fromEffect)
65 | {
66 | }
67 |
68 | ///
69 | /// Create the lit material.
70 | ///
71 | /// Effect to create material from.
72 | /// If true, will copy initial properties from effect.
73 | public LitMaterialAlphaTest(BasicEffect fromEffect, bool copyEffectProperties = true) : base(fromEffect, copyEffectProperties)
74 | {
75 | }
76 |
77 | ///
78 | /// Clone this material.
79 | ///
80 | /// Copy of this material.
81 | public override MaterialAPI Clone()
82 | {
83 | return new LitMaterialAlphaTest(this);
84 | }
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/GeonBit/Source/Core/Graphics/Materials/NormalMapLitMaterial.cs:
--------------------------------------------------------------------------------
1 | #region LICENSE
2 | //-----------------------------------------------------------------------------
3 | // For the purpose of making video games, educational projects or gamification,
4 | // GeonBit is distributed under the MIT license and is totally free to use.
5 | // To use this source code or GeonBit as a whole for other purposes, please seek
6 | // permission from the library author, Ronen Ness.
7 | //
8 | // Copyright (c) 2017 Ronen Ness [ronenness@gmail.com].
9 | // Do not remove this license notice.
10 | //-----------------------------------------------------------------------------
11 | #endregion
12 | #region File Description
13 | //-----------------------------------------------------------------------------
14 | // A basic one-pass lit material.
15 | //
16 | // Author: Ronen Ness.
17 | // Since: 2017.
18 | //-----------------------------------------------------------------------------
19 | #endregion
20 | using Microsoft.Xna.Framework;
21 | using Microsoft.Xna.Framework.Graphics;
22 | using System.Collections.Generic;
23 | using System;
24 |
25 | namespace GeonBit.Core.Graphics.Materials
26 | {
27 | ///
28 | /// A material that support ambient + several point / directional lights.
29 | ///
30 | public class NormalMapLitMaterial : LitMaterial
31 | {
32 | // effect path
33 | private static readonly string _effectPath = EffectsPath + "NormalMapLitEffect";
34 |
35 | ///
36 | /// Create new lit effect instance.
37 | ///
38 | /// New lit effect instance.
39 | public override Effect CreateEffect()
40 | {
41 | return ResourcesManager.Instance.GetEffect(_effectPath).Clone();
42 | }
43 |
44 | ///
45 | /// Create the lit material from an empty effect.
46 | ///
47 | public NormalMapLitMaterial() : base()
48 | {
49 | }
50 |
51 | ///
52 | /// Create the material from another material instance.
53 | ///
54 | /// Other material to clone.
55 | public NormalMapLitMaterial(LitMaterial other) : base(other)
56 | {
57 | }
58 |
59 | ///
60 | /// Create the lit material.
61 | ///
62 | /// Effect to create material from.
63 | public NormalMapLitMaterial(Effect fromEffect) : base(fromEffect)
64 | {
65 | }
66 |
67 | ///
68 | /// Create the lit material.
69 | ///
70 | /// Effect to create material from.
71 | /// If true, will copy initial properties from effect.
72 | public NormalMapLitMaterial(BasicEffect fromEffect, bool copyEffectProperties = true) : base(fromEffect, copyEffectProperties)
73 | {
74 | }
75 |
76 | ///
77 | /// Clone this material.
78 | ///
79 | /// Copy of this material.
80 | public override MaterialAPI Clone()
81 | {
82 | return new NormalMapLitMaterial(this);
83 | }
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/GeonBit/Source/Core/Graphics/Materials/SkyboxMaterial.cs:
--------------------------------------------------------------------------------
1 | #region LICENSE
2 | //-----------------------------------------------------------------------------
3 | // For the purpose of making video games, educational projects or gamification,
4 | // GeonBit is distributed under the MIT license and is totally free to use.
5 | // To use this source code or GeonBit as a whole for other purposes, please seek
6 | // permission from the library author, Ronen Ness.
7 | //
8 | // Copyright (c) 2017 Ronen Ness [ronenness@gmail.com].
9 | // Do not remove this license notice.
10 | //-----------------------------------------------------------------------------
11 | #endregion
12 | #region File Description
13 | //-----------------------------------------------------------------------------
14 | // A material to use on skybox mesh.
15 | //
16 | // Author: Ronen Ness.
17 | // Since: 2017.
18 | //-----------------------------------------------------------------------------
19 | #endregion
20 | using Microsoft.Xna.Framework;
21 | using Microsoft.Xna.Framework.Graphics;
22 | using System.Collections.Generic;
23 | using System;
24 |
25 | namespace GeonBit.Core.Graphics.Materials
26 | {
27 | ///
28 | /// A material for skybox mesh.
29 | ///
30 | public class SkyboxMaterial : MaterialAPI
31 | {
32 | // the effect instance of this material.
33 | BasicEffect _effect;
34 |
35 | ///
36 | /// Get the effect instance.
37 | ///
38 | public override Effect Effect { get { return _effect; } }
39 |
40 | ///
41 | /// If true, will rotate by 90 degrees on X axis to flip between Y and Z axis.
42 | /// Useful for blender exported models.
43 | ///
44 | public bool FlipYZ = false;
45 |
46 | ///
47 | /// Create the default material.
48 | ///
49 | /// Skybox texture.
50 | /// If true, will flip between Y and Z axis.
51 | public SkyboxMaterial(string texture, bool flipYZ = false)
52 | {
53 | // store effect and set default properties
54 | FlipYZ = flipYZ;
55 | _effect = new BasicEffect(GraphicsManager.GraphicsDevice);
56 | _effect.TextureEnabled = true;
57 | _effect.Texture = ResourcesManager.Instance.GetTexture(texture);
58 | _effect.LightingEnabled = false;
59 | }
60 |
61 | ///
62 | /// Create the material from another material instance.
63 | ///
64 | /// Other material to clone.
65 | public SkyboxMaterial(SkyboxMaterial other)
66 | {
67 | _effect = other._effect.Clone() as BasicEffect;
68 | MaterialAPI asBase = this;
69 | other.CloneBasics(ref asBase);
70 | FlipYZ = other.FlipYZ;
71 | }
72 |
73 | ///
74 | /// Apply this material.
75 | ///
76 | override protected void MaterialSpecificApply(bool wasLastMaterial)
77 | {
78 | // create world matrix which is camera position + scale large enough to cover far plane
79 | _effect.World =
80 | (FlipYZ ? Matrix.CreateRotationX((float)Math.PI * -0.5f) : Matrix.Identity) *
81 | Matrix.CreateScale(GraphicsManager.ActiveCamera.FarClipPlane * Vector3.One * 1.5f) *
82 | Matrix.CreateTranslation(GraphicsManager.ActiveCamera.Position);
83 | }
84 |
85 | ///
86 | /// Update material view matrix.
87 | ///
88 | /// New view to set.
89 | override protected void UpdateView(ref Matrix view)
90 | {
91 | _effect.View = View;
92 | }
93 |
94 | ///
95 | /// Update material projection matrix.
96 | ///
97 | /// New projection to set.
98 | override protected void UpdateProjection(ref Matrix projection)
99 | {
100 | _effect.Projection = Projection;
101 | }
102 |
103 | ///
104 | /// Clone this material.
105 | ///
106 | /// Copy of this material.
107 | public override MaterialAPI Clone()
108 | {
109 | return new SkyboxMaterial(this);
110 | }
111 | }
112 | }
113 |
--------------------------------------------------------------------------------
/GeonBit/Source/Core/Graphics/Materials/SpriteMaterial.cs:
--------------------------------------------------------------------------------
1 | #region LICENSE
2 | //-----------------------------------------------------------------------------
3 | // For the purpose of making video games, educational projects or gamification,
4 | // GeonBit is distributed under the MIT license and is totally free to use.
5 | // To use this source code or GeonBit as a whole for other purposes, please seek
6 | // permission from the library author, Ronen Ness.
7 | //
8 | // Copyright (c) 2017 Ronen Ness [ronenness@gmail.com].
9 | // Do not remove this license notice.
10 | //-----------------------------------------------------------------------------
11 | #endregion
12 | #region File Description
13 | //-----------------------------------------------------------------------------
14 | // A material for sprites and billboards with alpha-test.
15 | //
16 | // Author: Ronen Ness.
17 | // Since: 2017.
18 | //-----------------------------------------------------------------------------
19 | #endregion
20 | using Microsoft.Xna.Framework;
21 | using Microsoft.Xna.Framework.Graphics;
22 | using System.Collections.Generic;
23 | using System;
24 |
25 | namespace GeonBit.Core.Graphics.Materials
26 | {
27 | ///
28 | /// Material for sprites and billboards.
29 | ///
30 | public class SpriteMaterial : AlphaTestMaterial
31 | {
32 | ///
33 | /// Create the default material from empty effect.
34 | ///
35 | public SpriteMaterial() : base()
36 | {
37 | SamplerState = SamplerState.PointClamp;
38 | TextureEnabled = true;
39 | }
40 |
41 | ///
42 | /// Create the default material.
43 | ///
44 | /// Effect to use.
45 | /// If true, will copy initial properties from effect.
46 | public SpriteMaterial(AlphaTestEffect effect, bool copyEffectProperties = true) : base(effect, copyEffectProperties)
47 | {
48 | SamplerState = SamplerState.PointClamp;
49 | TextureEnabled = true;
50 | }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/GeonBit/Source/Core/Graphics/Nodes/BoundingBoxCullingNode.cs:
--------------------------------------------------------------------------------
1 | #region LICENSE
2 | //-----------------------------------------------------------------------------
3 | // For the purpose of making video games, educational projects or gamification,
4 | // GeonBit is distributed under the MIT license and is totally free to use.
5 | // To use this source code or GeonBit as a whole for other purposes, please seek
6 | // permission from the library author, Ronen Ness.
7 | //
8 | // Copyright (c) 2017 Ronen Ness [ronenness@gmail.com].
9 | // Do not remove this license notice.
10 | //-----------------------------------------------------------------------------
11 | #endregion
12 | #region File Description
13 | //-----------------------------------------------------------------------------
14 | // A scene node with basic Bounding-Box based culling.
15 | //
16 | // Author: Ronen Ness.
17 | // Since: 2017.
18 | //-----------------------------------------------------------------------------
19 | #endregion
20 | using Microsoft.Xna.Framework;
21 | using System.Collections.Generic;
22 |
23 | namespace GeonBit.Core.Graphics
24 | {
25 | ///
26 | /// Bounding-Box culling node will calculate the bounding box of the node and its children, and will cull out
27 | /// if it doesn't intersect with the camera frustum.
28 | ///
29 | public class BoundingBoxCullingNode : CullingNode
30 | {
31 | ///
32 | /// Clone this scene node.
33 | ///
34 | /// Node copy.
35 | public override Node Clone()
36 | {
37 | BoundingBoxCullingNode ret = new BoundingBoxCullingNode();
38 | ret.Transformations = Transformations.Clone();
39 | ret.LastBoundingBox = LastBoundingBox;
40 | ret.Visible = Visible;
41 | return ret;
42 | }
43 |
44 | ///
45 | /// Get if this node is currently visible in camera.
46 | ///
47 | override public bool IsInScreen
48 | {
49 | get
50 | {
51 | var bb = GetBoundingBox();
52 | return (bb.Min != bb.Max && CameraFrustum.Contains(bb) != ContainmentType.Disjoint);
53 | }
54 | }
55 |
56 | ///
57 | /// Get if this node is partly inside screen (eg intersects with camera frustum).
58 | ///
59 | override public bool IsPartlyInScreen
60 | {
61 | get
62 | {
63 | var bb = GetBoundingBox();
64 | return (bb.Min != bb.Max && CameraFrustum.Contains(GetBoundingBox()) == ContainmentType.Intersects);
65 | }
66 | }
67 |
68 | ///
69 | /// Update culling test / cached data.
70 | /// This is called whenever trying to draw this node after transformations update
71 | ///
72 | override protected void UpdateCullingData()
73 | {
74 | }
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/GeonBit/Source/Core/Graphics/Nodes/BoundingSphereCullingNode.cs:
--------------------------------------------------------------------------------
1 | #region LICENSE
2 | //-----------------------------------------------------------------------------
3 | // For the purpose of making video games, educational projects or gamification,
4 | // GeonBit is distributed under the MIT license and is totally free to use.
5 | // To use this source code or GeonBit as a whole for other purposes, please seek
6 | // permission from the library author, Ronen Ness.
7 | //
8 | // Copyright (c) 2017 Ronen Ness [ronenness@gmail.com].
9 | // Do not remove this license notice.
10 | //-----------------------------------------------------------------------------
11 | #endregion
12 | #region File Description
13 | //-----------------------------------------------------------------------------
14 | // A scene node with basic Bounding-sphere based culling.
15 | //
16 | // Author: Ronen Ness.
17 | // Since: 2017.
18 | //-----------------------------------------------------------------------------
19 | #endregion
20 | using Microsoft.Xna.Framework;
21 | using System.Collections.Generic;
22 |
23 | namespace GeonBit.Core.Graphics
24 | {
25 | ///
26 | /// Bounding-Sphere culling node will calculate the bounding sphere of the node and its children, and will cull out
27 | /// if it doesn't intersect with the camera frustum.
28 | ///
29 | public class BoundingSphereCullingNode : CullingNode
30 | {
31 | ///
32 | /// Clone this scene node.
33 | ///
34 | /// Node copy.
35 | public override Node Clone()
36 | {
37 | BoundingSphereCullingNode ret = new BoundingSphereCullingNode();
38 | ret.Transformations = Transformations.Clone();
39 | ret.LastBoundingSphere = LastBoundingSphere;
40 | ret.Visible = Visible;
41 | return ret;
42 | }
43 |
44 | ///
45 | /// Get if this node is currently visible in camera.
46 | ///
47 | override public bool IsInScreen
48 | {
49 | get
50 | {
51 | var bs = GetBoundingSphere();
52 | return (bs.Radius > 0f && CameraFrustum.Contains(bs) != ContainmentType.Disjoint);
53 | }
54 | }
55 |
56 | ///
57 | /// Get if this node is partly inside screen (eg intersects with camera frustum).
58 | ///
59 | override public bool IsPartlyInScreen
60 | {
61 | get
62 | {
63 | var bs = GetBoundingSphere();
64 | return (bs.Radius > 0f && CameraFrustum.Contains(bs) == ContainmentType.Intersects);
65 | }
66 | }
67 |
68 | ///
69 | /// Update culling test / cached data.
70 | /// This is called whenever trying to draw this node after transformations update
71 | ///
72 | override protected void UpdateCullingData()
73 | {
74 | }
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/GeonBit/Source/Core/Graphics/Nodes/NodesManager.cs:
--------------------------------------------------------------------------------
1 | #region LICENSE
2 | //-----------------------------------------------------------------------------
3 | // For the purpose of making video games, educational projects or gamification,
4 | // GeonBit is distributed under the MIT license and is totally free to use.
5 | // To use this source code or GeonBit as a whole for other purposes, please seek
6 | // permission from the library author, Ronen Ness.
7 | //
8 | // Copyright (c) 2017 Ronen Ness [ronenness@gmail.com].
9 | // Do not remove this license notice.
10 | //-----------------------------------------------------------------------------
11 | #endregion
12 | #region File Description
13 | //-----------------------------------------------------------------------------
14 | // Static manager for nodes transformations and caching.
15 | //
16 | // Author: Ronen Ness.
17 | // Since: 2017.
18 | //-----------------------------------------------------------------------------
19 | #endregion
20 | using System.Collections.Generic;
21 |
22 | namespace GeonBit.Core.Graphics
23 | {
24 | ///
25 | /// Static class to manage node updates and caching.
26 | ///
27 | public static class NodesManager
28 | {
29 | ///
30 | /// Frame identifier. Used for internal caching mechanisms.
31 | ///
32 | public static uint CurrFrame { get; private set; } = 0;
33 |
34 | ///
35 | /// Queue of nodes that require update at the end of the loop.
36 | ///
37 | static List _nodesUpdateQueue = new List();
38 |
39 | ///
40 | /// Start drawing frame (call this at the begining of your drawing loop, before drawing any nodes).
41 | ///
42 | public static void StartFrame()
43 | {
44 | // increase frame id
45 | CurrFrame++;
46 | }
47 |
48 | ///
49 | /// End drawing frame (call this at the end of your drawing loop, after drawing all nodes).
50 | ///
51 | public static void EndFrame()
52 | {
53 | // update nodes
54 | foreach (var node in _nodesUpdateQueue)
55 | {
56 | node.UpdateTransformations(true);
57 | }
58 |
59 | // clear nodes update queue
60 | _nodesUpdateQueue.Clear();
61 | }
62 |
63 | ///
64 | /// Add this node to a queue of nodes that will do transformations update at the end of the frame.
65 | ///
66 | /// Node to update when frame ends.
67 | public static void AddNodeToUpdateQueue(Node node)
68 | {
69 | _nodesUpdateQueue.Add(node);
70 | }
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/GeonBit/Source/Core/Graphics/Nodes/ParticlesNode.cs:
--------------------------------------------------------------------------------
1 | #region LICENSE
2 | //-----------------------------------------------------------------------------
3 | // For the purpose of making video games, educational projects or gamification,
4 | // GeonBit is distributed under the MIT license and is totally free to use.
5 | // To use this source code or GeonBit as a whole for other purposes, please seek
6 | // permission from the library author, Ronen Ness.
7 | //
8 | // Copyright (c) 2017 Ronen Ness [ronenness@gmail.com].
9 | // Do not remove this license notice.
10 | //-----------------------------------------------------------------------------
11 | #endregion
12 | #region File Description
13 | //-----------------------------------------------------------------------------
14 | // Scene node optimized for particle systems.
15 | //
16 | // Author: Ronen Ness.
17 | // Since: 2017.
18 | //-----------------------------------------------------------------------------
19 | #endregion
20 | using Microsoft.Xna.Framework;
21 | using System.Collections.Generic;
22 |
23 | namespace GeonBit.Core.Graphics
24 | {
25 | ///
26 | /// A scene node optimized for particles.
27 | ///
28 | public class ParticleNode : BoundingSphereCullingNode
29 | {
30 | ///
31 | /// Clone this scene node.
32 | ///
33 | /// Node copy.
34 | public override Node Clone()
35 | {
36 | ParticleNode ret = new ParticleNode();
37 | ret.Transformations = Transformations.Clone();
38 | ret.LastBoundingBox = LastBoundingBox;
39 | ret.Visible = Visible;
40 | return ret;
41 | }
42 |
43 | ///
44 | /// Update culling test / cached data.
45 | /// This is called whenever trying to draw this node after transformations update
46 | ///
47 | override protected void UpdateCullingData()
48 | {
49 | }
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/GeonBit/Source/Core/Input/Mouse.cs:
--------------------------------------------------------------------------------
1 | #region LICENSE
2 | //-----------------------------------------------------------------------------
3 | // For the purpose of making video games, educational projects or gamification,
4 | // GeonBit is distributed under the MIT license and is totally free to use.
5 | // To use this source code or GeonBit as a whole for other purposes, please seek
6 | // permission from the library author, Ronen Ness.
7 | //
8 | // Copyright (c) 2017 Ronen Ness [ronenness@gmail.com].
9 | // Do not remove this license notice.
10 | //-----------------------------------------------------------------------------
11 | #endregion
12 | #region File Description
13 | //-----------------------------------------------------------------------------
14 | // This file is just a copy of the GeonBit.UI MouseButtons, to create a proxy of
15 | // UI's MouseButtons but inside GeonBit namespace.
16 | //
17 | // Author: Ronen Ness.
18 | // Since: 2017.
19 | //-----------------------------------------------------------------------------
20 | #endregion
21 |
22 | namespace GeonBit.Input
23 | {
24 | ///
25 | /// Supported mouse buttons.
26 | /// Note: this is a proxy for the GeonBit.UI MouseButton enum, just to create encapsulation.
27 | ///
28 | public enum MouseButton
29 | {
30 | ///Left mouse button.
31 | Left = UI.MouseButton.Left,
32 |
33 | ///Right mouse button.
34 | Right = UI.MouseButton.Right,
35 |
36 | ///Middle mouse button (eg scrollwheel when clicked).
37 | Middle = UI.MouseButton.Middle
38 | };
39 | }
40 |
--------------------------------------------------------------------------------
/GeonBit/Source/Core/Physics/CollisionShapes/CollisionBox.cs:
--------------------------------------------------------------------------------
1 | #region LICENSE
2 | //-----------------------------------------------------------------------------
3 | // For the purpose of making video games, educational projects or gamification,
4 | // GeonBit is distributed under the MIT license and is totally free to use.
5 | // To use this source code or GeonBit as a whole for other purposes, please seek
6 | // permission from the library author, Ronen Ness.
7 | //
8 | // Copyright (c) 2017 Ronen Ness [ronenness@gmail.com].
9 | // Do not remove this license notice.
10 | //-----------------------------------------------------------------------------
11 | #endregion
12 | #region File Description
13 | //-----------------------------------------------------------------------------
14 | // Collision shape for a box.
15 | //
16 | // Author: Ronen Ness.
17 | // Since: 2017.
18 | //-----------------------------------------------------------------------------
19 | #endregion
20 | using Microsoft.Xna.Framework;
21 |
22 | namespace GeonBit.Core.Physics.CollisionShapes
23 | {
24 | ///
25 | /// Box collision shape.
26 | ///
27 | public class CollisionBox : ICollisionShape
28 | {
29 | ///
30 | /// Create the collision box.
31 | ///
32 | /// Box base width (X axis).
33 | /// Box base height (Y axis).
34 | /// Bow base depth (Z axis).
35 | public CollisionBox(float width = 1f, float height = 1f, float depth = 1f)
36 | {
37 | _shape = new BulletSharp.BoxShape(width / 2f, height / 2f, depth / 2f);
38 | }
39 |
40 | ///
41 | /// Clone the physical shape.
42 | ///
43 | /// Cloned shape.
44 | protected override ICollisionShape CloneImp()
45 | {
46 | var shape = _shape as BulletSharp.BoxShape;
47 | Vector3 halfExtent = ToMonoGame.Vector(shape.HalfExtentsWithoutMargin);
48 | return new CollisionBox(halfExtent.X * 2f, halfExtent.Y * 2f, halfExtent.Z * 2f);
49 | }
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/GeonBit/Source/Core/Physics/CollisionShapes/CollisionBox2d.cs:
--------------------------------------------------------------------------------
1 | #region LICENSE
2 | //-----------------------------------------------------------------------------
3 | // For the purpose of making video games, educational projects or gamification,
4 | // GeonBit is distributed under the MIT license and is totally free to use.
5 | // To use this source code or GeonBit as a whole for other purposes, please seek
6 | // permission from the library author, Ronen Ness.
7 | //
8 | // Copyright (c) 2017 Ronen Ness [ronenness@gmail.com].
9 | // Do not remove this license notice.
10 | //-----------------------------------------------------------------------------
11 | #endregion
12 | #region File Description
13 | //-----------------------------------------------------------------------------
14 | // Collision shape for a 2d box.
15 | //
16 | // Author: Ronen Ness.
17 | // Since: 2017.
18 | //-----------------------------------------------------------------------------
19 | #endregion
20 | using Microsoft.Xna.Framework;
21 |
22 | namespace GeonBit.Core.Physics.CollisionShapes
23 | {
24 | ///
25 | /// 2d Box collision shape.
26 | ///
27 | public class CollisionBox2D : ICollisionShape
28 | {
29 | ///
30 | /// Create the collision box2d.
31 | ///
32 | /// Box base width (X axis).
33 | /// Box base height (Y axis).
34 | /// Bow base depth (Z axis).
35 | public CollisionBox2D(float width = 1f, float height = 1f, float depth = 1f)
36 | {
37 | _shape = new BulletSharp.Box2DShape(width / 2f, height / 2f, depth / 2f);
38 | }
39 |
40 | ///
41 | /// Clone the physical shape.
42 | ///
43 | /// Cloned shape.
44 | protected override ICollisionShape CloneImp()
45 | {
46 | var shape = _shape as BulletSharp.Box2DShape;
47 | Vector3 halfExtent = ToMonoGame.Vector(shape.HalfExtentsWithoutMargin);
48 | return new CollisionBox2D(halfExtent.X * 2f, halfExtent.Y * 2f, halfExtent.Z * 2f);
49 | }
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/GeonBit/Source/Core/Physics/CollisionShapes/CollisionCapsule.cs:
--------------------------------------------------------------------------------
1 | #region LICENSE
2 | //-----------------------------------------------------------------------------
3 | // For the purpose of making video games, educational projects or gamification,
4 | // GeonBit is distributed under the MIT license and is totally free to use.
5 | // To use this source code or GeonBit as a whole for other purposes, please seek
6 | // permission from the library author, Ronen Ness.
7 | //
8 | // Copyright (c) 2017 Ronen Ness [ronenness@gmail.com].
9 | // Do not remove this license notice.
10 | //-----------------------------------------------------------------------------
11 | #endregion
12 | #region File Description
13 | //-----------------------------------------------------------------------------
14 | // Collision shape for a capsule.
15 | //
16 | // Author: Ronen Ness.
17 | // Since: 2017.
18 | //-----------------------------------------------------------------------------
19 | #endregion
20 | using Microsoft.Xna.Framework;
21 |
22 | namespace GeonBit.Core.Physics.CollisionShapes
23 | {
24 | ///
25 | /// Which axis the capsule is aligned with.
26 | ///
27 | public enum CapsuleDirectionAxis
28 | {
29 | ///
30 | /// Capsule aligned with X axis.
31 | ///
32 | X,
33 |
34 | ///
35 | /// Capsule aligned with Y axis.
36 | ///
37 | Y,
38 |
39 | ///
40 | /// Capsule aligned with Z axis.
41 | ///
42 | Z,
43 | }
44 |
45 | ///
46 | /// Capsule collision shape.
47 | ///
48 | public class CollisionCapsule : ICollisionShape
49 | {
50 | // cylinder axis type
51 | private CapsuleDirectionAxis _axisType;
52 |
53 | ///
54 | /// Create the collision capsule.
55 | ///
56 | /// Capsule radius.
57 | /// Capsule height.
58 | /// Capsule axis direction.
59 | public CollisionCapsule(float radius = 1f, float height = 1f, CapsuleDirectionAxis axis = CapsuleDirectionAxis.Y)
60 | {
61 | _axisType = axis;
62 | switch (_axisType)
63 | {
64 | case CapsuleDirectionAxis.X:
65 | _shape = new BulletSharp.CapsuleShapeX(radius, height);
66 | break;
67 |
68 | case CapsuleDirectionAxis.Y:
69 | _shape = new BulletSharp.CapsuleShape(radius, height);
70 | break;
71 |
72 | case CapsuleDirectionAxis.Z:
73 | _shape = new BulletSharp.CapsuleShapeZ(radius, height);
74 | break;
75 | }
76 | }
77 |
78 | ///
79 | /// Clone the physical shape.
80 | ///
81 | /// Cloned shape.
82 | protected override ICollisionShape CloneImp()
83 | {
84 | var shape = _shape as BulletSharp.CapsuleShape;
85 | return new CollisionCapsule(shape.Radius, shape.HalfHeight * 2f, _axisType);
86 | }
87 | }
88 | }
89 |
--------------------------------------------------------------------------------
/GeonBit/Source/Core/Physics/CollisionShapes/CollisionCompoundShape.cs:
--------------------------------------------------------------------------------
1 | #region LICENSE
2 | //-----------------------------------------------------------------------------
3 | // For the purpose of making video games, educational projects or gamification,
4 | // GeonBit is distributed under the MIT license and is totally free to use.
5 | // To use this source code or GeonBit as a whole for other purposes, please seek
6 | // permission from the library author, Ronen Ness.
7 | //
8 | // Copyright (c) 2017 Ronen Ness [ronenness@gmail.com].
9 | // Do not remove this license notice.
10 | //-----------------------------------------------------------------------------
11 | #endregion
12 | #region File Description
13 | //-----------------------------------------------------------------------------
14 | // Compound collision shape.
15 | //
16 | // Author: Ronen Ness.
17 | // Since: 2017.
18 | //-----------------------------------------------------------------------------
19 | #endregion
20 | using Microsoft.Xna.Framework;
21 |
22 | namespace GeonBit.Core.Physics.CollisionShapes
23 | {
24 | ///
25 | /// A compound shape, made of one or more collision shapes combined together.
26 | /// This is a great way to optimize static objects.
27 | ///
28 | public class CollisionCompoundShape : ICollisionShape
29 | {
30 | ///
31 | /// Create the compound shape.
32 | ///
33 | public CollisionCompoundShape()
34 | {
35 | _shape = new BulletSharp.CompoundShape();
36 | }
37 |
38 | ///
39 | /// Clear the compound shape and remove all children from it.
40 | ///
41 | public void Clear()
42 | {
43 | // note: while its tempting to just do '_shape = new BulletSharp.CompoundShape();' its not recommended,
44 | // as it will not apply bodies already using this shape!
45 | var shape = _shape as BulletSharp.CompoundShape;
46 | foreach (var child in shape.ChildList)
47 | {
48 | shape.RemoveChildShape(child.ChildShape);
49 | }
50 | }
51 |
52 | ///
53 | /// Add a child shape to this compound shape.
54 | ///
55 | /// Collision shape to add.
56 | /// Transformations for child shape.
57 | public void AddShape(ICollisionShape shape, Matrix? transform = null)
58 | {
59 | var comShape = _shape as BulletSharp.CompoundShape;
60 | comShape.AddChildShape(ToBullet.Matrix(transform ?? Matrix.Identity), shape.BulletCollisionShape);
61 | }
62 |
63 | ///
64 | /// Remove a child shape from this compound shape.
65 | ///
66 | /// Collision shape to remove.
67 | public void RemoveShape(ICollisionShape shape)
68 | {
69 | var comShape = _shape as BulletSharp.CompoundShape;
70 | comShape.RemoveChildShape(shape.BulletCollisionShape);
71 | }
72 |
73 | ///
74 | /// Clone the physical shape.
75 | ///
76 | /// Cloned shape.
77 | protected override ICollisionShape CloneImp()
78 | {
79 | // create a new, empty compound shape
80 | var ret = new CollisionCompoundShape();
81 |
82 | // get our compound shape
83 | var shape = _shape as BulletSharp.CompoundShape;
84 |
85 | // iterate our children and add them to the new shape
86 | foreach (var child in shape.ChildList)
87 | {
88 | // get shape and transformations
89 | var collShape = child.ChildShape;
90 | var transform = child.Transform;
91 | ((BulletSharp.CompoundShape)ret._shape).AddChildShape(transform, collShape);
92 | }
93 |
94 | // return the new compound shape
95 | return ret;
96 | }
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/GeonBit/Source/Core/Physics/CollisionShapes/CollisionCone.cs:
--------------------------------------------------------------------------------
1 | #region LICENSE
2 | //-----------------------------------------------------------------------------
3 | // For the purpose of making video games, educational projects or gamification,
4 | // GeonBit is distributed under the MIT license and is totally free to use.
5 | // To use this source code or GeonBit as a whole for other purposes, please seek
6 | // permission from the library author, Ronen Ness.
7 | //
8 | // Copyright (c) 2017 Ronen Ness [ronenness@gmail.com].
9 | // Do not remove this license notice.
10 | //-----------------------------------------------------------------------------
11 | #endregion
12 | #region File Description
13 | //-----------------------------------------------------------------------------
14 | // Collision shape for a cone.
15 | //
16 | // Author: Ronen Ness.
17 | // Since: 2017.
18 | //-----------------------------------------------------------------------------
19 | #endregion
20 | using Microsoft.Xna.Framework;
21 |
22 | namespace GeonBit.Core.Physics.CollisionShapes
23 | {
24 | ///
25 | /// Which axis the cone is aligned with.
26 | ///
27 | public enum ConeDirectionAxis
28 | {
29 | ///
30 | /// Cone aligned with X axis.
31 | ///
32 | X,
33 |
34 | ///
35 | /// Cone aligned with Y axis.
36 | ///
37 | Y,
38 |
39 | ///
40 | /// Cone aligned with Z axis.
41 | ///
42 | Z,
43 | }
44 |
45 | ///
46 | /// Cone collision shape.
47 | ///
48 | public class CollisionCone : ICollisionShape
49 | {
50 | // cylinder axis type
51 | private ConeDirectionAxis _axisType;
52 |
53 | ///
54 | /// Create the collision cone.
55 | ///
56 | /// Cone radius.
57 | /// Cone height.
58 | /// Cone axis direction.
59 | public CollisionCone(float radius = 1f, float height = 1f, ConeDirectionAxis axis = ConeDirectionAxis.Y)
60 | {
61 | _axisType = axis;
62 | switch (_axisType)
63 | {
64 | case ConeDirectionAxis.X:
65 | _shape = new BulletSharp.ConeShapeX(radius, height);
66 | break;
67 |
68 | case ConeDirectionAxis.Y:
69 | _shape = new BulletSharp.ConeShape(radius, height);
70 | break;
71 |
72 | case ConeDirectionAxis.Z:
73 | _shape = new BulletSharp.ConeShapeZ(radius, height);
74 | break;
75 | }
76 | }
77 |
78 | ///
79 | /// Clone the physical shape.
80 | ///
81 | /// Cloned shape.
82 | protected override ICollisionShape CloneImp()
83 | {
84 | var shape = _shape as BulletSharp.ConeShape;
85 | return new CollisionCone(shape.Radius, shape.Height, _axisType);
86 | }
87 | }
88 | }
89 |
--------------------------------------------------------------------------------
/GeonBit/Source/Core/Physics/CollisionShapes/CollisionConvexHull.cs:
--------------------------------------------------------------------------------
1 | #region LICENSE
2 | //-----------------------------------------------------------------------------
3 | // For the purpose of making video games, educational projects or gamification,
4 | // GeonBit is distributed under the MIT license and is totally free to use.
5 | // To use this source code or GeonBit as a whole for other purposes, please seek
6 | // permission from the library author, Ronen Ness.
7 | //
8 | // Copyright (c) 2017 Ronen Ness [ronenness@gmail.com].
9 | // Do not remove this license notice.
10 | //-----------------------------------------------------------------------------
11 | #endregion
12 | #region File Description
13 | //-----------------------------------------------------------------------------
14 | // Collision shape for a convex hull.
15 | //
16 | // Author: Ronen Ness.
17 | // Since: 2017.
18 | //-----------------------------------------------------------------------------
19 | #endregion
20 | using Microsoft.Xna.Framework;
21 |
22 | namespace GeonBit.Core.Physics.CollisionShapes
23 | {
24 |
25 | ///
26 | /// Convex-Hull collision shape.
27 | ///
28 | public class CollisionConvexHull : ICollisionShape
29 | {
30 | ///
31 | /// Create the collision convext hull.
32 | ///
33 | /// Points to create convex hull from.
34 | public CollisionConvexHull(Vector3[] points)
35 | {
36 | // convert to bullet vectors and create the shape
37 | BulletSharp.Math.Vector3[] bvectors = ToBullet.Vectors(points);
38 | _shape = new BulletSharp.ConvexHullShape(bvectors);
39 | }
40 |
41 | ///
42 | /// Clone the physical shape.
43 | ///
44 | /// Cloned shape.
45 | protected override ICollisionShape CloneImp()
46 | {
47 | // extract points from shape
48 | var shape = _shape as BulletSharp.ConvexHullShape;
49 | Vector3[] points = new Vector3[shape.NumPoints];
50 | int i = 0;
51 | foreach (var point in shape.Points)
52 | {
53 | points[i++] = ToMonoGame.Vector(point);
54 | }
55 |
56 | // create and return clone
57 | return new CollisionConvexHull(points);
58 | }
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/GeonBit/Source/Core/Physics/CollisionShapes/CollisionCylinder.cs:
--------------------------------------------------------------------------------
1 | #region LICENSE
2 | //-----------------------------------------------------------------------------
3 | // For the purpose of making video games, educational projects or gamification,
4 | // GeonBit is distributed under the MIT license and is totally free to use.
5 | // To use this source code or GeonBit as a whole for other purposes, please seek
6 | // permission from the library author, Ronen Ness.
7 | //
8 | // Copyright (c) 2017 Ronen Ness [ronenness@gmail.com].
9 | // Do not remove this license notice.
10 | //-----------------------------------------------------------------------------
11 | #endregion
12 | #region File Description
13 | //-----------------------------------------------------------------------------
14 | // Collision shape for a cone.
15 | //
16 | // Author: Ronen Ness.
17 | // Since: 2017.
18 | //-----------------------------------------------------------------------------
19 | #endregion
20 | using Microsoft.Xna.Framework;
21 |
22 | namespace GeonBit.Core.Physics.CollisionShapes
23 | {
24 | ///
25 | /// Which axis the cylinder is aligned with.
26 | ///
27 | public enum CylinderDirectionAxis
28 | {
29 | ///
30 | /// Cylinder aligned with X axis.
31 | ///
32 | X,
33 |
34 | ///
35 | /// Cylinder aligned with Y axis.
36 | ///
37 | Y,
38 |
39 | ///
40 | /// Cylinder aligned with Z axis.
41 | ///
42 | Z,
43 | }
44 |
45 | ///
46 | /// Cone collision shape.
47 | ///
48 | public class CollisionCylinder : ICollisionShape
49 | {
50 | // cylinder axis type
51 | private CylinderDirectionAxis _axisType;
52 |
53 | ///
54 | /// Create the collision cylinder.
55 | ///
56 | /// Half extent on X, Y and Z of the cylinder.
57 | /// Cylinder axis direction.
58 | public CollisionCylinder(Vector3 halfExtent, CylinderDirectionAxis axis = CylinderDirectionAxis.Y)
59 | {
60 | _axisType = axis;
61 | switch (_axisType)
62 | {
63 | case CylinderDirectionAxis.X:
64 | _shape = new BulletSharp.CylinderShapeX(halfExtent.X, halfExtent.Y, halfExtent.Z);
65 | break;
66 |
67 | case CylinderDirectionAxis.Y:
68 | _shape = new BulletSharp.CylinderShape(halfExtent.X, halfExtent.Y, halfExtent.Z);
69 | break;
70 |
71 | case CylinderDirectionAxis.Z:
72 | _shape = new BulletSharp.CylinderShapeZ(halfExtent.X, halfExtent.Y, halfExtent.Z);
73 | break;
74 | }
75 | }
76 |
77 | ///
78 | /// Clone the physical shape.
79 | ///
80 | /// Cloned shape.
81 | protected override ICollisionShape CloneImp()
82 | {
83 | var shape = _shape as BulletSharp.CylinderShape;
84 | return new CollisionCylinder(ToMonoGame.Vector(shape.HalfExtentsWithoutMargin), _axisType);
85 | }
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/GeonBit/Source/Core/Physics/CollisionShapes/CollisionEndlessPlane.cs:
--------------------------------------------------------------------------------
1 | #region LICENSE
2 | //-----------------------------------------------------------------------------
3 | // For the purpose of making video games, educational projects or gamification,
4 | // GeonBit is distributed under the MIT license and is totally free to use.
5 | // To use this source code or GeonBit as a whole for other purposes, please seek
6 | // permission from the library author, Ronen Ness.
7 | //
8 | // Copyright (c) 2017 Ronen Ness [ronenness@gmail.com].
9 | // Do not remove this license notice.
10 | //-----------------------------------------------------------------------------
11 | #endregion
12 | #region File Description
13 | //-----------------------------------------------------------------------------
14 | // Collision shape for a an endless plane.
15 | //
16 | // Author: Ronen Ness.
17 | // Since: 2017.
18 | //-----------------------------------------------------------------------------
19 | #endregion
20 | using Microsoft.Xna.Framework;
21 |
22 | namespace GeonBit.Core.Physics.CollisionShapes
23 | {
24 | ///
25 | /// Endless plane collision shape.
26 | ///
27 | public class CollisionEndlessPlane : ICollisionShape
28 | {
29 | ///
30 | /// Create the collision plane.
31 | ///
32 | /// Plane normal vector.
33 | public CollisionEndlessPlane(Vector3? normal = null)
34 | {
35 | // default normal
36 | if (normal == null) { normal = Vector3.Up; }
37 |
38 | // create the plane shape
39 | _shape = new BulletSharp.StaticPlaneShape(ToBullet.Vector((Vector3)normal), 1);
40 | }
41 |
42 | ///
43 | /// Clone the physical shape.
44 | ///
45 | /// Cloned shape.
46 | protected override ICollisionShape CloneImp()
47 | {
48 | var shape = _shape as BulletSharp.StaticPlaneShape;
49 | return new CollisionEndlessPlane(ToMonoGame.Vector(shape.PlaneNormal));
50 | }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/GeonBit/Source/Core/Physics/CollisionShapes/CollisionSphere.cs:
--------------------------------------------------------------------------------
1 | #region LICENSE
2 | //-----------------------------------------------------------------------------
3 | // For the purpose of making video games, educational projects or gamification,
4 | // GeonBit is distributed under the MIT license and is totally free to use.
5 | // To use this source code or GeonBit as a whole for other purposes, please seek
6 | // permission from the library author, Ronen Ness.
7 | //
8 | // Copyright (c) 2017 Ronen Ness [ronenness@gmail.com].
9 | // Do not remove this license notice.
10 | //-----------------------------------------------------------------------------
11 | #endregion
12 | #region File Description
13 | //-----------------------------------------------------------------------------
14 | // Collision shape for a sphere.
15 | //
16 | // Author: Ronen Ness.
17 | // Since: 2017.
18 | //-----------------------------------------------------------------------------
19 | #endregion
20 | using Microsoft.Xna.Framework;
21 |
22 | namespace GeonBit.Core.Physics.CollisionShapes
23 | {
24 | ///
25 | /// Sphere shape.
26 | ///
27 | public class CollisionSphere : ICollisionShape
28 | {
29 | ///
30 | /// Create the collision sphere.
31 | ///
32 | /// Sphere radius.
33 | public CollisionSphere(float radius = 1f)
34 | {
35 | _shape = new BulletSharp.SphereShape(radius);
36 | }
37 |
38 | ///
39 | /// Clone the physical shape.
40 | ///
41 | /// Cloned shape.
42 | protected override ICollisionShape CloneImp()
43 | {
44 | var shape = _shape as BulletSharp.SphereShape;
45 | return new CollisionSphere(shape.Radius);
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/GeonBit/Source/Core/Physics/CollisionShapes/CollisionTriangle.cs:
--------------------------------------------------------------------------------
1 | #region LICENSE
2 | //-----------------------------------------------------------------------------
3 | // For the purpose of making video games, educational projects or gamification,
4 | // GeonBit is distributed under the MIT license and is totally free to use.
5 | // To use this source code or GeonBit as a whole for other purposes, please seek
6 | // permission from the library author, Ronen Ness.
7 | //
8 | // Copyright (c) 2017 Ronen Ness [ronenness@gmail.com].
9 | // Do not remove this license notice.
10 | //-----------------------------------------------------------------------------
11 | #endregion
12 | #region File Description
13 | //-----------------------------------------------------------------------------
14 | // Collision shape for a box.
15 | //
16 | // Author: Ronen Ness.
17 | // Since: 2017.
18 | //-----------------------------------------------------------------------------
19 | #endregion
20 | using Microsoft.Xna.Framework;
21 |
22 | namespace GeonBit.Core.Physics.CollisionShapes
23 | {
24 | ///
25 | /// Triangle collision shape.
26 | ///
27 | public class CollisionTriangle : ICollisionShape
28 | {
29 | ///
30 | /// Create the collision triangle.
31 | ///
32 | /// Triangle point 1.
33 | /// Triangle point 2.
34 | /// Triangle point 2.
35 | public CollisionTriangle(Vector3 p1, Vector3 p2, Vector3 p3)
36 | {
37 | _shape = new BulletSharp.TriangleShape(ToBullet.Vector(p1), ToBullet.Vector(p2), ToBullet.Vector(p3));
38 | }
39 |
40 | ///
41 | /// Clone the physical shape.
42 | ///
43 | /// Cloned shape.
44 | protected override ICollisionShape CloneImp()
45 | {
46 | var shape = _shape as BulletSharp.TriangleShape;
47 | return new CollisionTriangle(ToMonoGame.Vector(shape.Vertices[0]), ToMonoGame.Vector(shape.Vertices[1]), ToMonoGame.Vector(shape.Vertices[2]));
48 | }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/GeonBit/Source/Core/Physics/CollisionShapes/ICollisionShape.cs:
--------------------------------------------------------------------------------
1 | #region LICENSE
2 | //-----------------------------------------------------------------------------
3 | // For the purpose of making video games, educational projects or gamification,
4 | // GeonBit is distributed under the MIT license and is totally free to use.
5 | // To use this source code or GeonBit as a whole for other purposes, please seek
6 | // permission from the library author, Ronen Ness.
7 | //
8 | // Copyright (c) 2017 Ronen Ness [ronenness@gmail.com].
9 | // Do not remove this license notice.
10 | //-----------------------------------------------------------------------------
11 | #endregion
12 | #region File Description
13 | //-----------------------------------------------------------------------------
14 | // Interface for a physical collision shape.
15 | //
16 | // Author: Ronen Ness.
17 | // Since: 2017.
18 | //-----------------------------------------------------------------------------
19 | #endregion
20 |
21 | namespace GeonBit.Core.Physics.CollisionShapes
22 | {
23 | ///
24 | /// GeonBit.Core.Physics.CollisionShapes contain all the physical shapes we can use for rigid bodies.
25 | ///
26 | [System.Runtime.CompilerServices.CompilerGenerated]
27 | class NamespaceDoc
28 | {
29 | }
30 |
31 | ///
32 | /// The interface of a physical collision shape.
33 | ///
34 | public abstract class ICollisionShape
35 | {
36 | ///
37 | /// Get the bullet collision shape.
38 | ///
39 | internal BulletSharp.CollisionShape BulletCollisionShape { get { return _shape; } }
40 |
41 | ///
42 | /// Bullet shape instance (must be set by the inheriting class).
43 | ///
44 | protected BulletSharp.CollisionShape _shape;
45 |
46 | ///
47 | /// Clone the physical shape.
48 | ///
49 | /// Cloned shape.
50 | public ICollisionShape Clone()
51 | {
52 | // store old scale and reset scaling
53 | var oldScale = _shape.LocalScaling;
54 | _shape.LocalScaling = BulletSharp.Math.Vector3.One;
55 |
56 | // call the per-shape cloning logic
57 | var ret = CloneImp();
58 |
59 | // turn scale back to normal and return cloned shape
60 | _shape.LocalScaling = oldScale;
61 | return ret;
62 | }
63 |
64 | ///
65 | /// Implement per-shape cloning logic.
66 | ///
67 | /// Cloned shape.
68 | protected abstract ICollisionShape CloneImp();
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/GeonBit/Source/Core/Physics/Convert.cs:
--------------------------------------------------------------------------------
1 | #region LICENSE
2 | //-----------------------------------------------------------------------------
3 | // For the purpose of making video games, educational projects or gamification,
4 | // GeonBit is distributed under the MIT license and is totally free to use.
5 | // To use this source code or GeonBit as a whole for other purposes, please seek
6 | // permission from the library author, Ronen Ness.
7 | //
8 | // Copyright (c) 2017 Ronen Ness [ronenness@gmail.com].
9 | // Do not remove this license notice.
10 | //-----------------------------------------------------------------------------
11 | #endregion
12 | #region File Description
13 | //-----------------------------------------------------------------------------
14 | // Provide utilities to convert between MonoGame and Bullet classes.
15 | //
16 | // Author: Ronen Ness.
17 | // Since: 2017.
18 | //-----------------------------------------------------------------------------
19 | #endregion
20 | using Microsoft.Xna.Framework;
21 |
22 | namespace GeonBit.Core.Physics
23 | {
24 | ///
25 | /// Convert from MonoGame to Bullet3d.
26 | ///
27 | public static class ToBullet
28 | {
29 | ///
30 | /// Convert a vector from MonoGame to Bullet3d.
31 | ///
32 | /// Vector to convert.
33 | /// Bullet vector.
34 | public static BulletSharp.Math.Vector3 Vector(Vector3 vec)
35 | {
36 | return new BulletSharp.Math.Vector3(vec.X, vec.Y, vec.Z);
37 | }
38 |
39 | ///
40 | /// Convert an array of vectors from MonoGame to Bullet3d.
41 | ///
42 | /// Vectors array to convert.
43 | /// Array of Bullet vectors.
44 | public static BulletSharp.Math.Vector3[] Vectors(Vector3[] vecs)
45 | {
46 | BulletSharp.Math.Vector3[] bvectors = new BulletSharp.Math.Vector3[vecs.Length];
47 | int i = 0;
48 | foreach (var vector in vecs)
49 | {
50 | bvectors[i++] = ToBullet.Vector(vector);
51 | }
52 | return bvectors;
53 | }
54 |
55 | ///
56 | /// Convert a matrix from MonoGame to Bullet3d.
57 | ///
58 | /// Matrix to convert.
59 | /// Bullet matrix.
60 | public static BulletSharp.Math.Matrix Matrix(Matrix matrix)
61 | {
62 | return new BulletSharp.Math.Matrix(
63 | matrix.M11, matrix.M12, matrix.M13, matrix.M14,
64 | matrix.M21, matrix.M22, matrix.M23, matrix.M24,
65 | matrix.M31, matrix.M32, matrix.M33, matrix.M34,
66 | matrix.M41, matrix.M42, matrix.M43, matrix.M44);
67 | }
68 | }
69 |
70 | ///
71 | /// Convert from Bullet3d to MonoGame.
72 | ///
73 | public static class ToMonoGame
74 | {
75 | ///
76 | /// Convert a vector from Bullet to MonoGame.
77 | ///
78 | /// Vector to convert.
79 | /// MonoGame vector
80 | public static Vector3 Vector(BulletSharp.Math.Vector3 vec)
81 | {
82 | return new Vector3(vec.X, vec.Y, vec.Z);
83 | }
84 |
85 | ///
86 | /// Convert an array of vectors from Bullet3d to MonoGame.
87 | ///
88 | /// Bullet3d vectors array to convert.
89 | /// Array of MonoGame vectors.
90 | public static Vector3[] Vectors(BulletSharp.Math.Vector3[] bvecs)
91 | {
92 | Vector3[] vectors = new Vector3[bvecs.Length];
93 | int i = 0;
94 | foreach (var bvector in bvecs)
95 | {
96 | vectors[i++] = ToMonoGame.Vector(bvector);
97 | }
98 | return vectors;
99 | }
100 |
101 | ///
102 | /// Convert a matrix from Bullet to MonoGame.
103 | ///
104 | /// Matrix to convert.
105 | /// MonoGame matrix.
106 | public static Matrix Matrix(BulletSharp.Math.Matrix matrix)
107 | {
108 | return new Matrix(
109 | matrix.M11, matrix.M12, matrix.M13, matrix.M14,
110 | matrix.M21, matrix.M22, matrix.M23, matrix.M24,
111 | matrix.M31, matrix.M32, matrix.M33, matrix.M34,
112 | matrix.M41, matrix.M42, matrix.M43, matrix.M44);
113 | }
114 | }
115 | }
116 |
--------------------------------------------------------------------------------
/GeonBit/Source/Core/README.md:
--------------------------------------------------------------------------------
1 | # Core
2 |
3 | 'Core' contains all the basic stuff used to implement different Components. You can think of this as the "driver" layer.
4 | For example, it contains basic nodes and entities to draw stuff, or basic physics and collision entities. Then the "Component" layer uses this Core for its internal implementation:
5 |
6 | GameObject:
7 | Component --> Core
8 | Component --> Core
9 | ...
10 |
11 | For example, lets talk about drawing a model. First we have the GameObject entity. Then we attach to it a DrawModel component. But the component itself doesn't know how to draw stuff, so it uses a "GraphicModel" entity from the Core layer.
12 | That's the basic role of the Core.
--------------------------------------------------------------------------------
/GeonBit/Source/Core/Utils/ResizeableArray.cs:
--------------------------------------------------------------------------------
1 | #region LICENSE
2 | //-----------------------------------------------------------------------------
3 | // For the purpose of making video games, educational projects or gamification,
4 | // GeonBit is distributed under the MIT license and is totally free to use.
5 | // To use this source code or GeonBit as a whole for other purposes, please seek
6 | // permission from the library author, Ronen Ness.
7 | //
8 | // Copyright (c) 2017 Ronen Ness [ronenness@gmail.com].
9 | // Do not remove this license notice.
10 | //-----------------------------------------------------------------------------
11 | #endregion
12 | #region File Description
13 | //-----------------------------------------------------------------------------
14 | // Implements basic resizeable array.
15 | //
16 | // Author: Ronen Ness.
17 | // Since: 2017.
18 | //-----------------------------------------------------------------------------
19 | #endregion
20 | using System;
21 |
22 |
23 | namespace GeonBit.Core.Utils
24 | {
25 | ///
26 | /// An array you can add elements to, but still access the internal array object.
27 | ///
28 | /// Type to store in array.
29 | class ResizableArray
30 | {
31 | ///
32 | /// Items array.
33 | ///
34 | T[] m_array;
35 |
36 | ///
37 | /// Items count.
38 | ///
39 | int m_count;
40 |
41 | ///
42 | /// Create the resizable array with default starting size.
43 | ///
44 | /// Optional initial starting size.
45 | public ResizableArray(int? initialCapacity = null)
46 | {
47 | m_array = new T[initialCapacity ?? 4];
48 | }
49 |
50 | ///
51 | /// Get the internal array.
52 | ///
53 | public T[] InternalArray { get { return m_array; } }
54 |
55 | ///
56 | /// Get array real size.
57 | ///
58 | public int Count { get { return m_count; } }
59 |
60 | ///
61 | /// Clear the array.
62 | ///
63 | public void Clear()
64 | {
65 | m_array = new T[4];
66 | m_count = 0;
67 | }
68 |
69 | ///
70 | /// Remove the extra buffer from array and resize it to actual size.
71 | ///
72 | public void Trim()
73 | {
74 | Array.Resize(ref m_array, m_count);
75 | }
76 |
77 | ///
78 | /// Add element to array.
79 | ///
80 | /// Element to add.
81 | public void Add(T element)
82 | {
83 | // check if need to enlarge array
84 | if (m_count == m_array.Length)
85 | {
86 | Array.Resize(ref m_array, m_array.Length * 2);
87 | }
88 |
89 | // add to array and increase count
90 | m_array[m_count++] = element;
91 | }
92 |
93 | ///
94 | /// Add range of values to array.
95 | ///
96 | ///
97 | public void AddRange(T[] values)
98 | {
99 | foreach (var val in values)
100 | {
101 | Add(val);
102 | }
103 | }
104 | }
105 | }
106 |
--------------------------------------------------------------------------------
/GeonBit/Source/ECS/Components/Graphics/Backgrounds/SkyBox.cs:
--------------------------------------------------------------------------------
1 | #region LICENSE
2 | //-----------------------------------------------------------------------------
3 | // For the purpose of making video games, educational projects or gamification,
4 | // GeonBit is distributed under the MIT license and is totally free to use.
5 | // To use this source code or GeonBit as a whole for other purposes, please seek
6 | // permission from the library author, Ronen Ness.
7 | //
8 | // Copyright (c) 2017 Ronen Ness [ronenness@gmail.com].
9 | // Do not remove this license notice.
10 | //-----------------------------------------------------------------------------
11 | #endregion
12 | #region File Description
13 | //-----------------------------------------------------------------------------
14 | // A component that renders a 3D skybox.
15 | //
16 | // Author: Ronen Ness.
17 | // Since: 2017.
18 | //-----------------------------------------------------------------------------
19 | #endregion
20 | using Microsoft.Xna.Framework;
21 | using Microsoft.Xna.Framework.Graphics;
22 |
23 | namespace GeonBit.ECS.Components.Graphics
24 | {
25 |
26 | ///
27 | /// This component renders a 3d skybox.
28 | ///
29 | public class SkyBox : ModelRenderer
30 | {
31 | ///
32 | /// Skybox texture path.
33 | ///
34 | public string TexturePath { get; private set; }
35 |
36 | ///
37 | /// Default skybox texture.
38 | ///
39 | public static string DefaultTexture = "GeonBit.Core/Textures/Skybox";
40 |
41 | ///
42 | /// Create the skybox renderer component.
43 | ///
44 | /// Skybox texture path (leave null for default texture).
45 | public SkyBox(string texture = null) : base(ShapeRenderer.ShapeModelsRoot + "Skybox")
46 | {
47 | TexturePath = texture ?? DefaultTexture;
48 | _entity.RenderingQueue = Core.Graphics.RenderingQueue.SolidBackNoCull;
49 | _entity.SetMaterial(new Core.Graphics.Materials.SkyboxMaterial(TexturePath, true));
50 | }
51 |
52 | ///
53 | /// Clone this component.
54 | ///
55 | /// Cloned copy of this component.
56 | override public BaseComponent Clone()
57 | {
58 | SkyBox ret = CopyBasics(new SkyBox(TexturePath)) as SkyBox;
59 | return ret;
60 | }
61 |
62 | ///
63 | /// Called when this component spawns.
64 | ///
65 | protected override void OnSpawn()
66 | {
67 | _GameObject.SceneNode.DisableCulling = true;
68 | }
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/GeonBit/Source/ECS/Components/Graphics/Docs.cs:
--------------------------------------------------------------------------------
1 | namespace GeonBit.ECS.Components.Graphics
2 | {
3 | ///
4 | /// GeonBit.ECS.Components.Graphics contain graphic-related components.
5 | ///
6 | [System.Runtime.CompilerServices.CompilerGenerated]
7 | class NamespaceDoc
8 | {
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/GeonBit/Source/ECS/Components/Graphics/Renderers/BaseRenderer.cs:
--------------------------------------------------------------------------------
1 | #region LICENSE
2 | //-----------------------------------------------------------------------------
3 | // For the purpose of making video games, educational projects or gamification,
4 | // GeonBit is distributed under the MIT license and is totally free to use.
5 | // To use this source code or GeonBit as a whole for other purposes, please seek
6 | // permission from the library author, Ronen Ness.
7 | //
8 | // Copyright (c) 2017 Ronen Ness [ronenness@gmail.com].
9 | // Do not remove this license notice.
10 | //-----------------------------------------------------------------------------
11 | #endregion
12 | #region File Description
13 | //-----------------------------------------------------------------------------
14 | // Implement basic functionality for components that render stuff.
15 | //
16 | // Author: Ronen Ness.
17 | // Since: 2017.
18 | //-----------------------------------------------------------------------------
19 | #endregion
20 | using Microsoft.Xna.Framework.Graphics;
21 |
22 | namespace GeonBit.ECS.Components.Graphics
23 | {
24 | ///
25 | /// Base implementation for most graphics-related components.
26 | ///
27 | public abstract class BaseRendererComponent : BaseComponent
28 | {
29 | ///
30 | /// Get the main entity instance of this renderer.
31 | ///
32 | protected abstract Core.Graphics.BaseRenderableEntity Entity { get; }
33 |
34 | ///
35 | /// Set / get Entity blending state.
36 | ///
37 | public BlendState BlendingState
38 | {
39 | set { Entity.BlendingState = value; }
40 | get { return Entity.BlendingState; }
41 | }
42 |
43 | ///
44 | /// Set / get the rendering queue of this entity.
45 | ///
46 | virtual public Core.Graphics.RenderingQueue RenderingQueue
47 | {
48 | get { return Entity.RenderingQueue; }
49 | set { Entity.RenderingQueue = value; }
50 | }
51 |
52 | ///
53 | /// Copy basic properties to another component (helper function to help with Cloning).
54 | ///
55 | /// Other component to copy values to.
56 | /// The object we are copying properties to.
57 | protected override BaseComponent CopyBasics(BaseComponent copyTo)
58 | {
59 | base.CopyBasics(copyTo);
60 | BaseRendererComponent otherRenderer = copyTo as BaseRendererComponent;
61 | otherRenderer.RenderingQueue = RenderingQueue;
62 | otherRenderer.BlendingState = BlendingState;
63 | return copyTo;
64 | }
65 |
66 | ///
67 | /// Called when GameObject turned disabled.
68 | ///
69 | protected override void OnDisabled()
70 | {
71 | Entity.Visible = false;
72 | }
73 |
74 | ///
75 | /// Called when GameObject is enabled.
76 | ///
77 | protected override void OnEnabled()
78 | {
79 | Entity.Visible = true;
80 | }
81 |
82 | ///
83 | /// Change component parent GameObject.
84 | ///
85 | /// Previous parent.
86 | /// New parent.
87 | override protected void OnParentChange(GameObject prevParent, GameObject newParent)
88 | {
89 | // remove from previous parent
90 | if (prevParent != null && prevParent.SceneNode != null)
91 | {
92 | prevParent.SceneNode.RemoveEntity(Entity);
93 | }
94 |
95 | // add model entity to new parent
96 | if (newParent != null && newParent.SceneNode != null)
97 | {
98 | newParent.SceneNode.AddEntity(Entity);
99 | }
100 | }
101 | }
102 | }
103 |
--------------------------------------------------------------------------------
/GeonBit/Source/ECS/Components/Graphics/Renderers/BaseRendererWithOverrideMaterial.cs:
--------------------------------------------------------------------------------
1 | #region LICENSE
2 | //-----------------------------------------------------------------------------
3 | // For the purpose of making video games, educational projects or gamification,
4 | // GeonBit is distributed under the MIT license and is totally free to use.
5 | // To use this source code or GeonBit as a whole for other purposes, please seek
6 | // permission from the library author, Ronen Ness.
7 | //
8 | // Copyright (c) 2017 Ronen Ness [ronenness@gmail.com].
9 | // Do not remove this license notice.
10 | //-----------------------------------------------------------------------------
11 | #endregion
12 | #region File Description
13 | //-----------------------------------------------------------------------------
14 | // Define a base renderer with override material options.
15 | //
16 | // Author: Ronen Ness.
17 | // Since: 2018.
18 | //-----------------------------------------------------------------------------
19 | #endregion
20 | using GeonBit.Core.Graphics;
21 |
22 |
23 | namespace GeonBit.ECS.Components.Graphics
24 | {
25 | ///
26 | /// A base renderer with override material options.
27 | ///
28 | public abstract class BaseRendererWithOverrideMaterial : BaseRendererComponent
29 | {
30 | ///
31 | /// Override material default settings for this specific renderer instance.
32 | ///
33 | public abstract MaterialOverrides MaterialOverride { get; set; }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/GeonBit/Source/ECS/Components/Graphics/Renderers/BoundingBoxRenderer.cs:
--------------------------------------------------------------------------------
1 | #region LICENSE
2 | //-----------------------------------------------------------------------------
3 | // For the purpose of making video games, educational projects or gamification,
4 | // GeonBit is distributed under the MIT license and is totally free to use.
5 | // To use this source code or GeonBit as a whole for other purposes, please seek
6 | // permission from the library author, Ronen Ness.
7 | //
8 | // Copyright (c) 2017 Ronen Ness [ronenness@gmail.com].
9 | // Do not remove this license notice.
10 | //-----------------------------------------------------------------------------
11 | #endregion
12 | #region File Description
13 | //-----------------------------------------------------------------------------
14 | // A component that renders a 3D bounding-box around this GameObject.
15 | //
16 | // Author: Ronen Ness.
17 | // Since: 2017.
18 | //-----------------------------------------------------------------------------
19 | #endregion
20 | using Microsoft.Xna.Framework;
21 | using Microsoft.Xna.Framework.Graphics;
22 |
23 | namespace GeonBit.ECS.Components.Graphics
24 | {
25 | ///
26 | /// This component renders a bounding-box around this GameObject.
27 | ///
28 | public class BoundingBoxRenderer : BaseRendererComponent
29 | {
30 | // the entity used to draw the model
31 | Core.Graphics.BoundingBoxEntity _entity;
32 |
33 | ///
34 | /// Get the main entity instance of this renderer.
35 | ///
36 | protected override Core.Graphics.BaseRenderableEntity Entity { get { return _entity; } }
37 |
38 | ///
39 | /// Create the bounding-box renderer component.
40 | ///
41 | public BoundingBoxRenderer()
42 | {
43 | _entity = new Core.Graphics.BoundingBoxEntity();
44 | }
45 |
46 | ///
47 | /// Clone this component.
48 | ///
49 | /// Cloned copy of this component.
50 | override public BaseComponent Clone()
51 | {
52 | return CopyBasics(new BoundingBoxRenderer());
53 | }
54 |
55 | ///
56 | /// Called every frame to do the component events.
57 | ///
58 | protected override void OnUpdate()
59 | {
60 | // update bounding box
61 | if (_GameObject != null)
62 | {
63 | _entity.Box = _GameObject.SceneNode.GetBoundingBox();
64 | }
65 | }
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/GeonBit/Source/ECS/Components/Graphics/Renderers/ShapeRenderer.cs:
--------------------------------------------------------------------------------
1 | #region LICENSE
2 | //-----------------------------------------------------------------------------
3 | // For the purpose of making video games, educational projects or gamification,
4 | // GeonBit is distributed under the MIT license and is totally free to use.
5 | // To use this source code or GeonBit as a whole for other purposes, please seek
6 | // permission from the library author, Ronen Ness.
7 | //
8 | // Copyright (c) 2017 Ronen Ness [ronenness@gmail.com].
9 | // Do not remove this license notice.
10 | //-----------------------------------------------------------------------------
11 | #endregion
12 | #region File Description
13 | //-----------------------------------------------------------------------------
14 | // A component that renders a 3D shape.
15 | //
16 | // Author: Ronen Ness.
17 | // Since: 2017.
18 | //-----------------------------------------------------------------------------
19 | #endregion
20 | using Microsoft.Xna.Framework;
21 | using Microsoft.Xna.Framework.Graphics;
22 |
23 | namespace GeonBit.ECS.Components.Graphics
24 | {
25 | ///
26 | /// Possible shapes we can draw.
27 | ///
28 | public enum ShapeMeshes
29 | {
30 | /// Low-poly sphere shape.
31 | SphereLowPoly,
32 |
33 | /// Sphere shape.
34 | Sphere,
35 |
36 | /// Sphere with smooth normals.
37 | SphereSmooth,
38 |
39 | /// Cube shape.
40 | Cube,
41 |
42 | /// Cylinder shape.
43 | Cylinder,
44 |
45 | /// Cone shape.
46 | Cone,
47 |
48 | /// Plane shape.
49 | Plane,
50 | }
51 |
52 | ///
53 | /// This component renders a 3D shape from a collection of predefined meshes.
54 | ///
55 | public class ShapeRenderer : ModelRenderer
56 | {
57 | ///
58 | /// Path of the shape models folder.
59 | ///
60 | public static readonly string ShapeModelsRoot = "GeonBit.Core/BasicMeshes/";
61 |
62 | ///
63 | /// Create the model renderer component.
64 | ///
65 | /// Shape to draw.
66 | public ShapeRenderer(ShapeMeshes shape) : base(ShapeModelsRoot + shape.ToString())
67 | {
68 | }
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/GeonBit/Source/ECS/Components/Graphics/Renderers/SimpleModelRenderer.cs:
--------------------------------------------------------------------------------
1 | #region LICENSE
2 | //-----------------------------------------------------------------------------
3 | // For the purpose of making video games, educational projects or gamification,
4 | // GeonBit is distributed under the MIT license and is totally free to use.
5 | // To use this source code or GeonBit as a whole for other purposes, please seek
6 | // permission from the library author, Ronen Ness.
7 | //
8 | // Copyright (c) 2017 Ronen Ness [ronenness@gmail.com].
9 | // Do not remove this license notice.
10 | //-----------------------------------------------------------------------------
11 | #endregion
12 | #region File Description
13 | //-----------------------------------------------------------------------------
14 | // A component that renders a simple 3D model.
15 | //
16 | // Author: Ronen Ness.
17 | // Since: 2017.
18 | //-----------------------------------------------------------------------------
19 | #endregion
20 | using Microsoft.Xna.Framework;
21 | using Microsoft.Xna.Framework.Graphics;
22 |
23 | namespace GeonBit.ECS.Components.Graphics
24 | {
25 | ///
26 | /// This component renders a simple 3D model.
27 | /// Unlike the ModelRenderer, this component is less customizeable, but renders slightly faster.
28 | ///
29 | public class SimpleModelRenderer : BaseRendererComponent
30 | {
31 | ///
32 | /// The entity from the core layer used to draw the model.
33 | ///
34 | protected Core.Graphics.SimpleModelEntity _entity;
35 |
36 | ///
37 | /// Get the main entity instance of this renderer.
38 | ///
39 | protected override Core.Graphics.BaseRenderableEntity Entity { get { return _entity; } }
40 |
41 | ///
42 | /// Protected constructor without params to use without creating entity, for inheriting classes.
43 | ///
44 | protected SimpleModelRenderer()
45 | {
46 | }
47 |
48 | ///
49 | /// Create the model renderer component.
50 | ///
51 | /// Model to draw.
52 | public SimpleModelRenderer(Model model)
53 | {
54 | _entity = new Core.Graphics.SimpleModelEntity(model);
55 | }
56 |
57 | ///
58 | /// Create the model renderer component.
59 | ///
60 | /// Path of the model asset to draw.
61 | public SimpleModelRenderer(string model) : this(Resources.GetModel(model))
62 | {
63 | }
64 |
65 | ///
66 | /// Clone this component.
67 | ///
68 | /// Cloned copy of this component.
69 | override public BaseComponent Clone()
70 | {
71 | SimpleModelRenderer ret = new SimpleModelRenderer(_entity.Model);
72 | CopyBasics(ret);
73 | return ret;
74 | }
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/GeonBit/Source/ECS/Components/Misc/Docs.cs:
--------------------------------------------------------------------------------
1 | namespace GeonBit.ECS.Components.Misc
2 | {
3 | ///
4 | /// GeonBit.ECS.Components.Misc contain misc components.
5 | ///
6 | [System.Runtime.CompilerServices.CompilerGenerated]
7 | class NamespaceDoc
8 | {
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/GeonBit/Source/ECS/Components/Misc/TimeToLive.cs:
--------------------------------------------------------------------------------
1 | #region LICENSE
2 | //-----------------------------------------------------------------------------
3 | // For the purpose of making video games, educational projects or gamification,
4 | // GeonBit is distributed under the MIT license and is totally free to use.
5 | // To use this source code or GeonBit as a whole for other purposes, please seek
6 | // permission from the library author, Ronen Ness.
7 | //
8 | // Copyright (c) 2017 Ronen Ness [ronenness@gmail.com].
9 | // Do not remove this license notice.
10 | //-----------------------------------------------------------------------------
11 | #endregion
12 | #region File Description
13 | //-----------------------------------------------------------------------------
14 | // A component that destroy a game object after X seconds.
15 | //
16 | // Author: Ronen Ness.
17 | // Since: 2017.
18 | //-----------------------------------------------------------------------------
19 | #endregion
20 | using Microsoft.Xna.Framework;
21 | using System.Collections.Generic;
22 |
23 | namespace GeonBit.ECS.Components.Misc
24 | {
25 | ///
26 | /// This component destroy game objects after given timer.
27 | ///
28 | public class TimeToLive : BaseComponent
29 | {
30 | // how long left to live
31 | float _timeToLive = 0f;
32 |
33 | ///
34 | /// Create the time to live component.
35 | ///
36 | /// How long to wait before destroying this object.
37 | public TimeToLive(float timeToLive)
38 | {
39 | _timeToLive = timeToLive;
40 | }
41 |
42 | ///
43 | /// Clone this component.
44 | ///
45 | /// Cloned copy of this component.
46 | override public BaseComponent Clone()
47 | {
48 | return CopyBasics(new TimeToLive(_timeToLive));
49 | }
50 |
51 | ///
52 | /// Called every frame in the Update() loop.
53 | /// Note: this is called only if GameObject is enabled.
54 | ///
55 | protected override void OnUpdate()
56 | {
57 | _timeToLive -= Managers.TimeManager.TimeFactor;
58 | if (_timeToLive <= 0f)
59 | {
60 | _GameObject.Destroy();
61 | }
62 | }
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/GeonBit/Source/ECS/Components/Particles/Animators/AnimatorUtils.cs:
--------------------------------------------------------------------------------
1 | #region LICENSE
2 | //-----------------------------------------------------------------------------
3 | // For the purpose of making video games, educational projects or gamification,
4 | // GeonBit is distributed under the MIT license and is totally free to use.
5 | // To use this source code or GeonBit as a whole for other purposes, please seek
6 | // permission from the library author, Ronen Ness.
7 | //
8 | // Copyright (c) 2017 Ronen Ness [ronenness@gmail.com].
9 | // Do not remove this license notice.
10 | //-----------------------------------------------------------------------------
11 | #endregion
12 | #region File Description
13 | //-----------------------------------------------------------------------------
14 | // Help functions and utilities for animators.
15 | //
16 | // Author: Ronen Ness.
17 | // Since: 2017.
18 | //-----------------------------------------------------------------------------
19 | #endregion
20 | using System;
21 | using Microsoft.Xna.Framework;
22 |
23 | namespace GeonBit.ECS.Components.Particles.Animators
24 | {
25 | ///
26 | /// Misc animator related utilities.
27 | ///
28 | static public class AnimatorUtils
29 | {
30 | ///
31 | /// Random vector direction.
32 | ///
33 | public static Vector3 RandDirection(Random random, Vector3 baseVector, Vector3 randDir)
34 | {
35 | float originalLen = baseVector.Length();
36 | if (originalLen == 0f) originalLen = 1f;
37 | Vector3 newVelocity = baseVector;
38 | newVelocity.X += (float)(random.NextDouble() * (randDir.X * 2) - randDir.X);
39 | newVelocity.Y += (float)(random.NextDouble() * (randDir.Y * 2) - randDir.Y);
40 | newVelocity.Z += (float)(random.NextDouble() * (randDir.Z * 2) - randDir.Z);
41 | newVelocity.Normalize();
42 | return newVelocity * originalLen;
43 | }
44 |
45 | ///
46 | /// Random a vector from min and max.
47 | ///
48 | public static Vector3 RandVector(Random random, Vector3 minVector, Vector3 maxVector)
49 | {
50 | return new Vector3(
51 | minVector.X + ((float)random.NextDouble() * (maxVector.X - minVector.X)),
52 | minVector.Y + ((float)random.NextDouble() * (maxVector.Y - minVector.Y)),
53 | minVector.Z + ((float)random.NextDouble() * (maxVector.Z - minVector.Z)));
54 | }
55 |
56 | ///
57 | /// Random a vector from max vector only.
58 | ///
59 | public static Vector3 RandVector(Random random, Vector3 maxVector)
60 | {
61 | return new Vector3(
62 | -maxVector.X + ((float)random.NextDouble() * (maxVector.X * 2f)),
63 | -maxVector.Y + ((float)random.NextDouble() * (maxVector.Y * 2f)),
64 | -maxVector.Z + ((float)random.NextDouble() * (maxVector.Z * 2f)));
65 | }
66 |
67 | ///
68 | /// Random color value from base and rand color.
69 | ///
70 | public static Color RandColor(Random random, Color baseColor, Color colorJitter)
71 | {
72 | return new Color(
73 | (byte)Math.Min((int)255, baseColor.R + random.Next(colorJitter.R)),
74 | (byte)Math.Min((int)255, baseColor.G + random.Next(colorJitter.G)),
75 | (byte)Math.Min((int)255, baseColor.B + random.Next(colorJitter.B)));
76 | }
77 |
78 | ///
79 | /// Random color value from min and max color values.
80 | ///
81 | public static Color RandColor2(Random random, Color minColor, Color maxColor)
82 | {
83 | return new Color(
84 | random.Next(minColor.R, maxColor.R),
85 | random.Next(minColor.G, maxColor.G),
86 | random.Next(minColor.B, maxColor.B));
87 | }
88 |
89 | ///
90 | /// Calculate transition percent from current time and max time (return values from 0f to 1f).
91 | ///
92 | public static float CalcTransitionPercent(float timeAnimated, float maxTime)
93 | {
94 | return Math.Min(timeAnimated / maxTime, 1f);
95 | }
96 | }
97 | }
98 |
--------------------------------------------------------------------------------
/GeonBit/Source/ECS/Components/Particles/Docs.cs:
--------------------------------------------------------------------------------
1 | namespace GeonBit.ECS.Components.Particles
2 | {
3 | ///
4 | /// GeonBit.ECS.Components.Particles contain particle system and particles related components.
5 | ///
6 | [System.Runtime.CompilerServices.CompilerGenerated]
7 | class NamespaceDoc
8 | {
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/GeonBit/Source/ECS/Components/Physics/Docs.cs:
--------------------------------------------------------------------------------
1 | namespace GeonBit.ECS.Components.Physics
2 | {
3 | ///
4 | /// GeonBit.ECS.Components.Physics contain physics and collision-related components.
5 | ///
6 | [System.Runtime.CompilerServices.CompilerGenerated]
7 | class NamespaceDoc
8 | {
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/GeonBit/Source/ECS/Components/Sound/Docs.cs:
--------------------------------------------------------------------------------
1 | namespace GeonBit.ECS.Components.Sound
2 | {
3 | ///
4 | /// GeonBit.ECS.Components.Sound contain sound and music related components.
5 | ///
6 | [System.Runtime.CompilerServices.CompilerGenerated]
7 | class NamespaceDoc
8 | {
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/GeonBit/Source/ECS/README.md:
--------------------------------------------------------------------------------
1 | # ECS
2 |
3 | ECS stands for "Entity–component–system" (https://en.wikipedia.org/wiki/Entity%E2%80%93component%E2%80%93system).
4 |
5 | Basically, every object in the game is a GameObject (aka entity), on which we can add or remove "Components" at runtime.
6 | A Component can be anything, from sound effect, physics behavior, drawing a model, or scripting.
7 |
8 | The GameObject is basically the 'node' in the scene, while the 'components' you attach to it are the interesting objects that interact and render stuff.
9 | Most components will just use stuff from the 'Core' layer, and provide the API and the connection between independant 'Core' components and the 'GameObject'.
--------------------------------------------------------------------------------
/GeonBit/Source/Main/README.md:
--------------------------------------------------------------------------------
1 | # Main
2 |
3 | This folder contains the GeonBit main class (that runs the show) and the GeonBitGame class that the user need to implement.
4 | In addition it holds the MonoGame wrapper, which is a class used to connect between MonoGame's ```Game``` class and GeonBitMain.
--------------------------------------------------------------------------------
/GeonBit/Source/Managers/EasyManagersGetters.cs:
--------------------------------------------------------------------------------
1 | #region LICENSE
2 | //-----------------------------------------------------------------------------
3 | // For the purpose of making video games, educational projects or gamification,
4 | // GeonBit is distributed under the MIT license and is totally free to use.
5 | // To use this source code or GeonBit as a whole for other purposes, please seek
6 | // permission from the library author, Ronen Ness.
7 | //
8 | // Copyright (c) 2017 Ronen Ness [ronenness@gmail.com].
9 | // Do not remove this license notice.
10 | //-----------------------------------------------------------------------------
11 | #endregion
12 | #region File Description
13 | //-----------------------------------------------------------------------------
14 | // This class is used to get easier access to all public core managers in GeonBit.
15 | // Inherit from it to get a set of pre-defined public getters for main entities.
16 | //
17 | // Author: Ronen Ness.
18 | // Since: 2017.
19 | //-----------------------------------------------------------------------------
20 | #endregion
21 |
22 | namespace GeonBit.Managers
23 | {
24 | ///
25 | /// Provide a shortcut to all the important public stuff and core managers.
26 | /// Once inherit from this, you can easily access managers with "Managers.Manager" style.
27 | ///
28 | public class EasyManagersGetters
29 | {
30 | /// Get the ActiveScene this entity is inside.
31 | public ECS.GameScene ActiveScene { get { return Application.Instance.ActiveScene; } }
32 |
33 | /// Get the TimeManager manager.
34 | public TimeManager TimeManager { get { return TimeManager.Instance; } }
35 |
36 | /// Get the Input manager.
37 | public GameInput GameInput { get { return GameInput.Instance; } }
38 |
39 | /// Get the Application manager.
40 | public Application Application { get { return Application.Instance; } }
41 |
42 | /// Get the Prototypes manager.
43 | public Prototypes Prototypes { get { return Prototypes.Instance; } }
44 |
45 | /// Get the Diagnostic manager.
46 | public Diagnostic Diagnostic { get { return Diagnostic.Instance; } }
47 |
48 | /// Get the Graphics manager.
49 | public GraphicsManager GraphicsManager { get { return GraphicsManager.Instance; } }
50 |
51 | /// Get the Sound manager.
52 | public SoundManager SoundManager { get { return SoundManager.Instance; } }
53 |
54 | /// Get the currently active physical world.
55 | public Core.Physics.PhysicsWorld ScenePhysics { get { return Application.Instance.ActiveScene.Physics; } }
56 |
57 | /// Get the plugins manager.
58 | public Plugins Plugins { get { return Plugins.Instance; } }
59 |
60 | /// Get the config storage manager.
61 | public ConfigStorage ConfigStorage { get { return ConfigStorage.Instance; } }
62 |
63 | /// Get the game files manager.
64 | public GameFiles GameFiles { get { return GameFiles.Instance; } }
65 |
66 | ///
67 | /// Return if we are currently in debug mode.
68 | ///
69 | public bool DebugMode { get { return GeonBitMain.Instance.DebugMode; } }
70 |
71 | /// Get resources manager.
72 | public Core.ResourcesManager Resources { get { return Core.ResourcesManager.Instance; } }
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/GeonBit/Source/Managers/IManager.cs:
--------------------------------------------------------------------------------
1 | #region LICENSE
2 | //-----------------------------------------------------------------------------
3 | // For the purpose of making video games, educational projects or gamification,
4 | // GeonBit is distributed under the MIT license and is totally free to use.
5 | // To use this source code or GeonBit as a whole for other purposes, please seek
6 | // permission from the library author, Ronen Ness.
7 | //
8 | // Copyright (c) 2017 Ronen Ness [ronenness@gmail.com].
9 | // Do not remove this license notice.
10 | //-----------------------------------------------------------------------------
11 | #endregion
12 | #region File Description
13 | //-----------------------------------------------------------------------------
14 | // The API for a global manager class.
15 | // A manager is a singleton in GeonBit that provide utilities to a specific
16 | // aspect of the game, like physics, time utils, input, etc.
17 | //
18 | // Author: Ronen Ness.
19 | // Since: 2017.
20 | //-----------------------------------------------------------------------------
21 | #endregion
22 | using Microsoft.Xna.Framework;
23 |
24 | namespace GeonBit.Managers
25 | {
26 | ///
27 | /// GeonBit.Managers contains all the built-in GeonBit manager classes.
28 | ///
29 | [System.Runtime.CompilerServices.CompilerGenerated]
30 | class NamespaceDoc
31 | {
32 | }
33 |
34 | ///
35 | /// API for a public manager class.
36 | ///
37 | public interface IManager
38 | {
39 | ///
40 | /// Initialize the manager.
41 | ///
42 | void Initialize();
43 |
44 | ///
45 | /// Called every frame during the Update() phase.
46 | ///
47 | void Update(GameTime time);
48 |
49 | ///
50 | /// Called every frame during the Draw() phase.
51 | ///
52 | void Draw(GameTime time);
53 |
54 | ///
55 | /// Called every constant X seconds during the Update() phase.
56 | ///
57 | /// Time since last FixedUpdate().
58 | void FixedUpdate(float interval);
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/GeonBit/Source/Managers/README.md:
--------------------------------------------------------------------------------
1 | # Managers
2 |
3 | Managers are high-level entities, usually singletons, that provide utilities and / or public API around a specific subject.
4 | For example, the TimeManager manager provide helper functions to manage and use game time.
5 |
6 | The Managers in this folder are the core managers, eg built-in stuff that are integral part of GeonBit.
--------------------------------------------------------------------------------
/GeonBit/Source/Managers/SoundManager.cs:
--------------------------------------------------------------------------------
1 | #region LICENSE
2 | //-----------------------------------------------------------------------------
3 | // For the purpose of making video games, educational projects or gamification,
4 | // GeonBit is distributed under the MIT license and is totally free to use.
5 | // To use this source code or GeonBit as a whole for other purposes, please seek
6 | // permission from the library author, Ronen Ness.
7 | //
8 | // Copyright (c) 2017 Ronen Ness [ronenness@gmail.com].
9 | // Do not remove this license notice.
10 | //-----------------------------------------------------------------------------
11 | #endregion
12 | #region File Description
13 | //-----------------------------------------------------------------------------
14 | // Manage game sound and provide sound-related utils.
15 | //
16 | // Author: Ronen Ness.
17 | // Since: 2017.
18 | //-----------------------------------------------------------------------------
19 | #endregion
20 | using Microsoft.Xna.Framework;
21 | using Microsoft.Xna.Framework.Media;
22 |
23 | namespace GeonBit.Managers
24 | {
25 | ///
26 | /// Manage game sound and provide sound-related utils
27 | ///
28 | public class SoundManager : IManager
29 | {
30 | // singleton instance
31 | static SoundManager _instance = null;
32 |
33 | ///
34 | /// Get instance.
35 | ///
36 | public static SoundManager Instance
37 | {
38 | get
39 | {
40 | if (_instance == null)
41 | {
42 | _instance = new SoundManager();
43 | }
44 | return _instance;
45 | }
46 | }
47 |
48 | ///
49 | /// To make it a singleton.
50 | ///
51 | private SoundManager() { }
52 |
53 | ///
54 | /// Update manager.
55 | ///
56 | /// GameTime, as provided by MonoGame.
57 | public void Update(GameTime time)
58 | {
59 | }
60 |
61 | ///
62 | /// Play a background music.
63 | ///
64 | /// Music content file path (must be of type song).
65 | /// If true, will play music in loop.
66 | /// If provided, will also set music volume. If not, will use last-set music volume.
67 | public void PlayMusic(string name, bool inLoop = true, float? volume = null)
68 | {
69 | Song song = Core.ResourcesManager.Instance.GetSong(name);
70 | MusicRepeats = inLoop;
71 | MediaPlayer.Play(song);
72 | if (volume != null) { MusicVolume = volume.Value; }
73 | }
74 |
75 | ///
76 | /// Get / Set music volume.
77 | ///
78 | public float MusicVolume
79 | {
80 | get { return MediaPlayer.Volume; }
81 | set { MediaPlayer.Volume = value; }
82 | }
83 |
84 | ///
85 | /// Get / Set if music repeats.
86 | ///
87 | public bool MusicRepeats
88 | {
89 | get { return MediaPlayer.IsRepeating; }
90 | set { MediaPlayer.IsRepeating = value; }
91 | }
92 |
93 | ///
94 | /// Stop playing currently playing background music.
95 | ///
96 | public void StopMusic()
97 | {
98 | MediaPlayer.Stop();
99 | }
100 |
101 | ///
102 | /// Pause background music.
103 | ///
104 | public void PauseMusic()
105 | {
106 | MediaPlayer.Pause();
107 | }
108 |
109 | ///
110 | /// Resume background music.
111 | ///
112 | public void ResumeMusic()
113 | {
114 | MediaPlayer.Resume();
115 | }
116 |
117 | ///
118 | /// Called every frame during the Draw() process.
119 | ///
120 | public void Draw(GameTime time)
121 | {
122 | }
123 |
124 | ///
125 | /// Init Game Utils manager.
126 | ///
127 | public void Initialize()
128 | {
129 | }
130 |
131 | ///
132 | /// Called every constant X seconds during the Update() phase.
133 | ///
134 | /// Time since last FixedUpdate().
135 | public void FixedUpdate(float interval)
136 | {
137 | }
138 | }
139 | }
140 |
--------------------------------------------------------------------------------
/GeonBit/Source/README.md:
--------------------------------------------------------------------------------
1 | # Source
2 |
3 | GeonBit main source code. This is where the magic happens.
--------------------------------------------------------------------------------
/GeonBit/app.manifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 | true/pm
39 |
40 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/GeonBit/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2017 Ronen Ness
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy
4 | of this software and associated documentation files (the "Software"), to deal
5 | in the Software without restriction, including without limitation the rights
6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | copies of the Software, and to permit persons to whom the Software is
8 | furnished to do so, subject to the following conditions:
9 |
10 | The above copyright notice and this permission notice shall be included in all
11 | copies or substantial portions of the Software.
12 |
13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | SOFTWARE.
20 |
--------------------------------------------------------------------------------
/PluginTemplate/GeonBitPluginTemplate.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RonenNess/GeonBit/988989b71e3ea695778d12cee264f0f849ab06c7/PluginTemplate/GeonBitPluginTemplate.zip
--------------------------------------------------------------------------------
/PluginTemplate/README.md:
--------------------------------------------------------------------------------
1 | # Plugin Template
2 |
3 | A template project to create GeonBit plugins.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | 
2 |
3 | # Warning
4 |
5 | This project is a bit old and no longer maintained. Also some would argue its not a real ECS due to the structure of the components and lack of actual systems.
6 | It's still a pretty cool framework, just maybe not what you're looking for.
7 |
8 | # GeonBit
9 |
10 | **A 3D Entity-Component-System engine, powered by MonoGame for C# games.**
11 |
12 | # License
13 |
14 | MIT
15 |
16 | # Documentation
17 |
18 | GeonBit docs are available [by chapters](docs/index.md) or [as a single file](docs/README.md).
19 |
20 | In addition, complete API docs can be found online [here](https://ronenness.github.io/GeonBit-docs/).
21 |
22 | # Installation
23 |
24 | Installing and using *GeonBit* takes only [3 simple steps](docs/chapters/setup.md)!
25 |
26 | # Demos
27 |
28 | Some *GeonBit* demo projects are available [here](https://github.com/RonenNess/GeonBit.Demos).
29 | Feel free to download and use them!
30 |
31 | # Changelog
32 |
33 | Versions changelog can be found [here](docs/changes.md).
34 |
35 |
36 | 
37 |
--------------------------------------------------------------------------------
/Template/GeonBit Desktop Application.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RonenNess/GeonBit/988989b71e3ea695778d12cee264f0f849ab06c7/Template/GeonBit Desktop Application.zip
--------------------------------------------------------------------------------
/Template/README.md:
--------------------------------------------------------------------------------
1 | # Template
2 |
3 | Template file for an empty GeonBit project.
4 |
5 | Template project git:
6 | https://github.com/RonenNess/GeonBit.Template
--------------------------------------------------------------------------------
/docs/CNAME:
--------------------------------------------------------------------------------
1 | geonbit.com
--------------------------------------------------------------------------------
/docs/Documentation.chm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RonenNess/GeonBit/988989b71e3ea695778d12cee264f0f849ab06c7/docs/Documentation.chm
--------------------------------------------------------------------------------
/docs/_config.yml:
--------------------------------------------------------------------------------
1 | theme: jekyll-theme-slate
--------------------------------------------------------------------------------
/docs/assets/GeonBit-sm.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RonenNess/GeonBit/988989b71e3ea695778d12cee264f0f849ab06c7/docs/assets/GeonBit-sm.png
--------------------------------------------------------------------------------
/docs/assets/UI-example1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RonenNess/GeonBit/988989b71e3ea695778d12cee264f0f849ab06c7/docs/assets/UI-example1.png
--------------------------------------------------------------------------------
/docs/assets/ecs-explained.pptx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RonenNess/GeonBit/988989b71e3ea695778d12cee264f0f849ab06c7/docs/assets/ecs-explained.pptx
--------------------------------------------------------------------------------
/docs/assets/ecs-model.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RonenNess/GeonBit/988989b71e3ea695778d12cee264f0f849ab06c7/docs/assets/ecs-model.png
--------------------------------------------------------------------------------
/docs/assets/ecs-vs-non-ecs.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RonenNess/GeonBit/988989b71e3ea695778d12cee264f0f849ab06c7/docs/assets/ecs-vs-non-ecs.png
--------------------------------------------------------------------------------
/docs/assets/example1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RonenNess/GeonBit/988989b71e3ea695778d12cee264f0f849ab06c7/docs/assets/example1.png
--------------------------------------------------------------------------------
/docs/assets/examples.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RonenNess/GeonBit/988989b71e3ea695778d12cee264f0f849ab06c7/docs/assets/examples.jpg
--------------------------------------------------------------------------------
/docs/assets/non-ecs-model.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RonenNess/GeonBit/988989b71e3ea695778d12cee264f0f849ab06c7/docs/assets/non-ecs-model.png
--------------------------------------------------------------------------------
/docs/assets/octree.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RonenNess/GeonBit/988989b71e3ea695778d12cee264f0f849ab06c7/docs/assets/octree.png
--------------------------------------------------------------------------------
/docs/assets/overview.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RonenNess/GeonBit/988989b71e3ea695778d12cee264f0f849ab06c7/docs/assets/overview.jpg
--------------------------------------------------------------------------------
/docs/assets/overview.pptx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RonenNess/GeonBit/988989b71e3ea695778d12cee264f0f849ab06c7/docs/assets/overview.pptx
--------------------------------------------------------------------------------
/docs/assets/physics.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RonenNess/GeonBit/988989b71e3ea695778d12cee264f0f849ab06c7/docs/assets/physics.png
--------------------------------------------------------------------------------
/docs/assets/spaceship-demo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RonenNess/GeonBit/988989b71e3ea695778d12cee264f0f849ab06c7/docs/assets/spaceship-demo.png
--------------------------------------------------------------------------------
/docs/assets/sprite.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RonenNess/GeonBit/988989b71e3ea695778d12cee264f0f849ab06c7/docs/assets/sprite.png
--------------------------------------------------------------------------------
/docs/assets/template-project.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RonenNess/GeonBit/988989b71e3ea695778d12cee264f0f849ab06c7/docs/assets/template-project.png
--------------------------------------------------------------------------------
/docs/assets/template-window.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RonenNess/GeonBit/988989b71e3ea695778d12cee264f0f849ab06c7/docs/assets/template-window.png
--------------------------------------------------------------------------------
/docs/build.py:
--------------------------------------------------------------------------------
1 | """
2 | README.md contains the entire readme document, with all chapters.
3 | This script breaks the main readme file into chapters and create a file with links to them.
4 | """
5 | # read entire file
6 | readme = open("README.md", "r").read()
7 |
8 | # break into chapters
9 | chapters = readme.split("\n# ")
10 | print("Found", len(chapters), "potential chapters.")
11 |
12 | # will contain a list of chapter names and the urls
13 | out_chapters = []
14 |
15 | # iterate chapters
16 | for chapter in chapters:
17 |
18 | # get current chapter header
19 | header = chapter.split('\n')[0]
20 |
21 | # fix assets path
22 | chapter = chapter.replace('(assets/', '(../assets/')
23 |
24 | # if special chars appear in chapter name its the opening image, skip it
25 | if '[' in header:
26 | continue
27 |
28 | # if chapter header is just 'GeonBit', its still part of the opening, skip it
29 | if header == 'GeonBit':
30 | continue
31 |
32 | # create chapter filename
33 | chapter_filename = "chapters/" + header.lower().replace(' ', '_') + ".md"
34 |
35 | # add to output list
36 | out_chapters.append((header, chapter_filename))
37 |
38 | # write chapter file
39 | with open(chapter_filename, 'w') as chapter_file:
40 | chapter_file.write('# ' + chapter)
41 |
42 | # print total chapters
43 | print("\nOutput chapters: ")
44 | for i in out_chapters:
45 | print(i)
46 |
47 | # build table of content
48 | toc = ""
49 | for i in out_chapters:
50 | toc += "[%s](%s)\n\n" % (i[0], i[1])
51 |
52 | # create TOC file
53 | with open("index.md", 'w') as outfile:
54 | outfile.write("""
55 |
56 | # GeonBit
57 |
58 | **A 3D Entity-Component-System engine, powered by MonoGame for C# games.**
59 |
60 | ## Table Of Contents
61 |
62 | __toc__
63 |
64 | Or read the whole readme file in one chunk [here](README.md).
65 | """.replace('__toc__', toc))
66 |
--------------------------------------------------------------------------------
/docs/chapters/(alternative)_manual_setup.md:
--------------------------------------------------------------------------------
1 | # (Alternative) Manual Setup
2 |
3 | If you don't want to use *GeonBit*'s template (not recommended!), you can also install *GeonBit* manually:
4 |
5 | ### Setup GeonBit.UI
6 |
7 | First setup GeonBit.UI, which is the UI system that comes with *GeonBit*.
8 | Its git and installation instructions can be found [here](https://github.com/RonenNess/GeonBit.UI).
9 |
10 | ### Setup GeonBit Core
11 |
12 | After the UI is setup, install the *GeonBit* NuGet package with the following command:
13 |
14 | ```
15 | Install-Package GeonBit
16 | ```
17 |
18 | This will also install the required dependencies.
19 |
20 | Once the all the NuGet packages are successfully installed, follow these steps:
21 |
22 | 1. Add all the Content that comes with the package (under the ```Content/GeonBit/``` folder).
23 | 2. Instead of implementing ```MonoGame``` 'Game' class, inherit and implement a ```GeonBit.GeonBitGame``` class, and implement the following functions:
24 | 1. ```Draw()``` to add extra drawing logic.
25 | 2. ```Update()``` to add extra update logic.
26 | 3. ```Initialize()``` to create your scene and initialize stuff.
27 | 3. From your program's ```Main()``` function, Run *GeonBit* with your GeonBitGame class: ```GeonBitMain.Instance.Run(new MyGeonBitGame());```
28 |
29 |
--------------------------------------------------------------------------------
/docs/chapters/cookbook.md:
--------------------------------------------------------------------------------
1 | # Cookbook
2 |
3 | In previous chapters we learned about the different classes of *GeonBit* and what the engine has to offer.
4 | In this chapter we'll go throught a set of coding examples to show how to do basic and common things required for different game styles.
5 |
6 | This is a basic how-to collection with *GeonBit*.
7 |
8 |
9 | ## Create Animated Sprites
10 |
11 | TBD
12 |
13 | ## Use Skinned Models
14 |
15 | TBD
16 |
17 | ## Backgrounds and Skybox
18 |
19 | TBD
20 |
21 | ## Create Player Controls
22 |
23 | TBD
24 |
25 | ## Make Isometric Game
26 |
27 | TBD
28 |
29 | ## Make FPS Game
30 |
31 | TBD
32 |
33 | ## Make Top Down Game
34 |
35 | TBD
36 |
37 |
--------------------------------------------------------------------------------
/docs/chapters/demos.md:
--------------------------------------------------------------------------------
1 | # Demos
2 |
3 | Some *GeonBit* demo projects are available [here](https://github.com/RonenNess/GeonBit.Demos).
4 | Feel free to download and use them!
5 |
6 | 
7 |
--------------------------------------------------------------------------------
/docs/chapters/geonbit_overview.md:
--------------------------------------------------------------------------------
1 | # GeonBit Overview
2 |
3 | This section provides a broad overview of the layers of *GeonBit*. It's arranged from top down, eg from the highest-level APIs to the lower-level "drivers".
4 |
5 | 
6 |
7 | ## GeonBitMain
8 |
9 | A singleton class that reside directly under the *GeonBit* namespace, and provide the main API to initialize and run the *GeonBit* engine.
10 |
11 | You can use this class in two ways:
12 |
13 | 1. Implement a GeonBitGame class and call ```GeonBitMain.Instance.Run()``` to execute it.
14 | 2. Create your own *MonoGame* ```Game``` class, and call ```Initialize()```, ```Update()``` and ```Draw()``` manually (less recommended method).
15 |
16 |
17 | ## GeonBitGame
18 |
19 | A class that replace *MonoGame*'s ```Game``` class and integrates with *GeonBit*.
20 | You should inherit from this class to implement your game logic and use ```GeonBitMain.Run()``` to start the game main loop.
21 |
22 |
23 | ## Resources
24 |
25 | Instead of the default *MonoGame* Content class, in *GeonBit* you use the Resources Manager.
26 | When implementing a custom component or GeonBitGame class, the resources manager is easily accessible via the ```Resources``` getter.
27 |
28 |
29 | ## GeonBit.Managers
30 |
31 | The ```Managers``` layer is a collection of singleton classes, which provide API and utilities for things like input, game-time, diagnostics, physics, filesystem, etc.
32 |
33 | These classes are accessible by the game components and scripts you write.
34 |
35 |
36 | ## GeonBit.UI
37 |
38 | This layer contain a variety of UI elements you can create and use, and a main ```User Interface``` manager that runs the UI engine.
39 |
40 | Note that ```GeonBit.UI``` is also released as an external independent library you can use for other ```MonoGame``` projects, even if they don't use *GeonBit*. More details [here](https://github.com/RonenNess/GeonBit.UI).
41 |
42 |
43 | ## GeonBit.ECS
44 |
45 | The namespace that contains all the Entity-Component-System related classes.
46 | The basic *GameObject* class is implemented in this layer, as well the *GameScene* and all the *Components* you can attach to objects.
47 |
48 |
49 | ## GeonBit.Core
50 |
51 | The ```Core``` layer provide the actual implementation of the different built-in components and engine components.
52 |
53 | For example, a component to render a 3D model will not deal with ```MonoGame``` models directly, but instead will use an object implemented in the ```Core``` layer that will do all the dirty work.
54 | The ```Core``` layer also implements the integration with some third-party libraries, like the ```Bullet3D``` Physics engine.
55 |
56 | While most of the ```Core``` classes are public and can be accessed by your game, usually its best to stick to the ```ECS``` layer and reduce ```Core``` usage to minumum.
57 |
58 |
59 | ## External Libs
60 |
61 | In addition to *MonoGame*, *GeonBit* uses some external libraries to implement different components of the engine, like ```Bullet3D``` for physics.
62 |
63 | These libs are used by the ```Core``` layer and you should not use them directly. Just know its there.
64 |
65 |
--------------------------------------------------------------------------------
/docs/chapters/glossary.md:
--------------------------------------------------------------------------------
1 | # Glossary
2 |
3 | Before diving deeper into *GeonBit*, lets define some basic concepts (these are relevant to most ECS engines out there):
4 |
5 | ## GameObject
6 |
7 | Game Objects are our main entities in the Engine. They are the ```Entities``` of the Entity-Component-System model.
8 | Every element of the game is implemented by a Game Object with components attached to it, from monsters to scripting and sound effects.
9 |
10 | There is only one type of a *GameObject*, the difference between objects reside in the component types attached to them.
11 | For example, if you want to place trees in your game, you'll probably create a *GameObject* with a 3D model of a tree + physical body attached to it.
12 |
13 | Every *GameObject* have a list of child *GameObject*s, and a 3D scene node that represent its transformations in 3d space (eg position, rotation, scale etc).
14 |
15 |
16 | ## Components
17 |
18 | *Components* are the logic pieces you attach to *GameObjects*, like a 3d model to render, a physicla body, sound effect to play, etc.
19 |
20 | A *GameObject* without any components is just a node in the Scene, it has transformations and a 3D position and can hold children, but it doesn't do much without any *Components*. To make a *GameObject* a meaningful part of your game, you attach *Components* to it.
21 |
22 | Most components are independent and do not communicate with each other, but there are some exceptions that depeand on each other or even affect the transformations of the *GameObject* itself (for example, physics-related components often change the position & rotation of the *GameObject* containing them).
23 |
24 | Note that *Components* are also the objects you will implement the most. For example, to create an AI to control your game monsters, you'll probably write some sort of an ```NPCs-Controller``` component and attach it to your monsters ```Game Objects```.
25 |
26 |
27 | ## SceneNode
28 |
29 | Every *GameObject* has a scene node that represent its 3d transformations, eg position, scale, rotation, etc.
30 | Unlike the *GameObject* that only has one type, there are many types of ```SceneNode```s that behave differently and are optimized for different purposes. We will cover those later.
31 |
32 |
33 | ## Prototypes
34 |
35 | Since different objects in the game are made of *GameObject* with components attached to them, you probably want a way to define a game-specific type and create instances of it with all the components it needs. To do so, we use ```Prototypes```.
36 |
37 | A ```Prototype``` is an instance of a *GameObject* you register to the ```Prototypes Manager``` and later you can create clones of it, or 'instanciate' it if you will.
38 |
39 |
40 | ## Scene
41 |
42 | A ```Scene``` is a tree of *GameObjects* + some global settings, that represent a level or a 'screen' in your game.
43 |
44 | ```Scenes``` can be easily loaded / unload to switch between levels and scenery.
45 |
46 |
--------------------------------------------------------------------------------
/docs/chapters/intro.md:
--------------------------------------------------------------------------------
1 | # Intro
2 |
3 | GeonBit is an extensive Entity-Component based game engine, written in ```C#``` and powered by ```MonoGame```.
4 |
5 |
6 | ## What's ECS
7 |
8 | From [Wikipedia](https://en.wikipedia.org/wiki/Entity%E2%80%93component%E2%80%93system):
9 |
10 | > Entity-component system (ECS) is an architectural pattern that is mostly used in game development.
11 | >
12 | > An ECS follows the Composition over inheritance principle that allows greater flexibility in defining entities where every object in a game's scene is an entity (e.g. enemies, bullets, vehicles, etc.).
13 | >
14 | > Every Entity consists of one or more components which add additional behavior or functionality. Therefore, the behavior of an entity can be changed at runtime by adding or removing components. This eliminates the ambiguity problems of deep and wide inheritance hierarchies that are difficult to understand, maintain and extend. Common ECS approaches are highly compatible and often combined with data oriented design techniques.
15 |
16 | Or in short, GeonBit provide a system of generic Game Objects to which you can attach / detach components. These are the building-blocks of your game.
17 | In addition to the ECS system and framework, GeonBit also comes with a large set of built-in components, that make things like drawing, animating and physics a breeze.
18 |
19 |
20 | 
21 |
22 |
23 | ## Key Features
24 |
25 | In addition to its built-in ECS framework, *GeonBit* provide the following features / classes:
26 |
27 |
28 | - UI
29 | - - GeonBit.UI v3.x
30 | - Managers
31 | - - Application
32 | - - ConfigStorage
33 | - - Diagnostics
34 | - - GameFiles
35 | - - GameInput
36 | - - Graphics
37 | - - Plugins
38 | - - Prototypes
39 | - - Sounds
40 | - - GameTime
41 | - Graphics
42 | - - Background
43 | - - Skybox
44 | - - Models
45 | - - Skinned Models
46 | - - Composite Models
47 | - - Combined Meshes
48 | - - Managed lights & lit materials
49 | - - Billboard
50 | - - Sprite
51 | - - Shapes
52 | - Resources Manager
53 | - Misc
54 | - - TileMap
55 | - - Editor Controller
56 | - - Time To Live
57 | - Particles System
58 | - - CPU Particles
59 | - - Animators
60 | - Physics
61 | - - All basic collision shapes
62 | - - Height maps
63 | - - Convex / hull shapes
64 | - - Compound collision shapes
65 | - - Rigid Body
66 | - - Kinematic Body
67 | - - Static Body
68 | - - Collision groups & filters
69 | - - Collision events
70 | - - Ethereal objects
71 | - - Raytesting
72 | - Sound
73 | - - Sound effects
74 | - - 3D sounds
75 | - - Background music
76 |
77 | In short, GeonBit comes with everything you need to make a basic 3D game, fast and easy!
78 |
79 | For more complicated stuff (for example, if you build a multiplayer game and need networking components), *GeonBit* is open source and easy to extend. So you can easily write your own components and integrate them into the existing ECS framework.
80 |
81 |
--------------------------------------------------------------------------------
/docs/chapters/misc.md:
--------------------------------------------------------------------------------
1 | # Misc
2 |
3 | ## Working on GeonBit
4 |
5 | This repo contains the source of GeonBit engine. It should build to a cross-platform Any CPU dll, and should not run directly from here.
6 |
7 | ### Distributing New Version
8 |
9 | To distribute a new version follow these steps:
10 |
11 | - Build the new dll.
12 | - Update NuGet package - be sure to update version in both the nuget spec and in the code const.
13 | - Build a new template (described later).
14 | - Put the result template under ```Template/``` folder.
15 |
16 | ### Updating GeonBit.UI
17 |
18 | When updating GeonBit.UI version, we need to update the version via the NuGet package manager, but after installation remove all of GeonBit.UI content and resources.
19 | The reason for that is that we don't want to store them in the git (while they already appear in GeonBit.UI git) and when we build the template (will be described soon) those resources will be restored anyway.
20 |
21 | ### Building The Template
22 |
23 | To distribute GeonBit we build a visual studio template.
24 |
25 | To build a new template, go to the [GeonBit.Template](https://github.com/RonenNess/GeonBit.Template) project (note: its private) and update GeonBit to latest version.
26 |
27 | Follow the instructions in git, and put the result in ```Template/``` folder.
28 |
29 |
30 | ## TBDS
31 |
32 | Things I want to add to GeonBit in near future.
33 |
34 | - GPU particles system.
35 | - LoD renderer - a component that is a collection of renderer components and switch between them automatically based on distance from camera.
36 | - Physical material.
37 |
38 | ## Credits
39 |
40 | - Kastellanos Nikolaos for Skinned Model animations (https://github.com/tainicom/Aether.Extras).
41 |
--------------------------------------------------------------------------------
/docs/chapters/plugins.md:
--------------------------------------------------------------------------------
1 | # Plugins
2 |
3 | Its very common to define your own Component types and custom Managers in GeonBit, and even more common to want to reuse or share them with other people.
4 | The best way to do it is to create Plugins.
5 |
6 | You can create custom a plugin by making a dll that reference ```GeonBit.Core``` and implements a special class called ```GeonBitPluginInitializer```, which will be described shortly.
7 | Inside your custom plugin you can define any number of Components, Managers, and other cool Utils, and adding plugins to GeonBit is simply a matter of referencing the plugin's dll.
8 |
9 | ## Core Plugins
10 |
11 | The following is a list of GeonBit core plugins that ship separately and you can easily add to your GeonBit projects:
12 |
13 | - LuaScript: plugin that add support in dynamically-loaded Lua scripts (via MoonSharp). TBD
14 | - CSharpScript: plugin that add support in dynamically-loaded C# scripts (via Roslyn). TBD
15 |
16 |
17 | ## GeonBitPluginInitializer
18 |
19 | To make your plugin recognized by *GeonBit*, define anywhere in your assembly a public class called ```GeonBitPluginInitializer```, that implements the following *public* static functions:
20 |
21 | #### GetName()
22 |
23 | Should return your plugin's name.
24 |
25 | #### Initialize()
26 |
27 | Called when your plugin is loaded by GeonBit.
28 |
29 | ### Example
30 |
31 | Here's an example of a basic ```GeonBitPluginInitializer``` class and how it should look like:
32 |
33 | ```cs
34 | public static class GeonBitPluginInitializer
35 | {
36 | // get plugin name
37 | static public string GetName()
38 | {
39 | return "MyPlugin";
40 | }
41 |
42 | // initialize plugin
43 | static public void Initialize()
44 | {
45 | // do init code
46 | }
47 | }
48 | ```
49 |
50 | Or, you can fetch a *GeonBit* plugin template from [here](https://github.com/RonenNess/GeonBit/PluginTemplate).
51 |
52 | Note that you can define a dll with custom Components etc without making that special class and it will still be usable, but in this case GeonBit won't know this plugin is loaded and you will have to initialize your Managers and other stuff manually.
53 | Its also a good practice to make your dlls a proper GeonBit plugins for whatever future features GeonBit might add for plugins.
54 |
55 | ## Creating Plugin Components
56 |
57 | To create a custom component, simply inherit from the ```GeonBit.ECS.Components.BaseComponent``` class and implement the required functions.
58 | Its recommended to put all your plugin Component classes under ```GeonBit.ECS.Components.``` namespace, to avoid collision with other plugins or future core features.
59 |
60 | Your custom components may access any core components, utilities and other built-ins GeonBit provides.
61 |
62 | ## Creating Plugin Managers
63 |
64 | To create a custom manager, simply inherit from the ```GeonBit.Managers.IManager``` interface and implement the required functions.
65 | Note that all managers must be registered into GeonBitMain prior Initialization, using the following API:
66 |
67 | ```cs
68 | // managerInstance is an instance of your manager class.
69 | GeonBit.GeonBitMain.RegisterManager(managerInstance);
70 | ```
71 |
72 | To do so please use the ```GeonBitPluginInitializer``` Initialize() function.
73 |
74 |
--------------------------------------------------------------------------------
/docs/chapters/setup.md:
--------------------------------------------------------------------------------
1 | # Setup
2 |
3 |
4 | *GeonBit* requires some unique init code and built-in content.
5 | Because of that, the best way to setup *GeonBit* is to use the provided ```Visual Studio``` template.
6 |
7 | To use GeonBit template, follow these steps:
8 |
9 | 1. Download GeonBit's template [from here](https://github.com/RonenNess/GeonBit/raw/master/Template/GeonBit%20Desktop%20Application.zip) (or take the zip file from ```Template/``` folder).
10 | 2. Install it on Visual Studio (most simple way is to copy it to VS templates folder, for example: ```C:\Users\\Documents\Visual Studio 2015\Templates\ProjectTemplates```).
11 | 3. Create a new project from the GeonBit template.
12 |
13 | **Important:** When you create a new project from the GeonBit template, please create it in Visual Studio's default project's folder (for example ```C:\Users\\Documents\Visual Studio 2015\Projects\```), otherwise some of the project settings may not be configured properly.
14 | This is due to a really strange bug with VS / MonoGame templates which I have yet to solved. But don't worry, once project is created in the right folder, you can move it anywhere you like and it will work.
15 |
16 | 
17 |
18 | ### That's it!
19 |
20 | When executing the new project, you should see something like this:
21 |
22 | 
23 |
24 |
--------------------------------------------------------------------------------
/docs/index.md:
--------------------------------------------------------------------------------
1 | 
2 |
3 | # GeonBit
4 |
5 | **A 3D Entity-Component-System engine, powered by MonoGame for C# games.**
6 |
7 | ## Table Of Contents
8 |
9 | [Intro](chapters/intro.md)
10 |
11 | [Demos](chapters/demos.md)
12 |
13 | [Glossary](chapters/glossary.md)
14 |
15 | [GeonBit Overview](chapters/geonbit_overview.md)
16 |
17 | [Setup](chapters/setup.md)
18 |
19 | [(Alternative) Manual Setup](chapters/(alternative)_manual_setup.md)
20 |
21 | [Using GeonBit](chapters/using_geonbit.md)
22 |
23 | [Advanced Topics](chapters/advanced_topics.md)
24 |
25 | [Plugins](chapters/plugins.md)
26 |
27 | [Misc](chapters/misc.md)
28 |
29 |
30 |
31 | Or read the whole readme file in one chunk [here](README.md).
32 |
--------------------------------------------------------------------------------
/readme.txt:
--------------------------------------------------------------------------------
1 | Thank you for using GeonBit!
2 |
3 | For more info and full docs, please visit the repo at https://github.com/RonenNess/GeonBit.
4 | Note: if you installed this lib via NuGet manually, and didn't use the GeonBit template, please see GeonBit docs on how to install manually (or better yet - just download and use the template instead).
5 |
6 | - Ronen Ness.
--------------------------------------------------------------------------------