[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4787: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3922)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4789: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3922)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4790: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3922)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4791: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3922)
InsideQC Forums • View topic - 3D Object Selection

3D Object Selection

Discuss programming topics for the various GPL'd game engine sources.

Moderator: InsideQC Admins

3D Object Selection

Postby Baker » Thu Jan 12, 2012 2:27 pm

3D Object Selection

This used to be one of the larger wants on my to-do list. A few days ago, I searched for this info like the holy grail, some tutorial or same project to explain it as I suck at 3D maths.

Better than finding one that works, I found one that almost worked. It was SO CLOSE. But it didn't work 100% right. Succumbing to being so close, I opened up DarkPlaces and searched for PRYDON_CURSOR and did a Googling frenzy on the topic. For hours, I was on the brink of fixing it, trying to work out the missing components and in my head the mechanics.

Finally, I did something I felt would work. It didn't. After 10 hours of frustration. And then I clicked it again. And it did work, I clicked wrong the first time.

3D calculations are, in fact, easy. I can say this in hindsight. And what makes me rather happy about this experience is that if I ever get time to mess with the , I should be able to add rotating brush texture rotation into it. And work with the BSP editor tools.

[I get ever increasingly irritated that when I took all those matrix math kind of college courses they never did explain decent practical uses or applications of matrix math. Had they done so ... grrrr]

But better than that, I'm going to explain the basics of 3D math calculations. I have some more to learn. But going from not understanding it to rather well understanding it, I think I can explain how it works very well even for people like myself from a week ago that struggled deeply with the concepts. And do it lucidly and easily. It really is super easy.

(To be continued. Next time ... explanation. The following time: a really fun working project I already wrote for Mac OS X but I need to convert it to MSVC6 and CodeBlocks for Windows. Won't have a MSVC Express 2008 project, my Vista notebook died in September and my XP desktop doesn't have the right stuff to run 2008.)
The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
User avatar
Baker
 
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Re: 3D Object Selection

Postby mankrip » Fri Jan 13, 2012 12:56 am

I'm deeply interested. There are tons more I could do in Quake if I knew 3D maths well.

Also, when I found I wondered if it hadn't been written by you. I've built a quite long to-read list over the last year.
Ph'nglui mglw'nafh mankrip Hell's end wgah'nagl fhtagn.
==-=-=-=-=-=-=-=-=-=-==
/ /
User avatar
mankrip
 
Posts: 915
Joined: Fri Jul 04, 2008 3:02 am

Re: 3D Object Selection

Postby Spike » Fri Jan 13, 2012 1:58 am

what really annoys me about matrix maths is that a*b is not the same as b*a.
I'm never sure if I'm multiplying it the right way.

Then there are column major and row major matrices, etc...
Note that model+view matricies in OpenGL and Direct3D are 100% identical. The differences are purely in the documentation.
(d3d projection matricies are different, however, as the hardware z range is 0 to 1 in d3d and -1 to 1 in opengl - this thus applies to all combined modelviewprojection matricies as well).
Thus you can (for the most part) reuse your matrix code for either rendering api.

to go from screen to 3d space, there's always gluUnProject.
FTE has a Matrix4x4_CM_UnProject function to do the equivelent work.
If you unproject a cursor at z=-1 and z=1, you will calculate the point at both the near clip plane and the far clip plane, you can then just trace a line from near to far to see what you hit.

unproject is also one of the functions provided in the csqc api (with a slight difference - z is world distance from near clip plane rather than z fraction, which is renderer api agnostic and more logical).
.
Spike
 
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Re: 3D Object Selection

Postby Baker » Fri Jan 13, 2012 2:31 am

Last edited by Baker on Fri Jan 13, 2012 3:00 am, edited 10 times in total.
The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
User avatar
Baker
 
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Re: 3D Object Selection

Postby mh » Fri Jan 13, 2012 2:34 am

User avatar
mh
 
Posts: 2292
Joined: Sat Jan 12, 2008 1:38 am

Re: 3D Object Selection

Postby Baker » Fri Jan 13, 2012 2:44 am

The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
User avatar
Baker
 
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Re: 3D Object Selection

Postby Baker » Fri Jan 13, 2012 3:54 am

The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
User avatar
Baker
 
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Re: 3D Object Selection

Postby mh » Sat Jan 14, 2012 12:05 am

Put the inverse of the world space matrix into R_PushDlights (it will be identity for the world), multiply each dlight origin by that, and suddenly you get dynamic lights being able to properly affect moving bmodels. Awsome example #1.
User avatar
mh
 
Posts: 2292
Joined: Sat Jan 12, 2008 1:38 am

Re: 3D Object Selection

Postby Baker » Sat Jan 14, 2012 12:43 am

The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
User avatar
Baker
 
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Re: 3D Object Selection

Postby Baker » Tue Jan 17, 2012 4:43 am

Image

I've been making a fun little demo that I should be able to make work in WebGL too (nothing beats beating able to play around without loading anything ... well ... except that it requires Google Chrome or Firefox. WebGL is inherently insecure in a way but that's another story ...).

However, I have sort of a stumbling block. Mentally. And I've always known this: there is no such thing as "ROLL" for avelocity. Part of the fun of the demo is mimicking Quake entities way of thinking.

ROLL only exists from a first person perspective. An object seen in 3rd person cannot have a roll, since roll is pitch seen from the side. 2 angles completely define an orientation and therefore any angular movement.

Also of a side note: Quake doesn't deal with roll from a map navigation point-of-view (therefore no upside down players walking on the ceiling :( ), like say a flight simulator would. And the addition of roll in first-person navigation changes what pitch and yaw and side stepping represent.

/Is thinking ...any insightful comments welcome.
The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
User avatar
Baker
 
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Re: 3D Object Selection

Postby Spike » Tue Jan 17, 2012 8:32 am

roll angles in quake exist in a form relative to the pitch+yaw angles. you can decouple them by using a matrix/quaternion instead.
you cannot express all orientations without a roll angle.
quake also doesn't change gravity based on pitch, so its at least consistant - a pitch of 180 is just as much fun as a roll of 180.
it could be fun to have some tunnel that changes your gravity direction based upon distance from the center, but doing it with eular angles is going to be painful.
if you were making a game like descent, you'd not use such terse angles, but just keep everything as a matrix. if you want to pitch up and down, you'd multiply the ship's current matrix by a rotation matrix, same as if you were rolling or yawing, the only difference is the rotation matrix's axis.
the most useful feature of eular angles is that if you interpolate them, your value will always travel around the edge of a sphere. but the issue there is that they won't travel in a straight line across the surface, especially if there's a roll angle. with an interpolated matrix, that point on the sphere would go from A to B *through* the sphere instead of across the surface. I'm not quite sure what a quaternion will do, but those can at least be normalized/scaled easily.
.
Spike
 
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Re: 3D Object Selection

Postby qbism » Wed Jan 18, 2012 6:01 pm

To mimick Quake navigation, give the viewer a jetpack... fly above the horizontal surfaces and look down (or under/up). Or give the entity a jetpack. Without a surrounding environment there's no basis to judge whether it's the camera or the object that's moving.
User avatar
qbism
 
Posts: 1236
Joined: Thu Nov 04, 2004 5:51 am

Re: 3D Object Selection

Postby Baker » Thu Jan 19, 2012 1:42 pm

The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
User avatar
Baker
 
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am


Return to Engine Programming

Who is online

Users browsing this forum: No registered users and 2 guests