Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
ModeSix
Mar 14, 2009

Stick100 posted:

If I recall correctly they just added a very generous subscription option, I suggest looking at that first.

What would be the point of getting a subscription when he can buy it for $75 US?

Adbot
ADBOT LOVES YOU

Music Theory
Aug 7, 2013

Avatar by Garden Walker
I'm using SDL2# for a project, and I'm getting this error at runtime whenever the program tries to call an SDL method:
code:
An unhandled exception of type 'System.DllNotFoundException' occurred in Flashlight.exe
Additional information: Unable to load DLL 'SDL2.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
I have SDL2-CS.dll (which is what SDL2# builds into) referenced in the project, and Visual Studio's IntelliSense can see it. What's going on?

Edit: Obsurveyor figured it out; it was because I needed to put SDL2.dll in the same folder as the executable.

Music Theory fucked around with this message at 00:02 on Mar 15, 2015

Inverness
Feb 4, 2009

Fully configurable personal assistant.

Music Theory posted:

I'm using SDL2# for a project, and I'm getting this error at runtime whenever the program tries to call an SDL method:
code:
An unhandled exception of type 'System.DllNotFoundException' occurred in Flashlight.exe
Additional information: Unable to load DLL 'SDL2.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
I have SDL2-CS.dll (which is what SDL2# builds into) referenced in the project, and Visual Studio's IntelliSense can see it. What's going on?

Edit: Obsurveyor figured it out; it was because I needed to put SDL2.dll in the same folder as the executable.
:stare: I'm not sure why you had a problem here. The error message said quite clearly it was unable to load SDL2.dll. Why were you confused?

Music Theory
Aug 7, 2013

Avatar by Garden Walker

Inverness posted:

:stare: I'm not sure why you had a problem here. The error message said quite clearly it was unable to load SDL2.dll. Why were you confused?

Misread it & assumed that SDL2# had included everything it needed.

ModeSix
Mar 14, 2009

I'm having a problem that I definitely shouldn't be having with moving an object at a 45 degree angle from straight up.

I'm using Unity.

These are my controls for going straight up, basic, simple:
code:
	    if (Input.GetAxis("Horizontal") != 0)
                GetComponent<Rigidbody2D>().velocity = new Vector2(Input.GetAxis("Horizontal") * 5, newVelocity.y);


            if (Input.GetAxis("Horizontal") == 0)
                GetComponent<Rigidbody2D>().velocity = new Vector2(0, newVelocity.y);
           
newVelocity.y is the objects foward movement speed which is adjusted using the up-down arrows.

I can't seem to wrap my ahead around making the movement and controls function in the same way when going either left or right at a 45 degree angle.

The player object is being rotated to the 45 degree angle left or right, and what I am attempting to do is translate the forward velocity into a 45 degree movement and have the left-right movement of the object adjusted to compensate for this new angle.

Hints tips or otherwise would be greatly appreciated.

My Maths are bad and shouldn't be.

edit: I solved this myself right after posting this. Apparently my maths are better than I thought.

ModeSix fucked around with this message at 00:46 on Mar 16, 2015

duck monster
Dec 15, 2004

I just found some old sourcecode for a game I wrote a decade ago. I was still learning python, so some of its pants-on-head retarded, but other than a few api updates, it..... works.

It was written when I was obsessed with eve online and wanted to make a game to agitate another team who goonfleet where waring with. I got half way and gave up.

I think I might strip out the cringeworthy 10 year old goon injokes and finish this drat thing.

Joda
Apr 24, 2010

When I'm off, I just like to really let go and have fun, y'know?

Fun Shoe
To what extent can you treat Bullet like a black box physics engine? It seems like they want you to extend their classes and override functions, but at the same time as far as I can tell you can just set up a dynamics world and fill it with stuff and get transformations from the objects you feed it. Is this an approach I'm gonna regret later, or should I just not worry about it?

Falcorum
Oct 21, 2010

Joda posted:

To what extent can you treat Bullet like a black box physics engine? It seems like they want you to extend their classes and override functions, but at the same time as far as I can tell you can just set up a dynamics world and fill it with stuff and get transformations from the objects you feed it. Is this an approach I'm gonna regret later, or should I just not worry about it?

You may have to extend the motion state interface in order to use it to sync data but other than that, you can pretty much treat it as a black box. There's also the debug drawer but that's optional.

Zaphod42
Sep 13, 2012

If there's anything more important than my ego around, I want it caught and shot now.
Wrong thread :doh: what are tabs?

Music Theory
Aug 7, 2013

Avatar by Garden Walker


First serious non-robot thing I've ever programmed. Just look at all that programmer art. :D

The visible bit is the rendering engine (Although it's pretty much a lawnmower engine compared to most things that are called that). I programmed a lot of the physics and stuff beforehand because I didn't feel like learning SDL until I had to. If you look closely, you may notice that I did something wrong.

ErIog
Jul 11, 2001

:nsacloud:

Music Theory posted:



First serious non-robot thing I've ever programmed. Just look at all that programmer art. :D

The visible bit is the rendering engine (Although it's pretty much a lawnmower engine compared to most things that are called that). I programmed a lot of the physics and stuff beforehand because I didn't feel like learning SDL until I had to. If you look closely, you may notice that I did something wrong.

Mixed up x and y in your tile locations?

ErIog fucked around with this message at 04:25 on Mar 18, 2015

Music Theory
Aug 7, 2013

Avatar by Garden Walker

ErIog posted:

Mixed up x and y in your tile locations?

Yep. I think I know why, though, so that will be an easy thing to fix.

Pollyanna
Mar 5, 2005

Milk's on them.


I'm reading Learning 2D Game Development With Unity, and it's interesting, but also kind of disappointing. The book isn't very well organized: the (required!) assets and files aren't included nor is it clear where you can get them, the book never actually tells you about critical components such as how to check if the player is on the ground, and there's a whole lot that's either skipped (e.g. aforementioned ground check component) or outdated because of changes in Unity 5. Plus, the editing is kind of mediocre.

It's kind of disappointing, really. What books on 2D game dev like this one (but better) are recommended? Unity-specific is ideal, since that's where I'm starting.

Yodzilla
Apr 29, 2005

Now who looks even dumber?

Beef Witch
Maybe there's some general 2D concept stuff but I'm going to go out on a limb here and say "none" because I don't see how books can keep up with the pace of engine development nowadays. Even since Unity 4.3 launched at the end of 2013 there's been more tools and other good stuff added to the 2D tool box since then and now Unity 5.

Obsurveyor
Jan 10, 2003

Most books are just going to be long, slow tutorials but Packt Publishing has been releasing a ton of new books for Unity lately and they're usually not too bad. The second edition of Unity 2D Game Development is coming out next month. A Safari subscription is nice because they have all of Packt's books and get new ones day one.

Synthbuttrange
May 6, 2007

echinopsis posted:

It would be good if I didn't already own painter :cry:

Substance Painter and Substance Designer are complementary, not competing products!

Joda
Apr 24, 2010

When I'm off, I just like to really let go and have fun, y'know?

Fun Shoe
Is there something I can write in my cmakelist or gcc arguments so I won't have to define GLEW_STATIC in every source file that include glew.h?

echinopsis
Apr 13, 2004

by Fluffdaddy

SynthOrange posted:

Substance Painter and Substance Designer are complementary, not competing products!

Yes, but the subscription service would mean I'd be paying for painter a second time :cry:

As it turns out, texturing doesn't really compliment the low-poly aesthetic I've got going with my games anyway. :/

Also good to find that painters update now has baking, curvature and AO for example

The_Franz
Aug 8, 2003

Joda posted:

Is there something I can write in my cmakelist or gcc arguments so I won't have to define GLEW_STATIC in every source file that include glew.h?

Add -DGLEW_STATIC to the compiler command line or add
code:
add_definitions(-DGLEW_STATIC)
to the CMakeLists file.

Harvey Mantaco
Mar 6, 2007

Someone please help me find my keys =(
In Unity if I used AddForce to push a rigidbody in a certain direction I'm noticing that even though I'm not pushing it at all in the Y direction it is still lifting slightly at the start of the push, which isn't good. I want it to have a big push in a perfectly horizontal direction and then begin dropping off as gravity takes over - how do I prevent this lift?

ModeSix
Mar 14, 2009

Harvey Mantaco posted:

In Unity if I used AddForce to push a rigidbody in a certain direction I'm noticing that even though I'm not pushing it at all in the Y direction it is still lifting slightly at the start of the push, which isn't good. I want it to have a big push in a perfectly horizontal direction and then begin dropping off as gravity takes over - how do I prevent this lift?

You could try using rigidbody.velocity instead? Or temporarily lock the rigidbody X movement for 0.1 seconds? Two random ideas.

Unormal
Nov 16, 2004

Mod sass? This evening?! But the cakes aren't ready! THE CAKES!
Fun Shoe
Wally perfection!

Pentecoastal Elites
Feb 27, 2007

Harvey Mantaco posted:

In Unity if I used AddForce to push a rigidbody in a certain direction I'm noticing that even though I'm not pushing it at all in the Y direction it is still lifting slightly at the start of the push, which isn't good. I want it to have a big push in a perfectly horizontal direction and then begin dropping off as gravity takes over - how do I prevent this lift?

Could be a few things. If you've got multiple child colliders and aren't setting Rigidbody.centerOfMass it could be trying to push from a weird point that causes it to pop up. It could also be that you have very slightly overlapping colliders that are forcing themselves out of collision as the rigidbody starts to move. It could be with your rigidbody registering a bounce based on physic materials settings, etc etc.

I've been writing a little physics-intensive thing in Unity and I'm quickly coming to the conclusion that the only time you should rely on the built-in physics is when you don't care about control, feel, or precision. I don't even know if it's bad bad (I'm not a physicist or mathematician) but it's a collection of black boxes.
Anyway I agree with ModeSix and will add that pretty much any time you're looking for specific behavior from Unity physics you'll want to grab it by the ears and force it into position.

e:
or like

code:
if (transform.position.y > minimumY)
{
  transform.position = new Vector3(transform.position.x, minimumY, transform.position.z)
}
or rigidbody.velocity instead of transform.position, based on your gameobject hierarchy
that's not the best solution performance-wise but if it's not happening to a bunch of transforms all the time it's probably not too bad

Pentecoastal Elites fucked around with this message at 04:54 on Mar 23, 2015

Harvey Mantaco
Mar 6, 2007

Someone please help me find my keys =(
Fixing the center mass worked, locking the y axis for a moment did too: )
Thanks buds.

AntiPseudonym
Apr 1, 2007
I EAT BABIES

:dukedog:
Unity Editor question: Does anyone know if there's a way to create/draw the RectTool through code at all?

The rect thing with the blue dots:


I'm trying to make a decent bitmap font editor and if a resizable rect is already available to me I'd prefer to use it rather than rolling my own. I swear I read about how to do it once but I'm not having any luck Googling it at all. :(

Literal Hamster
Mar 11, 2012

YOSPOS
This is a Unity3D problem:

I'm working on a game that has the player creating rooms out of layers of cubes. I want to hide all of the inner cube surfaces while leaving the outer surfaces visible to create a usable room.

Some images to explain what I'm talking about :





What I need:



Can anyone offer some advice or places to look?

duck monster
Dec 15, 2004

Daysvala posted:

This is a Unity3D problem:

I'm working on a game that has the player creating rooms out of layers of cubes. I want to hide all of the inner cube surfaces while leaving the outer surfaces visible to create a usable room.

Some images to explain what I'm talking about :





What I need:



Can anyone offer some advice or places to look?

well one fairly safe assumption is that if any plane is directly facing another block, it doesn't need to be drawn (depending on the alpha, of course)

If you want to combine the squares into a single surface,
http://stackoverflow.com/questions/2667748/how-do-i-combine-complex-polygons

possibly better:
http://stackoverflow.com/questions/643995/algorithm-to-merge-adjacent-rectangles-into-polygon

duck monster fucked around with this message at 08:39 on Mar 26, 2015

Literal Hamster
Mar 11, 2012

YOSPOS

duck monster posted:

well one fairly safe assumption is that if any plane is directly facing another block, it doesn't need to be drawn (depending on the alpha, of course)

That's a really good point. I'm not sure how I would go about doing this though.

One of the links you gave me suggested that I should create an array containing every point on each rectangle, find matching points and remove the rectangles containing those points. But this approach would effectively remove all of my walls, since every rectangle has at least one point that intersects with a point on another rectangle.

superh
Oct 10, 2007

Touching every treasure

AntiPseudonym posted:

Unity Editor question: Does anyone know if there's a way to create/draw the RectTool through code at all?

The rect thing with the blue dots:


I'm trying to make a decent bitmap font editor and if a resizable rect is already available to me I'd prefer to use it rather than rolling my own. I swear I read about how to do it once but I'm not having any luck Googling it at all. :(

That looks like it's in the sprite editor, is that what you mean? You can definitely script it. I'm not at my desk right now but, I know I grabbed a plugin for parsing texturepacker sprites and that's doing it, if you need an example.

Pentecoastal Elites
Feb 27, 2007

Daysvala posted:

That's a really good point. I'm not sure how I would go about doing this though.

One of the links you gave me suggested that I should create an array containing every point on each rectangle, find matching points and remove the rectangles containing those points. But this approach would effectively remove all of my walls, since every rectangle has at least one point that intersects with a point on another rectangle.

So, here are my thoughts. I don't know if they're, like, the "right ways", but hopefully it'll help.

The first (easier one, I think) is if you're building these rooms as a player or in like a level editor (seems that way) is to build your cell detection into the placement method. Basically like:
code:
PlaceBlock
     check to see if this newly-placed cell has any neighbors, and return a collection of them
     if neighbors.length > 0
          foreach neighbor in nieghbors
               delete/hide the vertices THAT cell shares with THIS cell
               delete/hide the vertices THIS cell shares with THAT cell 
Deleting cells would just do the opposite. Check if a cell has any neighbors on deletion, then re-crease/unhide the vertices that will no longer overlap with the to-be-deleted block.

Now, if you're building levels from external data, there are a whole bunch of ways you could do it. Of the top of my head:
Brute force I (slowest)
Iterate over every block. Raycast a little distance in every direction from each block. Did the ray intersect another block? If so, eliminate the vertices of that face.

Brute force II (not as slow but still pretty slow)
Store every block as an object in an array of block[mapsize_x, mapsize_y]
If a block has a neighbor, eliminate the vertices in that direction.
The upside is that you could do this before actually instantiating anything, and just build your gameobjects from the block[,] data.

Maybe okay technique I
Get a collection of your uppermost (highest z I guess) vertices. Let's say it's a 2D array - non-jagged so it'll be like verts[ , ].
Find and eliminate the vertices that appear four times (so we only have the edges)
Now, find the contour (which will become the only verts we want visible) by starting at the lowest-value (lower left) vertex and walking around our shape until we hit the original.
You can do this with a recursive function that marks each vertex it walks to, and tries to walk S>E>N>W. Because we eliminated interior squares (4-overlaps) it'll return your contour when it can't walk to a new vertex.
Now that you have your contour verts, delete/hide everything else in that z-plane.

I hope that made sense. I'm on two benadryl and extremely little sleep right now :shepface:

Pollyanna
Mar 5, 2005

Milk's on them.


e: wrong thread

Pollyanna fucked around with this message at 17:22 on Mar 26, 2015

Literal Hamster
Mar 11, 2012

YOSPOS

Onion Knight posted:

So, here are my thoughts. I don't know if they're, like, the "right ways", but hopefully it'll help.

The first (easier one, I think) is if you're building these rooms as a player or in like a level editor (seems that way) is to build your cell detection into the placement method. Basically like:
code:
PlaceBlock
     check to see if this newly-placed cell has any neighbors, and return a collection of them
     if neighbors.length > 0
          foreach neighbor in nieghbors
               delete/hide the vertices THAT cell shares with THIS cell
               delete/hide the vertices THIS cell shares with THAT cell 
Deleting cells would just do the opposite. Check if a cell has any neighbors on deletion, then re-crease/unhide the vertices that will no longer overlap with the to-be-deleted block.

Now, if you're building levels from external data, there are a whole bunch of ways you could do it. Of the top of my head:
Brute force I (slowest)
Iterate over every block. Raycast a little distance in every direction from each block. Did the ray intersect another block? If so, eliminate the vertices of that face.

Brute force II (not as slow but still pretty slow)
Store every block as an object in an array of block[mapsize_x, mapsize_y]
If a block has a neighbor, eliminate the vertices in that direction.
The upside is that you could do this before actually instantiating anything, and just build your gameobjects from the block[,] data.

Maybe okay technique I
Get a collection of your uppermost (highest z I guess) vertices. Let's say it's a 2D array - non-jagged so it'll be like verts[ , ].
Find and eliminate the vertices that appear four times (so we only have the edges)
Now, find the contour (which will become the only verts we want visible) by starting at the lowest-value (lower left) vertex and walking around our shape until we hit the original.
You can do this with a recursive function that marks each vertex it walks to, and tries to walk S>E>N>W. Because we eliminated interior squares (4-overlaps) it'll return your contour when it can't walk to a new vertex.
Now that you have your contour verts, delete/hide everything else in that z-plane.

I hope that made sense. I'm on two benadryl and extremely little sleep right now :shepface:

Thanks very much, I've got a few places to start now at least. The way I'm doing it at the moment is each block is actually 6 separate meshes and game objects which are children of an empty block parent game object. This is probably a very Dumb approach but it was the easiest way to start.

xgalaxy
Jan 27, 2004
i write code
Regarding Unity, the never ending stream of IL2CPP fixes in every one of their patch notes since its release is at the point of ridiculousness.

Joda
Apr 24, 2010

When I'm off, I just like to really let go and have fun, y'know?

Fun Shoe
I'm writing an Wavefront OBJ loader, and have made pretty good headway. I tried implementing it so that if no normals are provided, it'd calculate them by itself. My method is to take the cross product between the connected edges for a triangle/facet definition for every vertex, normalise them, and then loop through the cumulated normals by the end to divide them by the number of calculated normals to get the average normal. It seems to output approximately the right general idea of a direction, but it seems like it's out of scale or something. I get some very jarring differences when it crosses the model-space axes:



This is the code where I cumulate normals, which is done during the facet definition phase. faceIndices contains the position array indices for the facet currently being defined.

C++ code:
 for(int i = 0; i < 3; i++) {
                unsigned int ind0 = faceIndices[i];
                unsigned int ind1 = faceIndices[(i + 1) % 3];
                unsigned int ind2 = faceIndices[(i + 2) % 3];

                noConnections[ind0]++;

                glm::vec3 v1 = positions[ind1] - positions[ind0];
                glm::vec3 v2 = positions[ind2] - positions[ind0];

                cumulativeNormals[ind0] += glm::normalize(glm::cross(v1,v2));
}
and this is the code where I define a Vertex (ignore the UV coordinates; I haven't gotten to them yet.)

C++ code:
for(int i = 0; i < positions.size(); i++) {
        vertices.push_back(Vertex(positions[i],
				glm::normalize(cumulativeNormals[i]/(float) noConnections[i]),
				glm::vec2(0.5f,0.5f)));
}
As far as I can tell the way to average directions is to just add them and divide them by the number of directions you want to average between, so I can't figure out how I'm getting this problem. Can someone tell where I've gone wrong?

E: I just figured out I could just normalise the cumulated normals without having to divide by anything to get the combined direction. The problem still seems to persist though :(

Joda fucked around with this message at 02:05 on Mar 27, 2015

TheresaJayne
Jul 1, 2011

Daysvala posted:

Thanks very much, I've got a few places to start now at least. The way I'm doing it at the moment is each block is actually 6 separate meshes and game objects which are children of an empty block parent game object. This is probably a very Dumb approach but it was the easiest way to start.

is it feasible to find any duplicate faces and cull them all,

Get a list of all faces, if there are 2 with exactly the same coords (different facings though.) delete both.

Moon Wizard
Dec 29, 2011

Joda posted:

I'm writing an Wavefront OBJ loader, and have made pretty good headway. I tried implementing it so that if no normals are provided, it'd calculate them by itself. My method is to take the cross product between the connected edges for a triangle/facet definition for every vertex, normalise them, and then loop through the cumulated normals by the end to divide them by the number of calculated normals to get the average normal. It seems to output approximately the right general idea of a direction, but it seems like it's out of scale or something. I get some very jarring differences when it crosses the model-space axes:



...

As far as I can tell the way to average directions is to just add them and divide them by the number of directions you want to average between, so I can't figure out how I'm getting this problem. Can someone tell where I've gone wrong?

E: I just figured out I could just normalise the cumulated normals without having to divide by anything to get the combined direction. The problem still seems to persist though :(

There are a couple things that I can think of that might possibly be doing that, and it mostly comes down to your .obj file.

- Are there quads in the file? I think you might have other issues if there were, but your normal calculation assumes triangles.
- Are there any repeated positions? You could have two identical positions with different indices which would cause the kind of lines you are seeing, since each vertex would have a different normal.

Also I believe you can use one calculation for the entire face, since the vertices should all have the same normal.

Joda
Apr 24, 2010

When I'm off, I just like to really let go and have fun, y'know?

Fun Shoe

DaVideo posted:

There are a couple things that I can think of that might possibly be doing that, and it mostly comes down to your .obj file.

- Are there quads in the file? I think you might have other issues if there were, but your normal calculation assumes triangles.
- Are there any repeated positions? You could have two identical positions with different indices which would cause the kind of lines you are seeing, since each vertex would have a different normal.

Also I believe you can use one calculation for the entire face, since the vertices should all have the same normal.

Thanks. There are no quads defined, but I think you're right about some vertices being defined more than once where the artifacts occur. I guess I'll have to implement some alias detection to get around that.

wayfinder
Jul 7, 2003

Joda posted:

Thanks. There are no quads defined.

For defined quads, combine squats, leg presses and deadlifts with a calorie-reduced diet!

xzzy
Mar 5, 2009

Get your quads ready for summer by converting them to triangles with this simple workout!

Adbot
ADBOT LOVES YOU

Sex Bumbo
Aug 14, 2004
Try not dividing at all and scaling by the angle between edges. Also as mentioned weld the verts first and post a squat form video.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply