Well, I tried to set up OgreNewt today following [URL="http://www.ogre3d.org/tikiwiki/OgreNewt"]this[/URL] tutorial. I then tried to compile and got this:
[cpp]\OgreNewt\ogrenewt2.3\inc\OgreNewt_ContactJoint.h|115|error: cannot convert 'NewtonBody*' to 'float*' for argument '2' to 'void NewtonMaterialGetContactPositionAndNormal(const NewtonMaterial*, float*, float*)'|[/cpp]
The code in the line that gets marked for the error is this:
[cpp]void getPositionAndNormal( Ogre::Vector3& pos, Ogre::Vector3& norm,OgreNewt::Body*body ) const { NewtonMaterialGetContactPositionAndNormal(m_material,body->getNewtonBody(), &pos.x, &norm.x); }[/cpp]
It's a file that comes with OgreNewt, and I didn't even touch it.
So then I just copied and pasted the code from [url=http://www.ogre3d.org/tikiwiki/Newton+Game+Dynamics+2.0+Code]here[/url], and got the exact same error. I've also tried other different tutorials, but most of them are either outdated or give me the same error. What do?
I'm apparently substitute teaching a couple visual basic classes and some other stuff in a week or so. I'm really hyped for the experience because it will be great for my resume and a good exercise in teaching, which I like doing.
Only problem is I've never used visual basic.:v:
Anybody got a specific tutorial/crash course site they like for VB programming?
[QUOTE=ryan1271;32511511]I need to write a recursive function in java that takes one int stars and prints a triangle starting with one star and ending with the number entered. I have the printStars method which takes an int for the number of stars to print on one line.
For example:
printRecur(5);
should print
*
**
***
****
*****
Any idea how to do this? I already made the reverse of this which was much easier, just subtract one each time until it reaches 0.[/QUOTE]
call printRecur before you print the stars
[QUOTE=ryan1271;32511511]I need to write a recursive function in java that takes one int stars and prints a triangle starting with one star and ending with the number entered. I have the printStars method which takes an int for the number of stars to print on one line.[/QUOTE]
This is trivial to do — it sounds like you're asking someone to do your homework for you.
Ask yourself this:
* What's the base case for the recursion?
* What's on the first four lines of the five-star triangle?
[QUOTE=ryan1271;32511511]I need to write a recursive function in java that takes one int stars and prints a triangle starting with one star and ending with the number entered. I have the printStars method which takes an int for the number of stars to print on one line.
For example:
printRecur(5);
should print
*
**
***
****
*****
Any idea how to do this? I already made the reverse of this which was much easier, just subtract one each time until it reaches 0.[/QUOTE]
As Wyzard put it, a lot of Computer Science is problem solving. Just think about it for a minute. You said you already have the method that prints out from the number to 1, this code is very similar. What number would you have to start at? What would you have to do to that number to complete your task?
Since this is recursion, think about your simple case. When will the printing stop?
[img]http://dl.dropbox.com/u/12453703/negativeid.png[/img]
This is an SQL database which I've dragged into my Windows Form. However the ID is meant to increment by +1, not -1. Why is this happening?
The identity seed is 1, and the identity increment is also 1... so I'm a bit confused. =/
Anyone know how to make a C# program and a C++ program interact with each other?
I'm wanting to make a LCD applet (Logitech keyboards) for my XNA game
[QUOTE=Noth;32519528]Anyone know how to make a C# program and a C++ program interact with each other?
I'm wanting to make a LCD applet (Logitech keyboards) for my XNA game[/QUOTE]
You could PInvoke from C# down to C++, or bind a C++ library to C# using something like SWIG.
Or you could try using C++.Net or Managed C++ or whatever it's called now, but I'm sure there are plenty of FP members ready to jump in and tell you not to use that.
I'd use PInvoke from C# like thomasfn said. So compile the C++ program as a .dll and then DllImport it and call the functions.
[QUOTE=Robbis_1;32519841]I'd use PInvoke from C# like thomasfn said. So compile the C++ program as a .dll and then DllImport it and call the functions.[/QUOTE]
Shouldn't you be working? >:(
[QUOTE=Dr Magnusson;32520078]Shouldn't you be working? >:([/QUOTE]
Compiling!
[img]http://imgs.xkcd.com/comics/compiling.png[/img]
Oh, carry on!
[QUOTE=NovembrDobby;32509043]Does anyone know how to get any kind of decent texture filtering on Images in SFML?
I can't find anything about it or about auto-mipmaps, and Image.setSmooth(true) makes almost no difference. I'm using textures that normally only scale down (from 1024).[/QUOTE]
Never mind, fixed it by modifying setSmooth to gluBuild2DMipmaps() and use GL_LINEAR_MIPMAP_LINEAR.
[img]http://i.imgur.com/0b9UE.png[/img]
[editline]28th September 2011[/editline]
changed it to glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);
[QUOTE=Noth;32519528]Anyone know how to make a C# program and a C++ program interact with each other?
I'm wanting to make a LCD applet (Logitech keyboards) for my XNA game[/QUOTE]
There is a G15 library for .NET.
[url]http://gjlglcd.codeplex.com/[/url]
I'm using XNA4.0
This is the HLSL shader code.
Why does it not compile ?
[code]uniform extern float4x4 WorldViewProj : WORLDVIEWPROJECTION;
uniform extern texture UserTexture;
uniform extern float Radius;
struct VertexShaderOutput
{
float4 Position : POSITION0;
};
struct VSInput
{
float4 Position : POSITION0;
};
sampler textureSampler : register(s0);
VertexShaderOutput vShader(VSInput input)
{
VertexShaderOutput ret = (VertexShaderOutput)0;
ret.Position = mul(input.Position, WorldViewProj);
return ret;
}
float4 pShader(VertexShaderOutput vsout) : COLOR0
{
return tex2D(textureSampler, vsout.Position).rgba;
}
technique ShaderTechnique1
{
pass Pass0
{
vertexShader = compile vs_2_0 vShader();
pixelShader = compile ps_2_0 pShader();
}
}[/code]
This is my very first attempt on programming my own shader.
Can someone fix it for me please and give a short explanation?
Here the errors returned by the compiler:
[code](7,23): error X4502: invalid ps_2_0 input semantic 'POSITION0'
(34,24): ID3DXEffectCompiler::CompileEffect: There was an error compiling expression[/code]
I understand the error. I just have no idea how to fix it. I don't know what else to write there...
Edit: as an alternative a super simple hlsl2.0 shader that only displays a texture would suffice to get me going.
[QUOTE=high;32495460]You have to do something like
for(int i = 0; i < bulletList.Count; i++)
bulletList[i] = new Vector2(bulletList[i].X, bulletList[i].Y - 5);
As Vector2 is a struct so it gets copied by value and not by reference. This means the Vector2 bulletPosition is separate from the Vector2 inside the list.[/QUOTE]
I love you, please have my babies.
I dont understand it, but it works.
This is friggen driving me nuts. :pwn:
I've tried Ogre3D, and now Irrlicht, and all of them lead me into the same error. So I've followed all tutorials I could find about integrating Newton into Ogre3D and Irrlicht, and for some reason, all of them lead me into this error:
[cpp]newtonsdk\sdk\newton.h|333|error: too many arguments to function 'NewtonWorld* NewtonCreate()'|[/cpp]
This is the line causing the error:
[cpp]nWorld = NewtonCreate(NULL, NULL);[/cpp]
Line 33 of newton.h is:
[cpp]NEWTON_API NewtonWorld* NewtonCreate ();[/cpp]
I've updated NewtonSDK to 2.3, OgreNewt and IrrNewt, yet all of them give me the same error. I can compile an example Ogre3D/Irrlicht sample just fine though. All the tutorials I've followed on using Newton told me that I needed two arguments for NewtonCreate, so I'm 100% it's not my code.
I'm on Windows 7 Ultimate 64-bit, my IDE is Code::Blocks and I'm using the included MinGW compiler. I'm also using a custom (patched) W7 theme if that matters (it did when Game Maker was throwing me random errors) and my IrrNewt version is the latest I could find: 0.4. I could not find one single soul with the same error as me.
Please, I really need some help with this. Every time I try to get back to C++, some random error throws me off and nobody can ever help me figure out what it is.
I'm having some troubles with my collision detection for detecting when I hit either sides or the top of my rectangles or jump on a rectangle/box. I'm doing this in Python with Pygame and essentially everything is broken and not working as intended.
[code]
def RectCollision():
global hitwallL
global hitwallR
global hittop
for s in somelist:
if marioRect.colliderect(s['rect']):
[b]#i have a list with my rectangles, their x coordinates, and their y coordinates stored seperately
#my current rectangles have a height of 36 so adding 36 is the bottom of my rectangle[/b]
if characterRect.top == s['coordy'] + 36:
hittop = True
break
[b]#i still need to fix everything else before i work on my detection for if i'm standing on a rectangle, which is why this is just a comment currently[/b]
#elif characterRect.bottom == s['coordy']:
# onland == True
[b]#i have tried a shitload of things here, this is just my most recent attempt, its like this because my character can never be more than 7
over the x coordinate of the left side of my block and i needed some way
to figure out if my character was colliding with the left side of my rectangle if his speed wasn't a multiple of my x coordinates on the left side of the box[/b]
elif s['coordx'] - characterRect.right < 8 and s['coordx'] - characterRect.right > -1:
print('workin2')
hitwallR = True
break
[b]#this one is completely broken i think, i can see a bunch of flaws with it just looking at it again now in a less frustrated state
the second condition is there to make sure the result is not negative because it wont work if it is (well i mean, it would work even less)[/b]
elif characterRect.left - s['coordx'] < 8 and characterRect.left - s['coordx'] > -1:
print('ok')
hitwallL = True
break
[b]#if i fix the other things this should work fine i believe.[/b]
else:
print('yay')
hitwallR = hitwallL = hittop = False
[/code]
Now this is one of many iterations of this function and was written in a blurry minded state where I was trying all the things I could think of, I'm sure there must be a far simpler way and I'm going about this in a horrible way ATM. Now beyond this I just have if statements for the places that need it(like stopping a jump from rising when you hit the top etc etc) that check if hitwallL, hitwallR, and hittop are True and if so adjust themselves accordingly but that all works fine and if not I can figure that stuff out pretty easily.
[QUOTE=Samuka97;32530864]This is friggen driving me nuts. :pwn:
I've tried Ogre3D, and now Irrlicht, and all of them lead me into the same error. So I've followed all tutorials I could find about integrating Newton into Ogre3D and Irrlicht, and for some reason, all of them lead me into this error:
[cpp]newtonsdk\sdk\newton.h|333|error: too many arguments to function 'NewtonWorld* NewtonCreate()'|[/cpp]
This is the line causing the error:
[cpp]nWorld = NewtonCreate(NULL, NULL);[/cpp]
Line 33 of newton.h is:
[cpp]NEWTON_API NewtonWorld* NewtonCreate ();[/cpp]
I've updated NewtonSDK to 2.3, OgreNewt and IrrNewt, yet all of them give me the same error. I can compile an example Ogre3D/Irrlicht sample just fine though. All the tutorials I've followed on using Newton told me that I needed two arguments for NewtonCreate, so I'm 100% it's not my code.
I'm on Windows 7 Ultimate 64-bit, my IDE is Code::Blocks and I'm using the included MinGW compiler. I'm also using a custom (patched) W7 theme if that matters (it did when Game Maker was throwing me random errors) and my IrrNewt version is the latest I could find: 0.4. I could not find one single soul with the same error as me.
Please, I really need some help with this. Every time I try to get back to C++, some random error throws me off and nobody can ever help me figure out what it is.[/QUOTE]
Well, why are you passing NULL and NULL to NewtonCreate? The error tells you you're passing too many arguments and the function prototype obviously shows that it doesn't take any.
[QUOTE=ZeekyHBomb;32531195]Well, why are you passing NULL and NULL to NewtonCreate? The error tells you you're passing too many arguments and the function prototype obviously shows that it doesn't take any.[/QUOTE]
[url=http://content.gpwiki.org/index.php/Irrlicht:Physics]Because[/url] [url=http://irrlicht.sourceforge.net/tut_newtondevcpp.html]all the[/url] [url=http://www.ogre3d.org/forums/viewtopic.php?t=18204]different[/url] [url=http://www.newtondynamics.com/wiki/index.php5?title=Tutorial_-_Irrlicht_and_Newton_start]tutorials[/url] tell me to. Plus, [url="http://www.google.com/search?q=%22NewtonCreate%28NULL%2C+NULL%29%3B%22&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:unofficial&client=firefox-a"]it works for everybody else, apparently[/url]. And even if I don't pass any, I get more errors on NewtonCreateBody and a whole lot of other functions. The function prototype for all versions I've downloaded are exactly the same, yet I'm the only one who gets this error, even downloading a project file and compiles fine under everyone else's computers.
[QUOTE=Samuka97;32531229]\And even if I don't pass any, I get more errors on NewtonCreateBody and a whole lot of [b]other functions[/b].[/QUOTE]
You're getting errors on other functions which means you fixed that error. You should focus on the new errors instead. I don't know why everyone else passes NULL, NULL but if the prototype doesn't have it, then you don't need it. I'm guessing your version is newer, or older, than what most people have used in the past.
In C++ when you fix one error it is not uncommon for 50 more to show up. It's just that one took priority over the others and now that it's fixed the other ones will display.
I didnt fix it, I just commented it. Im on my phone but Ill try that tomorrow.
[QUOTE=Rocket;32531823]Cross posting from WAYWO.
Anyone have any articles on Wandering/Simple AI? I need some sort of AI, but I just need them to walk around randomly.[/QUOTE]
I dunno of any tutorials, but wandering is a pretty simple thing to do.
[img]http://dl.dropbox.com/u/11093974/Junk/wander.png[/img]
Imagine a circle in front of the bot. The bot picks a random spot on that circle and moves toward it. So basically...
pseudocode
[code]
target.x = position.x + cos(direction) * distance
target.y = position.y + sin(direction) * distance
randomAngle = rand(0, 360)
target.x += cos(randomAngle) * radius
target.y += sin(randomAngle) * radius
move toward target
[/code]
Adjust the distance of the circle from the player and the radius of the circle until the wander looks about how you want it. Also most languages would need radians instead of degrees.
For really basic steering algorithms there's always [url="http://www.red3d.com/cwr/steer/gdc99/"]this site[/url] and [url="http://wiki.unrealcreations.com/groups/kb/wiki/b05f0/The_Steering_Object.html"]this student-written article[/url].
[QUOTE=jalb;32532172]I dunno of any tutorials, but wandering is a pretty simple thing to do.
[img]http://dl.dropbox.com/u/11093974/Junk/wander.png[/img]
Imagine a circle in front of the bot. The bot picks a random spot on that circle and moves toward it. So basically...
pseudocode
[code]
target.x = position.x + cos(direction) * distance
target.y = position.y + sin(direction) * distance
randomAngle = rand(0, 360)
target.x += cos(randomAngle) * radius
target.y += sin(randomAngle) * radius
move toward target
[/code]
Adjust the distance of the circle from the player and the radius of the circle until the wander looks about how you want it. Also most languages would need radians instead of degrees.
[/QUOTE]
I find this to be a little bit of an unusual choice. It means that the bot will 'prefer' to head towards either side of the target circle and, to some extent, avoid the middle. This probability distribution is pretty much the opposite of what I'd think you'd want. Something like a gaussian distribution (or something cheaper like 1/(pi*(1+x^2))) seems more reasonable, as the bot will tend to move in straight-ish lines, with the occasional turn or exceedingly rare sharp turn.
It all depends on what you're looking for. When I think of wandering I usually think the opposite of the bot moving forward. This is a nice approach if you want the bot to move unexpectedly but not look like it's freaking out.
The nice thing about the circle-technique is you can adjust it visually. A smaller circle means less variety and a further away circle means less turning and more moving straight.
Can anyone confirm for me if I'm on the right track here? I'm wondering if the point of this algorithm is to locate in an array where a particular value is located.
[code]
int lowest, middle, highest;
const int N = 10;
int goal = 38;
int a[N] = { 10,27,38,59,60,76,79,80,82,86 };
lowest = 0;
highest = N-1;
while( lowest < highest )
{
middle = (lowest + highest) / 2;
if(goal > a[middle])
{
lowest = middle+1;
}
else
{
highest = middle;
}
}
[/code]
At the end of the program the values for lowest and highest are 2. I'm assuming this is because the goal (which is 38) is located in index 2 of the array? E.g. a[2] = 38.
So if I'm right, this program is basically meant to find the range (lowest, highest) of where the goal could be located, correct? Sounds like a silly-ass question but I just want to confirm. :v:
Thanks in advance.
That's correct. I'm not so sure about the whole "finding a range" thing, afaik it's suppose to only find one instance of the number. It's called a binary search, and from what I understand of it you would use it when data is in-order and if there are no duplicates. If there are duplicates it'll still work, it'll just find one of them (the others will be in the same area since it's in order though).
Aight that makes sense. I'm trying to decipher this one at the moment - this one seems worse, the variable names have intentionally been made horrible I presume:
[code] int s,v,i,k;
s = 0;
const int N = 5;
int a[N] = { 11,23,21,17,35};
while(s < N)
{
s = s+1;
v = a[s];
k = s;
i = s;
while( i < N )
{
i = i + 1;
if( a[i] > v)
{
v = a[i];
k = i;
}
}
a[k] = a[s];
a[s] = v;
}[/code]
I have an exam tomorrow for this sort of stuff and I gotta decipher this with pen and paper... so no putting this into Visual Studio and running the debug. Arghhhhhh!
Obviously the algorithm's gonna keep going till 's' and 'i' become equal to or greater than N... but I gotta find out what the purpose of this algorithm is. If you can give me any "hints" perhaps on being able to quickly analyze these algorithms that would be awesome. I'll edit this post (or post a new reply) hopefully if I come to any reasonable conclusion. :smile:
* Edit: Once algorithm finishes array is now: 11,35,23,21,17
Are you sure that's the exact algorithm? I know which algorithm it is, it has a name too, but there's an issue with it right off the bat...
[cpp]while(s < N)
{
s = s+1;
v = a[s];[/cpp]
This code will end up trying to fetch the array at index 5. The array has 5 indices so there is only 0, 1, 2, 3, 4. There is not an index at 5.
I'm assuming you're suppose to just read this and "play the computer." Maybe that error was intentional. Maybe they want you to assume that arrays go from 1-5 rather than 0-4. If not, that's a really novice error to make...
As for your hint: Try following what the value v is doing.
Sorry, you need to Log In to post a reply to this thread.