# Maximum PC

 It is currently Sun Apr 26, 2015 6:24 pm

 All times are UTC - 8 hours

 Page 1 of 1 [ 12 posts ]
 Print view Previous topic | Next topic
Author Message
 Post subject: 3-Dimensional mathPosted: Mon Feb 21, 2011 12:17 am
 Northwood

Joined: Sun Jul 15, 2007 6:37 pm
Posts: 2263
I'm working on a project right now, but i've hit a complete stand-still. This problem has to deal with taking 2 3-dimensional models and putting them together, based on things I call "golden areas". I have defined this golden area to be a quadrilateral (ie rectangle) in which all the vertices are parallel on either the X or Y axis (not going to deal with Z axis. Forget that.)

In C#, my vertices are defined basically as any other (textured) vertice, with an XYZ for normals and an XYZ for position. I do believe that I won't have to do jack to the normals, however I do have to jack with the Positions of them all in order to do what I want to do.

The basic idea for my app is a level builder, based on predefined models. We can assume a number of things (or I'll go insane, mark my words) 1. All golden areas that are of certain sides will be marked with a tag. +garea## where ## is a number defining the gareas that can attach to them (all garea00's will only attach to other garea00's).

(the below is the reason I'm posting for help!)
Now, here's the real problem(s) I have to determine how much I have to rotate the whole model. This rotation is called yaw.

Thus I gotta somehow use a method so I can find the orientation of the model, such that whenever it is rotated, I won't have, say, a model intersecting a model (ie a box inside a box).

here's a very, very basic example of what I want to do:

Note that I refer to a golden area as a flat plane with 4 verts, and 2 tris where we can attach other golden areas together to. In our case these are somewhat purple.

Edit: the problem is that there's no real way to find out what side of a triangle is on which side.

I'll probably figure this out on my own eventually but if you have any ideas or links please let me know! (wikipedia on linear algebra makes me want to kill small adorable animals)

Editx2: I found the answer to the figuring out of what side a triangle is, via vectors and normals... in my little program, it too, fits the counter-clockwise rule that all normals have to fit under.
You can download a nice pdf that explains it very well here

Now that problem is (sorta) figured out, it was simpler than I thought tbh, I gotta figure out how much I need to rotate the limb//branch such that it lines up properly. I guess I can calculate the 2-d vector of the lines between the 2 top and bottom vertices asdfasdfjsakdfjaksdjfds ugh brain freeze.

I'll revisit this later. It's 1:30 am and I'm tired.

Last edited by Dwood15 on Mon Feb 21, 2011 12:02 pm, edited 1 time in total.

Top

 Post subject: Re: 3-Dimensional mathPosted: Mon Feb 21, 2011 10:14 am
 Java Junkie

Joined: Mon Jun 14, 2004 10:23 am
Posts: 24245
Location: Granite Heaven
What is the purpose of the project?

Top

 Post subject: Re: 3-Dimensional mathPosted: Mon Feb 21, 2011 12:07 pm
 Northwood

Joined: Sun Jul 15, 2007 6:37 pm
Posts: 2263
Jipstyle wrote:
What is the purpose of the project?

The outcome is to be something like a modular level builder, similar to legos/train sets/Hotwheels tracks. The pieces are pre-made, and the user selects the ones to fit together, and where.

Top

 Post subject: Re: 3-Dimensional mathPosted: Mon Feb 21, 2011 1:05 pm
 SON OF A GUN

Joined: Mon Nov 01, 2004 5:41 am
Posts: 11605
Draw us some pictures.... it may help with the programming bits.

Although I question why you are trying to calculate on the fly. I would assume you'd have to have some kind of "parts" database for a level builder etc... Why not maintain some data about which bits can fit together with which ones? Then you know they are the right size / shape all you have to do is match the like vertices together.

Example:

Straight track A can mate with:
Right 90*, Left 90*, Straight

So when you have it loaded you can do:

Code:
if (oCurrentTrack.Mates.Contains(oTargetTrack.Type))
// DO STUFF

Clearly you can see that you can't connect a 15% grade track piece with a 90* Left bend. It doesn't matter how the ends of the track pieces look, even if they are the same size/shape you have defined what the possible joins are. I think this would not only be faster than doing the math but more flexible because you have an additional level of "control" built in.

"Sure you can physically connect the 15% grade with a 90* Left but that would make the train crash so we won't allow you to do it in the editor".

Top

 Post subject: Re: 3-Dimensional mathPosted: Mon Feb 21, 2011 1:21 pm
 Northwood

Joined: Sun Jul 15, 2007 6:37 pm
Posts: 2263
I don't have a pre-built database for it because of one reason: I want people to be able to design their own modular sections for the level builder.

But even then, I still have to figure out how much to rotate each piece based on the areas the user is attaching to. (I don't want to mess with pitch or roll, just yaw) I just think that calculating it on the fly would be best, in that we wouldn't have to predefine the pieces, however I am interested in your idea of having a catalog or database of sorts, where we store the information...

I guess I could create a database file that lists all the pieces and their corresponding angles. Then have every modular piece be under strict requirements that every golden area be parallel to the X or Y axes, and the Z axis.

All right, I'll draw some pictures.

Top

 Post subject: Re: 3-Dimensional mathPosted: Mon Feb 21, 2011 3:54 pm
 Northwood

Joined: Sun Jul 15, 2007 6:37 pm
Posts: 2263
Here's an image to hopefully further explain what I'm trying to do, the orange is meant to show what I want to happen, even though it's just as fine if I can simply rotate and then move it, not just rotate-move.

Spoiler: show

Top

 Post subject: Re: 3-Dimensional mathPosted: Mon Feb 21, 2011 8:37 pm
 SON OF A GUN

Joined: Mon Nov 01, 2004 5:41 am
Posts: 11605

I am not going to do a full reply... need to get to bed... but honestly you are digging yourself a really deep hole. Designing 3D objects is not something I'd give to the lay person (read: 90% of your user base). Especially if it is a game. It quickly leads to unexpected behavior that you then get blamed for. A structured sandbox is a good place to let people play. Give them a few blocks and see what they create.

Hell, that is all minecraft did.

Top

 Post subject: Re: 3-Dimensional mathPosted: Mon Feb 21, 2011 9:31 pm
 Northwood

Joined: Sun Jul 15, 2007 6:37 pm
Posts: 2263
Crash tech has cold feet for me.

Top

 Post subject: Re: 3-Dimensional mathPosted: Tue Feb 22, 2011 8:21 am
 SON OF A GUN

Joined: Mon Nov 01, 2004 5:41 am
Posts: 11605
1) Still no pictures explaining what you want.
2) Cold feet for you? WTF does that mean?

I am just saying... I think you need to understand the concept of "difficult vs useful".
viewtopic.php?f=23&t=108234

3D edge matching is difficult. Is it useful? Not really considering you can do what you need to do easier. I think you really should take a step back and think about what you are really trying to accomplish. I think you'll find a better solution that is more elegant and more useful.

Top

 Post subject: Re: 3-Dimensional mathPosted: Sun Feb 27, 2011 12:59 am
 Northwood

Joined: Sun Jul 15, 2007 6:37 pm
Posts: 2263
Yeah I dumped the rotation for now. I got it to work otherwise! Pretty awesome imo. Now I need to figure out how to create a layout designer. If I can't figure that out then no one will use it b/c it's stupid heh.

Top

 Post subject: Re: 3-Dimensional mathPosted: Sun Feb 27, 2011 12:26 pm
 SON OF A GUN

Joined: Mon Nov 01, 2004 5:41 am
Posts: 11605
Care to share how you solved it?

Top

 Post subject: Re: 3-Dimensional mathPosted: Sun Feb 27, 2011 2:10 pm
 Northwood

Joined: Sun Jul 15, 2007 6:37 pm
Posts: 2263
CrashTECH wrote:
Care to share how you solved it?

I take the center points of the defined quads (based on material ids per face) and figured out the translation needed, and then applied the translation to all the verts. My model format is such that I don't have to weld the vertices so yeah..

Edit: also, can someone share some tips on creating a ui via windows forms so I can design a ui like this:

or this:

Top

 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 1 of 1 [ 12 posts ]

 All times are UTC - 8 hours

#### Who is online

Users browsing this forum: No registered users and 2 guests

 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum

Search for:
 Jump to:  Select a forum ------------------ Maximum FAQs    Forum Rules, Posting Guidelines & Announcements    The Good, The Bad & The Banned    FAQs Help/Do It Yourself    PC Building Lab    The Help Desk    PC Modding    Education & Certification Hardware    Nuts & Bolts    Portable Talk    Appraisals, Deals & Bargains (oh my!) OS/Software/Programming    Windows Parlor    Alt.OS.Abode    Games Arena    Programmers' Paradise Networking/Internet    Internet Truckstop    Network Nook In/Out    Magazine and Book Feedback    Forum & Website Feedback    Dog Pound Team Maximum PC Folding at Home    Team Maximum PC - Folding at Home - FIND CURES TO DISEASES    Team MPC - Folding Gauntlets