View Full Version : Creating models
Petr Schreiber
11-03-2006, 22:20
Hi all,
as I'm thinking about painless use of TBGL, I finally get one idea.
For creating simple scenes, the built in primitives can be used without any problems. But when you stop to just play with it, and think about really practical use ...
What about 3D modeller designed exclusively for thinBASIC and TBGL ?!
Off course, there could be another way - import generally used 3D files some way. I investigated a little bit and get some interesting information.
3D Studio Max is marvelous tool, but available after paying unbelieveable prize :(
Free tool called GMax ( light version of 3D Studio MAX 4 ) is very nice, powerful, but it's difficult to get out data from it. Also I'm afraid that hacking .gmax format is not legal.
Blender is little bit complicated to handle.
So I'm again at the beginning :)
My idea is to create polygon-based modeller, which would support ( at least ) these features:
[list]
Creating objects by defining all types of polygons supported by TBGL
Tools like a "Build a wall using two clicks", "Deform terrain", ...
Assigning color and texture to each object
Possibility to handle model in various layers
Export simple file format, easily PARSEable using thinBASIC
It would be written using PowerBASIC to take advantage of extreme speed of compiled program but ...
... it would take advantage of power of thinBASIC heavily too! - user could launch it's own thinBASIC scripts to automate various tasks when modelling
[/list:u]
The last point will be much easier when some "inlanguage" thinBASIC SDK will appear for PowerBASIC, similar to one from Eros's previous project - BINT32. But it is posible ( at very restricted level ) even now.
I have already made some concept-program, but I have to translate the interface and helpfile from Czech to English, so it will take some time before first public testing :D
What do you think about it ?
Thanks,
Petr
P.S. Hmm, "thinEdge 3D" could be cool name :D
ErosOlmi
12-03-2006, 11:01
Give me the list of what you need and we will try to do our best to implement new thinBasic features.
Petr Schreiber
12-03-2006, 14:10
Hi Eros,
briefly, I just need to register functions ( like the ones from DLL modules ) from the 3D editor EXE.
Maybe something thinBASIC_ActivateInterpreter to tell TB core I will interface with it, then register some functions from the EXE to be able exchange e.g. vertex data. Then the thinBASIC scripts could directly call something like ed_GetVertexX(index), ed_GetNumberOfVertexes, ... without any problems.
I'm now solving some task as passing it to script command line ( like editor handle ... ). But for 10 000 triangle model it is clumsy :).
Would it be possible ?
Thanks for your time,
Petr
ErosOlmi
12-03-2006, 15:39
Petr,
using thinBasic in this way is not possible because thinBasic.exe is mainly a runner for thinCore.dll. And thinCore.dll has a protection schema in order not to allow to use thinCore.dll other than from thinBasic.exe
Also in our future plan we think to promote thinCore.dll as stand alone script engine for those programmers that wants to use thinBasic as application script engine.
I will think about how to give direct direct access to thinCore from inside you applicatio. To better understand this, can you provide me an application example with sources (I imagine in PB). I just need something to understand how you are actually using thinBasic.
Thanks a lot
Eros
Petr Schreiber
12-03-2006, 18:14
Hi Eros,
my use of thinBASIC in editor is very basic now :).
I just let the user to select which script will be executed and then I use:
ShellExecute ( hOGLWnd, "", CURDIR$+"\Scripts\"+ScriptName$, FORMAT$(hOGLWnd)+"-"+ModelName, "", %SW_SHOWNORMAL)
Then I can call script like:
USES "OS"
USES "UI"
USES "FILE"
DIM whandle AS DWORD = OS_GETCOMMAND(2)
DIM modelName AS STRING = OS_GETCOMMAND(3)
DIM modelBck AS STRING
IF wHandle = 0 THEN
MSGBOX 0, "This script must be launched from 3D Editor"
STOP
END IF
MOUSEPTR 1
CONSOLE_SETTEXTATTRIBUTE (%CONSOLE_FOREGROUND_RED OR %CONSOLE_FOREGROUND_GREEN OR %CONSOLE_FOREGROUND_BLUE)
CONSOLE_WRITE("The model you are using is : "+modelName )
CONSOLE_WRITELINE($CRLF + "Press any key to make a backup")
CONSOLE_SETTEXTATTRIBUTE (%CONSOLE_FOREGROUND_GREEN)
modelBck = FILE_LOAD(DIR_GETCURRENT+"\Modely\"+TRIM$(modelName, ANY " -"))
CONSOLE_WRITE( modelBck )
FILE_SAVE( DIR_GETCURRENT+"\Modely\"+TRIM$(modelName, ANY " -")+".BACKUP", modelBck )
CONSOLE_SETTEXTATTRIBUTE (%CONSOLE_FOREGROUND_RED OR %CONSOLE_FOREGROUND_GREEN OR %CONSOLE_FOREGROUND_BLUE)
CONSOLE_WRITELINE($CRLF + "File was backuped")
CONSOLE_WAITKEY
WIN_SETFOREGROUND(whandle)
MOUSEPTR 0
This script will just save the file with different name, and display it's contens in console ( see the picture ).
The code of whole editor is about 4 000 lines now, with czech comments and interface.
Nothing pleasant to read :D. But if you want I can send it to you.
It would be ideal, if it would be possible to easily use thinBASIC just like in your BINT32 "Examples\Test01.bas".
Thanks,
Petr
Petr Schreiber
31-03-2006, 21:46
Hi,
just to keep you all in ... suspense :)
Here is little demonstration of future use thinEdge ( 3D editor ) >> thinBASIC.
Loading of models is easy like a one-two-three, and using display lists ... you can get super fast rendering.
So here is my first demo of potencial of thinBASIC for advanced models in games. This is a just simple demonstration of confused F117 bomber in the hell of exploding shrapnels :).
I choosed F117 because it is so "cubist" dream airplane, that it is easy to modell. And it also looks like a bat :)
Hope you like it,
and remember ... this is just a beginning :D
Petr
UPDATED 10-Jan-2010 to fix some syntax problem. Please note TBGL contains direct support for m15 handling, so this example is considered obsolete from demonstrated approach point of view.
ErosOlmi
01-04-2006, 00:54
Just one word: fantastic! :shock:
ADDED:
the file structure of thinEdge is very clear and easy to use/change/implement.
I would suggest to add a version number of thinEdge in order to understand with wich version the file was created (possible version incompatibility)
Also your "meLoadM15File" thinBasic function you have created in F117 example gave me the idea of a new parsing function able to parse and load "rectangular" text buffers in one go. Something like:
PARSERECT StringBuffer, ArrayName(), LineSeparator, FieldSeparator
At the end ArrayName will be a 2 dimesional array with all the lines and fields parsed. This should speed-up a lot loading of files.
Quite easy to implement. Thanks a lot.
RobertoBianchi
02-04-2006, 09:48
Petr,
amazing, you make a great work!
Roberto.
Petr Schreiber
02-04-2006, 10:35
Thanks to you both,
the version info will be added, that's a good idea!
There is still much work on the editor. For anybody interested there is an BETAVERSION of thinEdge on tbgl pages (http://psch.thinbasic.com), but keep in mind it is not well optimized and can cause troubles on various computers :(. Anyway, any impressions would be appreciated.
I have now first set of ideas from Eros to implement ( like make it more "Windows look and feel", palletes, speed of cursor movement fix on fast computers ... ) So don't be shy to add new suggestions.
Thanks,
Petr
P.S. PARSERECT function would be greatly appreciated ! Good idea !
Petr Schreiber
21-04-2006, 21:51
Hi,
just to keep you updated.
I added some new stuff regarding thinEdge, thinBASIC file loading routines + screenshots on the tbgl pages (http://psch.thinbasic.com/).
Hope you like it. I hunted some bugs, added support for loading Wavefront OBJ 3D files and at last the transparency of layers works as it should :)
Bye,
Petr
Petr, I am here after almost a half year passed the last post. As you know I am enjoying thinEdge as all your creations.
Now that I am spending some time with Blender, I am impressed with it a lot. My thoughts would be to figure out how to use Blender with TBGL. Maybe how to use blender files directly in thinBasic and TBGL. thinEdge, is very nice and impressive, but your time is limited although your talent is not. You can do anything it seems from your great works. Just my thoughts at the moment.
Anyways not to get offtrack. I don't really understand fully the 3d world yet. The terragens, world builders, and of course TBGL, but it would be nice to be able to use popular proven open source programs with our efforts, so that we can do a lot quicker.
Would love to hear your thoughts about all of this. Thanks for all you have provided, I have a long way to go to catch up to you, if I ever can.
Petr Schreiber
25-11-2006, 11:20
Hi kryton9,
thanks for your idea.
You are right I am time limited, that's true :(.
thinEdge is my pet, so it will be supported in TBGL as long as I'm alive :)
Regarding support for others, this comes difficult. Every editor has its way to handle all this 3D stuff.
Regarding Blender ... I must say I like it more than before. The version I tested was very unstable, handged very often and I got very angry with it.
Latest release is something different, and I am not angry with it :).
But I still don't like the Blender format, I have no guarantee it won't change in future and this is I would be afraid of.
So I have little request to you. Could you please create simple model in Blender ( like cube and sphere ) with at least two textures used and some vertices colored ?
I could examine this model and find solution on the format loading and so on. If we could arrange on some old-but-working format like OBJ, which Blender can export in the original release without need to seek for plugins, it would be perfect.
The advantage of thinEdge format is, that it contains only information needed for TBGL. Although the files can be very large on disk, they have very good sizes after ZIPing them.
Worst is the modeling part, which is maybe too much complicated for "advanced" models. I am now prepairing one new modeling tool which would make lot of things easier, but I'm not sure how much time it will take.
Thanks a lot,
Petr
ErosOlmi
25-11-2006, 12:02
Petr,
if you are going to support multiple file format in thinEdge, why not creating some sort of thinEdge plug-in using dll?
Every file format would be handled by a different dll loaded at thinEdge runtime when needed. So no static linking but dynamic link using LoadLib when needed.
This will be very easy to maintain in case file format change.
Just idea.
Eros
Petr Schreiber
25-11-2006, 12:13
Hi Eros,
good idea ;)
So there would be "PlugIns" subdirectory in thinEdge containing for example
thinEdge_fileformat_3DS.dll
Which would have function with fixed name Import and Export with thinEdge array as parameter and plugin would feed it? Good !
I think for users of PB it is very easy to do, as the vertex buffer array would be passed BYREF to be able to REDIM it from the DLL module. But can this be done from other programming languages than PB ?
I'm thinking of adding following functions, which could plugin call:
thinEdge_Request_Layer_Add
thinEdge_Request_TextureLoad
Thanks a lot,
Petr
ErosOlmi
25-11-2006, 12:59
Petr,
to be able to create application plug-ins you need to export from thinEdge.exe some interface function like we do between thinCore.dll and its modules.
Than the plug-ins must have some standard function in order thinEdge control them.
For example, I suppose a plug-in that need to interface with thinEdge window should know window handle and some other info.
So I suppose the plugin should have a standard exported function called something like "thinEdgePlugIn_Init" executed by thinEdge when plugin is loaded just after a LoadLib. Usually the main application talk with plugins using pointer to common (common means shared with an .INC file to be distributed) structures.
You can find an example here: http://www.planetsquires.com/jellyfishpro.htm
This is the JellyFish edito you already know. It has the possibility to execute plugins created with edit SDK you can get from http://www.planetsquires.com/jproplugins.htm
It can be interesting for user 3rd party development. Also development can be done using any language capable of creating standard Win32 DLL.
Can you imagine?
And data format conversion can be a good start for implementing such things.
Ciao
Eros
Petr Schreiber
25-11-2006, 15:34
Hi Eros,
thanks for inspiration and samples.
I think I can get it.
Just one thing - for example the texture load request.
Do you think this would be acceptable ?
thinEdge code while loading using plugin ( this is abbreviated pseudo code, it would be done using CALL DWORDs in PB ):
' This is called from thinEdge
thinEdge_request_ImportFile ( Model$, m15Vertex(), LayerList$, Textures$ )
FOR i = 1 to Parsecount( Textures$ )
LoadTexture( PARSE$(Texture$, ",", i) )
NEXT
FOR i = 1 to Parsecount( LayerList$ )
CreateLayer( PARSE$( LayerList$, ",", i) )
NEXT
... I mean - it is easy to send data to the plugin, but hard to make request from plugin.
The thinEdge_request_ImportFile would fill the m15Vertex() array with polygon definition and links to layers and textures. LayerList$ and Textures$ would be BYREF and the DLL procedure would fill them with needed data and I could process them later.
Bye,
Petr
ErosOlmi
25-11-2006, 15:49
I'm sorry but is is very hard for me to understand what you are talking about.
Anyhow, you know you can call a sub/function just storing its pointer somewhere and using CALL DWORD in PB with the correct syntax.
So both plugin and main exe can exchange respective pointers of their functions.
Another option is to create a thread in main exec that remain active in order to wait for plugin requests maybe using a common structure and some pointers.
But most depends if for your plugins are just something that have to do a job when requested or are something directly interactig with your main exe objects in real time.
Eros
Petr Schreiber
25-11-2006, 16:04
Hi Eros,
I'm sorry for unclear explanation,
but your answer is exactly what I needed to know :)
Petr
ErosOlmi
25-11-2006, 19:02
Well, it is clear. I am the problem.
I do not have any clue of what behind the curtains of thinEdge and worst I'm not very good in 3D and 3D math. :-[
Petr, if thinEdge is your baby, that is fine. You have the time we have the use, so good combo then. I exported from blender with obj and it went into thinEdge with no problems, I didn't have textures however. I will do a test. Obj is available as an format I think on all modeling programs, so maybe you won't have to support the other formats. I just thought if we used Blender for animation and rigging, then if it could be used in thinBasic. You have to understand, I don't fully understand how all of this works, I tinkered with many 3d programs, and languages, but never really understood it and that is why i am so interested in doing this engine as finally i will try learning the things behind the magic box, well at least to some level. I know TBGL makes openGL magic already :) and other engines make directx magic, but still seem hardcore to use to me :)
I will make a textured cube, and sphere in blender and export as obj and see what happens.
I got lost in the dialog between you and Eros about plugins, callbacks and pointers. Is there more info I can read anywhere about this stuff or example to look at?
Petr Schreiber
25-11-2006, 21:34
Hi kryton9,
OBJ is quite old format, but very simple to load and handle.
I'm looking forward to your results. Don't forget thinEdge supports only BMPs at this time for textures :-[.
Regarding plugins you can study the link Eros provided and thinBASIC SDK.
I'm thinking of making thinEdge more open, so it could be pluginable as 3DS Max or Blender.
Then it will be possible to just write DLL which will have some "standard" functions to communicate with thinEdge.
You could design own "assistants", tools ... You could write plugin using any language, even in Turbo Delphi for example. Now I need to create some basic thinEdge module framework. ( ... and fix the wrong text typing, add wire/solid switch, saving of options to INI, ... :) )
My dream is still thinEdge scriptable using thinBASIC as Max script is for 3D Studio Max.
thinBASIC seems to me much more advanced and user friendly than Max script ( although it is also nice ).
And don't be afraid of TBGL, there is nothing hardcore about it!
Thanks,
Petr
Petr, got lost trying to get ubuntu to see my wireless card, I took a break and did a cube with a jpg texture on it. I exported it as OBJ file and the cube opened fine in thinEdge, but the texture was not with it. Do I need to place the jpg in the same folder with the obj file and it will find it then or is there another way I am missing?
I will try different things, but in case I go to sleep as sleepy, wanted to ask so you could see this and fill me in. Thanks.
ErosOlmi
26-11-2006, 11:05
kryton9,
I think thinEdge at the moment supports only .BMP files and not other graphic formats like .JPG
Not sure if this is the problem but Petr mentioned it in a previous post.
Eros
Petr Schreiber
26-11-2006, 11:11
Hi,
Eros is right, thinEdge does BMP only at the time.
So if you can, convert the JPGs to BMP and place them into "Textures" directory.
Thanks,
Petr
P.S. Good luck with Ubunutu
P.S.#2 Maybe I could make some option, which would allow to shell non BMP files to user defined file converter
ErosOlmi
26-11-2006, 11:15
Petr,
have you seen post from José at http://www.powerbasic.com/support/forums/Forum8/HTML/003668.html
It is about FreeImage lib. He produced PB inc file. I tested it under thinBasic and it is 100% compatible.
Not yet study how complicated is this library but maybe you can see if it can be used to make image conversion on the fly for thinEdge or even used formats different from BMP directly in thinEdge.
Cioa
Eros
Petr Schreiber
26-11-2006, 18:37
Thanks,
I'm watching it now.
I will try to find the 2 BMP conversion in FreeImage first, otherwise even TBGL would be FreeImage dependant.
Thanks a lot,
Petr
I was sleepy when doing all of this and forgot all about it needing to be a bmp. But nice to know it belongs in the textures folder.
Will do it all now while awake :)
Found out that you can't have spaces in the name of the bmp file, just wanted to let you know, no problem just something to note. I run into that a lot so when I had a problem knew to try that:)
I put the blender cube with the bmp cube mapped to it. I exported as an obj file, and in thinEdge it tiles 4 on the top and bottom and none on the sides.
in CubeTest.zip:
BlueTriadic.bmp
cubeWithColors.blend
cubeWithColors.obj
in Sphere.zip:
sphereWithColors.blend
sphereWithColors.obj
it uses the same bmp as the cube
It wrapped but tiled again.
Hope it helps Petr, this is magic to me at this point too. I understand it is converting all of the vertices, but I have no idea how it knows how to put the texture on it. Amazing stuff.
Petr Schreiber
27-11-2006, 12:16
Hi kryton9,
thanks a lot for sample objects.
I will check for texture names with spaces, thanks for reporting it.
Regarding the thinEdge and textures.
As you have noticed, when you export using "Wavefront OBJ" from Blender, you get two files - OBJ with geometry and MTL with material properties and textures.
There is one problem, the UV coordinates for texture mapping are not exported from Blender !
When thinEdge realize this, he start to be very sad and generates it's own texture mapping, which is based on XZ coordinates of object ( not amazing ). This is why the box displays texture only on top side in thinEdge, because the cube is 2x2x2, thinEdge maps it 2x2 times on the top side. The sides are too thin to be more than 1 pixel in oned direction from texture applied. When you model in thinEdge, sure it is done correctly, but importing is naughty beast.
So please try to find the way Blender will force export texture coordinates ( frequently called as UV coords, in thinEdge I call it TexX, TexY ) too. It will be presented as lines beginning with "vt " in OBJ file.
Current Blender export throws away "just" materials and faces data.
I think there is a bug in Blender OBJ exporter - if I check the normals export, I get the right "vn " lines.
But checking UV does nothing.
Maybe some third party OBJ exporter exists for Blender ?
There is also one limitation in thinEdge relating texture size - try to keep them in power-of-two sizes.
So texture 512x512 is ok, 2048x256 is ok too, but 640x400 ... this is just coincidence it works.
The non-power of two sizes for textures CAN be handled correctly, but in more advanced OpenGL versions using OpenGL extension mechanism. I'm trying to keep thinEdge working on older PCs too, and to keep the produced file interpretable on them also.
The power-of-two sized textures have also much much faster processing.
Thanks a lot,
Petr
Petr Schreiber
27-11-2006, 21:10
Hi kryton9,
I'm now tuning import/export in thinEdge.
The texture with spaces problem is now fixed.
Regarding export, it provides maximum comfort, as it does the following ( let's presume you save "MyMonster.OBJ"):
thinEdge will:
* Create "ExportedFiles" if it does not exist already
* Create "ExportedFiles\MyMonster_exported_to_OBJ" if it does not exist already
* Put OBJ file here
* Put MTL file here
* Create "ExportedFiles\MyMonster_exported_to_OBJ\Textures" if it does not exist already
* Fill "ExportedFiles\MyMonster_exported_to_OBJ\Textures" with all textures referenced from model ( no more manual work :) )
I still have some things to arrange in thinEdge, then I will release first 1.0.0.6 preview for tests, if you are interested.
Bye,
Petr
Petr, the new additions to thinEdge sound really nice. Of course I am interested to see the next release.
I will keep experimenting with Blender and obj export settings, it helps me learn more about all of that this way too.
When and if I find the magic combo, I will sure let you know.
Do I need to put the mtl file with the obj file in the models folder or would that go into the textures folder?
Petr Schreiber
28-11-2006, 20:21
Hi kryton9,
OBJ and MTL to "Models"
Textures to "Textures"
I'm sorry, I will cover it better in help file :)
Thanks a lot,
Petr
Thanks Petr, going to tinker with Blender a bit so will do more tests to see if I can get a nice export out with good settings from blender. Will keep you appraised of any discoveries of course.
I found a neat thing in Blender tonight while trying to get texture baking working again.
Once you have your faces uv mapped, you press Ctrl+Alt+B, then select normals from the texture bake panel.
It is neat, it tries to assign a unique color to each face normal, so it will be easier to identify when painting custom textures. I thought that was a neat feature I am sure it will come in handy.
Petr Schreiber
29-03-2007, 08:38
Thanks for the tip !
Bye,
Petr
Some more Blender and Mike's M15 Export script discoveries tonight.
I tested and so far successfully, the idea of making very simple meshes that are separate from each other.
This way when you uvunwrap you have very easy shapes to texture.
Then in Blender to export properly and to make it with less texture files, you join all the parts together.
You do this by right clicking on each object while holding the shift key down after the first selection.
Press CTRL+J to join all the meshes.
Then do an unwrap for this new joined object with all its parts textured. You get all the benefits of simpler texturing
and then the ability to unwrap into a single texture file to be used in the end.
Also if you get wierd m15 exports, know that you probably had separate meshes and that you forgot to join them before the export.
It is a great check to know that your model is correctly exported this way.
Mike, m15 export is working beautifully in these tests, I am so impressed and happy. Of course Petr, your M15 format is really nice and it is great to have these tools!!
Update on the shuttle. I got the model finished. In Blender it comes in at 282 Faces.
I started work on texturing and it takes time, but lots of fun.
Just wanted you to know it is on its way, just taking a bit of time as I figure out this low poly modeling and details in textures stuff.
Petr Schreiber
19-04-2007, 08:26
Hi kryton,
looks interesting.
Is it low poly version of that shuttle with round engines ?
Bye,
Petr
Michael Hartlef
19-04-2007, 10:09
Also if you get wierd m15 exports, know that you probably had separate meshes and that you forgot to join them before the export.
It is a great check to know that your model is correctly exported this way.
Hi Kent, with the latest version of the exporter, that should not be a problem. Can you send me a file that shows the problem?
Michael
Yes Petr, it is the double decker but in much lower poly version. I think I will be happy with this design as it looks futuristic enough without being too futuristic.
Mike, there is nothing wrong with your great script. It catches the problem in Blender if you don't join the meshes together, which makes sense.
Here are some ideas I had for the ship description and detail sheet:
The Schrieber Space System's Shuttle Duo X2 combines the speed, power and reliability to get your passengers and cargo to their destinations in the best fashion. Luna Transports Inc., with the largest commercial fleet in the UWF, offering service from Earth to all frontier locations, is happy to make the Shuttle Duo X2 its main work horse of the fleet. Offering the perfect mix of cargo and passenger transport to make all runs economical with a purpose.
Powered by two Hartlef Hercules-MI Engines, these maximum impulse engines offer the power and speed to make all trip distances with ease. You can fly faster than the wind and turn on a dime with these mighty engines.
To make sure the passengers, crew and cargo make their destinations in safety, the Shuttle Duo X2 is armed with two Kryton PC-2FM's.
These pulse canons offer two firing modes, the slower but more powerful Asteroid Buster and the faster but less powerful Rapid Fire. Both modes offer the perfect mix to clear the way for these fabulous shuttles.
Michael Hartlef
19-04-2007, 20:54
Spy! Where did you got the construction sheets about our new engines ? ;D
Sounds great!
Petr Schreiber
19-04-2007, 21:25
;D
Luckilly I managed to steal kryton plans for S.K.E.N.T.
This name is abbreviation of "Sarikaya Kadmium Extreme Neural Technology".
As a logical successor to old 20/21th Century fly-by-wire technology, this enables control by kadmium wires, lifelike growing to neural network, self optimizing for ideal ship control handling :).
Very nice kryton, I am really curious about final textured version !
Bye,
Petr
Thanks guys glad you liked it. We still need a name for the shuttle, as all ships have names that they are christened with.
I was thinking of the "U.W.F. Olmi Bianchi" piloted by Captain Marc Napolitani. Mike is good with names, so I will be interested on others he might come up wth.
Later on there is the fighter too, so maybe that should have the flagship name of Olmi Bianchi, or this could be the Bianchi and the fighter the Eros Olmi?