pick-up-a-cube-and-throw-it-away Sample + Video + Source

ColeZero

05-06-2006 14:09:29

i've created a small app, where you can pickup cubes and throw them away.
So this is a simple demo and really not best-programmed app, so this is not he best solution, but it is a solution..^^
And As ever you can download the source and do what ever you like.
Its VC8.0.

You can walk around with WASD, jump with Space.
To throw a sphere use rightclick and to pickup a cube use leftclick, to throw the picked up cube press E..

Image:



Code

SouceCodeVC8.0

Greets


The Video is at the end of the page..

betajaen

05-06-2006 14:47:43

Oh your so getting the NxOgre hat of the day award.

Looking at the source, that's how I did it with Tech Demo, setting the body to be a kinematic, but the problem is then kinematic bodies will go through static bodies.

Unless that bug has been fixed in later versions.

If you want to you can add these projects to the Wiki, I'll even host the projects for you.

But: Your ploughing along with this!

ColeZero

05-06-2006 15:09:32

Big thx for the award, i'll bear that in my heart :D :D
No iam kidding, anyway thx.


but the problem is then kinematic bodies will go through static bodies.


Yes i've also noticed this bug, hopefully the bug will be fixed later..

As i sad do what ever you want with this, maybe its better to host it on another server than the one i used..

betajaen

05-06-2006 15:19:39

I was thinking how you could carry the body around without making it kinematic.

Perhaps making it not respond to gravity, and some clever movement via forces would be the trick.

Or attaching a joint to the NxActor of the character controller.

ColeZero

05-06-2006 16:18:23

May be the joint-idea is the better one..

i will experiment with the joint idea, attaching it to a joint of the character sounds possible, not that the other ideas aren't possible, but i think the joints are the easiest way..Maybe we can add the object to some kind of invisible rope...


the gravity idea is harder, because when you turn around with you character you need to add a force which pushes the cube in the direction you rotate and a force which pushes the cube nearer to the character so that it'll make circular movement.
And you need to add a force, which pushes the cube up if you jump.

ColeZero

05-06-2006 16:28:47

Strange thing happend:
i simple commented out the line where i set the picked-up cube to be kinematic and it sill works....but there now some little graphical glitches,but they are not big,maybe they appear bcause of the high framerate, but it works without using a kinematic body...

betajaen

05-06-2006 16:33:05

Odd. So your moving the picked up body by hand? How does it fare with it hitting with other bodies or static bodies?

ColeZero

05-06-2006 16:44:16

So your idea with the gravity was great, so it still works with the same result,
i can move and throw the cube with my hand(mouse).
When i pick up a cube i set IgnoreGravity to true and when i want to shoot the cube i set it to false.

Now i need make some tests with Static Bodys, the problem is that the cube wants to go through the static body, but i can't.

its nearly the result i looking for...

it looks like it where attached to a joint, but it isn't, maybe i can make some video...

ColeZero

05-06-2006 17:06:07

I've made a small video showing the pick-up thing without using kinematic

Video

betajaen

05-06-2006 17:25:34

Very good work!

You can stop the spinning of the cube by increasing the Angular (and linear) dampening.

danharibo

05-06-2006 18:54:19

:roll: the host just won't let me download it

ColeZero

05-06-2006 22:48:50

strange.. i can send you the current version via mail?
Or do you know another host?

Wretched_Wyx

06-06-2006 01:36:43

Wow, that's real cool ColZero. You really are picking up on NxOgre quickly. Heck, you're already way farther into it than I am. Glad to see you decided to use NxOgre in the end.

I haven't looked over the code yet, but I had a question (which may end up being suggestion?):

Are you using 'states' for the objects that can be picked up? (Example: state "resting", state "pickedup", state "thrown") Might work better, I don't know. This way you can edit the states to do whatever you want?

betajaen

06-06-2006 08:22:21

States wouldn't be useful in this case, as it's related to the body rather than a relationship with others.

It can be done, but it's more suited for explosive things.

ColeZero

06-06-2006 11:30:23

Heck, you're already way farther into it than I am
No thats not true, so i only want to create an app where you can pick up things and throw them away, or use them as a shield or something^^.
So iam still a beginner and there's still so much to learn... :wink:


i begin to love nxOgre..... :lol:

praetor

06-06-2006 14:49:47

Moving the non-dynamic body using setPosition must work because you don't move it too fast. That is, when you move it around and it hits something, you don't set its position too far inside the other boxes. This keeps the restoring forces down and keeps it from stable. I wonder what would happen if you were to move boxes at much greater speeds using just setPosition calls.

ColeZero

10-06-2006 12:46:10

It seems that this forum is a little bit "quiet" at the moment.
In the last days i've worked on a another solution for mouse picking, thats because i don't like my first solution for the problem, i force the picked-up object to move to a position, as the result the object will go through static-models. so i made some thoughts about other solutions and i'm currently working on the joint idea, which seems to be the better solution.
So i created a body, which represents a weapon or a arm, so with this i can create a joint between the arm/weapon-body and the selected object, and it seems to work i think i can release a sample in the next days, because i had
some exams on monday, tuesday and wednesday i have to learn a little bit..
So you have to wait a few days till i have more time to develop :).

betajaen

10-06-2006 18:41:25

Excellent, that is how I would of approached it. :D

I assume you had to create the joint by hand, because of the character controller not being a body.

Another question, say if you was side stepping, and you held a cube and the cube banged into a wall, and you didn't, would the character controller stop moving too? If it did, that would be pretty awesome.

ColeZero

10-06-2006 22:02:23

No, sadly not, the character doesn't stops moving. :(
That would be cool, but maybe i'll do that later.

There are also some problems with the inertia, and the cube bounces to much, so its like the cube is a attached to a rubber-rope, that because i can't use limits, because if i want to pick up a cube from certain positions, the app crashes in cause of the limits.

betajaen

10-06-2006 22:12:47

Hmm, well it's a start. What joint are you using?

ColeZero

11-06-2006 10:38:49

Iam currently using a RevoluteJoint, but i also tried out the other ones, but i think this one is the best.

betajaen

11-06-2006 10:41:20

I would imagine Fixed or the Springy-Long distance joints would be another good choice, problem is I haven't written a class for either of them.

ColeZero

11-06-2006 13:34:00

Exact, if have already noticed this, sadly, because i wondered how to use the fixed-joint, so i've took a look into the Source of nxogre and i saw it, no code in here.. :D :D
The same with the explosion emitter..^^


So now i've got two choices: Wait until you implement it or code it myself..;)
I think i can wait..

betajaen

11-06-2006 15:04:20

Oh, it isn't hard code it yourself :P

I expect it's pretty much the same how a hingejoint works, except different class names.

ColeZero

14-06-2006 12:12:26

Yeah i think so, i've looked into the code and it seems to be "easy"..
At least now i got enough time to work, the last 3 days were hard, but now all is chilling and i can continue programming

anear

26-06-2006 16:40:19

Thanks for making your app downloadable.

Since I'm using vc7.1, I copy one of the tutorial .vcproj file, and add your src files and include directory. I got 2 compiling errors:

\NxOgre\PickingSample_OgreNX\OgreNX\src\OgreNX.cpp(40) : error C2664: 'nxOgre::world::world(const nxOgre::world &)' : cannot convert parameter 1 from 'Ogre::Root *' to 'const nxOgre::world &'
Reason: cannot convert from 'Ogre::Root *' to 'const nxOgre::world'
No constructor could take the source type, or constructor overload resolution was ambiguous

\NxOgre\PickingSample_OgreNX\OgreNX\src\OgreNX.cpp(41) : error C2660: 'nxOgre::world::createScene' : function does not take 2 arguments

Any idea?

betajaen

26-06-2006 17:45:13

Sounds like your using an old version of NxOgre. Preview 3?

anear

27-06-2006 11:26:18

Isn't NxOgre 0.5 Preview 3.0 the latest version? or shall I download cvs version?

betajaen

27-06-2006 11:30:25

CVS would be better.

For some reason Preview 3 (which I thought it was) isn't compatible with Dagon (due to Interface changes such as multiple SceneManagers).

ColeZero

27-06-2006 14:05:19

Yes you need to use The CVS Version.
But

For some reason Preview 3 (which I thought it was) isn't compatible with Dagon (due to Interface changes such as multiple SceneManagers).

I've used Preview 3 with Dagon 1.2.0 before, with no problems.. :?
But then i switched to the CVS-version.

anear

27-06-2006 15:39:31

I switch to cvs version now, and rebuild everything. Beside the two compiling errors in Tutorial110 and x06 that mentioned in http://www.ogre3d.org/phpBB2addons/viewtopic.php?t=1049&highlight=createsystem.

I got linking problems with the pick-a-cube project:


------ Build started: Project: Picking, Configuration: Release Win32 ------

Deleting intermediate files and output files for project 'Picking', configuration 'Release|Win32'.
Compiling...
OgreNX.cpp
main.cpp
BaseApplication.cpp
Generating Code...
Linking...
MSVCRT.lib(crtexe.obj) : error LNK2019: unresolved external symbol _main referenced in function _mainCRTStartup
..\..\bin\Release\Picking.exe : fatal error LNK1120: 1 unresolved externals

Build log was saved at "file://c:\NxOgre\PickingSample_OgreNX\OgreNX\Release\BuildLog.htm"
Picking - 2 error(s), 0 warning(s)


Any idea? Thanks.

ColeZero

27-06-2006 15:53:24

Are you compiling in Debug or Release mode?
Is the Project a Multithreaded-DLL? (Project-Properties->C/C++->CodeGeneration)

anear

27-06-2006 16:04:32

Yes, Release mode and Multithreaded-DLL.

I could't use the sln and vproj file coz they're vc8.0 and I'm using vc7.1. So I just copied one of the tutorial vproj file, renamed it, deleted its original src file, added pick-a-cube src files and the include directory.

betajaen

27-06-2006 17:08:14

Is the project being compiled as Windows or Console application?

ColeZero

27-06-2006 17:51:08

There is a little trick, you can open the *.vproj with a texteditor and change the following line from:
Version="8,00"
To:
Version="7,00"

Or if you are using VS 2003 to:
Version="7,10"

So this is quick and dirty, but now you can open the vcproj and resave it with another name.

Update:
Maybe this will help:
Project Properties->Configuration Properties->General.
Set "Minimize CRT Use in ATL" to "No".

anear

28-06-2006 10:10:12

It works! Thank you very much, ColeZero.

ColeZero

28-06-2006 10:56:21

Great and no Problem :D