diff --git a/404.html b/404.html index 911a6836..709f26d0 100644 --- a/404.html +++ b/404.html @@ -4,7 +4,7 @@ Page Not Found | Jitter Physics - + diff --git a/assets/js/34b8f584.530dd28a.js b/assets/js/34b8f584.f2332f66.js similarity index 60% rename from assets/js/34b8f584.530dd28a.js rename to assets/js/34b8f584.f2332f66.js index 0e08bd57..3b40d10c 100644 --- a/assets/js/34b8f584.530dd28a.js +++ b/assets/js/34b8f584.f2332f66.js @@ -1 +1 @@ -"use strict";(self.webpackChunkjitterphysics=self.webpackChunkjitterphysics||[]).push([[51],{2453:(e,n,o)=>{o.r(n),o.d(n,{assets:()=>d,contentTitle:()=>a,default:()=>u,frontMatter:()=>r,metadata:()=>s,toc:()=>l});var t=o(4848),i=o(8453);const r={sidebar_position:3},a="Hello World",s={id:"quickstart/hello-world",title:"Hello World",description:"We will now add physics to the scene. We do this by creating a new instance of the World class and adding several rigid bodies to it.",source:"@site/docs/01_quickstart/02-hello-world.md",sourceDirName:"01_quickstart",slug:"/quickstart/hello-world",permalink:"/docs/quickstart/hello-world",draft:!1,unlisted:!1,editUrl:"https://github.com/notgiven688/jitterphysics2/tree/main/docs/docs/01_quickstart/02-hello-world.md",tags:[],version:"current",sidebarPosition:3,frontMatter:{sidebar_position:3},sidebar:"tutorialSidebar",previous:{title:"Render Loop",permalink:"/docs/quickstart/render-loop"},next:{title:"Overview",permalink:"/docs/category/overview"}},d={},l=[];function c(e){const n={code:"code",h1:"h1",img:"img",p:"p",pre:"pre",...(0,i.R)(),...e.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(n.h1,{id:"hello-world",children:"Hello World"}),"\n",(0,t.jsx)(n.p,{children:"We will now add physics to the scene. We do this by creating a new instance of the World class and adding several rigid bodies to it."}),"\n",(0,t.jsxs)(n.p,{children:["Replace the content of ",(0,t.jsx)(n.code,{children:"Program.cs"})," with the following code (marked lines indicate the additions to the source code):"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-cs",metastring:"Program.cs {3-6,9-18,28,41-63,88-94} showLineNumbers",children:'using System.Numerics;\nusing Raylib_cs;\nusing Jitter2;\nusing Jitter2.Collision.Shapes;\nusing Jitter2.Dynamics;\nusing Jitter2.LinearMath;\nusing static Raylib_cs.Raylib;\n\nstatic Matrix4x4 GetRayLibTransformMatrix(RigidBody body)\n{\n JMatrix ori = JMatrix.CreateFromQuaternion(body.Orientation);\n JVector pos = body.Position;\n\n return new Matrix4x4(ori.M11, ori.M12, ori.M13, pos.X,\n ori.M21, ori.M22, ori.M23, pos.Y,\n ori.M31, ori.M32, ori.M33, pos.Z,\n 0, 0, 0, 1.0f);\n}\n\nstatic Texture2D GenCheckedTexture(int size, int checks, Color colorA, Color colorB)\n{\n Image imageMag = GenImageChecked(size, size, checks, checks, colorA, colorB);\n Texture2D textureMag = LoadTextureFromImage(imageMag);\n UnloadImage(imageMag);\n return textureMag;\n}\n\nconst int NumberOfBoxes = 12;\n\n// set a hint for anti-aliasing\nSetConfigFlags(ConfigFlags.Msaa4xHint);\n\n// initialize a 1200x800 px window with a title\nInitWindow(1200, 800, "BoxDrop example");\n\n// dynamically create a plane model\nTexture2D texture = GenCheckedTexture(10, 1, Color.LightGray, Color.Gray);\nModel planeModel = LoadModelFromMesh(GenMeshPlane(10, 10, 10, 10));\nSetMaterialTexture(ref planeModel, 0, MaterialMapIndex.Diffuse, ref texture);\n\n// dynamically create a box model\ntexture = GenCheckedTexture(2, 1, Color.White, Color.Magenta);\nMesh boxMesh = GenMeshCube(1, 1, 1);\nMaterial boxMat = LoadMaterialDefault();\nSetMaterialTexture(ref boxMat, MaterialMapIndex.Diffuse, texture);\n\n// initialize the Jitter physics world\nWorld world = new ();\nworld.NumberSubsteps = 4;\n\n// add a body representing the plane\nRigidBody planeBody = world.CreateRigidBody();\nplaneBody.AddShape(new BoxShape(10));\nplaneBody.Position = new JVector(0, -5, 0);\nplaneBody.IsStatic = true;\n\n// add NumberOfBoxes cubes\nfor(int i = 0; i < NumberOfBoxes; i++)\n{\n RigidBody body = world.CreateRigidBody();\n body.AddShape(new BoxShape(1));\n body.Position = new JVector(0, i * 2 + 0.5f, 0);\n}\n\n// create a camera\nCamera3D camera = new ()\n{\n Position = new Vector3(-20.0f, 8.0f, 10.0f),\n Target = new Vector3(0.0f, 4.0f, 0.0f),\n Up = new Vector3(0.0f, 1.0f, 0.0f),\n FovY = 45.0f,\n Projection = CameraProjection.Perspective\n};\n\n// 100 fps target\nSetTargetFPS(100);\n\n// simple render loop\nwhile (!WindowShouldClose())\n{\n BeginDrawing();\n ClearBackground(Color.Blue);\n\n BeginMode3D(camera);\n\n DrawModel(planeModel, Vector3.Zero, 1.0f, Color.White);\n\n world.Step(1.0f / 100.0f, true);\n\n foreach(var body in world.RigidBodies)\n {\n if(body == planeBody) continue; // do not draw this\n DrawMesh(boxMesh, boxMat, GetRayLibTransformMatrix(body));\n }\n\n EndMode3D();\n DrawText($"{GetFPS()} fps", 10, 10, 20, Color.White);\n\n EndDrawing();\n}\n\nCloseWindow();\n'})}),"\n",(0,t.jsx)(n.p,{children:"Running your program, you should now see a few boxes dynamically falling onto the ground."}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{alt:"plane",src:o(3232).A+"",width:"1198",height:"795"})})]})}function u(e={}){const{wrapper:n}={...(0,i.R)(),...e.components};return n?(0,t.jsx)(n,{...e,children:(0,t.jsx)(c,{...e})}):c(e)}},3232:(e,n,o)=>{o.d(n,{A:()=>t});const t=o.p+"assets/images/raylibjitter-70ae279a0ceb57d513433beed08859bd.gif"},8453:(e,n,o)=>{o.d(n,{R:()=>a,x:()=>s});var t=o(6540);const i={},r=t.createContext(i);function a(e){const n=t.useContext(r);return t.useMemo((function(){return"function"==typeof e?e(n):{...n,...e}}),[n,e])}function s(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(i):e.components||i:a(e.components),t.createElement(r.Provider,{value:n},e.children)}}}]); \ No newline at end of file +"use strict";(self.webpackChunkjitterphysics=self.webpackChunkjitterphysics||[]).push([[51],{2453:(e,n,o)=>{o.r(n),o.d(n,{assets:()=>d,contentTitle:()=>a,default:()=>u,frontMatter:()=>r,metadata:()=>s,toc:()=>l});var t=o(4848),i=o(8453);const r={sidebar_position:3},a="Hello World",s={id:"quickstart/hello-world",title:"Hello World",description:"We will now add physics to the scene. We do this by creating a new instance of the World class and adding several rigid bodies to it.",source:"@site/docs/01_quickstart/02-hello-world.md",sourceDirName:"01_quickstart",slug:"/quickstart/hello-world",permalink:"/docs/quickstart/hello-world",draft:!1,unlisted:!1,editUrl:"https://github.com/notgiven688/jitterphysics2/tree/main/docs/docs/01_quickstart/02-hello-world.md",tags:[],version:"current",sidebarPosition:3,frontMatter:{sidebar_position:3},sidebar:"tutorialSidebar",previous:{title:"Render Loop",permalink:"/docs/quickstart/render-loop"},next:{title:"Overview",permalink:"/docs/category/overview"}},d={},l=[];function c(e){const n={code:"code",h1:"h1",img:"img",p:"p",pre:"pre",...(0,i.R)(),...e.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(n.h1,{id:"hello-world",children:"Hello World"}),"\n",(0,t.jsx)(n.p,{children:"We will now add physics to the scene. We do this by creating a new instance of the World class and adding several rigid bodies to it."}),"\n",(0,t.jsxs)(n.p,{children:["Replace the content of ",(0,t.jsx)(n.code,{children:"Program.cs"})," with the following code (marked lines indicate the additions to the source code):"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-cs",metastring:"Program.cs {3-6,9-18,28,41-63,88-94} showLineNumbers",children:'using System.Numerics;\nusing Raylib_cs;\nusing Jitter2;\nusing Jitter2.Collision.Shapes;\nusing Jitter2.Dynamics;\nusing Jitter2.LinearMath;\nusing static Raylib_cs.Raylib;\n\nstatic Matrix4x4 GetRayLibTransformMatrix(RigidBody body)\n{\n JMatrix ori = JMatrix.CreateFromQuaternion(body.Orientation);\n JVector pos = body.Position;\n\n return new Matrix4x4(ori.M11, ori.M12, ori.M13, pos.X,\n ori.M21, ori.M22, ori.M23, pos.Y,\n ori.M31, ori.M32, ori.M33, pos.Z,\n 0, 0, 0, 1.0f);\n}\n\nstatic Texture2D GenCheckedTexture(int size, int checks, Color colorA, Color colorB)\n{\n Image imageMag = GenImageChecked(size, size, checks, checks, colorA, colorB);\n Texture2D textureMag = LoadTextureFromImage(imageMag);\n UnloadImage(imageMag);\n return textureMag;\n}\n\nconst int NumberOfBoxes = 12;\n\n// set a hint for anti-aliasing\nSetConfigFlags(ConfigFlags.Msaa4xHint);\n\n// initialize a 1200x800 px window with a title\nInitWindow(1200, 800, "BoxDrop example");\n\n// dynamically create a plane model\nTexture2D texture = GenCheckedTexture(10, 1, Color.LightGray, Color.Gray);\nModel planeModel = LoadModelFromMesh(GenMeshPlane(10, 10, 10, 10));\nSetMaterialTexture(ref planeModel, 0, MaterialMapIndex.Diffuse, ref texture);\n\n// dynamically create a box model\ntexture = GenCheckedTexture(2, 1, Color.White, Color.Magenta);\nMesh boxMesh = GenMeshCube(1, 1, 1);\nMaterial boxMat = LoadMaterialDefault();\nSetMaterialTexture(ref boxMat, MaterialMapIndex.Diffuse, texture);\n\n// initialize the Jitter physics world\nWorld world = new ();\nworld.SubstepCount = 4;\n\n// add a body representing the plane\nRigidBody planeBody = world.CreateRigidBody();\nplaneBody.AddShape(new BoxShape(10));\nplaneBody.Position = new JVector(0, -5, 0);\nplaneBody.IsStatic = true;\n\n// add NumberOfBoxes cubes\nfor(int i = 0; i < NumberOfBoxes; i++)\n{\n RigidBody body = world.CreateRigidBody();\n body.AddShape(new BoxShape(1));\n body.Position = new JVector(0, i * 2 + 0.5f, 0);\n}\n\n// create a camera\nCamera3D camera = new ()\n{\n Position = new Vector3(-20.0f, 8.0f, 10.0f),\n Target = new Vector3(0.0f, 4.0f, 0.0f),\n Up = new Vector3(0.0f, 1.0f, 0.0f),\n FovY = 45.0f,\n Projection = CameraProjection.Perspective\n};\n\n// 100 fps target\nSetTargetFPS(100);\n\n// simple render loop\nwhile (!WindowShouldClose())\n{\n BeginDrawing();\n ClearBackground(Color.Blue);\n\n BeginMode3D(camera);\n\n DrawModel(planeModel, Vector3.Zero, 1.0f, Color.White);\n\n world.Step(1.0f / 100.0f, true);\n\n foreach(var body in world.RigidBodies)\n {\n if(body == planeBody) continue; // do not draw this\n DrawMesh(boxMesh, boxMat, GetRayLibTransformMatrix(body));\n }\n\n EndMode3D();\n DrawText($"{GetFPS()} fps", 10, 10, 20, Color.White);\n\n EndDrawing();\n}\n\nCloseWindow();\n'})}),"\n",(0,t.jsx)(n.p,{children:"Running your program, you should now see a few boxes dynamically falling onto the ground."}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{alt:"plane",src:o(3232).A+"",width:"1198",height:"795"})})]})}function u(e={}){const{wrapper:n}={...(0,i.R)(),...e.components};return n?(0,t.jsx)(n,{...e,children:(0,t.jsx)(c,{...e})}):c(e)}},3232:(e,n,o)=>{o.d(n,{A:()=>t});const t=o.p+"assets/images/raylibjitter-70ae279a0ceb57d513433beed08859bd.gif"},8453:(e,n,o)=>{o.d(n,{R:()=>a,x:()=>s});var t=o(6540);const i={},r=t.createContext(i);function a(e){const n=t.useContext(r);return t.useMemo((function(){return"function"==typeof e?e(n):{...n,...e}}),[n,e])}function s(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(i):e.components||i:a(e.components),t.createElement(r.Provider,{value:n},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/runtime~main.85f9354d.js b/assets/js/runtime~main.3df125b6.js similarity index 98% rename from assets/js/runtime~main.85f9354d.js rename to assets/js/runtime~main.3df125b6.js index 21a1cdcf..37fb4c8f 100644 --- a/assets/js/runtime~main.85f9354d.js +++ b/assets/js/runtime~main.3df125b6.js @@ -1 +1 @@ -(()=>{"use strict";var e,t,r,a,o,f={},n={};function c(e){var t=n[e];if(void 0!==t)return t.exports;var r=n[e]={exports:{}};return f[e].call(r.exports,r,r.exports,c),r.exports}c.m=f,e=[],c.O=(t,r,a,o)=>{if(!r){var f=1/0;for(d=0;d=o)&&Object.keys(c.O).every((e=>c.O[e](r[i])))?r.splice(i--,1):(n=!1,o0&&e[d-1][2]>o;d--)e[d]=e[d-1];e[d]=[r,a,o]},c.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return c.d(t,{a:t}),t},r=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,c.t=function(e,a){if(1&a&&(e=this(e)),8&a)return e;if("object"==typeof e&&e){if(4&a&&e.__esModule)return e;if(16&a&&"function"==typeof e.then)return e}var o=Object.create(null);c.r(o);var f={};t=t||[null,r({}),r([]),r(r)];for(var n=2&a&&e;"object"==typeof n&&!~t.indexOf(n);n=r(n))Object.getOwnPropertyNames(n).forEach((t=>f[t]=()=>e[t]));return f.default=()=>e,c.d(o,f),o},c.d=(e,t)=>{for(var r in t)c.o(t,r)&&!c.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},c.f={},c.e=e=>Promise.all(Object.keys(c.f).reduce(((t,r)=>(c.f[r](e,t),t)),[])),c.u=e=>"assets/js/"+({38:"2a0f5d50",48:"a94703ab",51:"34b8f584",88:"deb49e46",94:"bf6df496",95:"2e408fef",98:"a7bd4aaa",200:"9b0af31e",235:"a7456010",401:"17896441",452:"34479fac",511:"0c6090a1",539:"9beb87c2",631:"d2f6244d",634:"c4f5d8e4",647:"5e95c892",681:"472985f5",742:"aba21aa0",849:"0058b4c6",853:"c8cd1b90",969:"14eb3368",976:"0e384e19"}[e]||e)+"."+{38:"6a4986b2",48:"f2f129ec",51:"530dd28a",88:"d6c18fff",94:"fa44a7d7",95:"2caceeab",98:"09770a5d",200:"41a8c480",235:"4f0d0dc9",237:"2ef5ef8b",401:"f65e4f4f",452:"80de0b83",511:"7815bf4e",539:"84a764c6",631:"27ec3fb5",634:"4d95c347",647:"df0f3aaf",681:"809de0a2",742:"c4f20e0e",849:"7187ab67",853:"2b75df9a",969:"0cdfe1bb",976:"6ccb6612"}[e]+".js",c.miniCssF=e=>{},c.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),c.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),a={},o="jitterphysics:",c.l=(e,t,r,f)=>{if(a[e])a[e].push(t);else{var n,i;if(void 0!==r)for(var b=document.getElementsByTagName("script"),d=0;d{n.onerror=n.onload=null,clearTimeout(s);var o=a[e];if(delete a[e],n.parentNode&&n.parentNode.removeChild(n),o&&o.forEach((e=>e(r))),t)return t(r)},s=setTimeout(l.bind(null,void 0,{type:"timeout",target:n}),12e4);n.onerror=l.bind(null,n.onerror),n.onload=l.bind(null,n.onload),i&&document.head.appendChild(n)}},c.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},c.p="/",c.gca=function(e){return e={17896441:"401","2a0f5d50":"38",a94703ab:"48","34b8f584":"51",deb49e46:"88",bf6df496:"94","2e408fef":"95",a7bd4aaa:"98","9b0af31e":"200",a7456010:"235","34479fac":"452","0c6090a1":"511","9beb87c2":"539",d2f6244d:"631",c4f5d8e4:"634","5e95c892":"647","472985f5":"681",aba21aa0:"742","0058b4c6":"849",c8cd1b90:"853","14eb3368":"969","0e384e19":"976"}[e]||e,c.p+c.u(e)},(()=>{var e={354:0,869:0};c.f.j=(t,r)=>{var a=c.o(e,t)?e[t]:void 0;if(0!==a)if(a)r.push(a[2]);else if(/^(354|869)$/.test(t))e[t]=0;else{var o=new Promise(((r,o)=>a=e[t]=[r,o]));r.push(a[2]=o);var f=c.p+c.u(t),n=new Error;c.l(f,(r=>{if(c.o(e,t)&&(0!==(a=e[t])&&(e[t]=void 0),a)){var o=r&&("load"===r.type?"missing":r.type),f=r&&r.target&&r.target.src;n.message="Loading chunk "+t+" failed.\n("+o+": "+f+")",n.name="ChunkLoadError",n.type=o,n.request=f,a[1](n)}}),"chunk-"+t,t)}},c.O.j=t=>0===e[t];var t=(t,r)=>{var a,o,f=r[0],n=r[1],i=r[2],b=0;if(f.some((t=>0!==e[t]))){for(a in n)c.o(n,a)&&(c.m[a]=n[a]);if(i)var d=i(c)}for(t&&t(r);b{"use strict";var e,t,r,a,o,f={},n={};function c(e){var t=n[e];if(void 0!==t)return t.exports;var r=n[e]={exports:{}};return f[e].call(r.exports,r,r.exports,c),r.exports}c.m=f,e=[],c.O=(t,r,a,o)=>{if(!r){var f=1/0;for(d=0;d=o)&&Object.keys(c.O).every((e=>c.O[e](r[i])))?r.splice(i--,1):(n=!1,o0&&e[d-1][2]>o;d--)e[d]=e[d-1];e[d]=[r,a,o]},c.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return c.d(t,{a:t}),t},r=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,c.t=function(e,a){if(1&a&&(e=this(e)),8&a)return e;if("object"==typeof e&&e){if(4&a&&e.__esModule)return e;if(16&a&&"function"==typeof e.then)return e}var o=Object.create(null);c.r(o);var f={};t=t||[null,r({}),r([]),r(r)];for(var n=2&a&&e;"object"==typeof n&&!~t.indexOf(n);n=r(n))Object.getOwnPropertyNames(n).forEach((t=>f[t]=()=>e[t]));return f.default=()=>e,c.d(o,f),o},c.d=(e,t)=>{for(var r in t)c.o(t,r)&&!c.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},c.f={},c.e=e=>Promise.all(Object.keys(c.f).reduce(((t,r)=>(c.f[r](e,t),t)),[])),c.u=e=>"assets/js/"+({38:"2a0f5d50",48:"a94703ab",51:"34b8f584",88:"deb49e46",94:"bf6df496",95:"2e408fef",98:"a7bd4aaa",200:"9b0af31e",235:"a7456010",401:"17896441",452:"34479fac",511:"0c6090a1",539:"9beb87c2",631:"d2f6244d",634:"c4f5d8e4",647:"5e95c892",681:"472985f5",742:"aba21aa0",849:"0058b4c6",853:"c8cd1b90",969:"14eb3368",976:"0e384e19"}[e]||e)+"."+{38:"6a4986b2",48:"f2f129ec",51:"f2332f66",88:"d6c18fff",94:"fa44a7d7",95:"2caceeab",98:"09770a5d",200:"41a8c480",235:"4f0d0dc9",237:"2ef5ef8b",401:"f65e4f4f",452:"80de0b83",511:"7815bf4e",539:"84a764c6",631:"27ec3fb5",634:"4d95c347",647:"df0f3aaf",681:"809de0a2",742:"c4f20e0e",849:"7187ab67",853:"2b75df9a",969:"0cdfe1bb",976:"6ccb6612"}[e]+".js",c.miniCssF=e=>{},c.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),c.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),a={},o="jitterphysics:",c.l=(e,t,r,f)=>{if(a[e])a[e].push(t);else{var n,i;if(void 0!==r)for(var b=document.getElementsByTagName("script"),d=0;d{n.onerror=n.onload=null,clearTimeout(s);var o=a[e];if(delete a[e],n.parentNode&&n.parentNode.removeChild(n),o&&o.forEach((e=>e(r))),t)return t(r)},s=setTimeout(l.bind(null,void 0,{type:"timeout",target:n}),12e4);n.onerror=l.bind(null,n.onerror),n.onload=l.bind(null,n.onload),i&&document.head.appendChild(n)}},c.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},c.p="/",c.gca=function(e){return e={17896441:"401","2a0f5d50":"38",a94703ab:"48","34b8f584":"51",deb49e46:"88",bf6df496:"94","2e408fef":"95",a7bd4aaa:"98","9b0af31e":"200",a7456010:"235","34479fac":"452","0c6090a1":"511","9beb87c2":"539",d2f6244d:"631",c4f5d8e4:"634","5e95c892":"647","472985f5":"681",aba21aa0:"742","0058b4c6":"849",c8cd1b90:"853","14eb3368":"969","0e384e19":"976"}[e]||e,c.p+c.u(e)},(()=>{var e={354:0,869:0};c.f.j=(t,r)=>{var a=c.o(e,t)?e[t]:void 0;if(0!==a)if(a)r.push(a[2]);else if(/^(354|869)$/.test(t))e[t]=0;else{var o=new Promise(((r,o)=>a=e[t]=[r,o]));r.push(a[2]=o);var f=c.p+c.u(t),n=new Error;c.l(f,(r=>{if(c.o(e,t)&&(0!==(a=e[t])&&(e[t]=void 0),a)){var o=r&&("load"===r.type?"missing":r.type),f=r&&r.target&&r.target.src;n.message="Loading chunk "+t+" failed.\n("+o+": "+f+")",n.name="ChunkLoadError",n.type=o,n.request=f,a[1](n)}}),"chunk-"+t,t)}},c.O.j=t=>0===e[t];var t=(t,r)=>{var a,o,f=r[0],n=r[1],i=r[2],b=0;if(f.some((t=>0!==e[t]))){for(a in n)c.o(n,a)&&(c.m[a]=n[a]);if(i)var d=i(c)}for(t&&t(r);b Overview | Jitter Physics - + diff --git a/docs/category/quickstart/index.html b/docs/category/quickstart/index.html index 4de0d151..db3b8e13 100644 --- a/docs/category/quickstart/index.html +++ b/docs/category/quickstart/index.html @@ -4,7 +4,7 @@ Quickstart | Jitter Physics - + diff --git a/docs/changelog/index.html b/docs/changelog/index.html index 8541ceea..b1b006c5 100644 --- a/docs/changelog/index.html +++ b/docs/changelog/index.html @@ -4,7 +4,7 @@ Changelog | Jitter Physics - + diff --git a/docs/documentation/01world/index.html b/docs/documentation/01world/index.html index 9e231267..74772807 100644 --- a/docs/documentation/01world/index.html +++ b/docs/documentation/01world/index.html @@ -4,7 +4,7 @@ Jitter World | Jitter Physics - + diff --git a/docs/documentation/02bodies/index.html b/docs/documentation/02bodies/index.html index 71e96c7b..1aa9a337 100644 --- a/docs/documentation/02bodies/index.html +++ b/docs/documentation/02bodies/index.html @@ -4,7 +4,7 @@ Rigid Bodies | Jitter Physics - + diff --git a/docs/documentation/03shapes/index.html b/docs/documentation/03shapes/index.html index 34149f39..f376cf70 100644 --- a/docs/documentation/03shapes/index.html +++ b/docs/documentation/03shapes/index.html @@ -4,7 +4,7 @@ Shapes | Jitter Physics - + diff --git a/docs/documentation/04constraints/index.html b/docs/documentation/04constraints/index.html index 0af23e60..b919c819 100644 --- a/docs/documentation/04constraints/index.html +++ b/docs/documentation/04constraints/index.html @@ -4,7 +4,7 @@ Constraints | Jitter Physics - + diff --git a/docs/documentation/05dynamictree/index.html b/docs/documentation/05dynamictree/index.html index 210e726b..948aa44f 100644 --- a/docs/documentation/05dynamictree/index.html +++ b/docs/documentation/05dynamictree/index.html @@ -4,7 +4,7 @@ Dynamic tree | Jitter Physics - + diff --git a/docs/documentation/06filters/index.html b/docs/documentation/06filters/index.html index 4a0c58d4..a8f67fdf 100644 --- a/docs/documentation/06filters/index.html +++ b/docs/documentation/06filters/index.html @@ -4,7 +4,7 @@ Collision Filters | Jitter Physics - + diff --git a/docs/intro/index.html b/docs/intro/index.html index f209b25c..47e1b9f2 100644 --- a/docs/intro/index.html +++ b/docs/intro/index.html @@ -4,7 +4,7 @@ Welcome | Jitter Physics - + diff --git a/docs/quickstart/hello-world/index.html b/docs/quickstart/hello-world/index.html index 2a50b21b..b6353ae8 100644 --- a/docs/quickstart/hello-world/index.html +++ b/docs/quickstart/hello-world/index.html @@ -4,14 +4,14 @@ Hello World | Jitter Physics - +

Hello World

We will now add physics to the scene. We do this by creating a new instance of the World class and adding several rigid bodies to it.

Replace the content of Program.cs with the following code (marked lines indicate the additions to the source code):

-
using System.Numerics;
using Raylib_cs;
using Jitter2;
using Jitter2.Collision.Shapes;
using Jitter2.Dynamics;
using Jitter2.LinearMath;
using static Raylib_cs.Raylib;

static Matrix4x4 GetRayLibTransformMatrix(RigidBody body)
{
JMatrix ori = JMatrix.CreateFromQuaternion(body.Orientation);
JVector pos = body.Position;

return new Matrix4x4(ori.M11, ori.M12, ori.M13, pos.X,
ori.M21, ori.M22, ori.M23, pos.Y,
ori.M31, ori.M32, ori.M33, pos.Z,
0, 0, 0, 1.0f);
}

static Texture2D GenCheckedTexture(int size, int checks, Color colorA, Color colorB)
{
Image imageMag = GenImageChecked(size, size, checks, checks, colorA, colorB);
Texture2D textureMag = LoadTextureFromImage(imageMag);
UnloadImage(imageMag);
return textureMag;
}

const int NumberOfBoxes = 12;

// set a hint for anti-aliasing
SetConfigFlags(ConfigFlags.Msaa4xHint);

// initialize a 1200x800 px window with a title
InitWindow(1200, 800, "BoxDrop example");

// dynamically create a plane model
Texture2D texture = GenCheckedTexture(10, 1, Color.LightGray, Color.Gray);
Model planeModel = LoadModelFromMesh(GenMeshPlane(10, 10, 10, 10));
SetMaterialTexture(ref planeModel, 0, MaterialMapIndex.Diffuse, ref texture);

// dynamically create a box model
texture = GenCheckedTexture(2, 1, Color.White, Color.Magenta);
Mesh boxMesh = GenMeshCube(1, 1, 1);
Material boxMat = LoadMaterialDefault();
SetMaterialTexture(ref boxMat, MaterialMapIndex.Diffuse, texture);

// initialize the Jitter physics world
World world = new ();
world.NumberSubsteps = 4;

// add a body representing the plane
RigidBody planeBody = world.CreateRigidBody();
planeBody.AddShape(new BoxShape(10));
planeBody.Position = new JVector(0, -5, 0);
planeBody.IsStatic = true;

// add NumberOfBoxes cubes
for(int i = 0; i < NumberOfBoxes; i++)
{
RigidBody body = world.CreateRigidBody();
body.AddShape(new BoxShape(1));
body.Position = new JVector(0, i * 2 + 0.5f, 0);
}

// create a camera
Camera3D camera = new ()
{
Position = new Vector3(-20.0f, 8.0f, 10.0f),
Target = new Vector3(0.0f, 4.0f, 0.0f),
Up = new Vector3(0.0f, 1.0f, 0.0f),
FovY = 45.0f,
Projection = CameraProjection.Perspective
};

// 100 fps target
SetTargetFPS(100);

// simple render loop
while (!WindowShouldClose())
{
BeginDrawing();
ClearBackground(Color.Blue);

BeginMode3D(camera);

DrawModel(planeModel, Vector3.Zero, 1.0f, Color.White);

world.Step(1.0f / 100.0f, true);

foreach(var body in world.RigidBodies)
{
if(body == planeBody) continue; // do not draw this
DrawMesh(boxMesh, boxMat, GetRayLibTransformMatrix(body));
}

EndMode3D();
DrawText($"{GetFPS()} fps", 10, 10, 20, Color.White);

EndDrawing();
}

CloseWindow();
+
using System.Numerics;
using Raylib_cs;
using Jitter2;
using Jitter2.Collision.Shapes;
using Jitter2.Dynamics;
using Jitter2.LinearMath;
using static Raylib_cs.Raylib;

static Matrix4x4 GetRayLibTransformMatrix(RigidBody body)
{
JMatrix ori = JMatrix.CreateFromQuaternion(body.Orientation);
JVector pos = body.Position;

return new Matrix4x4(ori.M11, ori.M12, ori.M13, pos.X,
ori.M21, ori.M22, ori.M23, pos.Y,
ori.M31, ori.M32, ori.M33, pos.Z,
0, 0, 0, 1.0f);
}

static Texture2D GenCheckedTexture(int size, int checks, Color colorA, Color colorB)
{
Image imageMag = GenImageChecked(size, size, checks, checks, colorA, colorB);
Texture2D textureMag = LoadTextureFromImage(imageMag);
UnloadImage(imageMag);
return textureMag;
}

const int NumberOfBoxes = 12;

// set a hint for anti-aliasing
SetConfigFlags(ConfigFlags.Msaa4xHint);

// initialize a 1200x800 px window with a title
InitWindow(1200, 800, "BoxDrop example");

// dynamically create a plane model
Texture2D texture = GenCheckedTexture(10, 1, Color.LightGray, Color.Gray);
Model planeModel = LoadModelFromMesh(GenMeshPlane(10, 10, 10, 10));
SetMaterialTexture(ref planeModel, 0, MaterialMapIndex.Diffuse, ref texture);

// dynamically create a box model
texture = GenCheckedTexture(2, 1, Color.White, Color.Magenta);
Mesh boxMesh = GenMeshCube(1, 1, 1);
Material boxMat = LoadMaterialDefault();
SetMaterialTexture(ref boxMat, MaterialMapIndex.Diffuse, texture);

// initialize the Jitter physics world
World world = new ();
world.SubstepCount = 4;

// add a body representing the plane
RigidBody planeBody = world.CreateRigidBody();
planeBody.AddShape(new BoxShape(10));
planeBody.Position = new JVector(0, -5, 0);
planeBody.IsStatic = true;

// add NumberOfBoxes cubes
for(int i = 0; i < NumberOfBoxes; i++)
{
RigidBody body = world.CreateRigidBody();
body.AddShape(new BoxShape(1));
body.Position = new JVector(0, i * 2 + 0.5f, 0);
}

// create a camera
Camera3D camera = new ()
{
Position = new Vector3(-20.0f, 8.0f, 10.0f),
Target = new Vector3(0.0f, 4.0f, 0.0f),
Up = new Vector3(0.0f, 1.0f, 0.0f),
FovY = 45.0f,
Projection = CameraProjection.Perspective
};

// 100 fps target
SetTargetFPS(100);

// simple render loop
while (!WindowShouldClose())
{
BeginDrawing();
ClearBackground(Color.Blue);

BeginMode3D(camera);

DrawModel(planeModel, Vector3.Zero, 1.0f, Color.White);

world.Step(1.0f / 100.0f, true);

foreach(var body in world.RigidBodies)
{
if(body == planeBody) continue; // do not draw this
DrawMesh(boxMesh, boxMat, GetRayLibTransformMatrix(body));
}

EndMode3D();
DrawText($"{GetFPS()} fps", 10, 10, 20, Color.White);

EndDrawing();
}

CloseWindow();

Running your program, you should now see a few boxes dynamically falling onto the ground.

plane

diff --git a/docs/quickstart/project-setup/index.html b/docs/quickstart/project-setup/index.html index 9f98da77..14701c6d 100644 --- a/docs/quickstart/project-setup/index.html +++ b/docs/quickstart/project-setup/index.html @@ -4,7 +4,7 @@ Project Setup | Jitter Physics - + diff --git a/docs/quickstart/render-loop/index.html b/docs/quickstart/render-loop/index.html index 4f28779a..300acbdd 100644 --- a/docs/quickstart/render-loop/index.html +++ b/docs/quickstart/render-loop/index.html @@ -4,7 +4,7 @@ Render Loop | Jitter Physics - + diff --git a/index.html b/index.html index a730de95..daa78413 100644 --- a/index.html +++ b/index.html @@ -4,7 +4,7 @@ Jitter Physics - +