[QUOTE=MountainWatcher;34116078]Oh, I see. What if I wanted to pass the array without it being a pointer? Would I just write (int v, int i, int n)?
I really should have paid more attention in class.
[editline]8th January 2012[/editline]
Wait, can you even do that?[/QUOTE]
skipping class is what all the cool kids do
[QUOTE=Mr. Smartass;34117123]This problem has been really stumping me, and preventing me from learning more in XNA. I'm trying to work on a camera that moves in accordance to the mouse, but I'm having some issues. Instead of moving up and down when the mouse is moved, the camera bobs up and down on it's own accord. When I move the mouse, it barely responds. If anyone could help, it would be greatly appreciated.
This is REALLY bugging me, because I'm sure that it's some small, petty mistake, but I haven't been able to figure it out for three days.[/QUOTE]I'm guessing your problem is somewhere in processMouse() but I can't really tell at a glance since the code you provided is kind of confusing.
[QUOTE=a203xi;34125706]I'm guessing your problem is somewhere in processMouse() but I can't really tell at a glance since the code you provided is kind of confusing.[/QUOTE]
Yeah, my code was a mess so I decided to completely rewrite the rotations bit. I assume that that's where the issue lies.
I'm trying to limit an angle. Let's call it [I]Joint.Rotation[/I]. This variable ranges from -Pi to +Pi. I also have [I]Joint.Sector[/I] and [I]Joint.SectorOffset[/I]. Sector is the amount of freedom the rotation has, and sectoroffset is the center-angle of the radius.
Can someone explain to me how to calculate the min/max angles, and use these to limit the rotation?
I gave it a decent attempt to solve it, but my math-knowledge is incredibly poor. Usually I get help from a friend who has more knowledge, but he's not available right now, so I ask you.
Here's an image of my project. Maybe it will help explain.
[url]http://dl.dropbox.com/u/4367505/AnimatorScreen3.png[/url]
It's supposed to look like a skeletal animation system.
Also: Also, radius should say "sector", and radiusoffset "sectoroffset". Oops!
Alright, so I need a list of Sha1 hashes of ~2k files. We started with PHP but that came to a fast end, I tried LuaJIT then but took more than a minute with 100% CPU..
What would be the best solution to do this (fastest / lowest CPU usage)?
I guess a small c program but I'd like to hear your ideas.
I'm really having some trouble understanding why the following code does not work:
[cpp]
int dofile( const char *file )
{
if( boost::algorithm::ends_with( file, ".lua" ) )
{
const char *filename = file;
} else {
const char *filename = file + (const char*)".lua";
}
// More code here about loading and running the file, but the error occurs above.
}
[/cpp]
Error:
[code]
dofile.cpp: invalid operands of types 'const char*' and 'const char*' to binary 'operator+'.
[/code]
Anyone?
[QUOTE=LuaStoned;34149175]Alright, so I need a list of Sha1 hashes of ~2k files. We started with PHP but that came to a fast end, I tried LuaJIT then but took more than a minute with 100% CPU..
What would be the best solution to do this (fastest / lowest CPU usage)?
I guess a small c program but I'd like to hear your ideas.[/QUOTE]
From my experience, when you want number crunching stuff like this you'll want to go as low level as you can.
Bear in mind, though, that there are many other ways to speed up this kind of thing, as simple as multithreading (fairly good speed gains) to something complex like GPU computation (very large speed gains).
[editline]10th January 2012[/editline]
[QUOTE=T3hGamerDK;34149294]I'm really having some trouble understanding why the following code does not work:
[cpp]
int dofile( const char *file )
{
if( boost::algorithm::ends_with( file, ".lua" ) )
{
const char *filename = file;
} else {
const char *filename = file + (const char*)".lua";
}
// More code here about loading and running the file, but the error occurs above.
}
[/cpp]
Anyone?[/QUOTE]
You can't concatenate C-strings with the + operator, look in [url=http://www.cplusplus.com/reference/clibrary/cstring/strcat/]strcat()[/url].
It's also worth noting that "filename" is being declared in the scope of the if/else blocks, and there is out of scope by the time those blocks terminate. You probably want something like this:
[cpp]int dofile( const char *file )
{
const char* suffix = ".lua";
char filename[64] = file;
if( !boost::algorithm::ends_with( file, suffix ) )
{
strcat(filename, suffix);
}
}[/cpp]
Bear in mind that the above code is untested and possibly contains mistakes.
For those familar with c# and winforms, I've been meaning to start a simple little project where I use point and line classes to define simple shapes, and display them on a grid on a winform that's connected to an array somehow, and I'd manipulate the points from there. This is intentionally low-tech for the sake of showing how to draw lines "by hand" and how to use matrixes to do shit. Any ideas what the best course of action is for displaying grids? I've seen "DataGridView", but that seems more like a spreadsheet than anything.
How do i apply an else statement to 2 if's in c++
eg
[code]
if (a == 1){
cout << "a is 1" << endl;
};
if (a == 2){
cout << "a is 2" << endl;
};
else{
cout << "you are an idiot" << endl;
};
[/code]
In this cut down example the else would only apply to the second if, how would i go about applying it to both?
[QUOTE=wad67;34157367]How do i apply an else statement to 2 if's in c++
eg
[code]
if (a == 1){
cout << "a is 1" << endl;
};
if (a == 2){
cout << "a is 2" << endl;
};
else{
cout << "you are an idiot" << endl;
};
[/code]
In this cut down example the else would only apply to the second if, how would i go about applying it to both?[/QUOTE]
Why are you putting semi-colons after your braces?
Does anyone have any experience with memory mapped files?
[QUOTE=mechanarchy;34158876]Does anyone have any experience with memory mapped files?[/QUOTE]
yeah
[QUOTE=mechanarchy;34158876]Does anyone have any experience with memory mapped files?[/QUOTE]
Just ask your question. If we can answer it we will.
Bugs me when people go "does anyone know anything about ___" It's just pointless. I mean, it might make sense if you were going to ask something really technical in general discussion or something stupid like that, but this is a programming forum. You can basically assume someone here is going to understand what you're talking about.
My question was as vague as it was because I wasn't really sure what to ask.
I'm trying to read files of arbitrary length. I'll need to read the entire thing sequentially at some point, but I anticipate jumping around will also happen. Given I've never really done anything of this degree before I wasn't sure what to do but a bit of googling pointed me towards memory-mapped files.
So I wrote a class that did some fairly brainless memory-mapping, just put the entire file in memory no matter how large it was. I've since realised this probably isn't the greatest idea, and I should probably be chunking the memory maps. Is this right? So (pending your input) when I get an opportunity I'll be rewriting my MemMapped class to handle various chunks of memory. This should make it perform a bit better.
[img]http://dl.dropbox.com/u/6929441/screenshots/hydrogen02.png[/img]
This is what I've got at the moment. The hex pane is just reading bytes of the memory map.
Are you actually manually loading the files into memory? If so, that is probably counter-productive.
Memory-mapped files should be provided by the OS. In posix, the function is mmap(). Windows should have something similar.
But, yeah, you probably don't want to mmap the entire file all at once if it is large. In some situations you can make assumptions about size (game assets, like textures, for example, typically aren't going to be many-gigabytes large), but if you're writing something like an archival/backup program, files could easily be larger than the available address space.
mmap may not be advisable in all cases, and you have to carefully weigh the trade-offs. If you could give us a little more context, maybe we could give you some useful feedback.
[QUOTE=ROBO_DONUT;34159811]Are you actually manually loading the files into memory? If so, that is probably counter-productive.
Memory-mapped files should be provided by the OS. In posix, the function is mmap(). Windows should have something similar.[/QUOTE]
I'm using mmap on Linux at the moment. The class I wrote was just a wrapper to make things a bit easier for myself and so I can eventually make it a bit cross-platform if necessary. I probably should have made this clear originally.
I believe it's time I create a proprietary model format for my project. I currently have the vertices and indices for meshes being extracted from Source's SMD format.
Because building the indices is a slow process and I'll have animations added soon, I believe I need to start building a binary model format. I believe I want to store my index and vertex list (as well as filename, material paths, etc.) into a binary file, which I'll read later, and then create a buffer on the GPU on load, copy the data to it and draw my meshes that way.
I'm using C++ - What's the best way to go about serializing data like this, preferably without using an external library such as Boost.
How can I simply implement applying force to a object my simple physics program.
My object has mass, height and speed.
[QUOTE=Lord Ned;34164944]I believe it's time I create a proprietary model format for my project. I currently have the vertices and indices for meshes being extracted from Source's SMD format.
Because building the indices is a slow process and I'll have animations added soon, I believe I need to start building a binary model format. I believe I want to store my index and vertex list (as well as filename, material paths, etc.) into a binary file, which I'll read later, and then create a buffer on the GPU on load, copy the data to it and draw my meshes that way.
I'm using C++ - What's the best way to go about serializing data like this, preferably without using an external library such as Boost.[/QUOTE]
Do you need to create your own format?
I've done it a few times and most of the time it isn't worth it, not because it's difficult to design a format or write a parser/writer (it isn't), but because you can't use any existing tools with it without writing a parser/writer for those as well.
Take a look at IQM. It probably has everything you need.
[editline]11th January 2012[/editline]
[QUOTE=bobiniki;34165325]How can I simply implement applying force to a object my simple physics program.
My object has mass, height and speed.[/QUOTE]
Force or impulse? Impulse is more natural to implement in a discrete-time system (like a computer game). The closest you can get to actual force is to break up the force into many small impulses (i.e. figure out the total impulse resulting from a force over the delta time of each game frame).
Impulse is force integrated over time, or delta-v times mass. To 'apply' an impulse to an object, divide the impulse by the object's mass and add the result to the current velocity.
[QUOTE=ROBO_DONUT;34166737]Do you need to create your own format?
I've done it a few times and most of the time it isn't worth it, not because it's difficult to design a format or write a parser/writer (it isn't), but because you can't use any existing tools with it without writing a parser/writer for those as well.
Take a look at IQM. It probably has everything you need.[/QUOTE]
Well I've already bridged the gap between software and the game via SMD format, so I've got an intermediate format that can do skeletal animations, vertex morphs, etc. So the tools are good.
Now I just need game specific ones - it'll eventually have blending animations and animation layers, etc. so they'll have to be stored anyways.
I'll look at IQM however.
I am making this small game in C# + XNA, and I want to begin on my first inventory system, how would I go about making such a system?
I'm just starting C in college and my teacher didn't say what kind of software we'd need to download in order to code and compile in C at home rather than on the computers in the classroom. Those computers run on a Linux distro and all he said was that the software we use in class isn't compatible with Windows so Windows users need to figure something else out.
In short, what's a good program for editing/coding and compiling in C? We use Terminal and Nano in class, if that means anything important.
What's the formula to animate across a certain distance within a set time?
I'm hoping my problem will be easy to solve.
I'm trying to get a script in the program AutoHotKey to work like this:
I need space to be pressed every 3 seconds. I got that part down, as it's easy.
[code]loop
{
send {space}
sleep 3000
}[/code]
I ALSO need the z key to be pressed and HELD DOWN for 3 seconds, every 15 seconds. This is the part I can't seem to get.
I don't know much of anything when it comes to coding in any language :(
D/T = Velocity (Distance / Time = Velocity), so if we increment the position by the velocity each frame, it should end up at right distance within the right time.
Anyone have any idea on my winform question? (Drawing grids that simulate pixels)? Much appreciated if someone could help.
[QUOTE=DSG;34168496]I'm just starting C in college and my teacher didn't say what kind of software we'd need to download in order to code and compile in C at home rather than on the computers in the classroom. Those computers run on a Linux distro and all he said was that the software we use in class isn't compatible with Windows so Windows users need to figure something else out.
In short, what's a good program for editing/coding and compiling in C? We use Terminal and Nano in class, if that means anything important.[/QUOTE]
Neither 'terminal' nor 'nano' are compilers. 'Terminal' is most likely a terminal emulator, while 'nano' is a very basic text editor. Nano probably runs on Windows, but I'd really recommend against using it, as it has no real benefits aside from being lightweight.
The compiler you're using is most likely GCC, as it is part of the GNU tools and GNU makes up half of Linux. GCC [i]is[/i] compatible with Windows. You can either install just the compiler + build environment (MinGW+GCC) or you can download an entire IDE with them included. Code::Blocks includes MinGW and GCC by default, and I highly recommend them.
How is your MVP matrix derived, and are you sure you have the data arranged correctly in memory (column-major vs. row-major, etc.)?
The convention typically used within OpenGL is column-major matrices and post-multiplication, such that operations are 'applied' to a vector from right-to-left. However, you can use whatever convention you wish as long as you are consistent with it.
[QUOTE=ROBO_DONUT;34168932]Neither 'terminal' nor 'nano' are compilers. 'Terminal' is most likely a terminal emulator, while 'nano' is a very basic text editor. Nano probably runs on Windows, but I'd really recommend against using it, as it has no real benefits aside from being lightweight.
The compiler you're using is most likely GCC, as it is part of the GNU tools and GNU makes up half of Linux. GCC [i]is[/i] compatible with Windows. You can either install just the compiler + build environment (MinGW+GCC) or you can download an entire IDE with them included. Code::Blocks includes MinGW and GCC by default, and I highly recommend them.[/QUOTE]
Thanks I downloaded it and it looks like a good interface. :)
EDIT: I'm having trouble compiling/making sure my program runs correctly using Code::Blocks. I clicked "Build," "Compile," and "Run," multiple times and they don't seem to do anything.... Am I doing something wrong? I'm trying to compile using GCC and need it to run specific arguments (-ansi -Wall -pedantic)
Sorry, you need to Log In to post a reply to this thread.