getting coords points from models and powder

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
Vsk
Posts: 343
Joined: Thu Sep 27, 2007 4:43 pm

getting coords points from models and powder

Post by Vsk »

1)Hi, maybe it is a stupid question but I don't like the way I am resolving actually.

I have a cannon, a gun any weapon or(no weapon) and I know that this weapon shoot a projectil from one hole. For practicity the bullet start its trajectory in the edge of this hole.

So, how do you obtain this initial position?

What I am doing now:
Find the position in the modeler, loaded with the file resource associeted to this object and then apply transforation according to the object actual transforamtions.

But this is not only that, I need the direction of fire which again, depends on the actual transformation of the weapon.
So again I need a INITIAL direcation (the one in which the model is loaded) and the I transform this vector to the apropied actual direction before shoot.

This works but I don't like it because you depend on the exact initianilzation of the models from the modeler and then the correct loading.

I would like to obtain this points withoug worry about which initial rotation or transformation that has my object in the modeller or initial loading, at same applyes for the direction shoot.

Is is possible doing this?
What do you do for solving this?


2) Anyone knows any powder-dust scene node :D or a good way to implemented (without shaders) this.
I need it for the vehicle wheels.

Thanks in advance.
spike314
Posts: 27
Joined: Sun Nov 19, 2006 11:51 am
Location: Shropshire (UK)
Contact:

Post by spike314 »

I would use something like this

1) If it's a animated node with bones you could set a bones name as "Fire_Point" then use:

Code: Select all

//Set up Bullet
Iscenenode*Fp= node->getJointNode  ( "Fire_point" ) ;
 Iscenenode* bullet=smgr->addSphereSceneNode(5,16);
 bullet->setPosition(Fp->getPosition());
 Fp->setRotation(Fp->getRotation());

//use this code to move the bullet in the direction its facing

void MoveNode(ISceneNode*node,irr::core::vector3df vel)
{
    irr::core::matrix4 m; 
    m.setRotationDegrees(node->getRotation()); 
    m.transformVect(vel); 
    node->setPosition(node->getPosition() + vel); 
}

if its not animated then you could do something like this:

Code: Select all


//Set up Bullet
Iscenenode*Fp= node->addEmptySceneNode ( weaponnode ) ;
Fp->setPosition(vector3df(0,0,1)); //put it just in front of the weaponnode
 Iscenenode* bullet=smgr->addSphereSceneNode(5,16);
 bullet->setPosition(Fp->getPosition());
 Fp->setRotation(Fp->getRotation());

//use this code to move the bullet in the direction its facing

void MoveNode(ISceneNode*node,irr::core::vector3df vel)
{
    irr::core::matrix4 m; 
    m.setRotationDegrees(node->getRotation()); 
    m.transformVect(vel); 
    node->setPosition(node->getPosition() + vel); 
}

hope that helps (im not 100% sure if that would work but it looks like it).

As for powder-dust i would use the particle system.
You can have all the power in the world but if you have no one to follow you what good is the power?
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

If you've got a point on the gun that you can grab in irrlicht to fire the bullet from then if you want to get the direction to fire in you could just grab another point on the gun directly behind the fire point.
Image Image Image
Vsk
Posts: 343
Joined: Thu Sep 27, 2007 4:43 pm

Post by Vsk »

spike314 wrote:I would use something like this



//Set up Bullet
Iscenenode*Fp= node->addEmptySceneNode ( weaponnode ) ;
Fp->setPosition(vector3df(0,0,1)); //put it just in front of the weaponnode
Iscenenode* bullet=smgr->addSphereSceneNode(5,16);
bullet->setPosition(Fp->getPosition());
Fp->setRotation(Fp->getRotation());
Thanks but the line is black is the one that I want to avoid. In this line you are assuming that "front" is (0,0,1). And how do I know that? I know it because the intial loading transformation (wich depends of the modeler).
what happend if I load the weapon horizontal inverted?
Then it will shoot for the back part :P :D.

I would like something like the animated one, but for all models and simple to add. That way you only get for the model doing someting like:
getCoordsFromPropertie(model,"namePropertie").
Which properties would be defined on the modeler with name "namePropertie".

I don't know if this existe or something like that.

Any other thought about it?

Thanks.
Last edited by Vsk on Thu Jan 31, 2008 5:12 pm, edited 1 time in total.
Vsk
Posts: 343
Joined: Thu Sep 27, 2007 4:43 pm

Post by Vsk »

JP wrote:If you've got a point on the gun that you can grab in irrlicht to fire the bullet from then if you want to get the direction to fire in you could just grab another point on the gun directly behind the fire point.
No, I have no problem with direcation or the point , I explained on the first post. My problem is the way you GET this points or you GRAB them on the first place.
(of course this points must be accuracy calculate it).

Please take a look at my explanation on the first post, if it is not undestandble please tell me. English is not my native language.

Thanks.
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

Ok, i see now, didn't understand the first post but it's clear now!

You can do this with joints... .ms3d files support joints and some others too (b3d maybe? someone else can weigh in here).

So in your model you'd put a joint on the end of the gun and then in irrlicht you could grab a pointer to the joint (returned as an ISceneNode*) and then you know the position of the firing point.
Image Image Image
spike314
Posts: 27
Joined: Sun Nov 19, 2006 11:51 am
Location: Shropshire (UK)
Contact:

Post by spike314 »

You can do this with joints... .ms3d files support joints and some others too (b3d maybe? someone else can weigh in here).
yeah b3d files do support joints.
You can have all the power in the world but if you have no one to follow you what good is the power?
Vsk
Posts: 343
Joined: Thu Sep 27, 2007 4:43 pm

Post by Vsk »

Ahja, so this is the proper way to do it right?
I mean this is the way it "must" be done?

It seems fine to me, it is almost what I wanted. But I thought joints where to "join" inside the self model. I didn't know you can use it for this tricks.


Well I stay with this Idea (I will try to convert my objects to b3d) any good convertor from 3ds and obj to b3d or ms3d.?
What do you reccomend as the best for irrlicht.

Any other thought or suggestions in which this is done?.

But still it is the problem of initial direcction, if I add two joints, one for bullent and other to get direcation from the first one, it will be ok?. Or this is done in other way?.

By the way, this joints, they have some ID right? The modeler gave you and you pass it to irrlicht. So at the end this two ID will be ones that I will storage on my "resource file" for this object.
By the way, I'm sucking on this theme because the position of "artist" on gamedev is the far away from me. And our "artist" (that didn't know at all about games) now is gone. So I have no chance even to learn a litle of this from him.

Thanks both of you.
spike314
Posts: 27
Joined: Sun Nov 19, 2006 11:51 am
Location: Shropshire (UK)
Contact:

Post by spike314 »

Well I stay with this Idea (I will try to convert my objects to b3d) any good convertor from 3ds and obj to b3d or ms3d.?
What do you reccomend as the best for irrlicht.
you could try Milkshape3D its cheap and it exports to B3d and its saves Ms3d files to. http://chumbalum.swissquake.ch/
By the way, this joints, they have some ID right?
You can give the Joints names so when your in irrlicht you can just call
Node->getJointNode ( Joint name)
You can have all the power in the world but if you have no one to follow you what good is the power?
Vsk
Posts: 343
Joined: Thu Sep 27, 2007 4:43 pm

Post by Vsk »

spike314 wrote:
You can give the Joints names so when your in irrlicht you can just call
Node->getJointNode ( Joint name)
Perfect!
Thanks
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

Vsk wrote:Ahja, so this is the proper way to do it right?
I mean this is the way it "must" be done?
It's one way of doing it, and it's the way that I do it. There may be other ways of doing it. For example, if you want to identify the centre of the round muzzle of a gun, then you may be able to find all the vertices with the largest Z, then average their X and Y. But that's entirely dependent on your model. Adding a joint is a neat, simple and more general way of putting extra info into a model

Vsk wrote:But still it is the problem of initial direcction, if I add two joints, one for bullent and other to get direcation from the first one, it will be ok?. Or this is done in other way?.
It'd be a strange weapon that didn't shoot straight along its long (e.g. Z) axis, but if you want an offset shot then using a vector between two joints would be one way of doing it. Alternatively, you could put some info into the joint name.
Vsk wrote:By the way, this joints, they have some ID right?
They have names, which are perhaps better than a numerical ID because you can use them to encode extra information. For example, I've used the names of joints on a Milkshape ship model to identify both the type of weapon that needs to be mounted there, and its allowed firing arc e.g. "M:KM:2x3.46A:0:240". You can get really creative with joints.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Vsk
Posts: 343
Joined: Thu Sep 27, 2007 4:43 pm

Post by Vsk »

rogerborg wrote:
Vsk wrote:Ahja, so this is the proper way to do it right?
I mean this is the way it "must" be done?
It's one way of doing it, and it's the way that I do it. There may be other ways of doing it. For example, if you want to identify the centre of the round muzzle of a gun, then you may be able to find all the vertices with the largest Z, then average their X and Y. But that's entirely dependent on your model. Adding a joint is a neat, simple and more general way of putting extra info into a model

Vsk wrote:But still it is the problem of initial direcction, if I add two joints, one for bullent and other to get direcation from the first one, it will be ok?. Or this is done in other way?.
It'd be a strange weapon that didn't shoot straight along its long (e.g. Z) axis, but if you want an offset shot then using a vector between two joints would be one way of doing it. Alternatively, you could put some info into the joint name.
Vsk wrote:By the way, this joints, they have some ID right?
They have names, which are perhaps better than a numerical ID because you can use them to encode extra information. For example, I've used the names of joints on a Milkshape ship model to identify both the type of weapon that needs to be mounted there, and its allowed firing arc e.g. "M:KM:2x3.46A:0:240". You can get really creative with joints.
ok, but I have a doubt, should not be joint present in all kind of model formatst?
if they have, that means that irrlicht doesn't support take joints from the other one, *yet*? (b3d,ms3d).
For example I was using 3ds or obj and now (just for make it easy) I must convert all my models to b3d. With all the problems that conversion bring, even more if modelers aren't your strong :(.
Should irredit or the same irrlicht has in future some converting model utility that transform all models into irrMesh so this thing could be unified?
Or am i in wrong paht?.

Thanks.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

obj files are not animated (and for 3ds we also don't support animation yet). Moreover, those formats do not support to save special vertices (which would work similar), so there wouldn't be a tool which could generate those "joints".
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

Apologies if we got your hopes up. The joints method works well in Milkshape, which is really all I use. :(
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

To avoid any misconceptions: All skeletal based animated formats do support joints. Due to the new animation system there's now a uniform access available to get and set joints. So .ms3d, .b3d, and .x files support this.
Post Reply