Panning world and TimelineFX
Home › Forums › TimelineFX Module › Panning world and TimelineFX
- This topic has 10 replies, 3 voices, and was last updated 14 years, 12 months ago by Imphy.
-
AuthorPosts
-
December 13, 2009 at 2:19 pm #3140
ImphyParticipantBackground:
I’ve got my own viewport and camera control setup in a 2D world and my next encounter is getting the effects to work as planned in this world. I’ve got a world that is 2048×1024 in size and my viewport is let’s say 1024×768. As I drive around in this landscape I use my own viewport function to center on the camera on object that I drive. When you approach the end of the larger world the camera stops within boundary and my vehicle drives closer to the boundary.I can get the smoke emitting effect to be placed exactly where my object is in my world because I get the onscreen coordinates from my viewport function. The problem I encounter is while the camera is panning and the smoke is emmited from the correct place, the smoke trail does not because it uses onscreen coordinates for the particles rather than my large world coordinate system.
Here’s a video of what I mean:
http://www.youtube.com/watch?v=wSKcBl_j0IUI’ve tried to mess about with SetOrigin but the problem isn’t where the emitter is, but where the historic particles are.
Any thoughts?
December 14, 2009 at 12:19 am #3553
imported_peterigzParticipantHi Imphy, how do you attach the effect to the car? It looks to me that when the car is centered on screen the emitter world coordinates no longer change, when it should instead be moving through the world still. Maybe there is no translation from screen space into world space? If you give the emitter coordinates the same as the vehicles world coordinates, then in theory that should be enough, as long as the origin of the particle manager is aligned properly with your world.
It seems like you might be getting the screen coordinates of the vehicle for the emitter instead, which is messing things up when the vehicle no longer moves in screenspace because it’s centered on screen.
Let me know how you get on 🙂
December 14, 2009 at 12:51 am #3555
ImphyParticipantThanks for your reply.
I use smokeeffect.setx() and .sety() to set the position of the smokeeffect and the coordinates i use are world-to-screen translated for the object.
The object has a position in the space 2048 x 1048 and when i use my method getObjTranslatedX() it takes the X-coordinate in world space and converts it to screen space using parameters such as my viewport X,Y, width, and height along with it’s cameraX and cameraY position.
Maybe I need to rethink how I translate my world to screen?
December 14, 2009 at 2:31 am #3556
imported_peterigzParticipantI would just place the effect at exactly the same world coordinates as the car then use particlemanager.setorigin. You might have to do something extra to line it up as by default a particle drawn at 0,0 coordinates is drawn at the centre of the screen.
So, if your map/camera position is 0,0 and the coordinates of one of your game objects is 0,0, then is it drawn at the centre of the screen, or the top left of the screen?
If it’s the top left then you’ll probably need something like:
ParticleManager.SetOrigin(MapPosition_X+GraphicsWidth()/2, MapPosition_Y+GraphicsHeight()/2)
otherwise just
ParticleManager.SetOrigin(MapPosition_X, MapPosition_Y2)
maybe enough.
December 15, 2009 at 12:59 am #3557
ImphyParticipantThanks so far, getting closer.
Using:
myparticlemanager.SetScreenSize(viewport.getWidth(), viewport.getHeight())
MyParticleManager.SetOrigin( obj_tank_base.getX() – viewport.getX(), obj_tank_base.getY() – viewport.getY())I get it correct once panning the world and object is in center. Now I just need to compensate when camera reaches boundary and the vehicle drives off center and near the edges. Will report back 🙂
December 15, 2009 at 4:27 pm #3558
imported_peterigzParticipantMaybe you could update the particlemanger origin by the camera position? So something like:
MyParticleManager.SetOrigin( camera.getX() - viewport.getX(), camera.getY() - viewport.getY())
December 15, 2009 at 11:04 pm #3559
ImphyParticipantI get lost in translation when it comes to multiple coordinate spaces but with your help this did the trick:
MyParticleManager.SetOrigin( viewport.getCameraX() – viewport.getX() + viewport.getWidth()/2, viewport.getCameraY() – viewport.getY() + viewport.getHeight()/2)
You’ve truly done an amazing job with this module – and editor 🙂 Did you use MaxGUI for the editor by the way? I’m evaluating what GUI to use for the mapeditor for my tile-engine.
December 15, 2009 at 11:19 pm #3560
imported_peterigzParticipantThanks, good to see you got it working 😎
For the GUI I used wxWidgets, which was wrapped into a module by Brucey. I did originally use maxgui but I re-wrote in wx as I found that maxgui got a bit limiting after a while. wxWidgets has a steeper learning curve but I found it a much better way of working in the end.
December 16, 2009 at 9:30 am #3561
thomashaaksParticipantPete,
I think it would be nice to have some simple sample code with a scrolling world and properly scrolling emitters 😉Do you think you could create something?
Thanks,
TommyDecember 16, 2009 at 10:44 am #3562
imported_peterigzParticipantWatch this space 🙂 I’m currently finishing off Rigz.Collision which will be complete with quadtrees allowing for managing game worlds like this much more easier. The particle manager will start using quadtrees quietly in the background to manage off screen culling and upadating of effects much more efficiently.
I’ll definitely write a few examples then for exactly this type of thing.
December 16, 2009 at 4:00 pm #3563
ImphyParticipantSounds interesting with your collisions. I’m in the process of making a scalable tile engine without the traditional limitations and unlimited layer and transition support etc. I probably have to create my own collisions for it to integrate fully but considering your efforts with timelineFX I’ll be keeping my eye at your progress 🙂
I’ll have a look at wxWidges as well, I bought ifsogui to have a play around with – I like to sponsor projects even though I’m unsure I will use it for sure.. but I’m quite happy with the simple approach of ifsogui.
-
AuthorPosts
You must be logged in to reply to this topic.