Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411512 Posts in 69376 Topics- by 58430 Members - Latest Member: Jesse Webb

April 27, 2024, 03:05:35 AM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)General thread for quick questions
Pages: 1 ... 6 7 [8] 9 10 ... 69
Print
Author Topic: General thread for quick questions  (Read 135452 times)
indie11
Level 2
**


View Profile
« Reply #140 on: August 11, 2015, 10:40:13 AM »

I have a big 3D environment in Unity with 2 points marked on it with latitude and longitude values. How can I convert these 2 points to unity world coordinates?

 

I'm not sure of the context, do you want to convert the polar coordinate to a flat map (the big environment with lat/lon) or do just want to find the equivalent 3D point from polar coordinate to carthesian?

if the latter look the post above, else you have a "torus paradox" (made up term) on your hand

I have Longitude/Latitude of two buildings in a plain 3D Environment. Is it possible to calculate the longitude and latitude step using only the long/lat values of the two buildings?
Logged

oahda
Level 10
*****



View Profile
« Reply #141 on: August 11, 2015, 10:51:14 AM »

Do you mean that if I simply split the bitriangular quad into a bunch of more triangles, OpenGL will optimise out all the triangles outside of the screen automatically, even if there's still just one big texture UV-mapped over the whole mesh, making it faster than drawing the same one big texture on a quad made up of only two triangles? Or something else?

OpenGL will optimize that out as much as that it will not run the fragment shader, it still has to run the vertex shader of course, and you still have to send all the vertices to the GPU. One single big quad is better than many small ones, but it takes time to generate that big quad if you do it dynamically.
It might just work, because the fragment shader is the big problem, doing all of the cool and heavy=slow stuff. I don't think the vertex shader is much of a problem.

But exactly what did you mean then? What do you mean by dynamically?
Logged

Layl
Level 3
***

professional jerkface


View Profile WWW
« Reply #142 on: August 11, 2015, 11:14:15 AM »

It might just work, because the fragment shader is the big problem, doing all of the cool and heavy=slow stuff. I don't think the vertex shader is much of a problem.

But exactly what did you mean then? What do you mean by dynamically?

Keep in mind it won't run the fragment shader for pixels outside the screen on one large quad as well. All this information is only useful if you're rendering data that has to change dynamically. There's no reason at all to split things up if you can just render a single static texture every time.
Logged
oahda
Level 10
*****



View Profile
« Reply #143 on: August 11, 2015, 11:17:23 AM »

Hm... Wonder what the best solution might be then.
Logged

gimymblert
Level 10
*****


The archivest master, leader of all documents


View Profile
« Reply #144 on: August 11, 2015, 12:10:43 PM »

I have a big 3D environment in Unity with 2 points marked on it with latitude and longitude values. How can I convert these 2 points to unity world coordinates?

 

I'm not sure of the context, do you want to convert the polar coordinate to a flat map (the big environment with lat/lon) or do just want to find the equivalent 3D point from polar coordinate to carthesian?

if the latter look the post above, else you have a "torus paradox" (made up term) on your hand

I have Longitude/Latitude of two buildings in a plain 3D Environment. Is it possible to calculate the longitude and latitude step using only the long/lat values of the two buildings?


I don't understand, define plain 3D environement, are you trying to have the building spawn relative to each other on a flat surface, or are you going for a 3D sphere (both are plain 3D) do you plan to have a whole map build on wraping itself, or you have definite boundaries to the maximum map?
Logged

indie11
Level 2
**


View Profile
« Reply #145 on: August 11, 2015, 09:05:57 PM »

Sorry I just can't explain it properly..

Its a flat surface with defined boundaries and has some little bumps but you can neglect them

There is a building A in the 3D Environment and I know its latitude and longitude values.

I  place building B relative to Building A at a distance of 30meter( just assuming this distance )

Is it possible to find out the lat/lon values of building B?


Logged

BorisTheBrave
Level 10
*****


View Profile WWW
« Reply #146 on: August 12, 2015, 12:17:32 PM »

Is it possible to find out the lat/lon values of building B?
No. If all you know is a distance, then there is a circle around A of that radius, and B could be anywhere on it. You need to know the direction (bearing) as well as distances to place something relative to each other.

PS If you are dealing with a flat surface, then lattitude and longitude are the wrong words, those are used for navigating on a sphere. Yes, I know the earth is flat enough it's the same thing, but still, people will get the wrong impression. Use "X-Axis" and "Z-Axis" to be a bit clearer - that matches Unity's terminology.
Logged
gimymblert
Level 10
*****


The archivest master, leader of all documents


View Profile
« Reply #147 on: August 12, 2015, 12:42:56 PM »

Sorry I just can't explain it properly..

Its a flat surface with defined boundaries and has some little bumps but you can neglect them

There is a building A in the 3D Environment and I know its latitude and longitude values.

I  place building B relative to Building A at a distance of 30meter( just assuming this distance )

Is it possible to find out the lat/lon values of building B?




Read that https://en.wikipedia.org/wiki/Geographic_coordinate_system

And position of B is all the position that satisfies the distance, ie a circle around A, so yes it's possible, but it's not one position, you need more discriminant. The trick is that it's unlikely that a circle on sphere happen to be a circle too on the 2D projection.

Also you will have trouble if you cross the meridian and the "pole line" (on a 2D projection) which need specific case. SO that given starting position an distance I hope you are as far as possible as these arbitrary boundary.
Logged

TammiDev
Level 0
***


View Profile
« Reply #148 on: August 13, 2015, 11:31:57 AM »

Hey, quick question:

In Unity when I set a canvas active/ inactive I experience a slowdown in my game. Should I set the individual components in the canvas active/ inactive. Is the slowdown maybe because I'm not doing it in a thread? Should I be doing something else instead of SetActive to switch visibility of the views?
Logged
gimymblert
Level 10
*****


The archivest master, leader of all documents


View Profile
« Reply #149 on: August 26, 2015, 05:06:48 PM »

Quick JSON question

How does it work in practice? I just load the json and then it's a structure readuy to use? or I have to declare a class to pass it first?
Logged

zleub
Level 0
**


View Profile WWW
« Reply #150 on: August 26, 2015, 05:24:40 PM »

I think json is always meant to be parsed and load into a proper data-structure (hashtable), it depend on your language utilities.
Logged
ThemsAllTook
Administrator
Level 10
******



View Profile WWW
« Reply #151 on: August 26, 2015, 07:51:02 PM »

Quick JSON question

How does it work in practice? I just load the json and then it's a structure readuy to use? or I have to declare a class to pass it first?

Since you mentioned in the other thread that you're using C#: http://wiki.unity3d.com/index.php/SimpleJSON

It's a pretty nice implementation, but there was one bug I had to fix to get it not to barf when parsing null values. Replace AddElement with this:

Code:
		static void AddElement (JSONNode ctx, string token, string tokenName, bool tokenIsString)
{
if (tokenIsString) {
if (ctx is JSONArray)
ctx.Add (token);
else
ctx.Add (tokenName, token); // assume dictionary/object

// Fix SimpleJSON's inability to parse null
} else if (token == "null") {
if (ctx is JSONArray)
ctx.Add (null);
else
ctx.Add (tokenName, null);

} else {
JSONData number = Numberize (token);
if (ctx is JSONArray)
ctx.Add (number);
else
ctx.Add (tokenName, number);

}
}
Logged

gimymblert
Level 10
*****


The archivest master, leader of all documents


View Profile
« Reply #152 on: August 26, 2015, 08:31:15 PM »

Oh thanks!

I'm still not sure how to use json in practice, What does the function return, how do I use it, etc ...

Most stuff are like "hey I heard you like json! here is a json stuff so you can use json in your program", but not stepping through an explanation of how to use it.

Still hunting tutorial
Logged

qMopey
Level 6
*


View Profile WWW
« Reply #153 on: August 26, 2015, 09:22:23 PM »

Well JSON is just a file format. What you do with it can be anything, though it's almost always parsed to do something else. So for example you have some game objects in your game, but you want to store them into a nice human-readable file and load them later. You can store them in JSON format, and then use an implementation (some library someone made) to do this. Then you can use this library to read the information in the JSON file later.

It's just an intermediary data format. Things are converted to JSON and then converted to something else later. The specifics of "what is a way I can use JSON" depends on what library you want to use that deals with the JSON file format.
Logged
gimymblert
Level 10
*****


The archivest master, leader of all documents


View Profile
« Reply #154 on: August 26, 2015, 09:51:29 PM »

I know what a json is, thanks.

I'm talking about its (ease) of use, specifically how to load structured data where I don't know the structure in advance when I query a "database" (actually a text file read line by line), so I can review its structure and decide what to do with it.

I have the same database in two format, csv and json. I'm actually parsing the csv but it seems there is inconsistency in the data (5gb). It's a real hassle to anticipate unknown structure when you have more than 6millions line (estimations).

The csv is "tab" delimited and field have nested "[]", ",", and "/" as delimiter with variable number of member and some other shenanigan.

I'm looking at json if I can just load the json in a way the computer understand and just loop through its data to automate checking without knowing the key (to discover them).

edit: also because arbitrary nested data is "hard" in a way I don't want to deal with now, and directly parsing the json as txt will take me more time because there is evidence of them due to the structure of json.
« Last Edit: August 26, 2015, 10:14:34 PM by Jimym GIMBERT » Logged

ThemsAllTook
Administrator
Level 10
******



View Profile WWW
« Reply #155 on: August 26, 2015, 10:19:37 PM »

The purpose of a JSON library is to translate between textual representation and some sort of object hierarchy that can be easily inspected at runtime. A typical usage pattern would be to load the file into a root object, inspect it to see what type it is (either object or array) and its number of children, then process the elements one by one to turn them into the normal data structures used in your game. You wouldn't usually keep the parsed object hierarchy around; it's an intermediate representation you use to bootstrap the real one.
Logged

gimymblert
Level 10
*****


The archivest master, leader of all documents


View Profile
« Reply #156 on: August 26, 2015, 10:43:48 PM »

Yes I know that and that's exactly what I want to do, open a json, analyse its structure, then translate that to a structure of my liking.

I understand what you are saying conceptually, just not practically. For example simpleJSON allow me to load data as simple value:pair table which I can query using the key, but how do I loop through the key? My problem is that I want to parse arbitrary structure where I don't know the key in advance.

Basically right now I want to be able to loop all the json in the database, look for inconsistency or parse relevant data after analyzing the structure.

for example: looking at all the "assertion type" and store them in a list by looking at when a new element appears, extract all unique "English concept" (/c/en/...) while storing the different type of other language in a list (the element after /c/), parse all the edge into their assertion as a list and replace their concept node into an index to the concept list. Concept also have variable member (separated by "/") so I need to keep track of the variation to look at it (storing the 3 members long in a list and other in another list for inspection). And sometime assertion have more than one member (concept) per slot that complicate stuff to tell them apart (which I assume are always two but don't know yet, I need to analyse that, that was my latest discovery).

In csv for example I have a lot of trouble because some line have 9 "tab" separated elements, some have 10, I check this early to check for consistency before actual parsing, I have no (not yet) any idea why there is this variation (blitz3D is not the best to visualize this stuff, and it's slow!). Fortunately for me I check data first before starting a complete parse because I' have been in for a lot of unannounced surprise by the doc. I have also spot in the 5GB some error where language and tagging don't match (antonym for sure can't have two concept from different languages, that's a basic check to implement, harder in practice for me), using the simple early consistency check.

My code is so spaghetti because of assumption made early (I can't parse nested arguments, also the way element are done is difficult to parse if the number of element is inconsistent) and also because I never have done stuff like that and burning out quickly so progress is slow

That's why I'm looking at json, I thought it was the easy way to translate the data to machine stuff in a structured non noisy fashion, on the basis I can loop into arbitrary field easily.

edit

here is my current code, it's mostly wrong and incomplete, it's a sandbox to check assumption right now

Code:
Include "blitz 3D test parser.bb" ;http://www.blitzbasic.com/codearcs/codearcs.php?code=161

;http://www.zytrax.com/tech/codes.htm
;HT-09-9-Horizontal Tab



; Set The Graphic Mode
Graphics 1800,600,0,2

; Open the file to Read
filein = ReadFile("C:\Users\user\Desktop\part_00.csv")

Print "Lines of text read from file " + filein

;skim through each line parsing and filtering data
While Not Eof( filein ) Or KeyHit (1)

Read1$ = ReadLine$( filein ) ; read a new line
parse( Read1, Chr(9) ) ; parse the line into chunk

prevcount = count
count = 0

;strip the non desired data from the chunk, discard useless chunk
For back.parsereturn=Each parsereturn ;flip through the chunk
If Left(back\word,3) = "/a/" And count < 1 Then ;old there no line without /a/
back\word = Replace (back\word,"/a/","")
back\word = Replace (back\word,"[","")
back\word = Replace (back\word,"]","")
back\word = Replace (back\word,"/c/","")
back\word = Replace (back\word,"/r/","")

;ouput useful part (english concept)
If Instr (back\word,",en/" ) Then
strip1$ = back\word;:Print strip1; ---> output
;WaitKey()
parsethis = 1
EndIf

EndIf
count = count +1
Next

;further parse and strip the data (before the next line because the parser use the same list)
;..........................

If parsethis = 1 Then
parse( strip1,",")
;Print Read1
stripcount = 0
;Print
For back.parsereturn = Each parsereturn
stripcount = stripcount + 1: ;Print stripcount

;back\word = Replace (back\word,"en","")

If stripcount = 1 Then back\word = Replace (back\word,"/","")
;If stripcount = 2 Then back\word = Replace (back\word,"/"," ")
;If stripcount > 1 Then back\word = Replace (back\word,"/"," ")
;Print back\word
If stripcount = 6 Then Print read1; back\word

parsethis = 0
Next
EndIf

If KeyHit (28) Then
WaitKey()
Print "pause"
EndIf
;Print

Wend

Print "end"

CloseFile( filein )
WaitKey()

edit 2
More about conceptnet 5 (I use the v5.3 it is at 5.4 now)
http://www.lrec-conf.org/proceedings/lrec2012/pdf/1072_Paper.pdf
« Last Edit: August 26, 2015, 11:45:13 PM by Jimym GIMBERT » Logged

zleub
Level 0
**


View Profile WWW
« Reply #157 on: August 27, 2015, 12:21:13 AM »

JSON use [] to specify an indexed-ordered table, which can be translated into queue and  {} for hashtable. Reference.

I would glady see the json you're troubling with, but such definition is correct and allow complete iteration :

Code:
[
{ "foo" : "bar" },
{ "foo" : "meh" }
]

[...] how to load structured data where I don't know the structure in advance when I query a "database" (actually a text file read line by line), so I can review its structure and decide what to do with it.

JSON is about opening stuff. You either open an queue or a hashtable while finals items can be about multiple types (numbers, string ...). If the struggle is about reading a file, you can read everything, replace those nasty new-lines by some space shit and build a parser upon it. If you're willing to do some serious stuff, some grammar can help you as well as tokens.
Logged
gimymblert
Level 10
*****


The archivest master, leader of all documents


View Profile
« Reply #158 on: August 27, 2015, 12:21:36 AM »

Using @themsAllTook simple json suggestion, I look at the code and located the class jsonclass, it seem that the data is stored in its private dictionaries and ways to access it is

Code:
	public override IEnumerable<JSONNode> Children
{
get {
foreach (KeyValuePair<string,JSONNode> N in m_Dict)
yield return N.Value;
}
}
 
public IEnumerator GetEnumerator ()
{
foreach (KeyValuePair<string, JSONNode> N in m_Dict)
yield return N;
}

I have no mastery of IEnumarator and don't know how to handle the yield, I guess it mean it will output a result every cycle.

SO I might add a way to access the dictionary immediately and parse it myself? I don't know yet the implication and if nested structure can be stored in a dictionary ...

Problem is that the "parse" function return a jsonnode of which jsonclass inherit as it is an abstract class ... I'm consude to where the data is store and how to access from the ROOT to iterate so far ...


edit: damn it the "children" function is used only used in a function call deepchildren which in itself is used nowhere ...
« Last Edit: August 27, 2015, 12:33:13 AM by Jimym GIMBERT » Logged

gimymblert
Level 10
*****


The archivest master, leader of all documents


View Profile
« Reply #159 on: August 27, 2015, 12:24:28 AM »

JSON use [] to specify an indexed-ordered table, which can be translated into queue and  {} for hashtable. Reference.

I would glady see the json you're troubling with, but such definition is correct and allow complete iteration :

Code:
[
{ "foo" : "bar" },
{ "foo" : "meh" }
]

[...] how to load structured data where I don't know the structure in advance when I query a "database" (actually a text file read line by line), so I can review its structure and decide what to do with it.

JSON is about opening stuff. You either open an queue or a hashtable while finals items can be about multiple types (numbers, string ...). If the struggle is about reading a file, you can read everything, replace those nasty new-lines by some space shit and build a parser upon it. If you're willing to do some serious stuff, some grammar can help you as well as tokens

I still don't see how to do it concretely, in fact I'm not a programmer, I'm learning on the fly.

Also I only need all value as string, no fancy type mangling will be in use. I think All I need them is to iterate through the key value pair graph.

I mean the interesting stuff would be that I have no need to parse it myself to access consistently structured data, that's what I do with csv already and that being non consistent is a pain in the ass!

I need to PRACTICALLY access stuff, conceptual explanation don't help at all.
Logged

Pages: 1 ... 6 7 [8] 9 10 ... 69
Print
Jump to:  

Theme orange-lt created by panic