PDA

View Full Version : 3d Modelling HELP PLEASE!!! ARRGHH



shanedudddy2
12-18-2002, 08:46 PM
I am trying to make a 3d modeller and was wondering how I can implement a triangle maker with the user clicking to define vertices.
I know how to use gluunproject()
But How can I do this please help!!

shanedudddy2
12-18-2002, 08:57 PM
By the way I want to add more than just one triangle I want the user to add unlimited number of triangles Plz help!!

shanedudddy2
12-19-2002, 01:45 PM
help me please reply!!

SirKnight
12-19-2002, 01:48 PM
There are a lot of open source modelling programs on the net. Check SourceForge, they have many.

Try this one: http://prdownloads.sourceforge.net/aztec/

-SirKnight

[This message has been edited by SirKnight (edited 12-19-2002).]

shanedudddy2
12-19-2002, 09:13 PM
Thanks but I was just looking for ideas and sourcecodes. Have you ever looked at the source code for aztec modeller its complex and unreliable and doesn't compile. And for source code HUGE!!!
More help Please
ANYBBODY??

davepermen
12-19-2002, 11:46 PM
case WM_LBUTTONDOWN:
userClicksLeft(x,y);
break;

userClicksLeft(x,y):
switch userMode:
case userWantsNewVertex:
vector3d newVertex = gluDoProjext(x,y);
scene.currentMesh().vertexList.pushBack(newVertex) ;
break;


with

struct Scene:
vector<Mesh&gt meshes;
int currentMeshIndex;
Mesh& currentMesh(): return meshes[currentMeshIndex];

and

struct Mesh:
vector<Vertex> vertexList;


now, for generating triangles, you expand the mesh struct, add a new userMode, and code up a method to find out if a user clicks on a specific point (hint: draw them with glPointSize(10) and every point with another color, read back the color at the specific pixel the user clicked, recalculate wich point that was, and voilą.. then redraw the scene with normal view before swapping buffers http://www.opengl.org/discussion_boards/ubb/biggrin.gif)

create a struct Triangle: unsigned int v[3]; style, and make a "currentTriangle", wich you fill per click with the index you clicked. when its filled (currentTriangle.size() == 3), push_back it in your Mesh::triangleList

and voilą...

gaby
12-20-2002, 12:15 AM
I have made a modeler with wich I have done ALL models of a fun race game (that I've fully done too). (you can see a screenshot at www.z-oxyde.com) (http://www.z-oxyde.com)) To do a such program, I think you MUST have many years of use with most important softwares like Maya, 3ds or Lightwave. If not, your software might be not efficient and ergonomic, because you cannot understand what are the key feature that make it fast and reliable.

The best thing is to have a working environement where you can flip from front, side, top and pers view. In each, you can define an insert point wich is, in ortho views, the depth where you will input something. Screen is in 2D, so, to define something in 3d, you do it in an ortho view, on 2 axes, and in a specified depth.

To define a mesch, I've done a 2 step process : first, define vertices, second, build triangles between vertices. It's very usefull. To modify the mesh, you can do lot of features to select a vertex, growth the selection, select a part of an object, select adjacent trangles, etc...

Well, after that, you must do a full features projection system for texture coords generation, normal viewing and editing, etc... Build some triangle is only a very small part of the work to build a good modeler. Build tools is a particulare thing.

Good luck !

Gaby

gaby
12-20-2002, 12:28 AM
Well... I think I'm not so clean in my explanation.

Create a tools (or a key combination, it's usefull) wich permit to move an insert point in 3D. For a z in depth, if you are on front view, you move define x and y fields by taking directly the mouse coords inverse multiplied by view matrix. When on side view, you define x and z of the point. On top, z and x.

Create a Vertice creation tools : in one of the 3 ortho view (front, side, or top), this insert point will define the position on the depth axes of the view.

For exemple : if we are one side view, the mouse is on the z and y axes. When the user clic you have :

new_vertex.x = insert_point.x
new_vertex.y = mouse.y
new_vertex.z = mouse.x

I hope that will help you !

Regards,

Gaby

shanedudddy2
12-20-2002, 12:58 AM
that sort of helps me but is kind of confusing. By the way the website did not work. An example of this would help thanks!!

davepermen
12-20-2002, 01:09 AM
Originally posted by shanedudddy2:
that sort of helps me but is kind of confusing. By the way the website did not work. An example of this would help thanks!!

website works, you just has to realise that it accidentally highlighted a ) in the url.. delete that, and voilą, it works

LordOfTheUniverse
12-20-2002, 03:20 AM
Check www.loiv.torun.pl/~stinger (http://www.loiv.torun.pl/~stinger)

there's sample of my program,
but don't get confused, code is
someway <specific> , but you should get a hint

richardve
12-20-2002, 03:42 AM
Originally posted by shanedudddy2:
Thanks but I was just looking for ideas and sourcecodes. Have you ever looked at the source code for aztec modeller its complex and unreliable and doesn't compile.

Maybe you already know this, but you should follow the instructions from the BuildingAztec.html file from cvs when building Aztec, not the one currently online @ the sf.net project page (which is out of date).


And for source code HUGE!!!

No, 70.000+ lines of code isn't huge at all.. it's quite much, but not huge http://www.opengl.org/discussion_boards/ubb/wink.gif


btw. The 'unreliable' parts are (mostly) going to be fixed next year (using a new super-duper-ultra-good-and-modern-kicks-butt GUI front-end (which isn't in cvs yet))

gaby
12-20-2002, 07:13 AM
It's very difficult to explain such ideas without writing many pages... Well, perhaps you'd better parse how a simple modeler work and redo it. We never have one way to build a such tool : so, focus on what you have to do and try lot of modelers to grab the basic ideas. My modeler is running on Macintosh without accelerator (the software renderer is hand writed), so, I cannot bring you the source...

Yes, here the exact url : www.z-oxyde.com (http://www.z-oxyde.com)
and for fun, you can see a physic simulated structure : www.z-oxyde.com/research/download.html (http://www.z-oxyde.com/research/download.html)

Regards,

Gaby

dorbie
12-20-2002, 03:03 PM
Yep you're missing some important and fundamental concepts.

Modellers tend to allow the input of positions through the intersection of the eye->mouse ray with some plane or existing objects.

There is no way to unambiguously input a 3D vertex with the simple position of the 2D mouse without some additional concept to supply depth. A plane of input is typically used with possibly a snap to grid in operation.

More complex objects are constructed by extruding simply input objects or performing other more complex operations like the construction of spheres, cones, cuboids or other solids. These can often then be deformed & subdivided. Models are NOT created by supplying triangles with 3 vertices each for the entire model, that would be tedious and inefficient.

It is advisable that you learn several existing modeling packages before writing a new one. You should probably try harder to learn (and maybe one day contribute to) an existing project, there are several open source modelers out there now, please don't write another one unless you intend it mostly as a learning exercise.

shanedudddy2
12-20-2002, 05:20 PM
ARRHHH you people don't give me any of the answers I want. By the way all shapes are made of triangles including polygon which make up nearly all shapes.

Could some body please just give me source code on how to do this thanks!!

gaby
12-21-2002, 02:28 AM
Dorbie,

All what you said is true. Sure, a modeler is not only a vertices/triangle setup interface : for very low poly object, it is not uneficient. It's a good basis. That is the request of this thread.

In my post, I've exposed exactly how to build a system to have the missing coords wich is, in all cases, the depth coord. It use exactly working plane wich are x=incertpoint.x, y=incertpoint.y, z=incertpoint.z. But I'm agree, my explanations are confuse.

So, here a new explanation, in more step by step form :

1- Create a environement where you define 4 camera :
Front, Side, Top, and Perse Camera
Make it switchable by keys (F1,F2,F3,F4 for example). Front, Side, Top must be othogonal projection, and must be zoomable / movable.

2- Create a tool, for exemple by pressing F5 key to select it, that permit to enter a "incertpoint". You must draw it as 3 long lines in red, for example.
When you clic in the view with this tool, it will move the point taking care of wich camera is current.

Front : you map mouse coords like this :

incertpoint.x = x;
incertpoint.y = y;

side : you map mouse coords like this :

incertpoint.z = x;
incertpoint.y = y;

Top : you map mouse coords like this :

incertpoint.x = x;
incertpoint.z = -y;

Pers : more complexe : but for a 3 button mouse, button 1 move on X axe, button 2 move on Y axe, button 3 move on Z axe.

So, at this time, you have a tool wich permit to move the incertpoint every where in the space.

3 - Create a tool to create a vertex :
For this, you will take the incertpoint to define the depth.
When in Front camera :
nv.x=mouse.x;
nv.y=mouse.y;
nv.z=incertpoint.z;
When in Top camera :
nv.x=mouse.x;
nv.y=incertpoint.y;
nv.z=mouse.y;
When in Side camera :
nv.x=incertpoint.x;
nv.y=mouse.y;
nv.z=mouse.x;

4 - create a tool to create triangle : you can do a simple picking vertice system. You count the number of picked vertices, and when 3 are picked, create a triangle.

If you are not able to build something with this explanation, you'd have to start by the biginning : learning a 3d package, learn to build interactive tools, learn the building process of data, etc...

We cannot say more... I'm working in 3D graphics from many years, i'm daylly using Maya and coding OpenGL, so I can do the work for you, but I cannot explain all this in few words !... ;-)

Regards,

Gaby

shanedudddy2
12-21-2002, 01:34 PM
Thanks Gaby. By the way I have 3ds max 4 and use it all the time along with other asorted modelling tools.

I know how to get the x,y coordinates of the mouse converted into x,y,z world coordinates.

But what I need is a routine that can build as many triangles as the user wishes.
As many as 1 triangle up to 2,000,000.
I know I will have to define new integer and add loops etc. But could somebody please help me with this routine PLEASE??

OneSadCookie
12-21-2002, 02:16 PM
Step 1. Learn to program.
Step 2. Learn OpenGL
Step 3. Hard work
Step 4. Bug everyone on OpenGL advanced forum
Step 5. Modeller!

Please go back and do steps 1-3.

V-man
12-21-2002, 05:40 PM
Better yet, hire someone with the ability. Your project will move faster.

shanedudddy2
12-21-2002, 07:31 PM
Thanks you all for giving me no help whatsoever.

Nobody seems to have the answer so I guess none of you guys really know or....

.....YOUR ARSEHOLES

OneSadCookie
12-21-2002, 11:43 PM
a) you can't spell, that should have been "you're".

b) that's not the way to endear yourself to people and make them want to help you.

c) your request has nothing to do with opengl as far as I can tell, only to do with data structures and algorithms.

d) if you don't want to write the source code yourself, do as people have suggested, and grab the source to an open-source modeling program.

e) if you do want to write the source code yourself, you're going to need to know how to make something like a resizable array or a linked list. Your posts above hint that you don't know how to do these basic things, in which case a "beginner's C and algorithms" forum would be a more appropriate venue for your question than the "advanced opengl" board.

gaby
12-22-2002, 05:05 AM
shanedudddy2, I must say that I'm little bit agree with OneSadCookie.

Do you know what is a linked list and resizable arrays ? Do you know how build such simple structures with template ? Do you know what are pointers ? Dow you know inheritance, polymorphism, and all other C++ concepts ?

If you don't know one of this, simply start learning programming with one of the good books on the market. After that, by a good book on 3dcg coding. Only after that, try to build a first modeller, that you will delete and rewrite few month later, and do it again many times... Or call us to write it !

Regards, no offense,

Gaby

davepermen
12-22-2002, 05:10 AM
Originally posted by shanedudddy2:
Thanks you all for giving me no help whatsoever.

Nobody seems to have the answer so I guess none of you guys really know or....

.....YOUR ARSEHOLES

i've gave you the answer right at the top of the page how to have a structure that stores as much points and as much triangles as you want.

learn to read

and, in your logic:
YOU ARE AN *******

richardve
12-22-2002, 07:08 AM
ARSEHOLES

Sorry, I prefer other parts of the (female) body, thank you very much.

gaby
12-23-2002, 01:04 AM
I'm french and I have looked to the traduction of the word "ARSEHOLES". Let say that you are a stupid men, shaneduddy, you are a looser. I'm shamed to have spend time to try to explain an interesting thing to a such immature men.

Gaby

shanedudddy2
12-23-2002, 11:34 AM
sorry about last post I was just really angry that out of 19 or so answers 12 were complaining about me.

Sorry to all i`ve hurt.

davepermen do you think you could expand your code or add to comments to make it easier to understand thanks!

SirKnight
12-23-2002, 01:01 PM
Look, what are you expecting from us? To give you the all one magical answer that will suddenly somehow magically give you many years of advanced experience of 3d coding and fill you with all the knowledge needed to write the next 3ds max? I mean come on man; you have more than enough info from all of us to do what you ask. If you still can't do it then you are still too newbie to write such a thing.

This reminds me of posts I have seen not only here but also other places as well where someone asks something like this for example:

Q: "How do I draw an md2 model?"
A: "Here is a simple app I wrote which does this very thing. The url is: <insert url here>"
Q: "How do I draw an md2 model?"
A: "I just told you, here is my code which does this. <insert url here again>"
Q: "Damn it, how to I draw a freaking md2 model you idiots?"
A: "sigh"

http://www.opengl.org/discussion_boards/ubb/biggrin.gif

Oh and about the "HUGE" size to the Aztec modeler, well I'm sorry but for real 3d apps such as this, you won't get a mere 2 page program. It takes quite a bit to do things like this. Even a simple window with 4 view panes with grids that allows you to draw a simple cube with what ever dimensions you specify will take a lot more than a few lines of code. http://www.opengl.org/discussion_boards/ubb/smile.gif

I do remember a little 3d editor at some website called "The Cornflake Zone." It's simple, uses MFC and can draw simple and basic things. Maybe that will be your magical answer you are looking for.


-SirKnight

[This message has been edited by SirKnight (edited 12-23-2002).]

rgpc
12-23-2002, 03:47 PM
Originally posted by OneSadCookie:
Step 1. Learn to program.
Step 2. Learn OpenGL
Step 3. Hard work
Step 4. Bug everyone on OpenGL advanced forum
Step 5. Modeller!

Please go back and do steps 1-3.

Actually you missed two steps

Step 0.5f. Learn how to use Google.
Step 0.75f. Learn how to look things up.

I have a co-worker that I supervise and he suffers from the same problem I see in this post. Rather than try something himself, rather than use what is given to him, rather than look for the answers himself, he just keeps asking until the exact answer is given to him. And I am seeing this here.

The really sad part of it all is, your problem is very, very simple. Even having not written such functionality you should be able to figure it out in a matter of minutes.

What you want to do is map screen coordinates to x,y,z. Presumably you have a quad view (or even a single view) which is displaying a view that is perpendicular to a plane (eg. x=0, y=0, z=0 are the standard planes).

The view(s) being displayed will have a scale that maps a single pixel/fragment to a unit of measurement. The standard is 1 pixel = 1 unit.

Given this, all you need do is map the x/y of your mouse click to the corresponding axes in the view that has been clicked.

For example, if you click at coord 100,100 and there is a viewport of x=0 that spans from 0,0 to 400,300 (quarter view), then you adjust your coords relative to the center of that view (assuming the view is based around the origin).

Your mouse click then becomes -100, -50.

Because you have clicked in the x=0 viewport we know that x=0 and the x/y translate directly to the z/y axes. This makes the coord of your new point x=0, y=-50 and z=-100.

You continue the process, creating a triangle out of groups of 3 points (you can decide how to do this, typically it is done by creating the points for the mesh and then selecting 3 points at a time, and then creating the triangle.

--------------------------------------------

No I will not write the code for you.

--------------------------------------------

Calling people names will get you nothing. Getting off your butt and trying will get you everything.