Search the Community

Showing results for tags 'geometry'.

More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • HTML5 Game Coding
    • News
    • Game Showcase
    • Coding and Game Design
  • Frameworks
    • Phaser 3
    • Phaser 2
    • Pixi.js
    • Babylon.js
    • Panda 2
    • melonJS
    • Haxe JS
    • Kiwi.js
  • General
    • General Talk
  • Business
    • Collaborations (un-paid)
    • Jobs (Hiring and Freelance)
    • Services Offered

Found 27 results

  1. Hi everyone, I know it's possible and advised to use InstancedMesh when several meshes share the same geometry and the same material. Is there some recommended optimization to do when two meshes share the same geometry but have different materials ? For example with this case : (here VertexData object is already loaded) Is there something better than two calls to "applyToMesh" ? Like obj1.geometry = obj2.geometry, this kind of thing... (my question is based on the fact that Unity explicitly share the same geometry across objects, even when Materials are different. But perhaps it's only done to optimize data packing / loading and has no impact at runtime...) (I'm fairly sure I have already found this question somewhere, but can't remember the answer nor find where it was...) Thanks a lot for your inputs ! Have a nice day,
  2. Updating vertex position

    Hi, I'm loading two mesh, one T-shirt and one shorts, some parts of T-shirt goes through the shorts, so I'm trying to update T-shirt vertices where there is intersection point with the shorts, and make a small expansion of these, But when I do this, it's as if my t-shirt mesh is broken. PR:
  3. Colors on shapes

    Hi there! OK, so I just figured out how to draw shapes with the graphics object. But, I wonder why this method exist ?!?! line = new Phaser.Line(100, 100, 200, 200); ... and then it gets positioned on update() But a line, never gets rendered Does this mean that, this method "Phaser.Line()" is useless ?!?!?!
  4. Area of any mesh

    Hi people, As this has been requested from time to time on this forum, here is a simple and fast method for computing any mesh area : var area = function(mesh) { if (!mesh) { return 0.0; } var indices = mesh.getIndices(); var positions = mesh.getVerticesData(BABYLON.VertexBuffer.PositionKind); var v1x = 0.0; var v1y = 0.0; var v1z = 0.0; var v2x = 0.0; var v2y = 0.0; var v2z = 0.0; var crossx = 0.0; var crossy = 0.0; var crossz = 0.0; var ar = 0.0; var i1 = 0; var i2 = 0; var i3 = 0; var nbFaces = indices.length / 3; for (var i = 0; i < nbFaces; i++) { i1 = indices[i * 3]; i2 = indices[i * 3 + 1]; i3 = indices[i * 3 + 2]; v1x = positions[i1 * 3] - positions[i2 * 3]; v1y = positions[i1 * 3 + 1] - positions[i2 * 3 + 1]; v1z = positions[i1 * 3 + 2] - positions[i2 * 3 + 2]; v2x = positions[i3 * 3] - positions[i2 * 3]; v2y = positions[i3 * 3 + 1] - positions[i2 * 3 + 1]; v2z = positions[i3 * 3 + 2] - positions[i2 * 3 + 2]; crossx = v1y * v2z - v1z * v2y; crossy = v1z * v2x - v1x * v2z; crossz = v1x * v2y - v1y * v2x; ar = ar + Math.sqrt(crossx * crossx + crossy * crossy + crossz * crossz); } return ar * 0.5; }; As it doesn't allocate any object, nor calls external functions, it should be fast, GC friendly and it might be called within the render loop. Just let me know if you want it to be integrated in BJS as a method of the class Mesh or AbstractMesh. [EDIT] For experts, note that this computation could be shared and done in one line only within the method ComputeNormals() of the class VertexData just after this line : with something like : area += length * 0.5;
  5. Detect sectors of a circle

    So, circles are confounding me today... About twenty years ago I did GCSE maths and remember wondering when or why I would ever need to know any of this stuff about circles and angles and the like. Now. Now is when I need to know all that stuff. So I've been all over the interwebz and have learned lots about circles, but while there are myriad explainations of how to work out the length of an arc, the angle and area of a sector... and use both radians and degrees to calculate same; I can find nothing that will tell me which sector a given value (theta, radian, degree, whatever) is in. If I've divided my circle into 12 segments, can I pass a value and know that it belongs in sector 3, for instance?
  6. I was wondering since I have a chunked (tiled) based terrain system, I have a height tool made now, but at the edge of each tile I have gaps forming, I have seen somewhere a way that this can be fixed but hours of searching I haven't been able to find it and I seem to forgotten to bookmark it.. so hoping for some pointers here on possible ways this can be achieved. I attached a image to show what is happening between chunks (meshes). Thanks! Edit: Found the article and it has to deal with Three.js so not at all useful for me..
  7. BABYLON.SceneSerializer.SerializeMesh isn't including the most important bit for meshes, the geometry! I make a cube and then use BABYLON.SceneSerializer.SerializeMesh(cube) and output to console, sure enough no geometry, thus when I use the importer it spits out no geometry found warning.. var thebox = BABYLON.Mesh.CreateBox("thebox", 10, scene); thebox.position.x=thebox.position.z=112; thebox.position.y=5;'thebox'; thebox.receiveShadows = true; var box = BABYLON.SceneSerializer.SerializeMesh(thebox); That is all I use, shouldn't the geometry be included in the output of SerializeMesh? I am using Babylon 2.4.0 Here is the JSON stringified output of the serialized mesh that I stored into a file that I'm trying to load from. {"geometries":{"boxes":[],"spheres":[],"cylinders":[],"toruses":[],"grounds":[],"planes":[],"torusKnots":[],"vertexData":[]},"meshes":[{"name":"thebox","id":"thebox","position":[112,5,112],"rotationQuaternion":[0,0,0,1],"scaling":[1,1,1],"localMatrix":{"0":1,"1":0,"2":0,"3":0,"4":0,"5":1,"6":0,"7":0,"8":0,"9":0,"10":1,"11":0,"12":0,"13":0,"14":0,"15":1},"isEnabled":true,"isVisible":true,"infiniteDistance":false,"pickable":true,"receiveShadows":true,"billboardMode":0,"visibility":1,"checkCollisions":true,"geometryId":"98a28707-f3ba-4062-bfc4-47ca8830cf79","subMeshes":[{"materialIndex":0,"verticesStart":0,"verticesCount":24,"indexStart":0,"indexCount":36}],"physicsMass":0,"physicsFriction":0.2,"physicsImpostor":2,"instances":[],"animations":[],"ranges":[],"layerMask":268435455}]} No vertexData or geometry matching the geometryId..
  8. Hi guys how can I get geometry vertices , in three.js i can get positions with box.geometry.vertices and returns coordinate for 8 points ( of a box ) ; now via Bjs i tried to use box.getVerticesData(BABYLON.VertexBuffer.PositionKind); , but seems returns 24 points ! am I wrong or Babylon js use duplicate/separate vertices for each face ! if so , how can I avoid to return duplicated coordinate ? thanks in advance .
  9. Hello In some cases, its more efficient to compute models in real time, rather then download the provided geometry in a babylon file. I want to create markers in my room, terrain ...and replace this specific spots with something like a trees currently i have to create a separate mesh as marker, it would save some space, if i could simply define a marker as a different material Thank you all very much, whoever wants to contribute The playground
  10. hi do you know any tools to generate 2d mesh from geometry or Points like following image? i wanna create navmesh data from tiled tool. but i can't find good tool to generate from tiled data yet.. please tell me any good news .. thx.. best regards..
  11. Procedural geometry physics

    Hi, I need to generate a terrain mesh procedurally. I am currently doing it with lots of sprites stuck together in a line to generate the contour of the terrain. It works fairly well, but has a few quirks and seems to affect performance badly. What I was thinking of doing is generating the points in the preload function, then from that, draw a line to rendering the terrain, and then use the same points to generate the collision polygon. The issue I found is that the game.load.physics() function works with a url to a json object. Is there a way to pass it a json object that I created in the game itself instead of a url? By the way, I am using P2 physics for this.
  12. Adding Geometry to Groups

    First off, thanks very much for the amazing tool, it must be a lot of work to maintain and it's amazing to be able to use it for free. As for the main issue, I'm getting an error when I try to add a geometric object to a group: phaser.js:14115 Uncaught TypeError: a.setStageReference is not a function Perhaps this is because groups are implemented in Pixi and geometry in Phaser? I'm doing this because I have a custom bitmapText, and text in general seems very unresponsive when I tap it. In particular, I think tapping in between adjacent characters won't fire an event. So I want to place a rectangle over each bitmapText with corresponding width and height, to capture and fire the appropriate event, but my text is part of a group for positioning, and so I would need to add the geometry to group as well. Any solution or alternatives would be greatly appreciated.
  13. Hi guys. I have a little task that I can't complet it Let me explain. I have a sphere with 3 bones. Using bones and a slider I modify the sphere geometry, I can scale, translate or rotate the bones, It works like a morph. After deform the mesh I want to save it as new babylon file, without bones, but keep deform geometry, not original. In this scope I update positions, normals, compute normals, but all time the new babylon file is saved like original, and not deform. I have to update anything else? Or I have to save the skeleton too? ....If yes, than I have a problem, because I want to add an animation to the new mesh, that I think will overwrite the skeleton. Here are 2 picture that show my problem first sphere is the original, and second is sphere saved. And I make a playground. Any opinion is welcome. Thanks
  14. how can smooth modify geometry in Babylonjs .
  15. Hi guys, I need draw some lines, they need be drawed instead of images because it's for an education game, so I need draw triangles dynamically (different angles,sizes,etc)..I'd like some retro effect for fun but I'm not sure if it's possible achieve this... is it possible?..any clue about how achieve it?, thank you guys!
  16. Rotating items

    Hello! For my project I want to re-arrange an interesting feature: the rotation of the object by clicking in the right direction (and of its movement) on the principle of moving the spacecraft to point and rotation to the desired degree. How can I make such a function? Example attached.
  17. Greetings! I had an idea for the organization to move the camera when the cursor to a specific side of the screen, for example - have brought the cursor to the top of the screen, the camera moves up. Brought down - the camera moves down. But I do not know how to organize it. There is another problem with importing models from 3ds Max 2015 models do not rotate absolutely nothing, no one axis. Tried already and simple rotation, and rotation directly in 3ds Max. Even tried to change the angle of the file .babylon. Nothing changes. Blender model of spin, but their appearance does not suit me, the model curve. Also wanted to ask. Is it possible for someone to ask for help (direct support), can somebody help me a little bit in the course of writing my project?
  18. This is rather programming logic question . But if I get answer to this, I will be able to know more about what information babylon.js provides for mesh and how I can use to do dynamic mesh generation. Assuming there's one plane mesh (can be positioned anywhere, facing any direction) , how do I draw another plane mesh exactly parallel to it ? As shown image below, the mesh which is in back will be there in the model. It will be accessible to me by name. While the 6 smaller meshes in the front will the one I will be creating and positioning dynamically which will be parallel to the mesh in the back. The important thing is the dynamic meshes should be perfectly aligned with the mesh in the back . ie. top left corner of 1st mesh in the front (going by top left to right bottom) should match top left corner of mesh in the back.
  19. Hey Everyone, I just completed and released a simple, physics based game that user Phaser. As the circle, your job is to avoid the triangles and gain points by hitting the rectangles. The game gets progressively harder after certain point thresholds are reached. The level change is indicated by the player (circle) changing colors. The game is intended to be challenging, however there is strategy in controlling the player which will allows for much higher scores. Leaderboard and achievements have been included on each platform using Google Play Games and iOS Game Center. The iOS version has a new version with bug fixes waiting for review (current version still playable), but the Android version is up-to-date. Feedback is welcome. Thanks
  20. I've read the code written by the awesome @Temechon, which addresses modifying the vertices in a mesh. However, I don't understand exactly how to create one such mesh from scratch, especially in such a way that it can be updated frequently with new vertex data. Could someone explain that more clearly? (Also, does BabylonJS have a way to use a VBO for such a task?) I'd post example code, but I don't really have anything that even begins to work yet. EDIT: Clarification. I know the logic and steps needed to create a mesh using vertices and the like. What I don't know is how one applies the arrays to the mesh itself, or how to create the mesh so the vertices can be updated.
  21. Text wrapping to shapes?

    Anyone got a bit of code for Phaser (or PIXI.Text) that does text wrapping to fit inside simple geometry or better yet arbitrary masks?
  22. [Phaser] Okto

    Hello all, This is my new game Okto. Goal of this game is to avoid collision between the ball and the oktagons, and survive as much as possible. You can play it here: Here are some screens also - Fun fact: first I had tried to create this game with KineticJS canvas framework (don't get me wrong it is an amazing framework). But I could not get passed 30fps even on desktop devices, whilst the code was highly optimized. With Phaser all my problems are solved and I'm seeing 50-60 fps at least on newer mobile devices and of-course dekstop. Thanks for your time!
  23. Hey folks! I'm working on creating a game that uses a hexagon grid as its board. I'd like to let players click/tap on a hexagon cell to select it. I can use drawPolygon() from a Geometry instance to get the hexagons drawn, but drawPolygon doesn't return anything I can attach an input handler event to? I know I can always translate pixel values into hexagons with an algorithm, but is there an easier way to detect which polygon I've clicked/touched?
  24. Dotted line

    Hi again! Is there any way to draw dotted line, except sprite and many small lines?
  25. I am considering getting started with Phaser. I might like to use it in LD29 next weekend. I had question about the performance of geometry in Phaser. When tinkering with the circle geometry example, I set the rendering mode to WebGL. I noticed that basic animations on the circle made it very choppy. I thought that WebGL was typically more performant compared to 2D canvas. Is this only true for displaying raster graphics, or should it apply to generated geometry as well? Just want to make sure this situation wasn't an anomaly for my system. If working with rectangles, circles, lines, and points is meant for 2D canvas, that is fine, I just want to prepare for that going in so that I can get the best performance possible. Thank you in advance for any answers!