• What Do You Need Help With? V6
    7,544 replies, posted
[QUOTE=WTF Nuke;41381433]Alright so I should make a new model for each usemtl group, as all those faces will use those settings? Then the model will store the newmtl data from the .mtl file, so that I can just draw each set of faces with their appropriate settings. Actually, I think I will have one model instance for each .obj file, and in it I will group faces with their usemtl group, so I can draw the whole model while still retaining usemtl groups. Can I keep all the data in the same buffer, then just do a drawElements call for the amount of items in a usemtl group, and then change uniform data?[/QUOTE] Yeah, I do it the same way with a Model containing multiple groups of materials and meshes. I personally don't store all the data in a single VBO, but you definitely can.
[QUOTE=marvinelo;41382829]The school that I'll start visiting mid-August will teach programming in Java. I already did some programming in C++, but due to C++'s nature I kinda stagnated to the point where I don't program at all(Note: C++ is also my first language). Now I thought about learning Java, as I will also need it in my new class and if I learn some Java before school starts I have a little advantage to anyone else and of course, I also want to do lots of programming as a hobby and for a living later on too. I've already heard about many different Java IDEs, but I still have no idea which one to choose and also saw that some actually cost money. Which free IDE can you guys recommend me? I could also need some good tutorial sites or videos(Though I prefer sites/documents or anything else that's in text form). Thanks in advance![/QUOTE] Finally I can recommend this book :dance: Here: [URL="http://openbook.galileocomputing.de/javainsel/"]Java ist auch eine Insel[/URL] It has everything you need, and there are also books for most other popular programming languages on the site for when you've finished this one.
I've been doing a bit of programming in c# and I've come across properties a few times but never really understood their purpose. What advantage, if any, is there to use properties and do this: [code]class SomeClass { private int health; public int Health; { get { return health; } set { health = value; } } }[/code] [code]SomeClass.Health = 100;[/code] rather than simply using a public variable like this: [code]class SomeClass { public int Health; }[/code] [code]SomeClass.Health = 100;[/code]
[QUOTE=Pelf;41386161]I've been doing a bit of programming in c# and I've come across properties a few times but never really understood their purpose. What advantage, if any, is there to use properties and do this:[/QUOTE] One thing of note is that you can do a shorthand declaration of a property like so and acts almost like a normal variable: [code]public int Property { get; set; }[/code] Properties are the C# answer to what you would use accessors for in other languages. You can have access levels to the get and/or set to easily make them read or write only outside the scope of the class. You can also define the behavior of both the get and the set so you can do stuff like clamp the value to a range, as just one example. The general convention is to use properties rather than variables for anything that will be available outside of the class.
[QUOTE=Pelf;41386161]I've been doing a bit of programming in c# and I've come across properties a few times but never really understood their purpose. What advantage, if any, is there to use properties and do this: [code]class SomeClass { private int health; public int Health; { get { return health; } set { health = value; } } }[/code] [code]SomeClass.Health = 100;[/code] rather than simply using a public variable like this: [code]class SomeClass { public int Health; }[/code] [code]SomeClass.Health = 100;[/code][/QUOTE] Well first, you can use "public int Health { get; set; }" if you're not doing anything else to the value. The benefit of properties in C# are that they look like variables, but are actually methods being called. So let's say you want to make sure health has to be between 0 and 100. You can do this by validating the input before setting the field inside of the property: [code]set { if (value < 0 || value > 100) throw new ArgumentOutOfRangeException("Health must be between 0 and 100"); health = value; }[/code] You could also clamp the value between 0 and 100 if you want it to work without throwing exceptions. Additionally, let's say you wanted some other class to do something when health changes. You can create an event and call it from inside the set block. That way other classes can automatically know when health changes. The "get" block can be useful too. Let's say the class internally stores "life" and "armor" and health is the two added together. You could just add the two together every time you want to calculate health, or you could expose a Health property that adds the two together: [code]get { return life + armor; }[/code] Generally, it's best practice to make variables properties if they're publicly exposed, so that you can make these kinds of changes without breaking other code that relies on it. Also, there's no performance penalty for auto-implemented properties, they're pretty much guaranteed to be inlined.
I have a question about OpenGL. Is it unheard of to use more than one VAO? If not then when would you want to use another one?
[QUOTE=chaoselite;41388322]I have a question about OpenGL. Is it unheard of to use more than one VAO? If not then when would you want to use another one?[/QUOTE] Use one with each mesh you have. VAOs were made to reduce the overhead of drawing objects. There would be no point in them were you to only use one and rebind all your vertex attributes to it all the time.
[QUOTE=robmaister12;41386647]Generally, it's best practice to make variables properties if they're publicly exposed, so that you can make these kinds of changes without breaking other code that relies on it.[/QUOTE] Right now i'm using fields for pretty much everything (Since i don't need any special get/set functions and public bool Enabled; looks cleaner than public bool Enabled { get; set; }). What exactly would break if you change from a field to a property?
[QUOTE=Goz3rr;41390138]Right now i'm using fields for pretty much everything (Since i don't need any special get/set functions and public bool Enabled; looks cleaner than public bool Enabled { get; set; }). What exactly would break if you change from a field to a property?[/QUOTE] 1) Making that change loses binary compatibility with old versions of the assembly. This means that if you're writing a library that other people depend on, they would all have to recompile or their users will get some weird error message about your library. 2) Reflection breaks. 3) ref/out parameters suddenly stop working 4) Using the "fixed" keyword no longer works on the property (in unsafe blocks) 5) Fields that are mutable structs start giving different results (silently) or compiler errors. [url]http://csharpindepth.com/articles/chapter8/propertiesmatter.aspx[/url] The performance difference is going to be 0 on basically all CLR implementations and switching from an auto-implemented property to a regular one won't break anything. (Unless you throw an exception in your expanded set block or something, but that's an entirely expected breaking change) The difference is 13 characters, it's not that bad. You'll get used to the way they look. [editline]10th July 2013[/editline] Though there is always at least one exception to the rule. If you're making something like a game, defining your vector and matrix classes as structs with fields and passing them around with ref/out is going to be significantly faster than it would be passing them around by value or defining them as classes. I would say it's acceptable to make any commonly read vectors/matrices fields so that you can use ref/out parameters with them. I still define these as auto properties as I've never seen the overhead as significant in a profiler. I may still break that rule for particles when I get to them, as the tiniest of overheads add up when multiplied by a few thousand.
[QUOTE=marvinelo;41382829]The school that I'll start visiting mid-August will teach programming in Java. I already did some programming in C++, but due to C++'s nature I kinda stagnated to the point where I don't program at all(Note: C++ is also my first language). Now I thought about learning Java, as I will also need it in my new class and if I learn some Java before school starts I have a little advantage to anyone else and of course, I also want to do lots of programming as a hobby and for a living later on too. I've already heard about many different Java IDEs, but I still have no idea which one to choose and also saw that some actually cost money. Which free IDE can you guys recommend me? I could also need some good tutorial sites or videos(Though I prefer sites/documents or anything else that's in text form). Thanks in advance![/QUOTE] There's a 50/50 chance your school will force you to use either Eclipse or Netbeans as an IDE. They're both free, slow and you will develop a love-hate relationship with them.
s/love-hate/hate-hate/
I love Eclipse and hate Netbeans. Does that count?
[QUOTE=Agent766;41392250]I love Eclipse and hate Netbeans. Does that count?[/QUOTE] I used to not-hate Netbeans, then switched college and had to use Eclipse and I loved it and hated Netbeans, then I tried setting up Eclipse how I wanted it to look, then I was happy. Then I started a new project and FUCK ECLIPSE. Too bad I can't use anything else, like IntelliJ, thanks college!
[QUOTE=mobrockers;41392331]I used to not-hate Netbeans, then switched college and had to use Eclipse and I loved it and hated Netbeans, then I tried setting up Eclipse how I wanted it to look, then I was happy. Then I started a new project and FUCK ECLIPSE. Too bad I can't use anything else, like IntelliJ, thanks college![/QUOTE] What's so bad about setting up a new project in eclipse? Never had a problem
[QUOTE=Goz3rr;41392630]What's so bad about setting up a new project in eclipse? Never had a problem[/QUOTE] You lose all your settings as they're workspace specific and there's no easy way to migrate them over.
Hey guys, has anyone got any opinions on how one would go about making a DB-renderer, for use of a better word. I have a file-type that stores the equivalent of an access database, but with some procedures to sort and query tailored to my needs. The data is all there, but currently im displaying it as formatted text in a text-box, which is naturally horrible. Anyone know of a decent way to display the data?...how is it done in Access e.g? I was thinking along the lines of define a "viewing rectangle" and Blit the background/cells + render text thats visible onto a bitmap on the form but iv'e no ideas of any standard. As it is a demonstration/marked projects (college) I can't simply use the built in visual studio database. (P.S using c#.net), thanks
If you can't use the built-in data grid controls you will need to create your own, as custom/user control. WPF has a Grid that you could use together with TextBoxes to create a view, but there is a database-view like control in WPF and I think in WinForms too. For the custom control you could either draw everything yourself by overriding the redraw handlers in the custom control or build your custom control using existing controls, which can be created dynamically base on the data you bind to.
[QUOTE=mobrockers;41392636]You lose all your settings as they're workspace specific and there's no easy way to migrate them over.[/QUOTE] Why would you start a new workspace for a new project? I only have different workspaces for Android, Libgdx and minecraft
[QUOTE=Goz3rr;41393345]Why would you start a new workspace for a new project? I only have different workspaces for Android, Libgdx and minecraft[/QUOTE] Because that's Eclipses philosophy for workspaces and because I don't like having 30 projects in a workspace. I did end up only creating a new workspace for different courses with ~10 projects in each but it's still a pain in the ass.
[QUOTE=Lemmingz95;41392762]As it is a demonstration/marked projects (college) I can't simply use the built in visual studio database. (P.S using c#.net), thanks[/QUOTE] Does DataGridView fall into that?
What can cause an application to show as not responding (grayed out screen and prompt) while still working perfectly fine? I'm making an SFML project and as soon as I click on the window it happens though the cursor is still free in game and all the controls still work. [editline]sdasdasd[/editline] Scratch that, fixed.
[quote]Does DataGridView fall into that?[/quote] Im not sure, Ill ask...it would make it alot easier if for instance, the data was wider than the form (scroll-bars built in) Although as a backup, the grid w/ textboxes should work, thanks
Do you guys have any tips on how to optimize this? [cpp]for(int i = 0; i < elemSize; i++){ //pack all the elements that are unique data[i*8] = vertices[(triangleData[sortElem[i]*3]-1)*3]; data[i*8+1] = vertices[(triangleData[sortElem[i]*3]-1)*3+1]; data[i*8+2] = vertices[(triangleData[sortElem[i]*3]-1)*3+2]; //textures, unused right now /*if(triangleData[sortElem[i]*3+1] != 0){ data[i*8+3] = textures[(triangleData[sortElem[i]*3+1] -1)*2]; data[i*8+4] = textures[(triangleData[sortElem[i]*3+1] -1)*2+1]; } else*/{ data[i*8+3] = 0; data[i*8+4] = 0; } if(triangleData[sortElem[i]*3+2] != 0){ data[i*8+5] = normals[(triangleData[sortElem[i]*3+2] -1)*3]; data[i*8+6] = normals[(triangleData[sortElem[i]*3+2] -1)*3+1]; data[i*8+7] = normals[(triangleData[sortElem[i]*3+2] -1)*3+2]; } else{ data[i*8+5] = 0.3; data[i*8+6] = 0.3; data[i*8+7] = 0.3; } //point elements to their true location, rather than their previous pos location if(i != sortElem[i]){ std::replace(elements.begin(), elements.end(), sortElem[i], (GLuint)i); } }[/cpp] Or this? [cpp]for(int i =0; i<size; i++){ if(elements[i] != i) continue; for(int j = i+1; j <size; j++){ if(triangleData[i*3] == triangleData[j*3] && triangleData[i*3+1] == triangleData[j*3+1] && triangleData[i*3+2] == triangleData[j*3+2]){ elements[j] = i; } } }[/cpp]
[QUOTE=WTF Nuke;41401665]Or this? for(int i =0; i<size; i++){ if(elements[i] != i) continue; for(int j = i+1; j <size; j++){ if(triangleData[i*3] == triangleData[j*3] && triangleData[i*3+1] == triangleData[j*3+1] && triangleData[i*3+2] == triangleData[j*3+2]){ elements[j] = i; } }} [/QUOTE] [cpp]for(int i =0; i<size; i++){ if(elements[i] == i) { for(int j = i+1; j <size; j++){ if(triangleData[i*3] == triangleData[j*3] && triangleData[i*3+1] == triangleData[j*3+1] && triangleData[i*3+2] == triangleData[j*3+2]){ elements[j] = i; } } } }[/cpp] B)
Didn't really change anything, I'm sure the optimizer would change it anyway. I am also trying to get phong specular lighting model to work, but I am having issues. I am following tutorials word for word, but it doesn't work nonetheless. The code is as follows in the frag shader: [cpp]vec3 viewDirection = normalize(EyeDir); vec3 reflectDir = reflect(-dirToLight, normModelSpace); float phongTerm = dot(viewDirection, reflectDir); phongTerm = clamp(phongTerm, 0, 1); phongTerm = cosTheta != 0.0 ? phongTerm : 0.0; phongTerm = pow(phongTerm, 3);"[/cpp] and the EyeDir is computed in the vertex shader: [cpp]EyeDir = -(V*M*vec4(position,1.0)).xyz;[/cpp] This is supposed to be computed in model space. I changed it all into camera space where needed, and did some optimizations, basically my code is a mirror image of the one in this tutorial: [url]http://www.opengl-tutorial.org/beginners-tutorials/tutorial-8-basic-shading/[/url] However, I still have a bug. The same as before, I have this effect and no actual specular shading [img]http://i.imgur.com/BBoArEv.png[/img]
How do you enter a date into a table in SQL? All I remember my professor saying is enter the four digit year. I want it to appear as 01-JAN-98. I've tried entering 01-JAN-1998 and '01-JAN-1998' and neither are working. [editline]10th July 2013[/editline] It looks like my error is something else. It's telling me I'm missing a right parenthesis but this looks right to me. [code]CREATE TABLE empbb02 (EMPNO VARCHAR2(5), ENAME VARCHAR2(10), POS VARCHAR2(12), BOSS VARCHAR2(4) HIREDATE DATE, SAL NUMBER(6), DEPTNO NUMBER(2), INCENTIVES NUMBER(6));[/code] [editline]10th July 2013[/editline] Nevermind, I see it, I'm missing a god damn, comma.
[QUOTE=WTF Nuke;41404130]Didn't really change anything, I'm sure the optimizer would change it anyway. I am also trying to get phong specular lighting model to work, but I am having issues. I am following tutorials word for word, but it doesn't work nonetheless. The code is as follows in the frag shader: [cpp]vec3 viewDirection = normalize(EyeDir); vec3 reflectDir = reflect(-dirToLight, normModelSpace); float phongTerm = dot(viewDirection, reflectDir); phongTerm = clamp(phongTerm, 0, 1); phongTerm = cosTheta != 0.0 ? phongTerm : 0.0; phongTerm = pow(phongTerm, 3);"[/cpp] and the EyeDir is computed in the vertex shader: [cpp]EyeDir = -(V*M*vec4(position,1.0)).xyz;[/cpp] This is supposed to be computed in model space. I changed it all into camera space where needed, and did some optimizations, basically my code is a mirror image of the one in this tutorial: [url]http://www.opengl-tutorial.org/beginners-tutorials/tutorial-8-basic-shading/[/url] However, I still have a bug. The same as before, I have this effect and no actual specular shading[/QUOTE] Make sure that dirToLight is in camera space and that you have transformed the normModelSpace to camera space.
[QUOTE=WTF Nuke;41401665]Do you guys have any tips on how to optimize this? [cpp]//code[/cpp] Or this? [cpp]//code[/cpp][/QUOTE] Make sure these containers are arrays or vectors (for cache coherence). If the assignments are to primitive types, the compiler might be able to leverage some vectorized instructions, provided you compile with optimizations enabled and target a newer processor architecture. With trivially copyable types, the compiler can use memcpy. If you are not using a primitive type, try to make them [url=http://en.cppreference.com/w/cpp/types/is_trivially_copyable]trivially copyable[/url]. Speaking of memcpy, the compiler might be able to optimize it better if you use std::copy(vertices+(triangleData[sortElem[i]*3]-1)*3, vertices+(triangleData[sortElem[i]*3]-1)*3+3, data+i*8); instead of assigning consecutive elements by hand. Although I think the compiler is smart enough to catch that, in which case it's just a stylistic difference (looks clearer IMO). I'd also not repeat myself that often (cache i*8, sortElem[i]*3 and stuff in a local variable, do increments when appropriate), but that won't increase performance (the compiler is likely to do that anyway) and is just stylistic. Maybe you could decrement each element of triangleData instead of doing it ad-hoc? It might be better to store the default value of 0.3 in normals instead of doing it conditionally, but you'd have to benchmark that.
Didn't know where to ask this, fuck it... what is a good IDE for LUA? Keep in mind i'm currently working with corona SDK
[url=http://lua-users.org/wiki/LuaIntegratedDevelopmentEnvironments]These[/url]. Not completely up-to-date tough, [url=https://github.com/unknownworlds/decoda]Decoda[/url] was open-sourced.
Sorry, you need to Log In to post a reply to this thread.