Welcome to Keen Software House Forums! Log in or Sign up to interact with the KSH community.
  1. You are currently browsing our forum as a guest. Create your own forum account to access all forum functionality.

Render a List<Vector3I> on LCD?

Discussion in 'Programming Questions and Suggestions' started by Sumguy720, Jun 25, 2016.

Thread Status:
This last post in this thread was made more than 31 days old.
  1. Sumguy720 Trainee Engineer

    Messages:
    19
    I made a script that creates a List<Vector3I> of all the positions of all the blocks on a ship, and I want to render that list on an LCD panel.

    First, it would be really nice if there was a way to easily project the vectors onto a 2D matrix somehow. I can do it now, but it is basically three nested FOR loops with a List.Contains(new Vector3I(i,j,k)); which seems... more brute force than it should be.

    Also, it seems like Keen doesn't let us use the 2D int[,]. Only the 1D version: int[]. So once I break down my vectors I have no way to store them in an image-like format. Is there a 2D storage solution ingame?

    My biggest obstacle though, is rendering to an LCD once I have it all flattened out. Has someone already written a program that could handle my kind of data? Either a list of 2d vectors or 3d vectors? An int array?

    So I'm basically wondering if anyone has some thoughts/advice on how to do these kinds of things or overcome these kinds of obstacles.
     
  2. Wicorel Senior Engineer

    Messages:
    1,262
    "Rendering" is a bit misused, I think.

    You want to serialize your data for storage, right?

    Why can't you just iterate through the list and output the values?

    For example, formatted one line per Vector3I with value separated by commas?
     
  3. plaYer2k Master Engineer

    Messages:
    3,160
    Multidimensional arrays are a bit limited right now but the next weeks dev branch change promises a whole lot with their step over to Rosly thanks to @Malware (once again <3).

    The simple and "pretty" multidimensional arrays a'la Cake[,] dont work due to issues with the code injection used for ingame programming. These are always NxM for 2D and thus all arrays in one dimension are equally long.
    What you have to use are jagged arrays, which essentially are arrays of arrays, and thus Cake[][]. There you cant just initialize Cake[9][2] but instead have to initialize Cake[9][] and for all "second-order-arrays" you have to initialize them separately while looping over the "first-order-array". These can have different array lengths per dimension and thus Cake[j].Length != Cake[k].Length can be true for any j != k and 0 <= j,k < Cake.Length.

    As small code example, this is what one would prefer:
    Code:
    Cake[,] omnomnom = new Cake[10,5];
    But instead you have to do:
    Code:
    Cake[][] omnomnom = new Cake[10][];
    for(int i = 0; i < omnomnom.length; i++)
      omnomnom[i] = new Cake[5];
    But again, this quite likely will be fixed next week on the dev branch. There likely/probably/hopefulynot will come other bugs in exchange or it will be wonderful out of the box.
    So while jagged arrays do work and will continue to work afterwards, they often are not desired.


    I also agree with @Wicorel there. The "render" part seems to be off, or do you actually mean to draw a 2D image (lines, dots) on the text panel? In that case, it "aint possible*" because there is no such function for ingame programming. The ModAPI however has MySimpleObjectDraw for various 2D and 3D figures in 3D space.

    * There is however a way to abuse the XBox controller characters as crude and low resolution matrix display. In addition to that, some attempts to add "pixel" as characters to the font exist so that more colored displays with "pixel access" (character manipulation) exist.
     
  4. Sumguy720 Trainee Engineer

    Messages:
    19
    Man, bummer about the 2d arrays. Well I did hack a rendering script together using the cyrilic w looking character since it is close in size to three spaces. I basically am working on an MRI style rendering program for ships so you can diagnose damage on the fly. I'll be uploading a video soon. It draws a picture of your ship on the LCD in a series of cross sections.

    Eagerly anticipating the upcoming changes next week in the dev branch! Though I might wait for it to come out in stable, because I'm am escared.
     
Thread Status:
This last post in this thread was made more than 31 days old.