Camera as guns parent?

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
WalterWzK

Camera as guns parent?

Post by WalterWzK »

Hi

Im using Irrlicht 0.7 and Visual Basic .NET, but dont let that scare you.
Any answer, even without code and just logic is welcome.

Im developing a 3D-Shooter game, not original but its ment as a test
project to get to know Irrlicht. Actually im doing pretty good cuz i've overcome a lot of problems because most of the stuff isn't implemented
yet in the .NET version and development is still at 2% the last 2 months :(

But i've got a question:

I would like to link my 3D Rifle to the camera, just like in any other 3DShooter. So when you walk, it moves along. I've read alot about settings
its parent, and i've even used the gun-placer-tool that i've found on the forum. But I cant get it work...

- When I set the parent of the gun-object to the camera, and run the game it just wont appear... its gone.

- When I set NO parent to the gun it appears at the location I've set it to, just normal.

Maybe this problem is caused because the position of the gun, when the camera is its parent, is out of the viewport... so its "dragging around behind the camera, behind my back :P". Is this possible? and if so.. how do I set up the gun to appear as in any other 3D Shooter?

Thanks already!
Spintz
Posts: 1688
Joined: Thu Nov 04, 2004 3:25 pm

Post by Spintz »

You may also have a problem, with the gun being placed before the near plane of the camera. The default near value is 1.0f. If the gun is a child of the camera, and it placed at the same location as the camera, you may not see it, as it will be clipped by the viewing frustrm.

Just a suggestion.
Guest

Post by Guest »

seams very logic to me spintz. Thanks! never thought of that!

So I could just alter the Camera's near-value to....? to what? lol.. what should it be according to you?
WalterWzK

Post by WalterWzK »

^^^ This post was mine also, sorry forgot to fill in my name

But i've alterd the near-value of the camera to 0.5, and it still doesnt show up.. maybe because my gun is not pointing the right way. But what did happen is a kind of FishEye effect.. so it almost looks like ur watching trough a glass ball you know what I mean?
WalterWzK

Post by WalterWzK »

Sorry for the almost-spamming action... but just found out that if I set the near-value to 0.1f the gun is visible and reacting.. so linked to the camera. Thats great. But one problem, with this near-value the game is even more FishEyed :P... very weird effect. Any solution??
Spintz
Posts: 1688
Joined: Thu Nov 04, 2004 3:25 pm

Post by Spintz »

I believe you can set the guns relative position from it's parent. position the gun so it's 1.0 units from the camera.
WalterWzK

Post by WalterWzK »

I sure hope this is already implemented.. because I cant find it.
Can you give me a little code? C\C+ maybe..

I found:
RelativeTransformation
But it has no position stuff just scale and rotation.

Thanks alot Spintz ur help is great!
Cairon
Posts: 40
Joined: Sun Apr 11, 2004 12:52 am
Contact:

Post by Cairon »

Hi Walter!

You can just set the position with setPosition().
If your scene node has a parent, the position is interpreted relatived to parents position and rotation.

If you want some code, check out http://aoh.arturh.com :-)
Arena of Honor: http://aoh.arturh.com
WalterWzK

Post by WalterWzK »

Thanks Cairon,

I've tried it. But somehow my object is not responding to the method.
I guess this is just not implemented the right way. I've tested it with
several settings but the gun remains on the exact position at wich the camera is..

Any suggestions?
WalterWzK

Post by WalterWzK »

Nope, first of all... i do not have any 'objectName.setPosition' function attached to an object. But i do have a function 'objectName.position.set(Vector3D)' So I've tried everything with it and the 3DS model loaded as an iSceneNode isnt reacting at all. Its 'stuck' to the exact camera position.

Help :P
Spintz
Posts: 1688
Joined: Thu Nov 04, 2004 3:25 pm

Post by Spintz »

I wish I could help you more, but I don't know .NET at all ( either Irrlicht or C# or VB.NET or anything.NET ), sorry! :(
WalterWzK
Posts: 72
Joined: Wed Jan 12, 2005 2:57 pm
Location: Netherlands
Contact:

Post by WalterWzK »

Well you have helped a great deal already spintz, so ill just wait for someone else to give it a try... or maybeill just need to wait for version 0.8 since its planned for more than 2 months to have better .NET capability's. Its a shame that niko has to do it all by himself, this way I can understand that the development of .NET capability's for version 0.8 is still at 2%
Current Project: Don Salvatore's Mafia
Genre: 3D Shooter \ RTS
Programming Language: VB .NET
Engine: Irrlicht 11 [.NET Wrapper]
Post Reply