Allthough somewhat webdev, its more a programming issue.
I dont really know scala but I have found something I think is silly in it.
Im passing:
an array from java like:
[code]return new Category[0];[/code]
and then using it in scala like:
[code]for( i <- 0 to categories.length){
println( i )
}[/code]
Which I would have thought shouldnt print anything as its an empty array, but it does print out 0
I'm throwing together inverse kinematics from my own derivation using gamemaker, but it's not working out and I'm not sure why.
The system has 2 joints and 2 bodies (ie forearm and upper arm, for example). Here's an image to explain the detail: green line is a forearm, red upper arm. The orange angles are the ones I need to solve for.
[img]http://imgur.com/pDqQNGN.png[/img]
From this you can deduce that:
a = arccos( (A1^2 + L^2 - A2^2) / 2*A1*L ))
b = arccos( (A2^2 + A1^2 - L^2) / (2*A1*A2))
Using the cosine laws.
Then:
phi = AngleFromXAxisToL - a
theta = 360-b-(180 - phi - 90)
= 450-b+phi
So in code:
[code]
var a,b, phi, theta,distL, A1;
A1 = 76 //both arms are the same length
distL=point_distance(obj_arm1.x,obj_arm1.y,mouse_x,mouse_y) //length of L
a = dist/(2*distL*A1)
a = arccos(clamp(a,-1,1)) //clamp a from -1 to 1 as that's where the only valid solutions lie
b = (2*A1*A1 - distL*distL)/(2*A1*A1)
b = arccos(clamp(b,-1,1))
phi = point_direction(obj_arm1.x,obj_arm1.y,mouse_x,mouse_y) - radtodeg(a) //find phi in degrees
theta = 450 - radtodeg(b) + phi
obj_arm1.image_angle = phi
obj_arm2.image_angle = theta[/code]
Unfortunately it's not working as expected - the correct angles aren't returned and the end of the forearm does not end up on the point the mouse clicked. Any thoughts on why not?
EDIT: nevermind, just messed up the code a bit! All fixed.
Any idea why this isn't working?
[code]
public ref class LuaLibrary {
private:
public:
virtual System::String^ GetTableName() {
return this->GetType()->Name;
}
virtual void Register(lua_State *L) {
array<System::Reflection::MethodInfo^, 1> ^Methods = this->GetType()->GetMethods();
System::String ^TableName = this->GetTableName();
GLua::CreateGlobalTable(L, TableName);
System::Type ^GFuncType = (gcnew GFunc(EmptyGFunc))->GetType();
for each (System::Reflection::MethodInfo ^MInfo in Methods) {
if (MInfo->ReturnType == (1).GetType()) {
auto Params = MInfo->GetParameters();
if (Params->Length == 1 and Params[0]->ParameterType->FullName == "lua_State*") {
GFunc ^Func = (GFunc^)System::Delegate::CreateDelegate(GFuncType, MInfo);
GLua::SetGlobalTableGFunc(L, TableName, MInfo->Name, Func);
}
}
}
}
static int EmptyGFunc(lua_State* L) {
return 0;
}
};
[/code]
GFunc
[code]
namespace GarrysMod {
[UnmanagedFunctionPointer(CallingConvention::Cdecl)]
public delegate int GFunc(lua_State* L);
}
[/code]
Test class
[code]
public unsafe class Cart : LuaLibrary {
public int TESTEES(lua_State* L) {
GLua.PushString(L, "HEY! YOU! HELLO THERE!");
return 1;
}
}
[/code]
How i initialize it
[code]
new Cart().Register(L);
[/code]
It gives me this error
[img]http://puu.sh/6pJ9z.png[/img]
it fails on this line
[code]GFunc ^Func = (GFunc^)System::Delegate::CreateDelegate(GFuncType, MInfo);[/code]
Any idea how to change it to not fail?
I need a little C help
When you have
int num = 10
how is *&num evalutated?
Will it return 10 because *(&num)
or something from adress 10?
[QUOTE=aurum481;43597598]I need a little C help
When you have
int num = 10
how is *&num evalutated?
Will it return 10 because *(&num)
or something from adress 10?[/QUOTE]
That would return 10, [del]it's evaluated[/del]it reads left to right so you're dereferencing the address of the 'num' variable.
[QUOTE=Chris220;43597719]That would return 10, it's evaluated left to right so you're dereferencing the address of the 'num' variable.[/QUOTE]
Actually it's evaluated right to left. You first take the address, then dereference it.
Okay i got my stuff working, it seems creating delegates on non static classes doesn't work.
[QUOTE=Dienes;43597763]Actually it's evaluated right to left. You first take the address, then dereference it.[/QUOTE]
Sorry, I meant in terms of how it 'reads', if that makes sense. As in, the dereference comes first, the operand of which is what comes to the right of that, in this case the address of the variable. I worded it badly I guess. :v:
[editline]19th January 2014[/editline]
You are correct in terms of the evaluation order, of course. :D
Android:
Does onLocationChanged and other such functions run even if my app is minimized?
Say I start the activity to get location data and then press the home button, does it still gather data and update while it is minimized?
Also, if i'm not mistaken starting an activity will pause the previous one and that would mean my location data won't update unless i keep the activity as the focus at all times. Is this correct?
[QUOTE=Bloodsh0t;43601862]Android:
Does onLocationChanged and other such functions run even if my app is minimized?
Say I start the activity to get location data and then press the home button, does it still gather data and update while it is minimized?
Also, if i'm not mistaken starting an activity will pause the previous one and that would mean my location data won't update unless i keep the activity as the focus at all times. Is this correct?[/QUOTE]
Use a service.
I'm sure this is easy, but for some reason I can't come up with how to do it. What's the easiest way to loop through all [b]edges[/b] of a cube and do something with each edge (in this case clip it against a plane)?
How about you tell us what you need help with and what your errors are and we do it for free?
What did he ask? I'm curious now.
Yeah why do people do that? if you fixed something, post the answer, don't delete the fucking question..
So i have a project that includes GL/glut.h, it compiles and runs fine in my uni computer lab
But my computer does not have glut. So i dowloaded glut and put it in the appropriate folders (ie my VS install folder and whatnot) but the fucking thing still doesn't work, it says it can't find glut.h
So someone suggested that i make a folder in my project dir and dump all the glut crap in it then reference that folder with the project
so i went into project properties > genreal properties > vc++ directories and added $(MSBuildProjectDirectory)\RefAssemblies to Include/Reference/Library directories and also added glut32.lib in Linker > Input > Additional Dependencies
and it's still not fucking finding anything
what do
[QUOTE=ArgvCompany;43604251]I'm sure this is easy, but for some reason I can't come up with how to do it. What's the easiest way to loop through all [b]edges[/b] of a cube and do something with each edge (in this case clip it against a plane)?[/QUOTE]
How is your cube stored? A list of points?
Are there any resources that tell you about the theory behind games?
I don't mean where to place ammo packs, but for example, how would I know that I need to draw things in a loop? Or if I was making a 2D topdown game where the player is always in the center of the screen, I'd just move everything relative to his position?
Could someone give me some links where I could start learning C#/C# Game Programming.
The tutorials does not have to be for beginners, it would be great if you could provide intermediate or advanced tutorials.
Does anyone know of any libraries for DECtalk (the Moonbase Alpha TTS)? I would like to use the engine from within a C# program of mine, but extensive Googling has proven unfruitful.
Even if there only exists an unmanaged library, I could make a wrapper for it as long as its functions/structs have documentation.
[QUOTE=Berkin;43611511]Does anyone know of any libraries for DECtalk (the Moonbase Alpha TTS)? I would like to use the engine from within a C# program of mine, but extensive Googling has proven unfruitful.
Even if there only exists an unmanaged library, I could make a wrapper for it as long as its functions/structs have documentation.[/QUOTE]
It seems like dll included with Moonbase Alpha has been obfuscated somewhat:
[t]http://puu.sh/6svQS.png[/t]
And all references to DECTalk seem to point to the [url=http://www.speechfxinc.com/dectalk.html]licensor[/url]. Apart from speak.EXE from [url=http://facepunch.com/showthread.php?t=1323522]this Facepunch (!) thread[/url], I couldn't find anything either.
[QUOTE=Hypershadsy;43614524]It seems like dll included with Moonbase Alpha has been obfuscated somewhat:
[t]http://puu.sh/6svQS.png[/t]
And all references to DECTalk seem to point to the [url=http://www.speechfxinc.com/dectalk.html]licensor[/url]. Apart from speak.EXE from [url=http://facepunch.com/showthread.php?t=1323522]this Facepunch (!) thread[/url], I couldn't find anything either.[/QUOTE]
I found the SDK from [URL="http://www.theflameofhope.co/DECTALK%20READ.html"]this site[/URL], downloaded it, read the documentation, and wrote my own managed wrapper. It works!
if I have facebook group, and I want it's posts to be in my android app in ArrayList, how would I go about doing this? any tutorials?
Thanks.
[QUOTE=arleitiss;43622231]if I have facebook group, and I want it's posts to be in my android app in ArrayList, how would I go about doing this? any tutorials?
Thanks.[/QUOTE]
You already got an answer to that in the thread you made. You'll have to connect the pieces by yourself though.
Search for the parts (official API documentation, parsing of that format in Java) and you should be able to make the rest of the way.
I know people have written tic tac toe AI that never loses but I wonder if you could make one that defaults to a draw if possible. Hm.
Might be a good exercise in pseudo AI. I'll experiment with it I guess.
Does anyone know how I could check if a cube is colliding (inside of, intersect or contains) with a flat quad?
I know how to check if the quad is completelly inside the cube or if any of the quads corners is inside it but im not sure how to check for a situation like:
[IMG]http://i.imgur.com/d6WNERm.png[/IMG]
Where its intersecting, yet as none of the corners are inside I cant check against them
[QUOTE=Richy19;43623895]Does anyone know how I could check if a cube is colliding (inside of, intersect or contains) with a flat quad?
I know how to check if the quad is completelly inside the cube or if any of the quads corners is inside it but im not sure how to check for a situation like:
[IMG]http://i.imgur.com/d6WNERm.png[/IMG]
Where its intersecting, yet as none of the corners are inside I cant check against them[/QUOTE]
You could try transforming them into axis-aligned space for the box and performing a ray/box intersection test against each of the quad's edges.
[QUOTE=Berkin;43624698]You could try transforming them into axis-aligned space for the box and performing a ray/box intersection test against each of the quad's edges.[/QUOTE]
Hmm, how do you mean?
Both of them have full rotation tho :S
-snip, wouldn't work-
[QUOTE=Richy19;43624839]Hmm, how do you mean?
Both of them have full rotation tho :S[/QUOTE]
Put the plane into the object space of the cube, then test each edge of the plane as a ray to see if it intersects the cube.
If you don't get any hits, do the opposite: put the cube into the plane's object space and test the twelve edges of the cube against the plane for intersection.
I thought I would be able to check for a point, but I have found this [url]http://mathinsight.org/distance_point_plane_examples[/url] and I have no idea what the D variable is.
My plane class has a position and a direction, both of which are 3dvectors
Sorry, you need to Log In to post a reply to this thread.