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 / Doom3 style ingame interfaces. Possible?

Author
Message
enderleit
19
Years of Service
User Offline
Joined: 30th May 2007
Location: Denmark
Posted: 12th Jan 2011 06:58 Edited at: 12th Jan 2011 07:00
Anybody got any ideas of how this could be accomplished in DBP?

For those of you who haven't played Doom3 you can interact with screens by walking up to them and clicking on buttons on the screen simply by using your crosshair(changes into an arrow when you get close). The surface is a simple plane/plain, textured with the user interface and it reacts/changes when you click on the buttons.

I know how to find out which object I'm pointing at, and I know how to do the updating of the texture stuff... the problem I think is how do you know what coordinates on the plane/plain you are pointing at when you click?

Any wild ideas?

enderleit
19
Years of Service
User Offline
Joined: 30th May 2007
Location: Denmark
Posted: 12th Jan 2011 09:34
I have been experimenting a little bit and came up with the following small test program. It seems to work as long as you don't rotate the object. I will probably have to add the Z coordinate into the calculations to get that to work.

For now atleast it is possible on an unrotated surface.



Please if you have further tips/ideas, please gimme!

thenerd
17
Years of Service
User Offline
Joined: 9th Mar 2009
Location: Boston, USA
Posted: 12th Jan 2011 17:02
I'm also interesting in this topic, and somewhere I do have code that allows for rotated surfaces. I will try to find it for you.
A few suggestions:
Use set object filter obj,0 to increase the clarity of the screen.
Also use the Image Kit plugin, it has several useful functions including a paste image to image command.

C0wbox
20
Years of Service
User Offline
Joined: 6th Jun 2006
Location: 0,50,-150
Posted: 12th Jan 2011 17:07
I've always wanted to stick this kinda stuff in a game, but I just figured it'd require some mad trigonometry. - Similar to the whole rendering the 3D point stuff (which I still can't get my head around )

enderleit
19
Years of Service
User Offline
Joined: 30th May 2007
Location: Denmark
Posted: 12th Jan 2011 18:30
thenerd: Would be great if you have some example code, or atleast some info on how to do the calculations correctly.

c0wbox: The program I posted is pretty quick/dirty, and the more I look at it the more I'm afraid it WILL require some trigonometry skills to get it to work on rotated surfaces.

Although I don't think the calculations would be too advanced to use in a game.

enderleit
19
Years of Service
User Offline
Joined: 30th May 2007
Location: Denmark
Posted: 12th Jan 2011 19:09 Edited at: 12th Jan 2011 19:10
Actually playing with it a bit more, I can now draw to a plane that is rotated around either X or Y, but not both at the same time.

Trick so far is to create a mesh from the object in its current state and use that for the vertexdata as otherwise you get local object coordinates. With the mesh transformed you get the correct coords for the vertexdata.

Still doesn't work if the plane is rotated on 2 axes at the same time, and I think it will require some vector-math to accomplish.

Mobiius
Valued Member
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 12th Jan 2011 19:29
I believe there's a plugin (or two) which can do just this.

It's either the fazeqium, or the dbflasher plugins.

They're flash plugins which render complete flash animations to a dbpro image to be textured to objects. You can interact with it just like the doom3 ones. (Once you've created the menu in flash first.)

Search the forum for them, they're buy the same guy I believe. (Forum name faziqium i think)

My signature is NOT a moderator plaything! Stop changing it!
revenant chaos
DBPro Master
19
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Robbinsdale, MN
Posted: 12th Jan 2011 19:42
Mabey the panel's screen could be made of layers of plain objects. By scrolling the textures, and hiding/showing the plains you could simulate an animated menu. Even the cursor could be a plain object, and checking for button clicks would then be a matter of using the pick commands to determine which button was clicked.
enderleit
19
Years of Service
User Offline
Joined: 30th May 2007
Location: Denmark
Posted: 12th Jan 2011 19:52
That's actually a great idea revenant, would make finding out which button you clicked a lot easier and spare me alot of vector-math...

As for the flash thingy, sounds cool/usable but, I'd really like to have full control over what it does in the code/game. Plus I don't really know/like flash. So...

Neuro Fuzzy
19
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 12th Jan 2011 21:35
:X I think I've come up with a solution, but i can't implement it ATM, and it uses matrix algebra. Basically, say you have a plane in 3d that has vertices (-1,1,0),(1,1,0),(1,-1,0),(-1,-1,0) (a vertical plane two units in side length)
Then, you rotate and scale this plane to be the position you want. Where T is the translation matrix, S is the scaling matrix, and R is the rotation matrix, for all points P on the plane,
P'=P*R*S*T

So, thats how you translate point P on the plane into the world. The point of intersection is in world space, so you just solve for P...
P=P'*Tinv*Sinv*Rinv
(where inv=inverse matrix)
the inverse matrices should be easy to calculate (negate translation values, take 1/scale values, and negate the angles).

So, once you have P, that's in plane coordinates. Just for added comfort, I would transform P into UV coordinates - take P/2+[.5,.5]

Thar you go! you have the UV coordinates of the point of intersection! (uhh, assuming (0,0) UV is at the bottom left of the plane, and (1,1) is at the top right. I'm not sure it's like that, but it's somethin' similar).

Now... this would be pretty straightforward if you knew a good bit about 3d transformations... but if you don't... uhh... I Might implement something later tonight? Actually I think I can write the function that gets the UV coordinates just fine, if you write some test code that demonstrates interactivity.



(just to recap, P=P'*Tinv*Sinv*Rinv, where P' is the point in the world that you want to "give input" to the plane, and T/S/R are transformation matrices. Also, I could be completely wrong about this because I'm not sure how good I am with transformations anymore ._.)

enderleit
19
Years of Service
User Offline
Joined: 30th May 2007
Location: Denmark
Posted: 12th Jan 2011 21:44 Edited at: 12th Jan 2011 21:45
So if I called your function with screen x/y coords it would return the UV coords on the plane (if valid)?

This would be great to study...

I know nothing of matrix math/tranformations, but your calculations sounds atleast like they make sense...

I am currently experimenting with vector math, getting the lengths of each side and trying to interpolate the coordinates to match the UV map. I hate this stuff, so it's going a bit slow.
Plus... it's alot of calculations, so it might become terribly slow...

Kira Vakaan
17
Years of Service
User Offline
Joined: 1st Dec 2008
Location: MI, United States
Posted: 13th Jan 2011 01:02 Edited at: 31st Jan 2011 08:51
Hmm, here's a little example I came up with. It does pretty much what Neuro Fuzzy describes, and I tried to explain all of the math as it was happening in the comments.



Anyhoo, take a look, and let me know if I can help to explain anything

Good luck!

Oh, and WASD to strafe and mouse to look.

Edit: Changed the object scale [x/y/z] commands to limb scale [x/y/z] commands. By some logic I can't possibly divine, the object scale commands are missing from the native command set and I just didn't notice that they came from the Matrix1 utilities I installed.

Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 13th Jan 2011 02:02 Edited at: 13th Jan 2011 02:06
I swear I've done this before using Vector Math... Hmm, will have to have a look around the back cave for a snippet.

I wonder if you could use Sparky's collision dll and a bit of trig to do this. I started having a play earlier, got the y rotation:



First version of this I went mad with trig to get the forward/up/right vectors for the camera so I could work out the pick vector position, then I realized that could be done in a few line with move camera.

@Kira, that's pretty neat, great work

A dream is a fantasy, if you achieve that fantasy it was never a dream to begin with.
enderleit
19
Years of Service
User Offline
Joined: 30th May 2007
Location: Denmark
Posted: 13th Jan 2011 07:15 Edited at: 13th Jan 2011 07:16
Great job Kira, I'm gonna have to read up a bit on matrix math so I can fully understand what's going on. Luckily I have a DX9 book with a matrix section in it, so I just have to read up a bit.

Sasuke: Yeah, I think the reason why I'm having trouble with vector-math is that it gets pretty complex when you have to take into account x/y/z rotation at the same time.

Thanks to both of you for having a go at it.

enderleit
19
Years of Service
User Offline
Joined: 30th May 2007
Location: Denmark
Posted: 13th Jan 2011 08:00


Why are we dividing the scale by 100.0?

enderleit
19
Years of Service
User Offline
Joined: 30th May 2007
Location: Denmark
Posted: 13th Jan 2011 08:35 Edited at: 13th Jan 2011 08:40
I understand most of it now, except the plane intersection point stuff. Gonna have to read the section on planes in the book aswell.

As I understand it, first you "backtrack" viewspace to worldspace, get the intersection point, and then use the inverse matrix to get the point back into viewspace... or something similar. Am I getting close?

EDIT: Replace viewspace with local space (objectspace)?

Scratch that, got my terms all screwed up...

You "backtrack" from worldspace into objectspace(object local coords) find the point, and then use the inverse matrix to get it back into world space coords. And then scale it to the 0-1 range (UV-coords)...

Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 13th Jan 2011 08:47 Edited at: 13th Jan 2011 08:48
Hmm... This line:


Would cause an error I think if the scale of the object changes. If I'm correct, this just needs to be set to 1 for each axis.

So Vector.One:


A dream is a fantasy, if you achieve that fantasy it was never a dream to begin with.
enderleit
19
Years of Service
User Offline
Joined: 30th May 2007
Location: Denmark
Posted: 13th Jan 2011 09:04 Edited at: 13th Jan 2011 09:07
OK... here it is... get ready...

You find the intersection point in WorldSpace, transform it into Object LocalSpace, and scale it into the 0-1 range, and there is your UV-Coords.

Took a bit of close inspection of the commands, but I get it now.

Still don't understand the plane intersection stuff though... Will read up on that later today...

Once I get a complete grasp of this I might try and make some visual drawings of the transformations to make it more clear for everyone.

EDIT: Btw, great job on the commenting. Really makes it easier when trying to understand what's going on.

enderleit
19
Years of Service
User Offline
Joined: 30th May 2007
Location: Denmark
Posted: 13th Jan 2011 11:36 Edited at: 13th Jan 2011 11:38
In an attempt to better understand the PlaneIntersect code, I created this small program to test it out in 2D.

With the values as they are now it seems to find the correct point, but if I change the RayOrigin it screws up...

Anyone able to tell me what's wrong?



enderleit
19
Years of Service
User Offline
Joined: 30th May 2007
Location: Denmark
Posted: 13th Jan 2011 11:57
Ok... figured out that RayVelocity is not the same as RayEnd...

But the point found is still a little bit offset from the plane, even if it is in the correct direction...



Neuro Fuzzy
19
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 13th Jan 2011 21:32
@Kira Vakaan
That's awesome!!!

1 mistake though >
it messes up if you scale by different amounts on different axes, because you multiply R*S instead of S*R

Kira Vakaan
17
Years of Service
User Offline
Joined: 1st Dec 2008
Location: MI, United States
Posted: 14th Jan 2011 21:51 Edited at: 14th Jan 2011 21:51
Hey guys Sorry, I didn't mean to ditch, I've just been away from an internet connection for a while.

I'm glad everyone liked it!

@enderleit: I'm glad the comments were helpful. As for your example, the intersection point your code finds is actually correct, you've just drawn the plane incorrectly. Remember that the normal of a plane is an imaginary line that sticks out of it perpendicular to the plane, not along the surface. You should replace:

with:


So really, the math behind your code is working fine! Lemme know if I can help with anything else.

@Neuro Fuzzy: Thanks! And thanks for pointing that out. How strange.. I did it without even thinking, as per my experience with DirectX programming... In the .x file format, the AnimationKey template lists the order of transformations as Rotation, Scale, Translation... but now that you bring my attention to it, it's obvious that's wrong. Thanks for waking me up!

enderleit
19
Years of Service
User Offline
Joined: 30th May 2007
Location: Denmark
Posted: 15th Jan 2011 18:45
Kira: Doh! I knew that... Stupid mistake... Thanks for pointing that out.

sindore
22
Years of Service
User Offline
Joined: 2nd Jul 2004
Location: Bedfordshire, UK
Posted: 30th Jan 2011 07:20
could you use physX to replace what you have done with sparkys collisions?

I know its an odd question, but I have the makings of this years ago, but I could never get it to work right, I was thinking of using raycasting, pick object, get pick distabce and pick screen, but I'm not shore were to filling the blanks as my maths is not red hot at the best of times

here's an image of what I was working on about 5 odd years ago.


Soul sucking devils, twisting the body's of the damned, slivering slim drips from every poor, sin licking at ears, and a smell so bad it stings the eyes, welcome to the darkness.
thenerd
17
Years of Service
User Offline
Joined: 9th Mar 2009
Location: Boston, USA
Posted: 30th Jan 2011 15:43
Just a suggestion, some of Image Kit's commands would help a lot when doing this, especially the paste image on image command.

sindore
22
Years of Service
User Offline
Joined: 2nd Jul 2004
Location: Bedfordshire, UK
Posted: 31st Jan 2011 00:23 Edited at: 31st Jan 2011 00:26
here is a small part of what I did to end up with the screen shot above


I was thinking using raycasting to find what object your looking at, and get pick distance to work out the camera distance from that object, pick object when object is with in the right distance to the camera, to lock on the object, and pick screen to allow movement of the mouse on screen to interact with the object, this is all a bit on the fly so I can't remember weather I used the right contexts to the code or not so sorry if I haven't.

but the down side to this is that I would have to test to see if the object is facing the right way or not, and I don't have the 1st clue about that, I would think syncing the screen mouse movement to the bitmap mouse movement would be a bit easier.

you could use the camera to zoom in on the object, so you have a better view of the bitmap on the screen, or even turn the camera to face the bitmap on the object, like the camera dose in oblivion when you talk to some one.

The world surcome to the power of an evil god, a new champion arise The dark Lord Sindore
Neuro Fuzzy
19
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 31st Jan 2011 01:07
@sindore:
The solution found above doesn't use sparky's collision! Try running the code in Kira Vakaan's post!

If you create a square plane, scale it to the size you want, and rotate and position it to where you want, you can do what you want using that code.

Also, checking which way an object is facing can be pretty easy. It's probably a good idea to learn about vectors and transformation matrices

sindore
22
Years of Service
User Offline
Joined: 2nd Jul 2004
Location: Bedfordshire, UK
Posted: 31st Jan 2011 01:20


it has a problem with this line but if its removed it works.

thanks Neuro Fuzzy btw I like your avatar

The world surcome to the power of an evil god, a new champion arise The dark Lord Sindore
Neuro Fuzzy
19
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 31st Jan 2011 01:30
thanks! I didn't make it though... stole it off another forum.

What's the problem with that line though?

Neuro Fuzzy
19
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 31st Jan 2011 01:32
D: what? Could it be those commands are in matrixutils?!

:\ well in that case it won't work if you scale the plane. Uhh replacing those commands with "limb scale [x/y/z](0)" should work.

Kira Vakaan
17
Years of Service
User Offline
Joined: 1st Dec 2008
Location: MI, United States
Posted: 31st Jan 2011 08:47
Oh my, they are!

Thanks for pointing that out. Yes, replacing each object scale [x/y/z](Object) with limb scale [x/y/z](Object, 0) will work just fine only if you scale limb 0 with the scale limb command instead of scaling the object with scale object. Gah, how stupid. That command should, with out a doubt, be in the native command set. I'm going to edit my code above to reflect the change.

sindore
22
Years of Service
User Offline
Joined: 2nd Jul 2004
Location: Bedfordshire, UK
Posted: 31st Jan 2011 14:08 Edited at: 31st Jan 2011 16:23
yeah sorry, I fell asleep, here is what it comes up with as an error, which is what you've said about any way.

Quote: "Could not determine parameter type of 'object scale x(Object)' at line 108."


I'll give the limb scale obj,0 ago, thanks for the help.

Edit

just run this again, I'm imprest, this could be used for a lot more than just a menu system on an object, this could be used to track blood splatter, bullet holes, and graffiti, etc, well done.

The world surcome to the power of an evil god, a new champion arise The dark Lord Sindore
sindore
22
Years of Service
User Offline
Joined: 2nd Jul 2004
Location: Bedfordshire, UK
Posted: 31st Jan 2011 14:41 Edited at: 31st Jan 2011 16:31
is there a way of doing this so it could be done to a more complex shaped object like say a cube or an objects texture, like a pillar or a tree, maybe even a wall?

I've just stared testing this out on a cube, I need to fit the texture across the shape of the cube so that the mouse tracks across the cube, so instead of just tiling the same image on all six sides of the cube, the image is stretched across the hole of the cube, allowing the image to be manipulated to track better across the surface of the cube.

Edit

just had a thought about this and wanted to know if this could be done using set vertexdata uv and set vertexdata normals to manipulate the object its self as well as the bitmap, I not 100% on this, but I think it would allow for a lot more complex objects to and bitmap manipulation.

The world surcome to the power of an evil god, a new champion arise The dark Lord Sindore

Login to post a reply

Server time is: 2026-07-19 01:26:52
Your offset time is: 2026-07-19 01:26:52