//-------------------------------------------------------------------------------------------------- // #Proposal for Brick objects for FreeBuild (The Building Game) // #By: Chris (gobbles) // // Notes: // -I plan on making a "Brick Creation" tool that will allow users to create // their own bricks in-game and share with others. The easier it is to generate // bricks, the easier it will be to make this tool. I believe a tool like this // will be not only cool, helpful, and sensible, but also critical and necessary // if we are to compete with a game such as Blockland. // -This is all PSEUDO-CODE. If you don't know what that means, look it up. I do // however want the brick's text files to look like the ones you will see below. // -The brick file's syntax will look like a simple Torquescript, but a parser will // need to be written in the engine to read the brick's file. // -The brick's name will come from it's class name (EX: -> plate1x2x1 <- { .. }). // Other info could be added, such as collision meshes(haven't thought of how those // will work yet. //------------------------------------------------------------------------------------------------ //-------------------------------------------------------------------------------------------------- // -A (Primitive) Brick's file will contain something like this... brick1x8x1 { genPrimBrick(1,8,1); } // -Yes, you can have more than one brick in a file, since each brick object will be loaded // seperate from one another. Groups of bricks can be stored in a single file this way. // This will be taken care of in the C++. // -The average primitive brick will use between 24-26 Quads // -More complex bricks will need to be written out using the genSide/Top/Bottom functions, // or custom, hard-coded quad generation(still isn't that bad) //-------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------- // Support functions // (will be written in the engine) // Notes: // -All these functions can used in the brick's file (EX: brick2x4x3.brk) // -Units are in studs // -the p[] array will contain all the points in the brick // -Some other functions may be nessesary for things such as windows, permanently transparent // objects, or slopes that may require a seperate texture. However, most bricks can be formed // by using these few support functions. function genPrimBrick(x,y,z) { p[1] = "0 0 0"; p[2] = "x 0 0"; p[3] = "x y 0"; p[4] = "0 y 0"; p[5] = "0 0 z"; p[6] = "x 0 z"; p[7] = "x y z"; p[8] = "0 y z"; genTop(p[5],p[6],p[7],p[8]); genSide(p[6],p[5],p[1],p[2]); genSide(p[7],p[6],p[2],p[3]); genSide(p[8],p[7],p[3],p[4]); genSide(p[5],p[8],p[4],p[1]); genBottom(p[2],p[1],p[4],p[3]); } function genTop(s1,s2,s3,s4) { // Simple Quad-creation code } function genSide(s1,s2,s3,s4) { // Determines where the edges will be, then creates 5 quads, and places them // in a way that gives the appearance of the side being "beveled"- colored accordingly } function genBottom(s1,s2,s3,s4) { // Pretty much the same code as the Side, except for a few checks to see if it's // a brick that's 1 or 2 studs wide, or more. (These can use less polies, so // it's best to optimize everything we can } function genSlope(s1,s2,s3,s4) { // Genereates a simple poly, but uses the slope grain texture overlaid on the brick's color } function genQuad(s1,s2,s3,s4) { // Generates a simple Quad } //------------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------------------------- //Example of a slope brick //slope2x2x3.brk //#Quads = 19 (Top=1 Sides=14 Bottom=4) slope2x2x3 { //Bottom p[1] = "0 0 0"; p[2] = "2 0 0"; p[3] = "2 2 0"; p[4] = "0 2 0"; //Bevel-Edge p[5] = "2 0 0.2"; p[6] = "2 2 0.2"; //Top p[7] = "0 0 3"; p[8] = "1 0 3"; p[9] = "1 2 3"; p[10] = "0 2 3"; genTop(p[10],p[7],p[8],p[9]); genSide(p[7],p[10],p[4],p[1]); //Back Edge opposite slope genSide(p[6],p[5],p[2],p[3]); //Edge right below slope genSlope(p[6],p[5],p[2],p[3]); //Slope (Duh) <- Slopes will have their own texture // For now the sides will remain un-beveled genQuad(p[5],p[8],p[8] - 3,p[2]); genQuad(p[9],p[6],p[3],p[9] - 3); genQuad(p[8],p[7],p[1],p[8] - 3); genQuad(p[10],p[9],p[9] - 3,p[4]); genBottom(p[2],p[1],p[4],p[3]); } //-------------------------------------------------------------------------------------------------