Mesh edges?

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.
fnolis
Posts: 10
Joined: Thu Jun 24, 2004 8:25 am
Location: Sweden

Mesh edges?

Post by fnolis »

I have a mesh in the shape of a car, and I need to find out how "big" this mesh is, where its front is so that I can draw a missile infront of it when fired and also put lights infront of the car. How do I do it? How can I find the front of the car? and its size?
thesmileman
Posts: 360
Joined: Tue Feb 10, 2004 2:20 am
Location: Lubbock, TX

Post by thesmileman »

Wahoooo lots of questions there. to find the direction the car is pointed you can use the getRotation funtion when you know this you can find out where you need to put the missile. and the lights. You would want to put the lights on the car at the begining of the scene then make them a child of the car so they would stay with the car and then toggle them on an off as needed. :D
fnolis
Posts: 10
Joined: Thu Jun 24, 2004 8:25 am
Location: Sweden

Post by fnolis »

Well.... the rotation I have... I need to find out how big the car is and in that way calculate where the lights should be placed... if I set the light (and the missiles) at the default (0,0,0) then it will be placed in the middle of the carmesh... so... what I'm after are the "box" around the car...
Felipe
Posts: 25
Joined: Thu Jun 10, 2004 9:13 pm
Location: Rio de Janeiro

Post by Felipe »

I needed to do something similar, but with a gun instead. I don't remember exactly how I did it, but if you take a look in the Newton+Irrlicht tutorial, you'll see how to get vertices out of the mesh. Just save the vertex with the largest X (or Z) value and use that for placing the lights.
Tyn
Posts: 932
Joined: Thu Nov 20, 2003 7:53 pm
Location: England
Contact:

Post by Tyn »

What I would do is open up your car mesh inside your modeller and find the 3D position that you want the lights to be. Then, create the effect and add it as a child of the car mesh. You will then be able to enter the position you found inside your modeller and it will be correct.

You will also not need to worry about rotation as whatever rotation the car is set to will be translated to the car light or whatever effect you plan to have.
thesmileman
Posts: 360
Joined: Tue Feb 10, 2004 2:20 am
Location: Lubbock, TX

Post by thesmileman »

Just try a few positions for the lights at the start of the scene until they are where you want them on the car then make the lights children of the car and you will not have to worry about them anymore only the car.


EDIT: I see Tyn already beat me to it.
Felipe
Posts: 25
Joined: Thu Jun 10, 2004 9:13 pm
Location: Rio de Janeiro

Post by Felipe »

but what if he has different car models? He'd have to pre-locate the headlights for every model. :?
thesmileman
Posts: 360
Joined: Tue Feb 10, 2004 2:20 am
Location: Lubbock, TX

Post by thesmileman »

Felipe wrote:but what if he has different car models? He'd have to pre-locate the headlights for every model. :?
Well of course, how is Irrlicht supposed to know where the lights on a car should go without the programmers guidence? You could simple have that data stored and then read in when a new model is loaded.
Felipe
Posts: 25
Joined: Thu Jun 10, 2004 9:13 pm
Location: Rio de Janeiro

Post by Felipe »

well, he could use the method I described above. Having to code the coordinates would not allow players to create there own cars. Players love messing around with game data. :)
Tyn
Posts: 932
Joined: Thu Nov 20, 2003 7:53 pm
Location: England
Contact:

Post by Tyn »

If they want to add their own meshes then they will have to define where abouts they want the lights exactly the same as they would have to define where the wheels would go on the car. Unless you wanted to model the car around a set of lights and wheels which not be a very intelligent solution. It doesn't need to be hardcoded but it DOES need to be defined.
Felipe
Posts: 25
Joined: Thu Jun 10, 2004 9:13 pm
Location: Rio de Janeiro

Post by Felipe »

I guess that's the easiest way to do it. Though, to me it feels like I'm doing something for the code that it could be doing by itself. Sorta like if a math game were to ask you the answer to a problem so it could tell you if your kid's answer was right or not.
thesmileman
Posts: 360
Joined: Tue Feb 10, 2004 2:20 am
Location: Lubbock, TX

Post by thesmileman »

Felipe wrote:I guess that's the easiest way to do it. Though, to me it feels like I'm doing something for the code that it could be doing by itself. Sorta like if a math game were to ask you the answer to a problem so it could tell you if your kid's answer was right or not.
NO its not the easiest way to do it. It is the only way. The location of the lights HAVE to be defined unless they are their own model. To Irrlicht the model is a set of trinagles nothing more nothing less (Well there are some normals and some other stuff but who cares). :evil: :evil: :evil: :twisted: :twisted: :twisted:
thesmileman
Posts: 360
Joined: Tue Feb 10, 2004 2:20 am
Location: Lubbock, TX

Post by thesmileman »

Sorrey for that I am really not feeling well and I haven't slept in two days. Some of you may have noticed I have been on the fourm for two days straight and have moved from 10th to 6th in total number of posts in just three days

I just got back from the doctor and he says that I have really bad asma even though I have never had it before. My chest is hurting and I can barely breath. I am 22 and I get #@@(#(!(!!! asma what the @#$!!!! :evil:

Anyway sorry just a little pissed.
Tyn
Posts: 932
Joined: Thu Nov 20, 2003 7:53 pm
Location: England
Contact:

Post by Tyn »

*off topic*
Quit smoking then ;)

*on topic*
Though, to me it feels like I'm doing something for the code that it could be doing by itself
If you can write some code that can figure out what you were thinking then I think some goverment officials may be interested in it ;)
fnolis
Posts: 10
Joined: Thu Jun 24, 2004 8:25 am
Location: Sweden

Post by fnolis »

some code would be good...
[/code]
Post Reply