/// <summary> /// See BlWindow3D for details. /// </summary> protected override void Setup() { // Any type of content (3D models, fonts, images, etc.) can be converted to an XNB file by downloading and // using the mgcb-editor (see Blotch3D.chm for details). XNB files are then normally added to the project // and loaded as shown here. 'Content', here, is the folder that contains the XNB files or subfolders with // XNB files. We need to create one ContentManager object for each top-level content folder we'll be loading // XNB files from. You can create multiple content managers if content is spread over diverse folders. Some // content can also be loaded in its native format using platform specific code (may not be portable) or // certain Blotch3D/Monogame methods, like BlGraphicsDeviceManager.LoadFromImageFile. var MyContent = new ContentManager(Services, "Content"); // The font we will use to draw the menu on the screen. // "Arial14" is the pathname to the font file Font = MyContent.Load <SpriteFont>("Arial14"); // The model var numX = 128; var numY = 2; var geoModel = BlGeometry.CreateCylindroid(numX, numY, 0); // transform it geoModel = BlGeometry.TransformVertices(geoModel, Matrix.CreateScale(1, 1, 2f)); // Uncomment this to generate face normals (for example, if the previous transform totally flattened the model) //geoModel = BlGeometry.CalcFacetNormals(geoModel); // Uncomment this to set texture to planar //geoModel = BlGeometry.SetTextureToXY(geoModel); // convert to vertex buffer var geoVertexBuffer = BlGeometry.TrianglesToVertexBuffer(Graphics.GraphicsDevice, geoModel); var tex = Graphics.LoadFromImageFile("Content/image.png"); // The sprite we draw in this window GeoObj = new BlSprite(Graphics, "geomodel"); GeoObj.LODs.Add(geoVertexBuffer); GeoObj.BoundSphere = new BoundingSphere(new Vector3(), 1); GeoObj.Mipmap = tex; /* * // Uncomment this to show insides, also * GeoObj.PreDraw = (s) => * { * Graphics.GraphicsDevice.RasterizerState = RasterizerState.CullNone; * return BlSprite.PreDrawCmd.Continue; * }; * GeoObj.DrawCleanup = (s) => * { * Graphics.GraphicsDevice.RasterizerState = RasterizerState.CullCounterClockwise; * }; */ }
/// <summary> /// See BlWindow3D for details. /// </summary> protected override void Setup() { // We need to create one ContentManager object for each top-level content folder we'll be // loading things from. Here "Content" is the most senior folder name of the content tree. // (Content [models, fonts, etc.] are added to the project with the Content utility. Double-click // 'Content.mgcb' in solution explorer.). You can create multiple content managers if content // is spread over diverse folders. var MyContent = new ContentManager(Services, "Content"); // The font we will use to draw the menu on the screen. // "Arial14" is the pathname to the font file Font = MyContent.Load <SpriteFont>("Arial14"); // The model var numX = 128; var numY = 2; var geoModel = BlGeometry.CreateCylindroid(numX, numY, 0); // transform it geoModel = BlGeometry.TransformVertices(geoModel, Matrix.CreateScale(1, 1, 2f)); // Uncomment this to generate face normals (for example, if the previous transform totally flattened the model) //geoModel = BlGeometry.CalcFacetNormals(geoModel); // Uncomment this to set texture to planar //geoModel = BlGeometry.SetTextureToXY(geoModel); // convert to vertex buffer var geoVertexBuffer = BlGeometry.TrianglesToVertexBuffer(Graphics.GraphicsDevice, geoModel); var tex = Graphics.LoadFromImageFile("image.png"); // The sprite we draw in this window GeoObj = new BlSprite(Graphics, "geomodel"); GeoObj.LODs.Add(geoVertexBuffer); GeoObj.BoundSphere = new BoundingSphere(new Vector3(), 1); GeoObj.Mipmap = tex; /* * // Uncomment this to show insides, also * GeoObj.PreDraw = (s) => * { * Graphics.GraphicsDevice.RasterizerState = RasterizerState.CullNone; * return BlSprite.PreDrawCmd.Continue; * }; * GeoObj.DrawCleanup = (s) => * { * Graphics.GraphicsDevice.RasterizerState = RasterizerState.CullCounterClockwise; * }; */ }
/// <summary> /// See BlWindow3D for details. /// </summary> protected override void Setup() { // We need to create one ContentManager object for each top-level content folder we'll be // loading things from. Here "Content" is the most senior folder name of the content tree. // (Content [models, fonts, etc.] are added to the project with the Content utility. Double-click // 'Content.mgcb' in solution explorer.). You can create multiple content managers if content // is spread over diverse folders. var MyContent = new ContentManager(Services, "Content"); // The font we will use to draw the menu on the screen. // "Arial14" is the pathname to the font file Font = MyContent.Load <SpriteFont>("Arial14"); // The model resolution var numX = 512; var numY = 512; // tapered bent screw shape parameters var taperSize = .1; var numThreads = 5; var numTurns = 8; // (total for all threads) var threadDepth = .2; var bend = .001; // Create bending matrix (this could also include scale and translation) var matrix = Matrix.CreateRotationX((float)bend); // Create the tapered screw var triangles = BlGeometry.CreateCylindroid ( (x, y) => threadDepth * Math.Sin(Math.PI * 2 * (numThreads * x / (double)numX + numTurns * y / (double)numY)) + 1, numX, numY, taperSize, false, true, true, matrix ); // Uncomment this for facet normals //geoModel = BlGeometry.CalcFacetNormals(geoModel); // uncomment this to transform it //geoModel = BlGeometry.TransformVertices(geoModel, Matrix.CreateScale(1, 1, 2f)); // Uncomment this to generate face normals (for example, if the previous transform totally flattened the model) //geoModel = BlGeometry.CalcFacetNormals(geoModel); // Uncomment this to set texture to planar // (note: to control the planar direction, transform the vertices, call this method, then transform them back) //geoModel = BlGeometry.SetTextureToXY(geoModel); // convert to vertex buffer var geoVertexBuffer = BlGeometry.TrianglesToVertexBuffer(Graphics.GraphicsDevice, triangles); // The sprite we draw in this window GeoObj = new BlSprite(Graphics, "geomodel"); GeoObj.LODs.Add(geoVertexBuffer); GeoObj.BoundSphere = BlGeometry.GetBoundingSphere(triangles); GeoObj.Mipmap = new BlMipmap(Graphics, Graphics.LoadFromImageFile("image.png")); /* * // Uncomment this to make insides visible, also. * GeoObj.PreDraw = (s) => * { * Graphics.GraphicsDevice.RasterizerState = RasterizerState.CullNone; * return BlSprite.PreDrawCmd.Continue; * }; * GeoObj.DrawCleanup = (s) => * { * Graphics.GraphicsDevice.RasterizerState = RasterizerState.CullCounterClockwise; * }; */ }
/// <summary> /// See BlWindow3D for details. /// </summary> protected override void Setup() { // Any type of content (3D models, fonts, images, etc.) can be converted to an XNB file by downloading and // using the mgcb-editor (see Blotch3D.chm for details). XNB files are then normally added to the project // and loaded as shown here. 'Content', here, is the folder that contains the XNB files or subfolders with // XNB files. We need to create one ContentManager object for each top-level content folder we'll be loading // XNB files from. You can create multiple content managers if content is spread over diverse folders. Some // content can also be loaded in its native format using platform specific code (may not be portable) or // certain Blotch3D/Monogame methods, like BlGraphicsDeviceManager.LoadFromImageFile. var MyContent = new ContentManager(Services, "Content"); // The font we will use to draw the menu on the screen. // "Arial14" is the pathname to the font file Font = MyContent.Load <SpriteFont>("Arial14"); // The model resolution var numX = 512; var numY = 512; // tapered bent screw shape parameters var taperSize = .1; var numThreads = 5; var numTurns = 8; // (total for all threads) var threadDepth = .2; var bend = .001; // Create bending matrix (this could also include scale and translation) var matrix = Matrix.CreateRotationX((float)bend); // Create the tapered screw var triangles = BlGeometry.CreateCylindroid ( (x, y) => threadDepth * Math.Sin(Math.PI * 2 * (numThreads * x / (double)numX + numTurns * y / (double)numY)) + 1, numX, numY, taperSize, false, true, true, matrix ); // Uncomment this for facet normals //geoModel = BlGeometry.CalcFacetNormals(geoModel); // uncomment this to transform it //geoModel = BlGeometry.TransformVertices(geoModel, Matrix.CreateScale(1, 1, 2f)); // Uncomment this to generate face normals (for example, if the previous transform totally flattened the model) //geoModel = BlGeometry.CalcFacetNormals(geoModel); // Uncomment this to set texture to planar // (note: to control the planar direction, transform the vertices, call this method, then transform them back) //geoModel = BlGeometry.SetTextureToXY(geoModel); // convert to vertex buffer var geoVertexBuffer = BlGeometry.TrianglesToVertexBuffer(Graphics.GraphicsDevice, triangles); // The sprite we draw in this window GeoObj = new BlSprite(Graphics, "geomodel"); GeoObj.LODs.Add(geoVertexBuffer); GeoObj.BoundSphere = BlGeometry.GetBoundingSphere(triangles); GeoObj.Mipmap = new BlMipmap(Graphics, Graphics.LoadFromImageFile("Content/image.png")); /* * // Uncomment this to make insides visible, also. * GeoObj.PreDraw = (s) => * { * Graphics.GraphicsDevice.RasterizerState = RasterizerState.CullNone; * return BlSprite.PreDrawCmd.Continue; * }; * GeoObj.DrawCleanup = (s) => * { * Graphics.GraphicsDevice.RasterizerState = RasterizerState.CullCounterClockwise; * }; */ }