• What Do You Need Help With? V6
    7,544 replies, posted
Which[URL="https://www.python.org/dev/peps/"] PEPs [/URL]should I definitely read?
In openGL, what is the most efficient way to do voxels? Do I draw them on the geometry shader, draw them as instanced objects on the vertex shader, or do I pre bake all the voxels onto one VBO and send it over?
[QUOTE=thrawn2787;46574089]Then he wants a 2d array of a list or something. [code] // don't have to use vector, use whatever container you want Vector<Foo>[][] array = new Vector<Foo>[y][x]; for(int i = 0; i < y; i++) for(int j = 0; j < x; j++) array[i][j] = new Vector<Foo>(); // now we can get our vectors and add stuff to them array[0][0].add(new Foo()); [/code][/QUOTE] How would you do this in Java?
[QUOTE=Talkbox;46579561]In openGL, what is the most efficient way to do voxels? Do I draw them on the geometry shader, draw them as instanced objects on the vertex shader, or do I pre bake all the voxels onto one VBO and send it over?[/QUOTE] GPUs vary too much for there to be one answer. But generally speaking, the speed difference between the first and third is negligible, and the second will be slow as fuck because you're not culling any occluded sides. [editline]26th November 2014[/editline] That being said, the first one requires the GPU to do a bit of extra calculations to create the necessary triangles, so it may be slower.
[QUOTE=NixNax123;46579562]How would you do this in Java?[/QUOTE] That [I]is [/I]java.
[QUOTE=thrawn2787;46579774]That [I]is [/I]java.[/QUOTE] That won't compile? [editline]26th November 2014[/editline] [code] // data private final List<Entity>[][] data; /** * Constructs a grid with the specified boundary. * @param boundary the boundary of the grid. */ public PartionedGrid(AABB boundary) { this.boundary = boundary; int edgeLength = (int)boundary.getRadius().x*2; gridCellSize = edgeLength / 32; data = new ArrayList<>()[edgeLength][edgeLength]; } [/code] [editline]26th November 2014[/editline] [quote]array required, but java.util.ArrayList<java.lang.Object> found[/quote]
[QUOTE=Talkbox;46579561]In openGL, what is the most efficient way to do voxels? Do I draw them on the geometry shader, draw them as instanced objects on the vertex shader, or do I pre bake all the voxels onto one VBO and send it over?[/QUOTE] the set of [url=https://open.gl/]tutorials[/url] I've been following states suggests that the [url=https://open.gl/geometry]geometry shader[/url] is well-suited to this task
[QUOTE=Talkbox;46579561]In openGL, what is the most efficient way to do voxels? Do I draw them on the geometry shader, draw them as instanced objects on the vertex shader, or do I pre bake all the voxels onto one VBO and send it over?[/QUOTE] Divide the voxels in chunk smalls enough to rebuild a few off per frame without causing an hitch, then generate a VBO per chunk. You can build the VBO on the GPU in a geometry shader, but you shouldn't do it each frame because its going to be significantly slower then just rendering a VBO, so you have to cache it in a feedback buffer if you do. Doing it on the GPU would probably be better since it reduces the CPU->GPU bandwidth and will be faster in general, however doing on the CPU is probably more then fast enough, i personally wouldn't waste time on implementing it on the GPU.
[QUOTE=NixNax123;46579940]That won't compile? [editline]26th November 2014[/editline] [code] // data private final List<Entity>[][] data; /** * Constructs a grid with the specified boundary. * @param boundary the boundary of the grid. */ public PartionedGrid(AABB boundary) { this.boundary = boundary; int edgeLength = (int)boundary.getRadius().x*2; gridCellSize = edgeLength / 32; data = new ArrayList<>()[edgeLength][edgeLength]; } [/code] [editline]26th November 2014[/editline][/QUOTE] Because you didn't look at the syntax right [code] data = new ArrayList<Entity>()[size][size]; // incorrect, calls array list constructor data = new ArrayList<Entity>[size][size]; // correct, allocates a 2d array of array lists. note that // all the elements in this 2d array are empty to begin with. [/code] And actually I was wrong you'll need to drop the generic [code] List<String>[][] data = new ArrayList[size][size]; [/code]
[QUOTE=thrawn2787;46580837] [code] List<String>[][] data = new ArrayList[size][size]; [/code][/QUOTE] That is the completely wrong syntax. You cannot have a multi-dimensional ArrayList in Java. It'll either have to be an actual array, or a List that contains a wrapper class for the two values. Plus, you'll [B]want[/B] the generic identifier within the diamond braces. [code] public class StringContainer { public StringContainer(String first, String second) { this.first = first; this.second = second; } //getters and setters... private String first; private String second; } [/code] [code] ArrayList<StringContainer> stringContainers = new ArrayList<StringContainer>(); [/code]
Dunno if it is right to post it here. Can anyone please take a peek at my [URL="http://steamcommunity.com/sharedfiles/filedetails/?id=346750498"]little scripting guide[/URL] for RoN on Steam and see if I did a mistake, especially in the first part? I hadn't studied C before RoN so there may be mistakes, but I can't find them myself, obviously.
[QUOTE=Contron;46581279]That is the completely wrong syntax. You cannot have a multi-dimensional ArrayList in Java. It'll either have to be an actual array, or a List that contains a wrapper class for the two values. Plus, you'll [B]want[/B] the generic identifier within the diamond braces. [code] public class StringContainer { public StringContainer(String first, String second) { this.first = first; this.second = second; } //getters and setters... private String first; private String second; } [/code] [code] ArrayList<StringContainer> stringContainers = new ArrayList<StringContainer>(); [/code][/QUOTE]That's what I thought. So I would need to make a separate class to handle coordinates and entity ID's, and put that into an ArrayList? [editline]26th November 2014[/editline] I think the simpler solution would just be to do what was said before, making a traditional 3D array that holds a max of 32 entities per cell. Now I just need to make ID's for entities. Anyone care to get me started on that?
[QUOTE=NixNax123;46581624]That's what I thought. So I would need to make a separate class to handle coordinates and entity ID's, and put that into an ArrayList? [editline]26th November 2014[/editline] I think the simpler solution would just be to do what was said before, making a traditional 3D array that holds a max of 32 entities per cell. Now I just need to make ID's for entities. Anyone care to get me started on that?[/QUOTE] Simple. Make an enum class in java called entityType and in there, list your types in caps (for good style) - PLAYER, ASTEROID, BULLET, etc. Include a GENERIC as a base case as well. Then you can distinguish what an entity is by giving it a simple data member of entityType named id, and use a getter to retrieve it. Set it in the constructor of entity. If you're looking to give every single entity on the screen a different id then that's a different story, but i'd question the necessity of that in the first place.
[QUOTE=Contron;46581279]That is the completely wrong syntax. You cannot have a multi-dimensional ArrayList in Java. It'll either have to be an actual array, or a List that contains a wrapper class for the two values. Plus, you'll [B]want[/B] the generic identifier within the diamond braces. [/QUOTE] It is a 2d array of array lists. There is absolutely nothing wrong with it if you want something that is 3d where only the innermost dimension can grow and shrink but not the outer dimensions. And it is 100% valid java A better approach is probably a list of list of list. Or a class like: [code] class Foo { List<Bar> list = new ArrayList<Bar>(); } Foo[][] ar; [/code] But my original approach seems to work fine [editline]26th November 2014[/editline] [QUOTE=killerteacup;46582339]Simple. Make an enum class in java called entityType and in there, list your types in caps (for good style) - PLAYER, ASTEROID, BULLET, etc. Include a GENERIC as a base case as well. Then you can distinguish what an entity is by giving it a simple data member of entityType named id, and use a getter to retrieve it. Set it in the constructor of entity. If you're looking to give every single entity on the screen a different id then that's a different story, but i'd question the necessity of that in the first place.[/QUOTE] Why not just have a list of IGameEntity or ICollideable or something. If all this quadtree gives a shit about is stuff that takes up area and can collide then they should inherit from something common and you make a list out of that [editline]26th November 2014[/editline] I'm not saying he's going down the right path for his overall assignment, I'm just answering his specific questions Nax your teacher / professor / TAs are a better resource than facepunch / the internet.
[QUOTE=thrawn2787;46582656]It is a 2d array of array lists. There is absolutely nothing wrong with it if you want something that is 3d where only the innermost dimension can grow and shrink but not the outer dimensions. And it is 100% valid java A better approach is probably a list of list of list. Or a class like: [code] class Foo { List<Bar> list = new ArrayList<Bar>(); } Foo[][] ar; [/code] But my original approach seems to work fine [editline]26th November 2014[/editline] Why not just have a list of IGameEntity or ICollideable or something. If all this quadtree gives a shit about is stuff that takes up area and can collide then they should inherit from something common and you make a list out of that [editline]26th November 2014[/editline] I'm not saying he's going down the right path for his overall assignment, I'm just answering his specific questions Nax your teacher / professor / TAs are a better resource than facepunch / the internet.[/QUOTE] That's actually what I do on my games so you're 100% right. I actually wasn't entirely sure about the context of his question. If I needed to make each entity have an ID for generic purposes I probably would use enums but if its just for the use of a quadtree just grab everything from the list.
Is there a way to fetch the last message sent over Steam in Python?
[QUOTE=thrawn2787;46582656]It is a 2d array of array lists. There is absolutely nothing wrong with it if you want something that is 3d where only the innermost dimension can grow and shrink but not the outer dimensions. And it is 100% valid java A better approach is probably a list of list of list. Or a class like: [code] class Foo { List<Bar> list = new ArrayList<Bar>(); } Foo[][] ar; [/code] [/QUOTE] I apologise, you're completely right. It does work, I just misread your post wrong. Sorry. I've just never actually seen it been done like that so it's why I recommended having a container class of sorts.
So I've got this: [code] // data private final List<Entity>[][] grid; /** * Constructs a grid with the specified boundary. * @param gridSize the size of the grid. */ public PartionedGrid(Vector2f gridSize) { this.gridSize = gridSize; gridCellSize = gridSize.x / 32; rows = (int)((gridSize.y + gridCellSize - 1) / gridCellSize); cols = (int)((gridSize.x + gridCellSize - 1) / gridCellSize); grid = new ArrayList<Entity>[cols][rows]; }[/code] Which won't compile. How would I make this work without having a raw type for grid?
Well, I need some help understanding some stuff. I'm really new to proggramming, and %90 of the time I have minor questions about minor stuff, that isn't even worth to ask here, but also I need to know these stuff. What I'm asking for mainly is either some people here to ask stuff by PM, or someone to add me on Steam. I guess I can't simply post this here, so have some of the questions that bugged my mind for the past 2-3 hours. What is compiling and decompiling to sum up(maybe I've got it wrong)? Why is it particularly hard to decompile a C++ file? What other languages can be decompiled better than C++, and why is that, what difference is there? How can I see the interior of dlls in any other way? Also one last thing: Rise of Nations has a script editor, which has pre defined "trigger functions". All I wanted to find is where these are defined, and how they are defined. To learn from examples. Now , I have opened nearly every file that I can open with my Notepad++, and couldn't find anything. Any ideas?
[QUOTE=NixNax123;46585797]So I've got this: [code] // data private final List<Entity>[][] grid; /** * Constructs a grid with the specified boundary. * @param gridSize the size of the grid. */ public PartionedGrid(Vector2f gridSize) { this.gridSize = gridSize; gridCellSize = gridSize.x / 32; rows = (int)((gridSize.y + gridCellSize - 1) / gridCellSize); cols = (int)((gridSize.x + gridCellSize - 1) / gridCellSize); grid = new ArrayList[cols][rows]; }[/code] Which won't compile. How would I make this work without having a raw type for grid?[/QUOTE] As I said in my post above you need to exclude the generic on the rhs. I've edited the code in my quote [editline]27th November 2014[/editline] [QUOTE=Trebgarta;46587410] I guess I can't simply post this here, so have some of the questions that bugged my mind for the past 2-3 hours. What is compiling and decompiling to sum up(maybe I've got it wrong)? Why is it particularly hard to decompile a C++ file? What other languages can be decompiled better than C++, and why is that, what difference is there? How can I see the interior of dlls in any other way? Also one last thing: Rise of Nations has a script editor, which has pre defined "trigger functions". All I wanted to find is where these are defined, and how they are defined. To learn from examples. Now , I have opened nearly every file that I can open with my Notepad++, and couldn't find anything. Any ideas?[/QUOTE] Compiling = taking the written code and transforming it into something the computer actually understands (binary). Computers don't read C/C++/Java, they read binary. Decompiling = taking compiled binary code and transforming it back into the language it came from. Compilers do a shit ton of optimizations when compiling so it is very hard to recreate the original code most of the time. If you are new to programming and want to learn I recommend learning by making your own programs rather than trying to reverse engineer existing things. Seems like you want to mod games. Go mod games that have mod support rather than trying to do weird hacky things with games that don't have mod support. And if google yields nothing on finding where the rise of nations methods are defined then the devleopers have probably hidden them intentionally (aka only offered them as compiled code, not the source). Many programs do this. They will give you documentation as to what is [I]publicly [/I]exposed and how to use it but they do not give you access to the actual source code.
[url]http://stackoverflow.com/questions/448981/what-characters-are-valid-in-css-class-selectors[/url] This solved it.
[QUOTE=thrawn2787;46587450] Compiling = taking the written code and transforming it into something the computer actually understands (binary). Computers don't read C/C++/Java, they read binary. Decompiling = taking compiled binary code and transforming it back into the language it came from. Compilers do a shit ton of optimizations when compiling so it is very hard to recreate the original code most of the time. If you are new to programming and want to learn I recommend learning by making your own programs rather than trying to reverse engineer existing things. Seems like you want to mod games. Go mod games that have mod support rather than trying to do weird hacky things with games that don't have mod support. And if google yields nothing on finding where the rise of nations methods are defined then the devleopers have probably hidden them intentionally (aka only offered them as compiled code, not the source). Many programs do this. They will give you documentation as to what is [I]publicly [/I]exposed and how to use it but they do not give you access to the actual source code.[/QUOTE] Thanks for the info, however, I am not trying to do weird hacky things. I can define my own functions in the script maker very well as of now, but I just wanted to see the default ones to get an idea;I personally learn best through examples. Did modding on Company of Heroes before, it really helped. I am making scenarios with custom scripts for RoN now. You know, my idea was: The function to lock mouse of the player exists, but it is not particularly nice in Multiplayer since it locks everyone's mouse (in thory, haven't actually tested it, let's say 99% since it has no nation/player input). There is also disable_type (disables a unit globally) and disable_unit_by_tribe (disables a unit [I]for a single nation[/I]) there, so looking at the definition ways of three, I thought I could figure out a way myself to write a function that would lock the mouse of particular players. I could try making my own program in the future, right now I have 2 WIP scenarios in RoN, I will finish them first. One is in a deadlock because of MP problems I've mentioned here, and I'm working on the other one right now. The second one is progressing nicely. Or I could mod CoH2, since attribeditor is released and &#305; got it off exploration sale (if ti will download-20 hours, nice.)
Hey guys, I'm working with Python and I have a question I have a list of informations like this in a list: ['68', ' ?', ' 38317', ' 1st-4th', ' 2', ' Divorced', ' ?', ' Not-in-family', ' White', ' Female', ' 0', ' 0', ' 20', ' United-States', ' <=50K'] ['32', ' ?', ' 293936', ' 7th-8th', ' 4', ' Married-spouse-absent', ' ?', ' Not-in-family', ' White', ' Male', ' 0', ' 0', ' 40', ' ?', ' <=50K'] aka list[1] would be: ['68', ' ?', ' 38317', ' 1st-4th', ' 2', ' Divorced', ' ?', ' Not-in-family', ' White', ' Female', ' 0', ' 0', ' 20', ' United-States', ' <=50K'] and list[2] would be: ['32', ' ?', ' 293936', ' 7th-8th', ' 4', ' Married-spouse-absent', ' ?', ' Not-in-family', ' White', ' Male', ' 0', ' 0', ' 40', ' ?', ' <=50K'] I want to only take the last bit of it, <=50K, how do I do that?
[QUOTE=thrawn2787;46587450]As I said in my post above you need to exclude the generic on the rhs. I've edited the code in my quote [editline]27th November 2014[/editline] Compiling = taking the written code and transforming it into something the computer actually understands (binary). Computers don't read C/C++/Java, they read binary. Decompiling = taking compiled binary code and transforming it back into the language it came from. Compilers do a shit ton of optimizations when compiling so it is very hard to recreate the original code most of the time. If you are new to programming and want to learn I recommend learning by making your own programs rather than trying to reverse engineer existing things. Seems like you want to mod games. Go mod games that have mod support rather than trying to do weird hacky things with games that don't have mod support. And if google yields nothing on finding where the rise of nations methods are defined then the devleopers have probably hidden them intentionally (aka only offered them as compiled code, not the source). Many programs do this. They will give you documentation as to what is [I]publicly [/I]exposed and how to use it but they do not give you access to the actual source code.[/QUOTE] Removing the generic would just yield a raw data type warning. Which ends up in the list not being able to be used.
It is 100% useable. Did you try using it? Warnings aren't errors! [code] List<String>[][] l = new ArrayList[20][20]; for(int i = 0; i < 20; i++) for(int j = 0; j < 20; j++) l[i][j] = new ArrayList<String>(); l[0][0].add("ASDF"); System.out.println(l[0][0].get(0));[/code] Output: [code] ASDF [/code]
Oh, I totally forgot to initialize the indices. Silly me!
[QUOTE=Kingbob387;46588457]Hey guys, I'm working with Python and I have a question I have a list of informations like this in a list: ['68', ' ?', ' 38317', ' 1st-4th', ' 2', ' Divorced', ' ?', ' Not-in-family', ' White', ' Female', ' 0', ' 0', ' 20', ' United-States', ' <=50K'] ['32', ' ?', ' 293936', ' 7th-8th', ' 4', ' Married-spouse-absent', ' ?', ' Not-in-family', ' White', ' Male', ' 0', ' 0', ' 40', ' ?', ' <=50K'] aka list[1] would be: ['68', ' ?', ' 38317', ' 1st-4th', ' 2', ' Divorced', ' ?', ' Not-in-family', ' White', ' Female', ' 0', ' 0', ' 20', ' United-States', ' <=50K'] and list[2] would be: ['32', ' ?', ' 293936', ' 7th-8th', ' 4', ' Married-spouse-absent', ' ?', ' Not-in-family', ' White', ' Male', ' 0', ' 0', ' 40', ' ?', ' <=50K'] I want to only take the last bit of it, <=50K, how do I do that?[/QUOTE] If your list is named, for instance, foo, then you can either use negative indices: [code] foo[-1] [/code] or get length of the list and use it to access the last element: [code] foo[len(foo) - 1] [/code]
That's a feature I wish was implemented in some way for other high level programming languages. I feel so dumb sometimes doing arr[arr.length - 1].
I have a C# project (A) which is dependent on a C# library (L). Both have their own separate Git repo, and both are in development. Is there anything inherently wrong with including the entire library solution L as a submodule in the root directory of A, then referencing the required projects in L from A? Looks like this: [code] \A \ProjectInA\ \ProjectInA.csproj \A.sln \L \ProjectInL \ProjectInL.csproj \L.sln [/code] A.sln contains a reference to ProjectInL.csproj. L would be a Git submodule. Bonus question: Is there anything wrong with treating L as a 3rd party library and just including a DLL in the repo? Bonus question 2: Is NuGet overkill for this simple dependency situation?
[QUOTE=NixNax123;46591262]That's a feature I wish was implemented in some way for other high level programming languages. I feel so dumb sometimes doing arr[arr.length - 1].[/QUOTE] perl does away with array size completely and uses $# to get the last index of an array when you get used to it its pretty nice actually
Sorry, you need to Log In to post a reply to this thread.