[QUOTE=AzzyMaster;31025863]This is a more mathematical question, but how would I calculate the rotation of a player so that it is always pointing at where the mouse is?[/QUOTE]
atan2
[code]
Players[PlayerIndex].Rotation = (float)(Math.Atan2(mouse.Y - Players[PlayerIndex].Y,
mouse.X - Players[PlayerIndex].X))
[/code]
Isn't returning the correct rotation, and I can't see why.
[QUOTE=AzzyMaster;31026578][code]
Players[PlayerIndex].Rotation = (float)(Math.Atan2(mouse.Y - Players[PlayerIndex].Y,
mouse.X - Players[PlayerIndex].X))
[/code]
Isn't returning the correct rotation, and I can't see why.[/QUOTE]
atan2 returns the angle in radians, are you using it as a degrees angle? If so, you can convert to degrees by multiplying by (180 / pi)
[QUOTE=Chris220;31026602]atan2 returns the angle in radians, are you using it as a degrees angle? If so, you can convert to degrees by multiplying by (180 / pi)[/QUOTE]
Nope it is a radians angle, but the returned angle always seems to be off by about a quater.
What's the most common method of smoothing movement for 2d objects.
At the minute, what I do for smoothing is subtract the current x/y from the destination x/y, divide the difference by a value and add that value to the current. This results in smooth movement, fast at first and slowing down as it reaches the destination coordinates. Is this the most common way of doing it?
[QUOTE=Jimbomcb;31026970]What's the most common method of smoothing movement for 2d objects.
At the minute, what I do for smoothing is subtract the current x/y from the destination x/y, divide the difference by a value and add that value to the current. This results in smooth movement, fast at first and slowing down as it reaches the destination coordinates. Is this the most common way of doing it?[/QUOTE]
Linear interpolation is probably the most common. What you're doing is, uh, exponential interpolation. Probably coordinate-wise, so it converges on the destination quicker diagonally than along either axis. It requires an infinite amount of calculations to actually reach the destination, but in practice floating point imprecision kicks in pretty quickly.
A bad thing about exponential interpolation is that it requires somewhat expensive calculations to make it work correctly for variable timesteps.
[editline]10th July 2011[/editline]
It looks pretty smooth for camera position interpolation. IIRC it was used in Jedi Academy.
[editline]10th July 2011[/editline]
[QUOTE=AzzyMaster;31026669]Nope it is a radians angle, but the returned angle always seems to be off by about a quater.[/QUOTE]
That's probably because by default zero direction should be the positive X-axis, and positive orientation should be counter-clockwise. However on screen the zero direction is occasionally taken to be directly upwards (negative Y-axis). Clockwise orientation [i]to the user[/i] is counter-clockwise orientation to the computer because one of the axes is flipped.
So if you previously did atan2(y, x), try doing atan2(x, -y)
or do some other sign flips and swaps until you get the correct result.
Does anyone know if there's a shader validator which checks if the shader compiles correctly on NVidia cards? I found this...
[url]http://www.geeks3d.com/20100924/gpu-tool-ati-gpu-shaderanalyzer-1-55-released/[/url]
But that only checks if it compiles on ATI cards, which is useless because I already have an ATI video card.
[QUOTE=ThePuska;31027117]Linear interpolation is probably the most common. What you're doing is, uh, exponential interpolation. Probably coordinate-wise, so it converges on the destination quicker diagonally than along either axis. It requires an infinite amount of calculations to actually reach the destination, but in practice floating point imprecision kicks in pretty quickly.
A bad thing about exponential interpolation is that it requires somewhat expensive calculations to make it work correctly for variable timesteps.
[editline]10th July 2011[/editline]
It looks pretty smooth for camera position interpolation. IIRC it was used in Jedi Academy.
[editline]10th July 2011[/editline]
That's probably because by default zero direction should be the positive X-axis, and positive orientation should be counter-clockwise. However on screen the zero direction is occasionally taken to be directly upwards (negative Y-axis). Clockwise orientation [I]to the user[/I] is counter-clockwise orientation to the computer because one of the axes is flipped.
So if you previously did atan2(y, x), try doing atan2(x, -y)
or do some other sign flips and swaps until you get the correct result.[/QUOTE]
Yeah, the infinite calculations disregarding the floating point stuff is what I was worried about, the only reason I'm doing it is because it seems the simplest, and I'm not really sure of the best way to go about any other methods of smoothing.
For example on [URL]http://jimbomcb.net/spec/12/[/URL], I'm using the exponential interpolation for camera movement as I can't figure out how I could implement linear interpolation. I'm using linear interpolation for the player icon smoothing though as I know where the player was, where the player should be and how far between the two coordinates the player should be.
I don't know... It's not much of a problem, just slightly concerned about performance as when the camera is moving, it has to redraw the background, and the current smoothing slows way down near the end so it's still moving and having to redraw the background if only by a few pixels.
[QUOTE=Jimbomcb;31027348]Yeah, the infinite calculations disregarding the floating point stuff is what I was worried about, the only reason I'm doing it is because it seems the simplest, and I'm not really sure of the best way to go about any other methods of smoothing.
For example on [URL]http://jimbomcb.net/spec/12/[/URL], I'm using the exponential interpolation for camera movement as I can't figure out how I could implement linear interpolation. I'm using linear interpolation for the player icon smoothing though as I know where the player was, where the player should be and how far between the two coordinates the player should be.
I don't know... It's not much of a problem, just slightly concerned about performance as when the camera is moving, it has to redraw the background, and the current smoothing slows way down near the end so it's still moving and having to redraw the background if only by a few pixels.[/QUOTE]
This new round camera is better than the old automatic one, but the round camera sometimes zooms very much out, so I can see the entire map when people are still in only one corner.
[QUOTE=ThePuska;31027117]
That's probably because by default zero direction should be the positive X-axis, and positive orientation should be counter-clockwise. However on screen the zero direction is occasionally taken to be directly upwards (negative Y-axis). Clockwise orientation [i]to the user[/i] is counter-clockwise orientation to the computer because one of the axes is flipped.
So if you previously did atan2(y, x), try doing atan2(x, -y)
or do some other sign flips and swaps until you get the correct result.[/QUOTE]
I love you, it works now.
I just ran into endianness problem and it's making me want to stab myself
Is there a not completely convoluted way to convert it in c#?
[editline]10th July 2011[/editline]
I should probably mention that it's big endian that I want converted into little endian. Double, I have it hacked in bytes (intercepting minecraft packets)
Just reverse the array. You can use BitConverter.ToDouble to convert it back to a double.
I suck at VBOs, why does this not work? Nothing's drawing; just a blank screen. I tried drawing some vertices with immediate mode and that worked, so my mvp matrix is fine.
[cpp]/* in my initialisation bit: */
// Create our clientside data
const int V_SIZE = 30;
Vertex vertices[V_SIZE];
for(int i = 0; i < V_SIZE; i++)
{
vertices[i].x = sf::Randomizer::Random(-5.0f, 5.0f);
vertices[i].y = sf::Randomizer::Random(-5.0f, 5.0f);
vertices[i].z = sf::Randomizer::Random(-5.0f, 5.0f);
}
// Create the buffer
glGenBuffers(1, &m_vboId);
// Bind the buffer to the ARRAY_BUFFER
glBindBuffer(GL_ARRAY_BUFFER, m_vboId);
// Allocate some space for the buffer (1MB)
glBufferData(GL_ARRAY_BUFFER, V_SIZE * sizeof(Vertex), 0, GL_STATIC_DRAW);
// Buffer the data
glBufferSubData(GL_ARRAY_BUFFER, 0, V_SIZE * sizeof(Vertex), vertices);
/* And then in the drawing bit: */
glBindBuffer(GL_ARRAY_BUFFER, m_vboId);
glVertexPointer(3, GL_FLOAT, sizeof(Vertex), 0);
glDrawArrays(GL_POINTS, 0, 30);[/cpp]
Do you also flip the screen after drawing the arrays
[editline]11th July 2011[/editline]
Additionally you might require shaders
[QUOTE=esalaka;31034203]Do you also flip the screen after drawing the arrays
[editline]11th July 2011[/editline]
Additionally you might require shaders[/QUOTE]
Immediate mode still works, so my drawing code is working. And, I THINK you can still use VBOs with deprecated OpenGL-managed matrices, can't you? I'm pretty sure you can D:
yeah probably
Trying to display text in openTK, to do so i aparently have to draw text to a texture and then display that texture.
But I cant find the DrawString method in system.drawing
If anyone is experienced with openTK, could i add them please?
I doubt anyone can help me, but I tried making a script that checks for the kill count of a certain actor, and then increase the health of the actors still alive based on how many you killed. On gamebryo/netimmerse script, TES 3 Morrowind.
I'm gonna post the actual code after this, but I'm gonna detail my problem further first.
Every script in the engine gets executed every frame, so every if clause essentially turns into a while clause, and if you use a real while clause the game engine crashes due to infinite loops.
So what I did first, I made a script that checks for kill count every frame and increases the global NZ_round value every 11 kills, which works perfectly.
Then I made a script, that is on every actor that is being checked, that checks the global NZ_round every frame and increases health based on the value, now thats where the problem comes in.
There's 2 ways of changing health on Morrowind game syntax, modhealth and sethealth.
modhealth increases health by the value given, so modhealth 30 would increase by 30, and modhealth -24 would decrease by 24.
sethealth sets the health at a certain value, so sethealth 50 would set health at 50 regardless of anything.
Making the script with modhealth lead to health increasing every frame, so it would rise as long as the actor was alive, since the script is executed every frame.
Making it with sethealth lead to constantly replenishing health, so it would be reset to 50 every frame, and the only possibility to kill the actor is by dealing more than 50 damage on one blow.
I tried making the health increase dependant upon two seperate if-clauses, and setting one of them to something else inside the if-clause, but that didn't work for some reason.
I'm gonna try and recreate some of the code below here, and add some commentary since I didn't do that originally, and I also deleted the code, which was probably kinda dumb.
[b]begin NZ_roundcounter
if ( GetDeadCount "NZ_zombie_normal" == 10 )
set NZ_round to 2
endif
if ( GetDeadCount "NZ_zombie_normal" == 21 )
set NZ_round to 3
endif
end[/b]
Not the whole script, but thats how the rest looks.
GetDeadCount checks the number of killed actors.
[b]begin NZ_zombie_script_normal
;sethealth variant, replenishment problem
if ( NZ_round == 2 )
sethealth 50
endif
;modhealth variant, rise problem
if ( NZ_round == 2 )
modhealth 20
endif
;death check to increase the player's points with every kill
if ( OnDeath == 1 )
set NZ_cash to (NZ_cash + 10)
endif
end NZ_zombie_script_normal[/b]
Actor's script, I included both variants, any ideas on how to work around it?
use [code] tags
[QUOTE=Chris220;31033614]I suck at VBOs, why does this not work?[/QUOTE]
Before calling glDrawArrays(), you need to glEnableClientState(GL_VERTEX_ARRAY) to tell GL to actually use the array data that was specified by the glVertexPointer() call.
In C#, what is the best way of keeping a console window open when a program is opened.
For example: I have a program that is in exe but when it's launched, it launches java.exe.
[QUOTE=vexx21322;31040601]In C#, what is the best way of keeping a console window open when a program is opened.
For example: I have a program that is in exe but when it's launched, it launches java.exe.[/QUOTE]
I'm not really sure what the point of the application is if it's just launching a java program, but if you want to keep the console window open constantly, right click on the project -> Properties. In the "Application" tab, set the Output Type to "Console Application" instead of "Windows Application"
[QUOTE=vexx21322;31040601]In C#, what is the best way of keeping a console window open when a program is opened.
For example: I have a program that is in exe but when it's launched, it launches java.exe.[/QUOTE]
Errr, a while true loop?
I basically just want to add the program to steam, but when I launch it through steam, it says I'm in game for a micro second because the original exe isn't the one running for the program.
-snip-
Since I got no help on what I asked then, maybe this will work:
What would be the most efficient way to make a falling sand type game?
personally I would just have a List of a Particle class (with subclasses for all the different types of materials). That way you can have particles of different sizes that act differently. To me that seems to be the most straightforward way of doing it. Another way of doing it would be to have each pixel (assuming all particles are only 1px large) be a struct with a material ID and a velocity (for physics).
Both would probably be pretty efficient, the second one would get a lot slower as screen size increases.
[editline]10th July 2011[/editline]
and the first one would slow down a lot when you have a ton of particles
[QUOTE=robmaister12;31043462]personally I would just have a List of a Particle class (with subclasses for all the different types of materials). That way you can have particles of different sizes that act differently. To me that seems to be the most straightforward way of doing it. Another way of doing it would be to have each pixel (assuming all particles are only 1px large) be a struct with a material ID and a velocity (for physics).
Both would probably be pretty efficient, the second one would get a lot slower as screen size increases.
[editline]10th July 2011[/editline]
and the first one would slow down a lot when you have a ton of particles[/QUOTE]
I thought about that, but that would mean a new object for every particle. I didn't know how I would do physics, and render, thats 4 for loops for every particle.
[QUOTE=Wyzard;31039918]Before calling glDrawArrays(), you need to glEnableClientState(GL_VERTEX_ARRAY) to tell GL to actually use the array data that was specified by the glVertexPointer() call.[/QUOTE]
Ah, that worked, thanks!
So, since glEnableClientState() is deprecated (as is glVertexPointer and so on), I assume the next step is to get it running on shaders instead of OpenGL's own matrix manipulation; then using glVertexAttribPointer() and so on.
Thanks again :)
[QUOTE=vexx21322;31041943]I basically just want to add the program to steam, but when I launch it through steam, it says I'm in game for a micro second because the original exe isn't the one running for the program.[/QUOTE]
[url]http://www.dotnetspider.com/resources/4579-Start-process-wait-until-exits.aspx[/url]
Sorry, you need to Log In to post a reply to this thread.