Quantcast

Maximum PC

It is currently Sat Aug 30, 2014 6:15 pm

All times are UTC - 8 hours




Post new topic Reply to topic  [ 12 posts ] 
Author Message
 Post subject: 3-Dimensional math
PostPosted: Mon Feb 21, 2011 12:17 am 
Northwood
Northwood
User avatar

Joined: Sun Jul 15, 2007 6:37 pm
Posts: 2261
Location: No. 1 Thread Killer
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.
Image

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
  Profile  
 
 Post subject: Re: 3-Dimensional math
PostPosted: Mon Feb 21, 2011 10:14 am 
Java Junkie
Java Junkie
User avatar

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


Top
  Profile  
 
 Post subject: Re: 3-Dimensional math
PostPosted: Mon Feb 21, 2011 12:07 pm 
Northwood
Northwood
User avatar

Joined: Sun Jul 15, 2007 6:37 pm
Posts: 2261
Location: No. 1 Thread Killer
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
  Profile  
 
 Post subject: Re: 3-Dimensional math
PostPosted: Mon Feb 21, 2011 1:05 pm 
SON OF A GUN
SON OF A GUN
User avatar

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

15% Grade can mate with:
15% Grade, 30% Grade, 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
  Profile  
 
 Post subject: Re: 3-Dimensional math
PostPosted: Mon Feb 21, 2011 1:21 pm 
Northwood
Northwood
User avatar

Joined: Sun Jul 15, 2007 6:37 pm
Posts: 2261
Location: No. 1 Thread Killer
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
  Profile  
 
 Post subject: Re: 3-Dimensional math
PostPosted: Mon Feb 21, 2011 3:54 pm 
Northwood
Northwood
User avatar

Joined: Sun Jul 15, 2007 6:37 pm
Posts: 2261
Location: No. 1 Thread Killer
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
Image


Top
  Profile  
 
 Post subject: Re: 3-Dimensional math
PostPosted: Mon Feb 21, 2011 8:37 pm 
SON OF A GUN
SON OF A GUN
User avatar

Joined: Mon Nov 01, 2004 5:41 am
Posts: 11605
Hot linking bad....

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
  Profile  
 
 Post subject: Re: 3-Dimensional math
PostPosted: Mon Feb 21, 2011 9:31 pm 
Northwood
Northwood
User avatar

Joined: Sun Jul 15, 2007 6:37 pm
Posts: 2261
Location: No. 1 Thread Killer
Crash tech has cold feet for me. :!:


Top
  Profile  
 
 Post subject: Re: 3-Dimensional math
PostPosted: Tue Feb 22, 2011 8:21 am 
SON OF A GUN
SON OF A GUN
User avatar

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
  Profile  
 
 Post subject: Re: 3-Dimensional math
PostPosted: Sun Feb 27, 2011 12:59 am 
Northwood
Northwood
User avatar

Joined: Sun Jul 15, 2007 6:37 pm
Posts: 2261
Location: No. 1 Thread Killer
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
  Profile  
 
 Post subject: Re: 3-Dimensional math
PostPosted: Sun Feb 27, 2011 12:26 pm 
SON OF A GUN
SON OF A GUN
User avatar

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


Top
  Profile  
 
 Post subject: Re: 3-Dimensional math
PostPosted: Sun Feb 27, 2011 2:10 pm 
Northwood
Northwood
User avatar

Joined: Sun Jul 15, 2007 6:37 pm
Posts: 2261
Location: No. 1 Thread Killer
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: Image

or this: Image


Top
  Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 12 posts ] 

All times are UTC - 8 hours


Who is online

Users browsing this forum: No registered users and 1 guest


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

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group