3d mesh->c/c++ array, bitmap->c/c++ array

category: code [glöplog]
Hi all

Two quick questions:

1. Is there any tool which converts 3d mesh (.obj, .3ds files) to c/c++ array to include and use it in 4/64 kb intro?

2. How to include a group logo in a 64kb intro? Any conversion tool which convert file to c/c++ array?

Kind regards
added on the 2016-08-13 22:44:56 by mudlord mudlord
3d mesh you'd want to do your own exporter out of 3dsmax or so, exporting minimal info you need only. there were some good tutorials and talks by iq/rgba on how they optimized the 3d models for 192/92/64 and that intro with the rhino and horses.

most 3d models for tiny size intros are made by procedural code formulas. you can always do a tool to play around constructing them and store the procedural steps on how to replicate them. it's usually more byte effective to store the operands on how to obtain the model then the final mesh.

some folks use system font characters as starting points to extrude more complex shapes from. that saves some bytes from plotting the base path.

auld released this tool for doing modelling for tiny intros: http://qoob.weebly.com/

there were some conversion command line tools to convert binary into code include files (i remember using them in some 64ks many years ago) but i don't have any links for any of that right now.
added on the 2016-08-13 22:57:43 by psenough psenough
i meant 195/95/256 and paradise, special interest in http://www.iquilezles.org/www/articles/3dmodels/3dmodels.htm

but i recall he did an actual seminar talk about the 3d modelling optimization, you should be able to find slides or youtube of it somewhere.
added on the 2016-08-13 23:03:59 by psenough psenough
probably this one which is not on youtube by who knows what silly reason.
added on the 2016-08-13 23:17:40 by psenough psenough
bin2h or raw2h look promising. How to use and display in a 64 intro bitmap (logo) converted by bin2h or raw2h?
That would depend entirely in your choice of graphics API and rendering pipeline.
added on the 2016-08-15 15:58:12 by Preacher Preacher
c++ and open GL:)
Forgot. And no shaders.
added on the 2016-08-15 17:27:36 by raer raer
Use GDI+ for loading the image.
added on the 2016-08-16 08:45:13 by mudlord mudlord
It took me less than 10 minutes to code a small converter for bitmap to array in c#/.net !
And another 20 mins to code something that generates a texture (DirectX) from that array in c++.
I saved the array as "picture.h" and simply included it in my c++-code, so i can exchange it on the fly.
The Converter is as easy as (pseudocode)
Code: string fileNameOut = "picture.h" string fileName = "AwesomeLogo" string fileType = ".png"; Bitmap bitmap = new Bitmap(filename); StringBuilder bitmapString = new StringBuilder(); for(int i = 0; i < bitmap.Height; i++) { bitmapString.Append("{"); for(int j = 0; j < bitmap.Width; j++) { Color pixelColor = bitmap.GetPixel(j, i); bitmapString.Append(pixelColor.R.ToString() + ","); bitmapString.Append(pixelColor.G.ToString() + ","); bitmapString.Append(pixelColor.B.ToString() + ","); bitmapString.Append(pixelColor.A.ToString() + ","); } if(i != bitmap.Height) bitmapString.Append("},"); bitmapString.AppendLine(); } bitmapString.AppendLine(); bitmapString.Append("}"); using(System.IO.StreamWriter sw = new System.IO.StreamWriter(fileNameOut, false)) sw.WriteLine(bitmapString.ToString());

You can of course cast the values to whatever you need...if you want values between 0 and 255 so you can use bytes instead of floats this should work:
Code: byte pixelColR = (byte)(pixelColor.R * 255.0f);

I originally needed this converter to save an array of bools for a one-color-font i am currently using in my 8Ks.
"20 mins" should have been "2 mins" ;)