Jump to content

Search the Community

Showing results for tags 'minimize'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • HTML5 Game Coding
    • News
    • Game Showcase
    • Facebook Instant Games
    • Web Gaming Standards
    • Coding and Game Design
    • Paid Promotion (Buy Banner)
  • Frameworks
    • Pixi.js
    • Phaser 3
    • Phaser 2
    • Babylon.js
    • Panda 2
    • melonJS
    • Haxe JS
    • Kiwi.js
  • General
    • General Talk
    • GameMonetize
  • Business
    • Collaborations (un-paid)
    • Jobs (Hiring and Freelance)
    • Services Offered
    • Marketplace (Sell Apps, Websites, Games)

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Website URL


Twitter


Skype


Location


Interests

Found 3 results

  1. There is a CUT ROD game at http://www.html5pcode.com/a1ycutrod.htm The game uses a p-code. The p-code was written in HTML5 JavaScript. The home page is http://www.html5pcode.com You are to minimize the cost of cutting many bars of different lengths from 6 rods. Try to use the entire rod because the shorter the rod the less it is worth per unit of length. A rod of 50% of its original length is only worth 30 % of its original value. You can view the program's solution to the game. There are 100 different games. If you want, you can build your own game. Your game will be stored in a file within the local storage area of your browser. You can have up to 12 bars and 12 rods. This game is written in a p-code. The p-code is executed by a p-code engine. If you click on PROGRAM in the RED STRIPE at the top, you can view the p-code programs. The p-code engine can execute the programs and it can edit the programs.There is a DATA option that allows you to see the program's data as it is being executed. There is a TRAIL option that allows you to execute the program in small steps. There is an RT, Real Time, option that allows you to change the program as it is executing. There are many YouTube videos that will show you how it works.
  2. There is a REPLACE game at http://www.html5pcode.com/a1yreplace.htm The game uses a p-code. The p-code was written in HTML5 JavaScript. The home page is http://www.html5pcode.com The goal is to minimize a device's maintenance cost by replacing parts before they go dead. There is a cost for stopping the device (stop cost) and a cost for each part replaced. When the device is stopped, parts that are near their expected time-to-fail can be replaced. You decide what the replace time should be. There are 100 different games. You can make your own REPLACE PROBLEM. It will be saved in your browser's local storage. This game is written in a p-code. The p-code is executed by a p-code engine. If you click on PROGRAM in the RED STRIPE at the top, you can view the p-code programs. The p-code engine can execute the programs and it can edit the programs.There is a DATA option that allows you to see the program's data as it is being executed. There is a TRAIL option that allows you to execute the program in small steps. There is an RT, Real Time, option that allows you to change the program as it is executing. There are many YouTube videos that will show you how it works.
  3. The following function minimizes the number of vertices in a mesh. BABYLON.Mesh.prototype.minimizeVertices = function() { var _pdata = this.getVerticesData(BABYLON.VertexBuffer.PositionKind); var _ndata = this.getVerticesData(BABYLON.VertexBuffer.NormalKind); var _idata = this.getIndices(); var _newPdata = []; //new positions array var _newIdata =[]; //new indices array var _mapPtr =0; // new index; var _uniquePositions = []; // unique vertex positions for(var _i=0; _i<_idata.length; _i+=3) { var _facet = [_idata[_i], _idata[_i + 1], _idata[_i+2]]; //facet vertex indices var _pstring = []; //lists facet vertex positions (x,y,z) as string "xyz"" for(var _j = 0; _j<3; _j++) { // _pstring[_j] = ""; for(var _k = 0; _k<3; _k++) { //small values make 0 if (Math.abs(_pdata[3*_facet[_j] + _k]) < 0.0001) { _pdata[3*_facet[_j] + _k] = 0; } _pstring[_j] += _pdata[3*_facet[_j] + _k] + "|"; } _pstring[_j] = _pstring[_j].slice(0, -1); } //check facet vertices to see that none are repeated // do not process any facet that has a repeated vertex, ie is a line if(!(_pstring[0] == _pstring[1] || _pstring[0] == _pstring[2] || _pstring[1] == _pstring[2])) { //for each facet position check if already listed in uniquePositions // if not listed add to uniquePositions and set index pointer // if listed use its index in uniquePositions and new index pointer for(var _j = 0; _j<3; _j++) { var _ptr = _uniquePositions.indexOf(_pstring[_j]) if(_ptr < 0) { _uniquePositions.push(_pstring[_j]); _ptr = _mapPtr++; //not listed so add individual x, y, z coordinates to new positions array newPdata //and add matching normal data to new normals array newNdata for(var _k = 0; _k<3; _k++) { _newPdata.push(_pdata[3*_facet[_j] + _k]); } } // add new index pointer to new indices array newIdata _newIdata.push(_ptr); } } } _newNdata =[]; //new normal data BABYLON.VertexData.ComputeNormals(_newPdata, _newIdata, _newNdata); //create new vertex data object and update var _vertexData = new BABYLON.VertexData(); _vertexData.positions = _newPdata; _vertexData.indices = _newIdata; _vertexData.normals = _newNdata; _vertexData.applyToMesh(this); } If you check this playground http://www.babylonjs-playground.com/#1JBMJ3#15 and switch on the Debug Layer you will see the number of vertices is 366. Comment out line 78 (ie do not apply the minimize vertices function) the number of vertices is 435. Replacing line 78 with sphere.optimizeIndices() leaves the number of vertices as 435 EDIT Just to bring to the top RaananW's warning from his post, this will only help if the mesh material is a uniform colour or texture. Textures such as the map of the earth will not seam correctly if the above function is applied to the sphere. Questions Is this a useful function? Is there anything made not possible by applying the function? Could this already be done with existing functions? Some Background to The Developement Playing around with sphere with a small number of segments (1) (below) I counted 14 vertices but the Debug Layer showed 28 The console for the vertex data positions gave Array [ 0, 5, 0, 0, 5, 0, 0, 5, 0, 0, 74 more… ] and that for the indices gave Array [ 0, 1, 7, 7, 1, 8, 1, 2, 8, 8, 98 more… ] This showed two things (1) vertex positions are repeated, eg 0, 5, 0 is repeated at least three times (2) The indices for the first facet (one of the triangles used to construct a mesh) 0, 1, 7 gives the vertex positions as (0, 5, 0), (0, 5, 0) and (4.330126941204071, 2.5, 0). Since (0, 5, 0) accounts for two positions the facet 0, 1, 7 is not a true triangle but is a straight line. So I set about seeing if I could remove the redundancies. This playground http://www.babylonjs-playground.com/#1JBMJ3#16 shows it was possible. Next question was did the function affect sub meshes? This playground http://www.babylonjs-playground.com/#1JBMJ3#13 shows that it does not appear to? This playground http://www.babylonjs-playground.com/#1JBMJ3#14 (by uncommenting lines 79 and 80) seems to show that the function will take a flat shaded mesh and reverse it back. Is there a name for a mesh that is not flat shaded? A round shaded mesh does not sound correct.
×
×
  • Create New...