Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/20/24 01:28
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (kzhao, AndrewAMD, bigsmack), 824 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Grid tile highlighting? #314021
03/05/10 01:11
03/05/10 01:11
Joined: Nov 2007
Posts: 1,143
United Kingdom
DJBMASTER Offline OP
Serious User
DJBMASTER  Offline OP
Serious User

Joined: Nov 2007
Posts: 1,143
United Kingdom
Hi guys, I'm working on something for a level editor and i'm just throwing ideas together.

I'm trying to achieve individual tile highlighting on my grid. I've sort of got it to work, by tracing through the 3D mouse onto my grid and setting a position, but it seems to be a little inaccurate and I can't reach every position on the grid.



If anyone would be so kind as to take a look and help me see where I can improve my code, or give another solution then i'd be very grateful.

Thanks, DJB.

Last edited by DJBMASTER; 03/05/10 19:44.
Re: Grid tile highlighting? [Re: DJBMASTER] #314034
03/05/10 07:59
03/05/10 07:59
Joined: Oct 2007
Posts: 5,210
İstanbul, Turkey
Quad Offline
Senior Expert
Quad  Offline
Senior Expert

Joined: Oct 2007
Posts: 5,210
İstanbul, Turkey
q auick try:

tile.x = hit.x- (hit.x% grid_size) + grid_size/2;
tile.y = hit.y- (hit.y% grid_size) - grid_size/2;

(only this 2 lines in if changed)


3333333333
Re: Grid tile highlighting? [Re: Quad] #314043
03/05/10 09:45
03/05/10 09:45
Joined: Oct 2004
Posts: 4,134
Netherlands
Joozey Offline
Expert
Joozey  Offline
Expert

Joined: Oct 2004
Posts: 4,134
Netherlands
I have been playing around a bit but I couldn't find a solution that's significantly better. vec_set( mouse_cursor, mouse_pos ) strikes me as odd though. It should be the other way around. But nothing improves with that.


Click and join the 3dgs irc community!
Room: #3dgs
Re: Grid tile highlighting? [Re: Joozey] #314076
03/05/10 15:41
03/05/10 15:41
Joined: Nov 2007
Posts: 1,143
United Kingdom
DJBMASTER Offline OP
Serious User
DJBMASTER  Offline OP
Serious User

Joined: Nov 2007
Posts: 1,143
United Kingdom
@Joozey, yeh that was a mistake, but like you said it doesn't seem to change anything.

@Quadraxas, thanks that seems to improve it. I can reach any part of the grid now. The only problem is that it only works if I don't move the camera, but only rotate it. From the start position, the tile seems to keep in sync with the mouse position, but if I change the camera position then it starts to become offset from it.

I guess this is dependent on the distance from the plane, so any ideas how I can use the result from the c_trace, to make the dragging proportional?

Thanks again guys.

Re: Grid tile highlighting? [Re: DJBMASTER] #314098
03/05/10 17:55
03/05/10 17:55
Joined: Oct 2007
Posts: 5,210
İstanbul, Turkey
Quad Offline
Senior Expert
Quad  Offline
Senior Expert

Joined: Oct 2007
Posts: 5,210
İstanbul, Turkey
oh, i'll also look in to that.


3333333333
Re: Grid tile highlighting? [Re: Quad] #314105
03/05/10 18:32
03/05/10 18:32
Joined: Oct 2007
Posts: 5,210
İstanbul, Turkey
Quad Offline
Senior Expert
Quad  Offline
Senior Expert

Joined: Oct 2007
Posts: 5,210
İstanbul, Turkey
solved:

it's actually not related the camera pos/angle, it's related to hit.x or hit.y being negative or positive.

tile.x = hit.x - (hit.x% grid_size) + (grid_size/2) * sign(hit.x);
tile.y = hit.y - (hit.y% grid_size) + (grid_size/2) * sign(hit.y);

Last edited by Quadraxas; 03/05/10 18:32.

3333333333
Re: Grid tile highlighting? [Re: Quad] #314111
03/05/10 19:01
03/05/10 19:01
Joined: Nov 2007
Posts: 1,143
United Kingdom
DJBMASTER Offline OP
Serious User
DJBMASTER  Offline OP
Serious User

Joined: Nov 2007
Posts: 1,143
United Kingdom
Great! There's only a little bug that sometimes the highlighted tile will jump to a space outside the grid, but that can be fixed by clamping the position.

Thanks again , owe you one.

Re: Grid tile highlighting? [Re: DJBMASTER] #314121
03/05/10 20:08
03/05/10 20:08
Joined: Oct 2007
Posts: 5,210
İstanbul, Turkey
Quad Offline
Senior Expert
Quad  Offline
Senior Expert

Joined: Oct 2007
Posts: 5,210
İstanbul, Turkey
Anytime wink

Keep up the great work with Easy Scripter, i can't wait to get my hands on it.


3333333333
Re: Grid tile highlighting? [Re: Quad] #314130
03/05/10 21:35
03/05/10 21:35
Joined: Nov 2007
Posts: 1,143
United Kingdom
DJBMASTER Offline OP
Serious User
DJBMASTER  Offline OP
Serious User

Joined: Nov 2007
Posts: 1,143
United Kingdom
Thanks. Hopefully with this tile editor i'm working on, it'll be something special laugh.

One thing that I'm wondering about is the performance. If each tile is a seperate entity, then adding too many tiles is going to be a big performance hit.

I'm just talking about the editor. They'll be written out as blocks when compiled.

Any advice how I can increase performance?

Last edited by DJBMASTER; 03/05/10 21:36.
Re: Grid tile highlighting? [Re: DJBMASTER] #314132
03/05/10 21:40
03/05/10 21:40
Joined: Oct 2007
Posts: 5,210
İstanbul, Turkey
Quad Offline
Senior Expert
Quad  Offline
Senior Expert

Joined: Oct 2007
Posts: 5,210
İstanbul, Turkey
reset(ent,DYNAMIC);


3333333333
Page 1 of 2 1 2

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1