Importing CSV data into Stingray

Importing CSV data into Stingray

Anonymous
Not applicable
1,056 Views
3 Replies
Message 1 of 4

Importing CSV data into Stingray

Anonymous
Not applicable

Hi,

 

I am currently debating if to use Stingrary for my thesis, depending if what I want to do is possible with it.

In short, I am bringing in CSV data that is gathered from an external source and I want to know if Stingray can actually read the CSV file, and be able to parse it.

Ultimately, I would like to generate meshes based on the information found in the CSV file and have the user be able to navigate around those meshes.

 

The requirements:

  1. Automate the import of CSV data into Stingray every n seconds
  2. Generate meshes based on the information within the CSV file in real-time (i.e. while game is running)
  3. Allow the user freedom of navigation within this constantly evolving "landscape"

I know something similar can be achieved with Maya and Python (but not in real-time, unfortunately). That is why I'm looking to see if Stingray can provide this. I verified that UE4 does allow CSV input, but I do not have a C++ background.

 

Alternatively, it doesn't have to be CSV, it could be any other format that would allow for large amounts of data to be parsed in columns and rows (like JSON). The reason I'm asking for CSV is that I already wrote a Python framework to output the data as such.

 

Please let me know if it's doable. Even if that means translating the Python code to Lua/Flow.

 

Thank you.

Reply
Reply
0 Likes
Accepted solutions (1)
1,057 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable

Hi, My first guess would be yes. There is a textbook "Programming in Lua", written and created by Roberto Ierusalimschy and he has shown that Lua has C/C++ compatibility/portability and their is a decent string parser, though the parser may depend on the size of the data, which will probably send you to C application. Took me a one week read to get a good feel of Lua. I suggest acquiring this book, because if you can do it in Lua, you can do it in Stingray. Also: 

 

http://help.autodesk.com/view/Stingray/ENU/?guid=__lua_ref_obj_stingray_NavigationMesh_html 

 

refers to vertex manipulation. You may also want to peruse through the guide: 

 

http://help.autodesk.com/view/Stingray/ENU/

 

If not, I guessed wrong.

 

Cheers. 

Reply
Reply
Message 3 of 4

Anonymous
Not applicable
Ack?! the first link did not work...

I was linking you here ---> stingray.NavigationMesh.vertex()
Reply
Reply
Message 4 of 4

dave.tyner
Alumni
Alumni
Accepted solution

Hi, I did a similar thing to hotload meshes from a csv of Vector3 coordinates. You might have to change some stuff but I think this is what you're after. 

 

 

 

function spawnstuff(pos)

    local world = SimpleProject.world
    
    local x = 0;
local arr,nVec1,nVec2,nVec3 local y = 0; local uPos,unit,rd,nVec,arr,unitName for k,v in pairs(pos) do arr = {} x=0 for n in string.gmatch(v,"[^,]+") do table.insert(arr,n) end nVec1 = tonumber(arr[1]); nVec2 = tonumber(arr[2]); nVec3 = tonumber(arr[3]); uPos = stingray.Vector3(nVec1,nVec2,nVec3); unitName = randomUnit() unit = stingray.World.spawn_unit(world, unitName) stingray.Unit.set_local_position(unit,1,uPos); end end function file_exists(file) local f = io.open(file, "rb") if f then f:close() end return f ~= nil end function lines_from(file) if not file_exists(file) then return {} end lines = {} for line in io.lines(file) do lines[#lines + 1] = line end return lines end function getFileData() local directory = "<DRIVE>:/path/to/file/" local i, t, popen = 0, {}, io.popen for filename in popen('dir "'..directory..'" /b '):lines() do i = i + 1 if string.find(filename,"YOUR FILE EXTENSION") then local count = 1 local fullFileName = (directory .. filename); local mydata = lines_from(fullFileName) spawnstuff(mydata); end end end

 

 

Reply
Reply