PDA

View Full Version : model viewer k9



kryton9
26-04-2007, 12:51
I started to work again on the model viewer I started early last month. I hope to have something to use pretty soon.

I was laying out keyboard input for features. Would appreciate any things you guys can see I missed or we might need.
I will do keyboard input handling first then put in gamepad support.

Here is my outline of keyboard input:


m model mode
l light mode
c camere mode

F1 help toggle on/off
i toggle info on/off (property settings for objects)

model mode
r rotate mode
left/right about y axis
up/down about x axis
ctrl left/right z axis

p position mode
left/right x axis
up/down y axis
ctrl left/right z axis

s scale mode
left/right x axis
up/down y axis
ctrl left/right z axis

u uniform scale mode
left/right or up/down scales all


z model to 0,0,0 (zero,zero,zero)

0-9 quick select model

v toggle visibility

spacebar select next model, cycles around

l light toggle

b blend toggle

q reset model to loaded defaults

light mode
r rotate mode
left/right about y axis
up/down about x axis
ctrl left/right z axis

p position mode
left/right x axis
up/down y axis
ctrl left/right z axis


z light to 0,0,0

0-9 quick select light

g gel mode
set red left/right
set green ctrl left/right
set blue alt left/right

spacebar select next light, cycles around

l light toggle on/off

q reset light to loaded defaults


camera mode
r rotate mode
left/right about y axis
up/down about x axis
ctrl left/right z axis

p position mode
left/right x axis
up/down y axis
ctrl left/right z axis

l look at mode
left/right x axis
up/down y axis
ctrl left/right z axis

z camera to 0,0,0

t telephoto left/right or up/down zoom in and out

0-9 quick select camera

spacebar select next camera cycles around


q reset cameras to loaded defaults

Petr Schreiber
26-04-2007, 14:35
Nice kryton,

I am very curious about it.
I just don't understand "0-9 quick select model" ?


Bye,
Petr

Michael Hartlef
26-04-2007, 15:41
Model viewer? Did I miss something?

Petr Schreiber
26-04-2007, 18:52
kryton is prepairing some surprise again :)


Petr

kryton9
26-04-2007, 21:09
The model viewer will load all models in a project folder. Later you can create separate projects, but for now just one.

First version will be just for playing with. You can have full control in looking at your model and adding all we can now with opengl to it.
Later you can arrange the models for scenes and export the settings, so in the game you can just load a scene and start from there.
Or use composed scenes for backdrops.

The 0-9 keys, allow you to switch quikly between model 0-9, later if we find we have more models I will add ctrl 0-9 and alt 0-9. But the first version will just use 0-9. This way you can be working on model 5, adjust its position and then quickly switch to model 8 and tweek it and go back and forth quickly, instead of just cycling through the items.

I forgot, I will also add mode to set the control rate speed. Again once the mode is set, then 0-9 will give you different speed rates of control.

I might make the main mode keys F5-F8, this will free the letter shortcuts to be used other wise. So the mapping will be different slightly from my original list.

The program is creating a project file, loading all the models in the specified directory and displaying them. Next I will work on the keyboard input and adding the adjustments to the scene and models.

Once I get to that level I will put the first upload and then add gamepad support and make tweeks and add features we can come up with.

Once this is finished, this program can be used as the base for an animation creation program and also another program like nebula star creator to create complex images and great backdrops.



first test will be control speed rates:
0 - 0.01
1 - 0.05
2 - 0.10
3 - 0.50
4 - 1.00
5 - 2.00
6 - 5.00
7 - 10.0
8 - 50.0
9 - 100

Michael Hartlef
26-04-2007, 21:32
Sounds usefull.

kryton9
27-04-2007, 02:01
Thanks Mike, I hope to have a rough prototype soon and we can then discuss ideas you guys might have on additions, changes and improvements.

kryton9
27-04-2007, 08:38
I thought of another feature tonight, lighting presets.

Here are some that I thought would be nice to have, would like to hear more ideas.

light presets:

1. current Petr's lighting setup as in topdown instant action game
2. same with no colored lights, just white
3. popular 3 light setup (main light off of one side front, second light opposite side front to get rid of harsh shadows, top back light to highlight the subject)
4. maximum lights distributed evenly in all directions pointing to the center

5, 6,7,8,9,0 are available for your lighting preset ideas.

Petr Schreiber
27-04-2007, 09:11
Hi kryton,

if you consider the shade part too "harsh", just set the %TBGL_LIGHT_AMBIENT to something milder, no need for another light.


Bye,
Petr

kryton9
27-04-2007, 11:22
Will keep that in mind when I get to it Petr, just sort of planning things out setting up the structure for input and what will happen.

I did tests both with buildfont and using bmpfonts, when I change screen resolutions to check the text, it is never like what I hoped in the other resolutions compared to the 1440x900 I work in. That is I get it looking the way I want in 1440x900 and when I check in 800x600 or 1024x768, I understand the size will change, but the positions don't work. I need to figure out another way, since the interface is critical to make it useful.

Also on a side note, how is your Delphi class going this year? Are you enjoying it? What are you covering in it?

Petr Schreiber
27-04-2007, 15:51
Hi kryton,

this is weird, please show me code you use :) With BMP fonts, it is easy to take advantage of anchoring... so it should be positioned ok in every resolution, buildfont stuff is what I use less.

BEGIN ot:

Thanks for the question about Delphi kryton ;)
We were learning OOP in this term, it is interesting to see how it works, but it makes me think how much stuff must be done behind the scenes / how it can be done traditional way :)
Well, OOP is often very ellegant...

Also Delphi IDE "AI" which is sometimes too active ( changing source ) is little bit making me nervous sometimes :D as well as when my prog GPFs ( ooops ), IDE needs to be restarted.

For me Delphi IDE is world of two extremes - some extremely neat functions ( comfortable debug with tooltips dynamicaly appearing while moving across keywords ) on one side and missing basic stuff like procedures/functions combo known from thinAir / PowerBASIC on other side.

And semicolons ... I probably suffered some scary accident during my early childhood because I simply don't like them :) I also miss many string functions...

But what is positive is fast compiling, quite immediate. On other side exe starts at 350 kB :) ( I know there is a way how to do dialog in Delphi using SDK style so EXE is about 20 kB, but then Delphi is loosing is biggest advantage - dialog designer ).

Hard to say anything elaborate from my side, I am using it only at school. When there is no restrinction on tools used I go for thinBASIC / PowerBASIC :)

On other side fact is your REMMER is one of the most used tools I run every day multiple times.
So as says one guy on PB forum, "It's not the paintbrush, it's the artist" :)

END ot


Bye,
Petr

kryton9
27-04-2007, 19:14
Thanks for filling me in on your class on delphi Petr. I must say I agree with you on your review of Delphi. The colon makes no sense to me either and really takes away from the language. The 350+ K executeable to me is not an issue anymore, like it used to be. The IDE is as you say, both very magical, but does kick one out to the desktop at times.

About Remmer, I have an update for it that i haven't uploaded, I had a problem uploading the movie to show the update, so waiting for the forum update to handle 10mb files then will put it up.

I will work on model viewer using bmp font at my resolution, when the code is enough to show basic functions, I will upload and then you can test the font on different size displays and see the problem. I will not worry about it for now.

One thing on my c++ video course from 3dbuzz. They show where they change the viewing mode from 3d to 2d to get text to look good. Seeing how easy you made font handling compared to standard opengl code, perhaps you are already doing that, I am not sure. But it amazes me how much work you are doing behind the scenes for us with these fonts in both modes. Thanks.

Michael Hartlef
27-04-2007, 19:27
also miss many string functions...


??? Well I can only speak for Delphi6 but Delphi there had one of the mosdt complete string function sets available. I would bet on it, that this didn't change.

Petr Schreiber
27-04-2007, 20:39
Mike,

you are probably right, and I missed something.
I have Delphi 6 Personal.

As I said, I can't judge Delphi well, as I am not working in it too often.
And in classes we do the same again and again and again ... just surfing on the surface.
Delphi helpfile is extensive, but I don't like how it is structured.

kryton, ok then! New Remmer sounds great!
BMP fonts have some custom arrangements from my side, the "normal" font is not handled very intuitively in TBGL now for 2D, as I thought it will be used mainly as descriptor of things in 3D.
In C++ tutorials they were probably talking about Ortho mode ?


Bye and sorry,
Petr

kryton9
27-04-2007, 23:34
Nothing to be sorry about Petr, I was looking at the c++ code to do what you are doing and you made it such a joy to work with. I am really impressed.

About Delphi Help, I agree, the help I hate. Lots of info, but very hard to find what you want. Not intuitive at all, but for a free program, it is awesome in the amount of info, so can't complain... just the interface and access is very lame compared to the wonder of the IDE.

I haven't messed with the string functions that much or lots of the core stuff yet, probably will be sometime because when I work I need to work on c++.

I am thinking of doing remmer in c++. but I am so close in Delphi, I will probably finish it in Delphi and do future projects with c++, well will try to.

The model viewer I am trying to do all within thinBasic and no outside programs.

kryton9
10-05-2007, 08:24
Guys, I made a short video to show the interface idea I am developing for the model viewer. It is going to be all hot key based. I got just a few commands to show it in action. I hope you like the interface. I think it will allow for quick and easy access to all commands and make work fun and productive, but I would like to get your ideas and input before going further on.

Petr Schreiber
10-05-2007, 11:29
Hi kryton,

I like it, all necessary info on screen.
Just one problem - from 75%of position in video the image seems "locked", maybe I have wrong codec or does it show the same to you ? I have tried it on 2 PCs with same result.


Bye,
Petr

kryton9
10-05-2007, 16:42
Sorry Petr, it didn't move as I didn't put many of the keys in yet. I Just wanted to get a minimum to see how the interface worked.
THe user will be able to toggle the help on the left and the info on the right on/off separately with the same ease using h for help
and i for info.

I will add more to it and put a version up soon for you guys to test in person, once I have more useable features :)

Thanks for checking out the vid and commenting.

Petr Schreiber
10-05-2007, 19:38
Aha,

then it is ok, I am sorry :-[
I really like it, as I prefer keyboard before mouse.

Perfect,
Petr

kryton9
11-05-2007, 00:20
Adding the movement keys to the model viewer and went inside one of Mike's ships, nice interior and surprise.
I should have the first release with model mode working only by this weekend.

The texturing detail Mike did is amazing. I can't get any work done, just looking at his ships close up :)

kryton9
11-05-2007, 06:55
Please watch this video before trying to use the model viewer. It shows important things necessary to setup first before using it the first time. Thanks.

http://www.kryton9.com/web/posts/vids/xvid/k9ModelViewer/k9ModelViewerAlphaV1Intro.rar

Please place the script in your project folder after watching the video.

Still lots to come, but it is pretty handy right now for viewing. Once we iron out the ini file structure and get our user types nailed down, we can save out all the information to an ini file to be used by other programs.

Petr Schreiber
11-05-2007, 09:48
Hi kryton,

this is perfect!
Very easy to compose some action scene!

Just few details:
* what about passing script path to the "Choose folder" by default ?
* when bad folder is chosen, I got run-time error ( probably because no models found )
* avoid loading of model to the same point as camera is located - sometimes it is confusing

But it is nice tool, I will be playing with it now and report any additional tips/troubles.

Good work ;),
Petr

Michael Hartlef
11-05-2007, 10:22
Adding the movement keys to the model viewer and went inside one of Mike's ships, nice interior and surprise.
I should have the first release with model mode working only by this weekend.

The texturing detail Mike did is amazing. I can't get any work done, just looking at his ships close up :)


Thanks Kent.

kryton9
11-05-2007, 17:20
Petr, eventually you will be able to do get all the models and other files from where ever you like. The ini file will keep track after the initial setup. The idea is that we can use this without having one dedicated project folder. The script can be anywhere and it will create the project ini files for different projects. But since I am just starting with the program and adding stuff as I go along and figuring out how to do things... it will be a while before it is at its finished point.

Once I setup camera keys, we can just move the camera instead of the models. Also once the models are moved, it will save the data for those models, so next time they will load not on top of each other. So for now it is a minor pain till that feature is added. But I agree, it is hard now.

I am trying to figure out a fast way to access unlimited models, right now the limit is 10 because of the quick keys, but I would like to use the same sort of speed for more than 10, but can't think of any really good way. The only thing so far would be a 2 key entry.
0 5 for model 5, 1 5 for model 15, that is the first number is 10's unit and the second the 1's unit. But I would love to have a single key access if possible. It is very easy to fly down the 0-9 keys and toggle features now for the models. Maybe once multi-key handling is better, can use ctrl, alt and shift, that will give 40 models, then combos could give more? Using ctrl, alt and shift would still be fast as can hold down the option key with one hand and fly down the 0-9 keys :)

THanks for testing and commenting and feedback. Keep them coming and thanks.

kryton9
11-05-2007, 17:29
The multi-key thread was locked, so will say thanks for the new commands here. I will put them in this weekend, that is so nice to have those new commands!!! THanks again!!!!

kryton9
11-05-2007, 18:09
I realized I uploaded the older script last night. The correct script should load with all models visibility off. This way you can select he one you want to view and work with.

The script to match the video is attached here, sorry about that.

kryton9
12-05-2007, 07:24
Just updated the model viewer to take advantage of the new multi-key input commands. They work so much better now.
You will need the latest thinBasic Preview release for this to work. Everything else is as before.
The latest version is attached.

Before I add in the camera and light features, I am going to tweak how it loads files. My original idea was to have a project folder, but as I started to work on it, why copy models into another folder and waste space. You should be able to add models from anywhere, as well as the supporting files, like textures, sounds, music, effects.

Once you setup a scene, it will save that information and the next time you go to view or run the model viewer it will load the existing project. If you have more than one scene, ask you which one you want or offer to create another project. This way we can develop more than one scene and work on different projects.

I will start to use the ini module for all of this too instead of what I have now.

Petr, Mike... right now I have tmodel user defined type. This is for generic models. For ships we will need a type based on the model base type or make a whole new type for ships, and maybe even more than one type for types of ships?

I want the model viewer to eventually be a full blown scene and development tool. So we can use it to align particles, effects, attach sounds etc.

I guess we can develop the types as the project develops, but hope you guys think of some or have ideas on how the program can grow and adjust.

Do you guys have any types defined already we can use or I can add to the model viewer, and eventually the scene developer... Eventually animation and movie maker too. I have some ideas on how to do all of this already, just need to build it up as we go along:)

Michael Hartlef
12-05-2007, 10:39
Hi Kent,

did find time to look at this. Do I just have to download your last file?

Petr Schreiber
12-05-2007, 10:48
Mike,

I think just last file is ok.

Kent - I can see you hardcode some values to align text in various resolutions.
This is lot of work for you, and you never know if user does not have atypical resolution.

What about using text anchoring and format$ ?



tbgl_printbmp "Pos x: "+left$(m(cm).px,8)+" y: "+left$(m(cm).py,8)+" z: "+left$(m(cm).pz,8), infocolumn-15,0+i : incr i
tbgl_printbmp "Rot x: "+left$(m(cm).rx,8)+" y: "+left$(m(cm).ry,8)+" z: "+left$(m(cm).rz,8), infocolumn-15,0+i : incr i
tbgl_printbmp "Sca x: "+left$(m(cm).sx,8)+" y: "+left$(m(cm).sy,8)+" z: "+left$(m(cm).sz,8), infocolumn-15,0+i : incr i

vs.


tbgl_printbmp "Pos x: "+FORMAT$(m(cm).px, "0.000")+" y: "+FORMAT$(m(cm).py, "0.000")+" z: "+FORMAT$(m(cm).pz, "0.000"), 0, 1, %TBGL_ALIGN_RIGHT_UP

tbgl_printbmp "Rot x: "+FORMAT$(m(cm).rx, "0.000")+" y: "+FORMAT$(m(cm).ry, "0.000")+" z: "+FORMAT$(m(cm).rz, "0.000"), 0, 2, %TBGL_ALIGN_RIGHT_UP

tbgl_printbmp "Sca x: "+FORMAT$(m(cm).sx, "0.000")+" y: "+FORMAT$(m(cm).sy, "0.000")+" z: "+FORMAT$(m(cm).sz, "0.000"), 0, 3, %TBGL_ALIGN_RIGHT_UP


This way you have guaranteed aligment in any resolution, no need for calculations.
When you specify anchor, x and y values are used to determine change from this position

Bye,
Petr

Michael Hartlef
12-05-2007, 10:57
With the latest preview I get this error

Petr Schreiber
12-05-2007, 10:59
Hi Mike,

yes I get this error often too, beacuse I forget I have to select "Models" folder.
If you select other, no models are found and kryton tries to allocate space for 0 models - which is not standard.

TBGL 0.2.0.0 I am prepairing will give you more info on errors to make situation clear, don't worry :)

Bye,
Petr

Michael Hartlef
12-05-2007, 11:38
Ok, this is definately not bullet proof. ;) after selecting the models folder, I get several missing texture messages.

kryton9
12-05-2007, 20:08
Mike, if you watched the intro video, it needs certain setup right now as I was trying to get it out to get feedback on the interface. I am going to change how it handles files, but thanks for mentioning the errors. Those will all be addressed in alpha version 2, I hope.

With the new multi-key commands, I made some changes for version 2 already.

No more going to f1 rate mode, to set rate speeds. It is just ctrl+number, makes it quick to use now. f1 is going to be the more mode, this is where lots of management stuff will come in.

Thanks for downloading and trying it out guys and feedback.

kryton9
12-05-2007, 20:35
Kent - I can see you hardcode some values to align text in various resolutions.
This is lot of work for you, and you never know if user does not have atypical resolution.

What about using text anchoring and format$ ?
This way you have guaranteed aligment in any resolution, no need for calculations.
When you specify anchor, x and y values are used to determine change from this position

Bye,
Petr


Petr, thanks that is the answer to my problems. As always you have the easy solution, just a matter of knowing how to use it. Thanks that will make it so much nicer. I will convert the code to use this. Thanks again!!

kryton9
12-05-2007, 22:06
The new multi-key features really open up the possibilities. Here is a screen shot of alpha version 2.

As you can see using key combos really makes it possible to do what I had hoped. That is quick access and ability to control lots.

Now we will have banks. Alt + (0-9), each bank will have object 0-9. So that will be 110 models, 110 lights, 110 cameras etc.

The way I am thinking of cameras and lights is as follows.
there will be one camera, but different keys for that camera through out a movie or animation. The same for a few lights. There might be 3 lights being used, but each can have multiple keys. I need to think about it some more, but I think it will be cool.

Anyways here is a sceenshot of the changes so far.

Petr Schreiber
12-05-2007, 22:10
Looks good,

I really appreciate your work on this Kent!


Bye,
Petr

kryton9
12-05-2007, 22:13
My pleasure Petr. Thanks for the help. Understanding how the anchors works really makes it nice. Having the new multi key commands also opens up a lot. Fun to work with a great team. I appreciate your guys help, work on development and feedback!!!

kryton9
13-05-2007, 13:52
I couldn't sleep, been thinking of ideas for the model viewer and then later scene developer. Before I spent time doing tedious work, I thought let me see if the overall plan will work. I am very happy to say YES!!

Here is a little video of how with 2 keyframes set, we have an animation. Nothing fancy, but the idea works and the workflow will be ok.

Hope it gets you guys excited. Now I can go to sleep hopefully :)

Petr Schreiber
13-05-2007, 14:08
Hi kryton ( and good night ;D ),

keyframing looks good, I think K is good key for it.


Bye,
Petr

kryton9
15-05-2007, 09:24
Here is alpha version 2.4
It has lots of new features, so am releasing it so you guys can use it.

I just saw a new thinBasic with new tbgl is out, so I am sure many more new things will be added soon.

Please watch the video(xvid avi) in full screen to see the new features and how it works.
http://www.kryton9.com/web/posts/vids/xvid/k9ModelViewer/k9mvalphav2.4.rar

Attached is the latest source and some of Mike's models.

Briefly new features:
splash screen
multiple projects via ini files and ini module
saves settings to your projects automatically when you exit the app
Banks working, can load 100 models

Enjoy!!

Petr Schreiber
15-05-2007, 11:25
Hi kryton,

I like splash screen :)

And new functionality is definitely big step forward, it is really nice how you can save scene setups to INI.

Good work ;),
Petr

ErosOlmi
15-05-2007, 11:59
Really a good job.
Nice source code, well written and organized. Clever idea and great options.

Thanks a lot.
Eros

kryton9
15-05-2007, 19:19
Glad you liked it guys, thanks for the comments. It is possible because of wonderful thinBasic and tbgl, so thanks!!

kryton9
15-05-2007, 20:18
Small update using some of the new tbgl 2.0 commands and techniques.
Just save into your previous folder where you downloaded the full model viewer, thanks.

Updates:
TAB: view in wireframe mode (only while TAB key is held down)
Information about the number of vertices and polygons for a model is now provided.

Petr, I can't figure out how to get the texture name that a model uses. I tried the new commands and they give the names of the textures in memory. I would like to display the texture a model uses, after some time it is easy to forget what texture belongs to what model. Thanks for any help.

Petr Schreiber
15-05-2007, 22:02
Hi kryton,

I am not sure I understood it well, but if you want list of filenames of textures for specific model you can use this code.
Textures are separated by comma, $CRLF could be better for MSGBOX :)


function GetListOfTextures( model as long ) as string

local vtxcount as long = tbgl_m15GetModelVertexcount(model)
local i, j as long
local texN, texID as long = 1
local texIDUsed(255) as long
local outString as string

texIDUsed(1) = tbgl_M15GetVertexTexN( model, 1 ) ' From first vertex

for i = 4 to vtxcount step 3 ' Minimal polygon is 3 vertices long, doing it for each vertex would be waste of time
texN = tbgl_M15GetVertexTexN( model, i )

for j = 1 to texID ' Do we have this texture already on list ?
if texIDUsed(j) = texN then exit for
if j = texID then
incr texID
texIDUsed(texID) = texN
end if
next
next

for i = 1 to texID ' Formatting output
outString += tbgl_GetTextureName( texIDUsed(i) )+","
rem outString += parse$(tbgl_GetTextureName( texIDUsed(i) ), "\", -1)+"," ' If you want just filenames, no paths
next
function = Rtrim$(outString, ",")

end function


Hope this is what you need


Bye,
Petr

P.S. And thanks for new model viewer !

kryton9
15-05-2007, 23:28
THanks Petr, I would never have figured that out. Your new function is added to version alpha 2.6 attached.
Thanks again!!

kryton9
16-05-2007, 04:58
Sorry for another update, but a cool feature or 2 was added and wanted to get it to you guys.
You will need to watch the video to understand how it works, it is not hard, just need to see it to save yourself from wondering what is happening.

I changed folder naming a bit internally, so am uploading the latest full set.

Vid, view full screen please (xvid avi).
http://www.kryton9.com/web/posts/vids/xvid/k9ModelViewer/k9mvalphav2.7.rar

Petr Schreiber
16-05-2007, 10:35
Sorry for another update


:D

Thanks a lot kryton, lock sync is very nice feature.

One thing which maybe could be useful could be selecting models using mouse.
This can be done by considering all models bounded by sphere and than determine if click was inside sphere.

But the keyboard is also very fast, so no problem.


Thanks a lot,
Petr

kryton9
17-05-2007, 07:53
I am going to take a 2 week break from my projects here and focus on doing my c++ course. I have been putting it off and going back to Delphi when I needed something like that. Of course thinBasic is so much fun it is hard to stop using it. But the model viewer is useable as it is for viewing models.
And now would be a good time to try to learn c++ and have that at my disposal when needed. I am here and will be on the forums, just focusing on c++ :)

ErosOlmi
18-05-2007, 06:26
Good move c++ Ken.
Have good study.

kryton9
18-05-2007, 20:48
THanks Eros.