2-D Images
by Marcel Boule · in Torque Game Engine · 03/27/2006 (11:36 pm) · 5 replies
I would like add a class to the engine that handles some 2-D highly interactive imagery.
In the long run, this object will interact with the player mouse and have an in-depth relationship with the game mechanics, but for now I would be happy to simply draw something on the screen.
What class would I extend to be able to draw my own images (scaled and rotated, 2-D)?
From there, I will have a group of these things working together and I will need to extend some class that has a "processTick" function and something to render itself, but not much else (I think, for now). Which class is the best bet for that?
Thank you.
In the long run, this object will interact with the player mouse and have an in-depth relationship with the game mechanics, but for now I would be happy to simply draw something on the screen.
What class would I extend to be able to draw my own images (scaled and rotated, 2-D)?
From there, I will have a group of these things working together and I will need to extend some class that has a "processTick" function and something to render itself, but not much else (I think, for now). Which class is the best bet for that?
Thank you.
About the author
#2
Looking at GuiControl it seems to do a lot of what I want but then not some things, or some things incorrectly.
I need to invoke my onMouseEnter() when the mouse enters a circular area.
I need to run "processTick()" each frame to calculate the position of the object and how it interacts with the game world.
I can certainly work around the first problem, but working around the second is hacky at best.
I should point out that this object is not at all a control but highly interactive with both the mouse and game world, and very animated.
My main object is composed of simple triangles which are each individually rotated, positioned, and drawn.
I think there may be a better class for those to extend that has less of a control-like nature; performance is an issue and these things will bog down the frames if they are all catching mouse events and other GUI events.
The main object then can extend GuiControl but needs a processTick() to tell the triangles how to act.
Is there anything like this from which I can extend?
I may need to extend from multiple classes, but in which case, which ones?
Thank you.
03/28/2006 (12:33 am)
For future reference, how can I know when to post in general or when to post in private?Looking at GuiControl it seems to do a lot of what I want but then not some things, or some things incorrectly.
I need to invoke my onMouseEnter() when the mouse enters a circular area.
I need to run "processTick()" each frame to calculate the position of the object and how it interacts with the game world.
I can certainly work around the first problem, but working around the second is hacky at best.
I should point out that this object is not at all a control but highly interactive with both the mouse and game world, and very animated.
My main object is composed of simple triangles which are each individually rotated, positioned, and drawn.
I think there may be a better class for those to extend that has less of a control-like nature; performance is an issue and these things will bog down the frames if they are all catching mouse events and other GUI events.
The main object then can extend GuiControl but needs a processTick() to tell the triangles how to act.
Is there anything like this from which I can extend?
I may need to extend from multiple classes, but in which case, which ones?
Thank you.
#3
When you're asking for code examples, or simply when there's no point in placing the post in public (like your post) because the only one's who can answer it and benefit from it - are licensees, then you should post it in private.
About your question, I wouldn't go as deep as into the GuiControl base though.
Just take a look how all the bitmap controls work and implement your specific stuff there, unless you want to really draw lines and colors using math?
03/28/2006 (1:54 am)
Quote:
For future reference, how can I know when to post in general or when to post in private?
When you're asking for code examples, or simply when there's no point in placing the post in public (like your post) because the only one's who can answer it and benefit from it - are licensees, then you should post it in private.
About your question, I wouldn't go as deep as into the GuiControl base though.
Just take a look how all the bitmap controls work and implement your specific stuff there, unless you want to really draw lines and colors using math?
#4
I think it would be usable except for a few things.
What would be the least "hacky" way to get a processTick() on these little buggers?
onRender() is called every frame (right??) but that is definitely not where I want it to process its AI.
And also, if I wanted to rotate my image, I guess I have to write my own routine to draw it in rotated form?
Thank you.
03/28/2006 (2:22 am)
I'm looking at GuiBitmapCtrl.I think it would be usable except for a few things.
What would be the least "hacky" way to get a processTick() on these little buggers?
onRender() is called every frame (right??) but that is definitely not where I want it to process its AI.
And also, if I wanted to rotate my image, I guess I have to write my own routine to draw it in rotated form?
Thank you.
#5
-or possibly you want some variation of billboarded particles ?
those are highly dynamic and won't be processing mouseMove events.
altho how you plan on having onMouseEnter() without processing mouseMove is intrigueing.. ;)
re processTick() for GuiControls in general, i think onPreRender() would be the place.
ben garney recommends it in this thread.
re guiControl vs guiBitmapControl; whatever works best !
03/28/2006 (8:23 am)
@marcel - well, you could draw your image as a texture on a 2D quad and rotate the quad.-or possibly you want some variation of billboarded particles ?
those are highly dynamic and won't be processing mouseMove events.
altho how you plan on having onMouseEnter() without processing mouseMove is intrigueing.. ;)
re processTick() for GuiControls in general, i think onPreRender() would be the place.
ben garney recommends it in this thread.
re guiControl vs guiBitmapControl; whatever works best !
Associate Orion Elenzil
Real Life Plus
but the answer is GuiControl.
look at how it draws its border and fill;
that should give you a reasonable starting point for custom 2D control stuff.