Say I’m working on a flight sim, which would have simple 2D graphics in the viewing plane (children of aspect2d). If the basic task is “draw a bunch of green lines,” that will be animated, what’s the best way? I was expecting there’d be a “just draw a line in the aspect2d plane” sorta convenience thing somewhere in the panda API. Is there such a thing?
I found the GUI section of the docs and can, for instance, use CardMaker to make a long, narrow card and color it green, or maybe use a technique of some kind to make it conjoin with other similar line-like cards as-needed (say, texture it so the ends are rounded so they fit together okay at different angles).
But I can also make a large card and place it where the HUD will go on the screen and keep it updated with a dynamically-generated texture every frame, setting transparency/alpha appropriately. I suppose I’d find a 3rd-party vector-drawing library for this? Sorta blit every frame?
Greetings, and welcome to the forum! I hope that you find your time here to be enjoyable and constructive!
As to your question, let me answer with a question in turn: What do you have in mind to render with these lines? Are they to be largely-unchanging HUD elements? A small number of simple lines (e.g. lines pointing to enemy aircraft)? Wireframes of aircraft? (And if such wireframes, do they need to rotate in 3D space, e.g. to represent the relevant object’s orientation relative to the player?) Something else…?
What you have in mind may affect what approach I might be inclined to suggest!
The broad idea is a space fleet combat game similar to Homeworld or Star Hammer. It’s just an idea that’s cool to me, to keep me motivated.
As you guessed, I want to have indicators to show which ship is currently selected, etc, in plain outlines like squares and diamonds, like lock-on indicators in a flight sim. These would move with the object they refer to, but wouldn’t be animated.
What’s more mysterious is how to animate a line. For instance I’d like to provide a 3D radar to help the viewer reason spatially; copying Elite Dangerous was my initial idea:
The user would see vertical lines for altitude; these would extend or contract dynamically as objects move.
Okay, I might be inclined to handle those two UI elements separately and differently:
As the indicators don’t animated, I might represent them as actual polygonal models that just happen to look like simple lines. These could then be placed in aspect2d as desired.
The vertical lines I can see three approaches to:
First, if there’s always an opaque surface below them, and we can be confident of a reasonably-low maximum number of units to so mark, then I might try keeping a pool of tall, thin quads (i.e. cards) and then simply placing them appropriately. Specifically, their vertical placement would determine the “length” of the resulting line, with their remaining extent being hidden by the opaque floor.
Second, if there are expected to be a larger number of units, or if there is no opaque flooring below them, then I might use the MeshDrawer class to dynamically generate quads to represent the lines, updating this representation every frame.
And third, if there are expected to be a very great number of units, then… well, I would expect such a UI to be overly cluttered, but nevertheless, I might look into a vertex shader operating on a chunk of geometry.