2 registered members (AndrewAMD, rki),
390
guests, and 0
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
isometric distance to object and size
#450965
04/25/15 22:35
04/25/15 22:35
|
Joined: Dec 2011
Posts: 1,823 Netherlands
Reconnoiter
OP
Serious User
|
OP
Serious User
Joined: Dec 2011
Posts: 1,823
Netherlands
|
Good day, In manual I saw this under the flag 'Isometric': The distance of the camera to an object does not affect its size on the screen in this mode; How to do this for every entity seen on the view but still being able to change the arc / view borders? Basically I have 2 views, 1 is default camera view and the other is the isometric one. I want to clearly see units from above on the isometric view regardless of the distance between the isometric view and the unit, and being able to zoom in and out which I want it to only change the x/y pos of units on the view and not the size of the units (which currently changing arc/view borders does). Thanks for taking the time.
|
|
|
Re: isometric distance to object and size
[Re: Superku]
#451044
04/27/15 18:00
04/27/15 18:00
|
Joined: Sep 2003
Posts: 9,859
FBL
Senior Expert
|
Senior Expert
Joined: Sep 2003
Posts: 9,859
|
Maybe this helps in some way. I wrote it for the Ackmania isometric camera. The main reason was to make sure the distance doesn't change with different screen resolution (width being the master), but there is also an additional distance calculation, so the camera can move further away depending on the speed of the object in focus. I use some reference screen width and arc to calculate a default width (vViewWidth). For further calculation I can always refer to this default width. The calculation looks a bit strange (no, I haven't researched why the formula has to look like this), but basically it's just jcl's formula from the manual, rearranged so I can calculate what I need without taking assumptions or try and error.
#define CAMERA_DIST 2000
#define CAMERA_PAN 45
#define CAMERA_TILT -25
#define CAMERA_SPEEDFAC 0.015
#define CAMERA_REFSCRSIZEX 1920
#define CAMERA_REFARC 60
void create_camera(int layer)
{
cam = view_create(layer);
cam->pan = CAMERA_PAN;
cam->tilt = CAMERA_TILT;
cam->flags |= ISOMETRIC;
/* width = view.size_x * 2 * tan(view.arc/2); - from manual (view.arc) */
vViewWidth = CAMERA_REFSCRSIZEX * 2 * tanv(CAMERA_REFARC * 0.5);
}
void update_camera()
{
VECTOR vecPos;
if (camera_focus_ent != NULL)
{
vec_set(vecPos, vector(-CAMERA_DIST, 0, 0));
vec_rotate(vecPos, cam->pan);
vec_add(vecPos, vector(camera_focus_ent->x, camera_focus_ent->y, 0));
vec_set(cam->x, vecPos);
vDistanceFactor += ((is_kart_accelerating(camera_focus_ent) > 0) * 0.05 - 0.02) * time_step;
vDistanceFactor = clamp(abs(vDistanceFactor), 0.28, 0.6);
/* view.arc = 2*atan(width/(view.size_x * 2)); - from manual (view.arc) */
/* change camera arc by manipulating view size - delivers resolution independent result */
cam->arc = 2 * atanv(vViewWidth * 0.5 / (screen_size.x / vDistanceFactor));
}
}
The first part is only a follow-object implementation, but the vDistanceFactor stuff and the calculation might help.
|
|
|
Re: isometric distance to object and size
[Re: FBL]
#451066
04/28/15 09:33
04/28/15 09:33
|
Joined: Dec 2011
Posts: 1,823 Netherlands
Reconnoiter
OP
Serious User
|
OP
Serious User
Joined: Dec 2011
Posts: 1,823
Netherlands
|
Hi guys, Of course entities are rendered smaller when you increase the isometric view volume, everything would be highly confusing and impractical (I suggest you google isometric and perspective rendering). , I know , this isn't for a normal view. I assume you want to create some kind of radar functionality (and don't want to use 2D objects like panels or draw_...)? What you could do is fill the entity's scale_x vector (let's say with a view.right/256.0 formula) or do the scaling in a vertex shader which would be notably faster when you have to scale often/ every frame. , yes its something like that and zoom in and zoom out would only determine how many ents are on the screen and it should look clustered instead of very tiny ents. So that's why I want to keep them look the same regardless of the distance. I had been thinking about scaling but it seems like a very slow proces when scaling alot of them, though the vertex shader sounds very interesting, would that still work when I want to select an entity on the VIEW through mouse click? @Firoball, that's interesting, I don't think I can use it cause I already use the border/arc for determining the visible part of the map, but thanks nonetheless.
|
|
|
|