Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Using Joint Data to Build Models From Objects in DBP

Author
Message
Nateholio
20
Years of Service
User Offline
Joined: 30th Dec 2005
Location: I\'ve Been Everywhere
Posted: 3rd Nov 2011 08:32
Rewrote my model "building" function today and decided to share it with y'all.

In my project, models are constructed from individual objects which allows for, among other things, easy targeting and destruction of individual parts of tanks and other models.

I've simplified the process so that most parameters for constructing models within my program are set during modeling of the objects. I first build the entire model then split it up into its component parts. Along with this, I add "mount to" points to parent objects and "mount from" points to child objects. Each mount point also has X, Y, and Z mount direction points associated with it.

When it comes time to load a complete model, the program runs through a configuration script to load the individual objects and bind them to the correct mount points (another function, which I might post in the future). The program calculates the proper orientation for child objects without any input from the script, using joint data contained in each object.

Anywho, the program snippet is posted and included, along with a simple two object model for your enjoyment. The program is hard-coded to lead the objects from C:\, change as needed. The included objects are for example use only, not your own use or otherwise.



Comments and suggestions are welcome...enjoy!

In Development: K96 - Combat Simulation
Nateholio
20
Years of Service
User Offline
Joined: 30th Dec 2005
Location: I\'ve Been Everywhere
Posted: 5th Nov 2011 10:45
Grrr...I was thinking "man this is easier than I remember it originally being" as I was seeing the code work - well work with the incorrect angles. I caught what I did wrong, which was rotating the child object by the same angle the parent object was being rotated. I've been trying some things to solve the problem for several hours now; but being vaguely familiar with vector theory as it's used in 3D, I've came close but ultimately blank.

I've searched Google and read quite a few posts on the subject, but none helped much. Cross-products, arctans, atan2, and so on.

What I need to do is pretty simple - calculate the angle between two direction joints (see models), and here's the part I'm having trouble with...the sign of said angle. How would I go about this?

In Development: K96 - Combat Simulation
BatVink
Moderator
23
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 16th Nov 2011 22:25
That's a question I've often wondered about. I want to work out the sign of angles on a race track that could follow a complex curve.

Login to post a reply

Server time is: 2026-07-10 11:25:03
Your offset time is: 2026-07-10 11:25:03