|
Grid tile highlighting?
#314021
03/05/10 01:11
03/05/10 01:11
|
Joined: Nov 2007
Posts: 1,143 United Kingdom
DJBMASTER
OP
Serious User
|
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
Senior Expert
|
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: Joozey]
#314076
03/05/10 15:41
03/05/10 15:41
|
Joined: Nov 2007
Posts: 1,143 United Kingdom
DJBMASTER
OP
Serious User
|
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: Quad]
#314105
03/05/10 18:32
03/05/10 18:32
|
Joined: Oct 2007
Posts: 5,210 İstanbul, Turkey
Quad
Senior Expert
|
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: DJBMASTER]
#314121
03/05/10 20:08
03/05/10 20:08
|
Joined: Oct 2007
Posts: 5,210 İstanbul, Turkey
Quad
Senior Expert
|
Senior Expert
Joined: Oct 2007
Posts: 5,210
İstanbul, Turkey
|
Anytime 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
OP
Serious User
|
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 . 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.
|
|
|
|