Problem: Using camerapick to drag 3d entities

Blitz3D Forums/Blitz3D Programming/Problem: Using camerapick to drag 3d entities

Ross C(Posted 2009) [#1]
Hi. I'm having a slight difficulty dragging a 3d entity, using the mouse. My first approach, was to simply use the mousexspeed and mouseyspeed, and move the entity using these values. However, the further away the camera gets, the slower the waypoints move. Also, the cursor doesn't stay over the entity your trying to drag.

Now, i decided, i'll use camerapick. Pick the 3d scenary below the mouse, and move the entity straight to that spot, missing out the Y co-ord, as i want to keep the movement along the X and Z axis. All's good and well, but when i have waypoint entities above the ground, it doesn't work, as i'm picking to scenary on a different level.

Is there a more elegant solution to this? All i really want to do, is drag my waypoints with the mouse, to the location of the mouse onscreen.

The way i can see this happening, is to have a "pick plane" that i set to the height of the waypoint i select. Or could i do some fancy maths to extrapolate the position, based on the length of the pick to the ground and the length of the pick to the entity?


gosse(Posted 2009) [#2]
Why not linearly scale the mouse speed with the distance of the object from the camera?


Ross C(Posted 2009) [#3]
Ok, I have tried the pick plane option and it works good, as long as it's deactivated after usage. Other suggestions are still welcome though :)


Warner(Posted 2009) [#4]
Maybe TFormVector the picked (movement) vector from the ground into the entity the you want to drag?


Ross C(Posted 2009) [#5]
Thanks gosse, but i think Warners solution may be easier for me here. Thanks guys :)


GIB3D(Posted 2009) [#6]
I've thought about this already a few days ago! Use CameraPick to move it, then use CameraProject to move the mouse where the model is.


Ross C(Posted 2009) [#7]
Problem is, if the entity is floating mid air. I'm currently using a pick plane at the entity height, until i use one of the other options, if it's easier :S


big10p(Posted 2009) [#8]
I seem to remember there was some code in the archives to drag 3D objects around.


_PJ_(Posted 2009) [#9]
Perhaps I'm not fully understanding your issue, but from what I think you're saying, is that the parallax (I never could spell that word) effect of 'dragging' something further away should mean that it's dragged slower?

Perhaps a very 'kludgey' kind of approach would be:

Get the Sgn() of the MouseSpeed() then multiply it according to the distance to camera.

Next, Move the object that you are 'dragging' by the required amount.

Despite the action from a user point of view of using a Mousepointer to drag the object, in this workaround, the object itself is controlled and effectively drags the mousepointer :)

By using MoveMouse(), reposition the mousepointer relevant to the position of the object on-screen. Not only does this keep the pointer n top of the object, but also removes any differences between ther MouseSpeed() you got earlier and the 'current' Mouse position.

It's ot as techy and likely not as effective as the other suggestions here, but it's the way I would approach it :)


Ross C(Posted 2009) [#10]
I'll upload what i have so far:

http://www.rosscrooks.pwp.blueyonder.co.uk/Level_Editor.zip

Normal controls really:

Left button click to create a waypoint.
Left button drag, to drag (X/Z axis) a waypoint if you start the drag on a waypoint.
Left button click to select a waypoint. Use SHIFT for Multiple and Left ALT to remove selections.
Left mouse drag to box select waypoints. Use SHIFT and Left ALT again for additional options.
Right mouse drag to move a waypoint along the Y axis.
Delete key to delete selected waypoints.

Free to use btw. I'm not finished, but i'll post the whole thing when i'm done.


_PJ_(Posted 2009) [#11]
Hey it's very neat :)

Overall it seemed to work as I expected it to. The fiddly bits of trying to place the WP's in the air are only to be expected I think, but it wasn't too difficult with a bit of rotating. (Well, not too difficult considering I didn't have any definite plans where I ought to place WP's ;) )

Considering the very nature of the 2D screen and Z-Direction depth, then there's always going to be intrinsic difficulties, and I don't expect any remedies to be effective in all situtions, you can always have other objects in front of or behind the 'desired' location, or the 'desired' location could effectively be any distance away, since looking at the rendered view from a 2D point of view at any particular time, X is constant, Z is totally unknown, and Y is (at least partly) relative to Z, so you could never truley get it 'right'

Sorry I obviously didn't understand the problem when I made that first post, but I think I have an idea now.

Why not default the Z value away from the camera, so it's , say, half the landscape-size away, that way you have X and Z and can get the Y from some relationship to the 3D X and Z and the 2D Y
Only don;t ask me what that relationship is . . . . I'll have a tinker about and see what I can come up with.
Does that make sense?


_PJ_(Posted 2009) [#12]
Ahh... scratch that last stuff.

I think I got it now.
I wanted to try making the pick_planes EntityOrdered to -something, but couldn't change the 'pick_plane_mode', pickplane v and h always seem to be 'off' :(


Ross C(Posted 2009) [#13]
Yeah, the code automatically sets them to off, so you can resume normal operations when not moving. I didn't want to keep the pick_planes on, as it might cause some annoyances when saying laying down a waypoint. However, i could use the pick_planes to position waypoints along a set level, if you wanted to create waypoints in the air.

Thanks, it's got me thinking bout that :)


_PJ_(Posted 2009) [#14]
It would seem the best way (that I can think of), otherwise the only geometry to pick is the terrain which "interferes" with trying to position things in the air.

Alternatively, I wonder about the possibilities of a "pickable" Skyphere/box but then, tha may mean more verts in the sphere/box which could affect your rendering performance. Also, a 'pickable skybox' would ultimately be of similar effect to the 'PickPlane' I guess ? ? ?

I Like what you have so far, and this is specially good for me because I was workign on a simple but very user frioendly particle engine idea. The entire issue of emitter-placing seemed the most intimidating part until I have seen this :D


Ross C(Posted 2009) [#15]
Well, i will post my results, as i'm pretty close to finishing up now. Waypoints can be linked, and deleted links, automatically fall back to the previous waypoint.


_PJ_(Posted 2009) [#16]
I didn't even realise the Right-Mouse Button allowed for vertical dragging. Having played around some more, I think it all works beautfiully!

I'm not sure why, but using A and Z didn't work, perhaps this is linked to deactivated modes?

One sugegstion for Waypoints in the air, though, is to have a vertical line or something so it's clear where their X and Z are in relation to the terrain?


Ross C(Posted 2009) [#17]
Good thinking. Maybe even tie in a height value, displayed on the line, with the option to toggle lines and display values.

I have also added lines to show the links between each waypoint, and an arrow showing the direction of the link. You have the option down the right hand side to toggle these view options.

I have disabled all the keys now for moving, since the move speed will change the further the camera is, or the larger scale the level is. I'd prefer to stick with the mouse, as it's drag speed is constant.


_PJ_(Posted 2009) [#18]
In which case, instead of keys, the Mousewheel could be used to raise/lower the WP's in the Y axis?


Ross C(Posted 2009) [#19]
This is also an idea. But again, I will need to find a way of adjusting the move speed, when landscape sizes are different. With the mouse drag, i have that. Also, i was thinking of mousewheel scroll to zoom in. I currently have Middle mouse button held and drag to rotate the camera. I will post what i have when i get in, in about an hour :)

Thanks for your suggestions!


Ross C(Posted 2009) [#20]
Ok man, here it is so far:

http://www.rosscrooks.pwp.blueyonder.co.uk/Level_Editor_v0_6.rar

Controls:

Left click : place waypoint/ select waypoint (Hold shift to multiple select, or Left ALT to remove a selection)

Left drag: If drag starts on a waypoint, it will move all selected waypoints
If drag doesn't start on a waypoint, then enter box select mode. SHIFT and Left ALT keys apply here too.

Right Drag: Same as above, except no box select mode.

Middle Drag: Rotate camera, with mouse movements

GUI:

Green A - Auto linking waypoint mode. Any created waypoint, will auto link back to the last one.

Buttons down the right:

Arrows - View the direction of the waypoint link
Lines - View the lines linking the waypoints
Numbers - View the path number of each waypoint.

Keys: Delete - will delete any selected waypoint(s). If they are linked, it will automatically relink.

I think thats all?


Ross C(Posted 2009) [#21]
*pointless bump*


Ross C(Posted 2009) [#22]
I have fixed the download link. There was missing source code files. Re uploaded.


_PJ_(Posted 2009) [#23]
Hey ROss, I had trouble with getting either arrows or lines to show. In fact, whatever I tried, they didn't show at all.

partly because I spent a while just randomly cicking everything. This resulted in something getting confused (as well as me ;) ) and I was unable to place aypoints after that.

For the complete dummy, could you add some more descriptive info for the current 'status/mode/selection even' ?

To end on a more positive note, the change from square circle WP, though a small adjustment really makes it look better!

Edited:
Seems somwehere the UI is a little quirky. According to what I could gather from the debuglog, at times, clicking on the UI Buttons is registered as clicks on the 'normal 3D world'


Ross C(Posted 2009) [#24]
Thanks for pointing these out. I'll have a look, and add tooltips to the buttons, and sort the picking of the 3d world. I'll also turn on arrows and lines by default.

From opening the application, if you click the Green A button, then lay down a few waypoints, then click to view th lines and arrows, (The buttons down the right hand side) it should show the linkage. I'll sort this and reupload.


Guy Fawkes(Posted 2009) [#25]
Ross. Look. Im sorry. I was upset the other day ok? My dad is having nose surgery, and I just.... I'm upset ok?

Forgive me...


Flemmonk(Posted 2009) [#26]
How many noses does your dad have?


Guy Fawkes(Posted 2009) [#27]
O ha ha...


RGR(Posted 2009) [#28]
.

Last edited 2012


Ross C(Posted 2009) [#29]

How many noses does your dad have?



Must have been the gas leak that caused it.

Anyways, humour aside. DarkShadowWing, you don't owe me an apology. Maybe i shouldn't post in your topics, as i generally don't have anything constructive to say. I do enjoy helping people, but only when i can lead them to figure out there own answers, maybe with a bit of code to show the way. It doesn't work like that with you, so, that's fair enough.

But regardless, I appreciate it. No hard feelings eh? It's only the internet :)

RGR, thanks. I'm fairly happy with the movement stuff, and i'm glad you showed that code off. Means i'm doing the right sort of stuff.


Guy Fawkes(Posted 2009) [#30]
dont joke around about that.

it proally was O_O

LOL! jk :P

anyway, ross, its not that i dont want u to not post about any questions i may have, and its not that i dont appreciate what you've done for me in the past, and what you're doing now, it's just that i've had a really bad week. along w/ a cough that wont go away. im just hoping and praying its allergies.

but anyway.

i truely am sorry, ross..


Ross C(Posted 2009) [#31]
As i say, no big deal man. If you let people get to you on a forum board or chat room and don't forget about it the next day, you've got no chance in the real world. It's the internet. End of the day, you switch your computer off, and live in the real world.


Guy Fawkes(Posted 2009) [#32]
ok :)

we cool?


Warner(Posted 2009) [#33]
End of the day, you switch your computer off, and live in the real world.
What is this switch off thing that you are speaking of?


Guy Fawkes(Posted 2009) [#34]
LMAO!

I have no idea.

is it coffee?

god are we totally bored or what? ROFL LMAO XD!


GIB3D(Posted 2009) [#35]
I have no idea.

is it coffee?

What is this coffee thing that you are speaking of?

...Man I hate coffee...


Guy Fawkes(Posted 2009) [#36]
idk. they say its some kinda drink that makes people hyper!

XD


Guy Fawkes(Posted 2009) [#37]
o u guys want FUNNY?!

Check out THIS guys!

http://www.youtube.com/watch?v=8jibOl4LxZM&NR=1

XD

Single. greatest. thing in the world.

simple. as. that.

XD


GIB3D(Posted 2009) [#38]
LOL! Hilarious.


_PJ_(Posted 2009) [#39]
Coffee is foul, I used to do QA for a factory where they converted the raw powder into granules and packaged it for supermarkets etc.

the whole place stinks and the stuff gets in your clothes and hair and skin-pores, even up your nose so you smell coffee 24hours a day no matter how much you shower.

I swear, I've never had a decent sleeping pattern since, and despite how foul the stuff is, I think I'm hopelessly addicted to caffeine and it's a very nasty drug.

Anyway....to try and post somethng related to the topic ;) ...

I'm currently getting my particle engine up to speed, at which point, I should be able to really get into your code, Ross, and work on implementing it. As it stands now, I'm reluctant to mess with it too much for fear of breaking parts that I don't yet really understand or know what they're for. With any luck, when I get to that stage which I'm guessing should be about a week away, I might then be able to offer more actual practical suggestions and hopefully even provide some code changes rather than just say "Oh this doesnt work" or "can you do that?"


Ross C(Posted 2009) [#40]
Well, last night i completely re-wrote the mode switching stuff, to make it far simplier to add more modes. Hopefully this will help if you personally need to add any modes.

I sorted the GUI problems out too, and disabled buttons that don't work yet, from switching modes.

I have enabled lines and arrows view modes by default, and i'll add more link modes, so you can manually link them. Lastly, i'll stick in a save function, and write some loader code for blitzbasic, so you can load your waypoints into your blitz application.


_PJ_(Posted 2009) [#41]
Sounds great, Ross. For my needs, I doubt I'll require anything other than just the ability to place/delete the poitns, although I'm thinking that linking them may be useful not as waypoints, but a means to set some form of trigger, i.e. if one "emitter" is activated, then it will activated any others linked to it. Of course, that's largelly irrelevant here.


Guy Fawkes(Posted 2009) [#42]
single GREATEST thing.

thas all that i got to say. lmao


Ross C(Posted 2009) [#43]
TBH Malice, that shouldn't be a problem. i'd need to change my waypoints from being stored in an array, to using types, but not much code should be needed.


_PJ_(Posted 2009) [#44]
Oh don't change your plans on my account, it wouldn't be a bother for me to change what's needed for that.

Another thing did occur to me, and it may be getting a bit far ahead for now, but you mention the renumbering of WP's if one is removed, but is it possible to say, add in a new WP BETWEEN two existing ones?
(By between, I mean numerically, not necessarily physically) or would that just involve swapping a few around?


Ross C(Posted 2009) [#45]
Hehe, just working on that. That is primary why waypoints need to be linked. To give them an order. So by linking them, you have a start and finish, and if you choose insert mode, and drop the waypoint onto a link between two waypoints, it will insert itself, and creates links between the to, in the direction of the linking.

It's almost finished :)


Guy Fawkes(Posted 2009) [#46]
nice :)


_PJ_(Posted 2009) [#47]
Awesome stuff :)


Guy Fawkes(Posted 2009) [#48]
yup