Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411512 Posts in 69376 Topics- by 58431 Members - Latest Member: Bohdan_Zoshchenko

April 27, 2024, 08:27:35 AM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)General thread for quick questions
Pages: 1 ... 17 18 [19] 20 21 ... 69
Print
Author Topic: General thread for quick questions  (Read 135462 times)
gimymblert
Level 10
*****


The archivest master, leader of all documents


View Profile
« Reply #360 on: October 10, 2015, 08:56:46 AM »

Catmull spline are the most use and easier to compute than bezier too
http://www.mvps.org/directx/articles/catmull/
Logged

Cheesegrater
Level 1
*



View Profile
« Reply #361 on: October 10, 2015, 11:57:29 AM »

Catmull pass through all control points, though. The example shown passed through two and used the other two control points for tangency - that is a cubic bezier.
Logged
Dacke
Level 10
*****



View Profile
« Reply #362 on: October 10, 2015, 12:03:50 PM »

What example? ProgramGamer's pic only had two points (A and B). Depending on the implementation you could add more points wherever. My assumption when suggesting a spline was that you had two lines and knew at which point you wanted them to start curving heavily. So you could just pro grammatically add more points lower on the line.
Logged

programming • free software
animal liberation • veganism
anarcho-communism • intersectionality • feminism
Cheesegrater
Level 1
*



View Profile
« Reply #363 on: October 10, 2015, 12:21:37 PM »

does anyone know what the name of this type of curve is? it's generated by two points and two lines and is generally used in vector drawing programs such as flash or photoshop.
Logged
Dacke
Level 10
*****



View Profile
« Reply #364 on: October 10, 2015, 12:26:14 PM »

haha, oops

I'm too dumb to read the text, I just looked at the image.
Logged

programming • free software
animal liberation • veganism
anarcho-communism • intersectionality • feminism
gimymblert
Level 10
*****


The archivest master, leader of all documents


View Profile
« Reply #365 on: October 10, 2015, 12:27:12 PM »

Catmull pass through all control points, though. The example shown passed through two and used the other two control points for tangency - that is a cubic bezier.

That's fair but debatable, it goes through all points except beyond extremity which are the control point. So if you extend those hanging point to extremity you get the tangent just like in his drawing.



Also given the tangent cross and it seems to follow the weight at the point it crossed, it can be a quadratic bezier curve, mention is done for two control point for tangency that could be a cubic bezier curve.



So if he is refering to photoshop and illustrator, it's cubic.

However I didn't say it was that, I mention catmull to offer more options as its best to talk about the family of curve and show the TYPE of curve he is asking for.

Now he have all the options
Logged

oahda
Level 10
*****



View Profile
« Reply #366 on: October 12, 2015, 09:49:29 PM »

1. What's the best cross-platform way to check if files have been updated externally, using C++?

2. I remember from an earlier discussion that editing the contents (assets) folder in an OS X .app directory "breaks code signing", and that I would have to rebuild the project in Xcode or w/e to avoid this. Is there some way to circumvent this, as I want to make an editor that allows me to edit and add assets (level files and so on) to an already built .app without necessarily having to rebuild in Xcode if nothing in the actual executable has changed?
Logged

ProgramGamer
Administrator
Level 10
******


aka Mireille


View Profile
« Reply #367 on: October 12, 2015, 10:14:45 PM »

Thanks for all the resources, I'll be checking them out! I must admit, what I'm trying to achieve with this is a bit tricky. Ideally, I'd like to be able to make filled shapes with these curves, though I'm not sure how that'd work. It really comes down to a choice I made for a game. I want the graphics to be vector based, but the characters that I'm going to be using have a lot curves, so I'd like to be able to render curved, filled shapes. I'm not even sure that's possible from a strict technical standpoint, but I'm looking at my options. Also, if anyone has knowledge on how graphic cards process data and instructions, that'd be a great deal of help towards what I'm trying to achieve.
Logged

ThemsAllTook
Administrator
Level 10
******



View Profile WWW
« Reply #368 on: October 12, 2015, 11:05:14 PM »

1. What's the best cross-platform way to check if files have been updated externally, using C++?

By "updated externally", do you mean you want to be notified when a file has changed on disk? Polling the modification date with fstat() would probably do the job OK, but there may be better options in each OS's API that can dispatch an event to you upon modification. I'm pretty sure at least OS X has a mechanism for that (I think FSEvents is what you'd want?)

2. I remember from an earlier discussion that editing the contents (assets) folder in an OS X .app directory "breaks code signing", and that I would have to rebuild the project in Xcode or w/e to avoid this. Is there some way to circumvent this, as I want to make an editor that allows me to edit and add assets (level files and so on) to an already built .app without necessarily having to rebuild in Xcode if nothing in the actual executable has changed?

Is it necessary to modify a fully built and signed app bundle in your situation? From my guesses at what this would be used for, it sounds like something that could be done on an unsigned debug build. If you're planning to make it so that any user can modify a signed release build of something, you'll probably need to look into the details of code signing pretty closely, or opt not to sign your app, or store editable files elsewhere on disk.
Logged

oahda
Level 10
*****



View Profile
« Reply #369 on: October 12, 2015, 11:33:49 PM »

1. What's the best cross-platform way to check if files have been updated externally, using C++?

By "updated externally", do you mean you want to be notified when a file has changed on disk?
Yep.

Polling the modification date with fstat() would probably do the job OK, but there may be better options in each OS's API that can dispatch an event to you upon modification. I'm pretty sure at least OS X has a mechanism for that (I think FSEvents is what you'd want?)
Any portable solution would come first. Is fstat() portable?

2. I remember from an earlier discussion that editing the contents (assets) folder in an OS X .app directory "breaks code signing", and that I would have to rebuild the project in Xcode or w/e to avoid this. Is there some way to circumvent this, as I want to make an editor that allows me to edit and add assets (level files and so on) to an already built .app without necessarily having to rebuild in Xcode if nothing in the actual executable has changed?

Is it necessary to modify a fully built and signed app bundle in your situation? From my guesses at what this would be used for, it sounds like something that could be done on an unsigned debug build. If you're planning to make it so that any user can modify a signed release build of something, you'll probably need to look into the details of code signing pretty closely, or opt not to sign your app, or store editable files elsewhere on disk.
Storing the assets outside of the .app is both inelegant and violates standard expectations from Mac users in this case IMO. The worst case scenario isn't that bad anyhow. I'll just keep putting stuff into the .app this way while working on it (while it may "break code signing", which I'm not sure what it means, the app will still work in my experience, so it's viable for development) and then just press the build button whenever I need to deploy something.

But eh, I guess I'll have to do that anyway, since the editor would be working with the debug build, bloated with debug and edit features of the engine, whereas I would deploy a release build with all of that stuff taken out by the preprocessor.

Maybe I could get my hands dirty and have my editor do the compilation under the hood at some point. Tongue
Logged

edmundmk
Level 0
**


View Profile
« Reply #370 on: October 13, 2015, 02:56:00 AM »

Thanks for all the resources, I'll be checking them out! I must admit, what I'm trying to achieve with this is a bit tricky. Ideally, I'd like to be able to make filled shapes with these curves, though I'm not sure how that'd work. It really comes down to a choice I made for a game. I want the graphics to be vector based, but the characters that I'm going to be using have a lot curves, so I'd like to be able to render curved, filled shapes. I'm not even sure that's possible from a strict technical standpoint, but I'm looking at my options. Also, if anyone has knowledge on how graphic cards process data and instructions, that'd be a great deal of help towards what I'm trying to achieve.

Drawing vector graphics on the GPU is a bit tricky.  GPUs like raster data and triangles, and can't handle curves natively.  Curves typically have to be 'flattened' into a polyline before you ask the GPU to draw them.  And if your vector shapes have holes or intersections then you have to take the fill rule into account to identify which parts are 'inside' and 'outside' the shape.  Even just drawing a concave polygon isn't totally straightforward.

There are various approaches you can take to drawing vectors.  Most renderers flatten curves by recursively splitting them (see the de Casteljau algorithm) until the curve pieces are small or flat enough that you can't see the difference.  CPU renderers then typically split this flattened shape into trapezoidal pieces which can be rasterized a scanline at a time.

Some GPU renderers can evaluate curves without flattening by using a shader (using something like Loop-Blinn), but either way filled shapes have to be rendered with the correct holes.  Most GPU renderers use the stencil buffer to create a mask indicating which pixels are inside the shape, and then draw the fill in a second pass.  Another option is to triangulate the flattened polygon on the CPU.  Triangulating a shape with curved edges is even more difficult (cubic bezier curves can self-intersect, and two cubic curves can intersect at up to 9 points, so you have to start splitting again).

Some GPU vendors have custom vector support in their drivers, but it is non-portable.

One other option is to precalculate a distance field texture which can be used in a shader to tell if a pixel is inside, outside, or close to the edge of a particular shape.

I recommend that you don't try and write your own renderer for vector art.  Either export your artwork as a raster image at the appropriate resolution(s), or use a library or system which already has support for drawing vector art (e.g. flash, web canvas, cairo, skia, nanovg).



Logged
Cheesegrater
Level 1
*



View Profile
« Reply #371 on: October 13, 2015, 06:40:02 AM »

I agree that it is usually a much better option to fake this with bitmap art that just looks like true vectors.

If you must facet curves into triangles yourself, this will get you started - (but be warned this is not a simple topic): http://http.developer.nvidia.com/GPUGems3/gpugems3_ch25.html
Logged
ProgramGamer
Administrator
Level 10
******


aka Mireille


View Profile
« Reply #372 on: October 13, 2015, 06:47:05 AM »

Alright, if high-rez bitmaps are a much better solution then I'm willing to give them a try. Still, coming up with curved shapes that work with GPU's would have been sweet.
Logged

ThemsAllTook
Administrator
Level 10
******



View Profile WWW
« Reply #373 on: October 13, 2015, 11:30:45 AM »

Storing the assets outside of the .app is both inelegant and violates standard expectations from Mac users in this case IMO.

The situation I was imagining was that at first launch, your game (or the editor) creates a directory for itself in ~/Library/Application Support, and reads things out of that if they've been edited instead of what's inside its own bundle. Storing stuff in a directory next to the bundle would indeed be terrible!
Logged

InfiniteStateMachine
Level 10
*****



View Profile
« Reply #374 on: October 14, 2015, 07:58:30 AM »

Can anyone recommend a C/C++ library for interacting with IRC? The end goal being to make a simple IRC application.

C++11 libs are fine too
Logged

Kyuugatsu
Level 1
*



View Profile
« Reply #375 on: October 14, 2015, 10:41:00 AM »

I'm making a game where you essentially watch a tree grow. I haven't decided whether this will be 2D or 3D, I'd prefer 3D but will probably go with whichever is easier.

The requirements are:
- The tree will have various different states (seed/seedling/sapling/adult)
- Each stage will have multiple states (1 branch, 2 branches...+)
- Each stage/branch will have multiple states (1 leaf, 2 leaves...+)
- All of these states and stages will have various animations, as well as transition animations when the tree grows.

My question is, what is the easiest (least work) way to accomplish this? Would 3D be better than 2D? How would I do the transition animation in 3D (e.g. sapling to adult)? How could I do the leaves and various states in 3D?
Logged

oahda
Level 10
*****



View Profile
« Reply #376 on: October 14, 2015, 10:52:45 AM »

Even if you do it in 2D it would seem practical for you to use some sort of system that can work like a mesh renderer (like OpenGL) and draw the thing using faces so that you can just keep adding more vertices when and where you need to (so vector graphics, basically).

That way you can simply start from nothing, pull up some vertices to animate it growing upward, then also make it wider and so on, just by moving vertices programmatically and have the thing (like OpenGL) render faces between them.

You can basically just go through the process by hand to begin with, in either a 3D modeling program or a vector graphics program, to see how you need to arrange the vertices, and then you just translate what you've gathered into some sort of programmatic system (recursive, probably).

And 2D is probably a lot easier since you'll only have to worry about the silhouette of the tree and not which branches are actually behind each other in what ways and so on, tho how good this will look might depend on your art style — it might have to be a bit simplistic like the two tree games I've seen on TIGS here so far (Prune and How to be a tree, I think?).
Logged

Kyuugatsu
Level 1
*



View Profile
« Reply #377 on: October 14, 2015, 11:44:34 AM »

I think I will go 3D after all. One thing I forgot to mention is that this "game" will only have one tree in the end, so that all players will eventually end up with the same tree. Maybe I can even do away with the limited "branching" (heh) in choice.

So I don't have to worry about some things that come with 3D, but I'm still not sure about animation, wind effects, snow effects, etc. I guess I should hire a 3D modeler/animator.
Logged

InfiniteStateMachine
Level 10
*****



View Profile
« Reply #378 on: October 14, 2015, 12:41:26 PM »

I'm making a game where you essentially watch a tree grow. I haven't decided whether this will be 2D or 3D, I'd prefer 3D but will probably go with whichever is easier.

The requirements are:
- The tree will have various different states (seed/seedling/sapling/adult)
- Each stage will have multiple states (1 branch, 2 branches...+)
- Each stage/branch will have multiple states (1 leaf, 2 leaves...+)
- All of these states and stages will have various animations, as well as transition animations when the tree grows.

My question is, what is the easiest (least work) way to accomplish this? Would 3D be better than 2D? How would I do the transition animation in 3D (e.g. sapling to adult)? How could I do the leaves and various states in 3D?

Maybe take a look at this

http://illogictree.com/games/kyoto/
Logged

oahda
Level 10
*****



View Profile
« Reply #379 on: October 14, 2015, 12:45:32 PM »

I think I will go 3D after all. One thing I forgot to mention is that this "game" will only have one tree in the end, so that all players will eventually end up with the same tree. Maybe I can even do away with the limited "branching" (heh) in choice.

So I don't have to worry about some things that come with 3D, but I'm still not sure about animation, wind effects, snow effects, etc. I guess I should hire a 3D modeler/animator.
Well, you can still use the technique I suggested in 3D (since my "2D" technique basically is 3D tech, but only uses two axes). It just gets a little more complicated to work with, but it's essentially the same.

But when you talk about models and stuff I begin to wonder whether you're actually intending to premodel the trees in all of its various stages. Maybe blendshapes could be use to tween between those in that case...
Logged

Pages: 1 ... 17 18 [19] 20 21 ... 69
Print
Jump to:  

Theme orange-lt created by panic