Advertisement

Concepts on creating a model program

Started by April 04, 2003 12:45 PM
17 comments, last by PsychoPaul 21 years, 10 months ago
In short i'm trying to create a small program to create 3d models. so... 1. I'm wondering how i can take the x and y axis of the mouse and use it to plot vertexs in a 3d evironment. 2. How can i keep track of all the vertexs that a user selects/creates. Like how do i store all the points that the user selected in an array or something like that so that i can store that information to a file and restore it at a later time. Any way of doing some kind of optimizations etc. 3. How do i find a path through all the vertexs which allows me to connect them all in one chain/secuentially. I'm thinking that might help with the saving/loading of the vertexs from a file. I'm looking more or less for some tutorials on how to do this or parts of it so i can get the project past the point of just being a window, hehehe. or if anyone can provide some concepts as to how i should go about doing this. [edited by - PsychoPaul on April 4, 2003 7:02:21 PM]
Paulhttp://members.lycos.co.uk/p79
Well does anyone know any good free "level" editors then?
Paulhttp://members.lycos.co.uk/p79
Advertisement

Milkshape could make you some models pretty good. it isnt free, 20 bucks or something...

but 20 bucks sure as heck saves alot of time


-James..
dam i need to register..
try looking into gluUnProject and gluProject
1.
get the click coordinate

CPoint class if you use MFC

get the zoom mode
the window size of the viewport you clicked in and think about the rest on your own it s damn easy to convert these coordinates to worldspace

^^^for the 2d views

for 3d views you use the above mentions glun/project functions and trace from your eye coord until you hit a vertex

line->sphere test

2. either use a very large vertex array memory shouldnt be a problem on modern systems

500000 vertices should be enough for a plain model
or linked lists although i prefer the vertex array cause it is much more secure regarding memory management not stupid pointer checking all the time

selection: you might want to add a flag or boolean to each vertex to mark it as selected
and maybe create a selection object to mark the lower and higher borders of the selected vertices` indices in your vertex array

^^^^ damn why didn t i think of this solution earlier

if your browse your array of floats ( i guess floats)
float vertexarray[500000][3];
float *p=NULL;
p= vertexarray;

for(int i=0;i<500000;i++,p++)
{
//do you stuff here
}

i think this piece of code is correct didn t test it though didn t code for 1 month now cause i am damn busy with other thinks right now but i think you can assign the array to the pointer that way
i read about this way of browsing an array in a optimization tut
it shall run quite a bit faster just test it

3. you are talking about the face creation?

well trace until you hit a vertex and once you have 3 vertices selected and face creation mode actived you can create a face and store the indices of these vertices in a face object

and then you just save the vertices and face objects where i have to suggest you only save the elementary data types which are inside your objects since memory management can be a pain in the ass on other systems
and you spare space

you shouldn t need any tut anymore aslong as you have set up your windows gui already and as long as you know how to use MFC or what ever you are using
http://www.8ung.at/basiror/theironcross.html
thanks all for your replys. I'll go and try some of the things you have suggested. If i get anywhere i'll post it...

Forgot to mention i'm using Dev-C++ for my coding needs.

[edited by - PsychoPaul on April 5, 2003 11:18:44 AM]
Paulhttp://members.lycos.co.uk/p79
Advertisement
Errr last time I checked most modeling programs use ''fast'' linked lists or other dynamic memory allocating methods to store objects / vertices / face indices, ect. Creating that large of an array just wastes a ton of memory and is slower than a normal linked list.
Hi, I just thought I''d mention that you could check my site for a model editor which can give you some ideas or whatever. And if you have some questions just email. Also one reason to create your own editor (especially if you''ll use it for your own games) is that you can customize it for whatever you need (ie. polygon flags, special feature, etc). Good luck and as for your questions which were pretty much answered already but for how I did it:

1) I just projected the points 2D and got the info that way.
2) I used my own object class which I wrote for my engine (this is where the customization comes in).
3) Same as #2.


Luigi
www.lp23.com
quote:
Original post by Hawkeye3
Errr last time I checked most modeling programs use ''fast'' linked lists or other dynamic memory allocating methods to store objects / vertices / face indices, ect. Creating that large of an array just wastes a ton of memory and is slower than a normal linked list.



as long as you are only doing models and not entire maps you don t have to care about this little bit of a performance decrease or memory wast

i hardly know a game that uses models with more than 8000 triangles and a array of 8000 members isn t that slow at all
and btw the way i use to browse with pointers instead of the [x] will increase speed a lot

and from experience i doubt that linked lists are faster than arrays
checking a pointer will decrease your performance quite a bit
and handling tons of pointers is in my opinion just a waste of development time which can be spend on other more important things
http://www.8ung.at/basiror/theironcross.html
Arrays ARE faster than linked lists, thats a fact, but when it comes to dynamically allocating things, they aren''t a good choice. Sure, if you know how large the model is going to be RIGHT when you allocate the memory for the array, then all is well. ( Like when you load the actual model into a game ) The problem lies that when using a fixed length array you''re going to be wasting memory one way or another, and resizing it is a costly operation.

A well designed linked list will have many uses. It is worth your time an effort to create one. For example keeping track of enemies in a level that are being destroyed ( code wise ) and created. I''m using them right now to keep track of several things in my program such as the GUI windows and the objects currently loaded.

But hey, as long as it works for you, use it. But you can almost guarantee one day someone will create more vertices than your array can hold and cause the program to crash.

This topic is closed to new replies.

Advertisement