Need some help..

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
WWW
Posts: 26
Joined: Thu Oct 04, 2007 1:41 pm

Need some help..

Post by WWW »

Hi,

How can i create a box or a 3d mesh when i click a mouse button or when i press a button :roll: .Im not so good in irrlicht so a small code would help me to understand better .THANKS
shogun
Posts: 162
Joined: Wed Sep 05, 2007 11:02 am
Location: inside

Re: Need some help..

Post by shogun »

WWW wrote:Im not so good in irrlicht so a small code would help me to understand better .THANKS
That's what the tutorials are written for!
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

1st: a subject like "Need some Help.." doesn't say anything, everybody who opens a new thread in this forum needs help, that's why they open a new thread, so please choose a more specific subject the next time... :roll:

2nd: if you're "not so good in Irrlicht" than please work through the tutorials first, all of your question are covered there... :roll:

for example the button click is covered in tutorial #05.UserInterface and the creation of a simple cube is covered in many tutorials (e.g. #04.Movement)... ;)
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
WWW
Posts: 26
Joined: Thu Oct 04, 2007 1:41 pm

Post by WWW »

You didn't understand what i want (or maybe i give you too little information :roll: )
I checked all the tutorials and none is what i want.So, I want to create(let's say) a mesh with left mouse click an to be positioned in front of the camera.How can I do that ???
I know how to position the mesh in front of the camera , i know how to create event receiver for mouse click but i dont know how to create multiple meshes with their own position (or maybe other variable like health or armour for an enemy).
I think this can be done with classes :roll: but i dont know how :cry:
THANKS again :wink:
shogun
Posts: 162
Joined: Wed Sep 05, 2007 11:02 am
Location: inside

Post by shogun »

WWW wrote:but i dont know how :cry:
Then you should learn your programming language. Buy a book.
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

well, if you know all this than there should be no problem to create multiple meshes...
simply do what you did for a single mesh to create as much meshes as you want and you'll get several meshes (no need to use classes for this)... ;)
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
WWW
Posts: 26
Joined: Thu Oct 04, 2007 1:41 pm

Post by WWW »

LOL :lol: :oops: , you are right Aki ,thanks ,but how can i access them individually?(for exemple if i want to check the third mesh)
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

Code: Select all

// Create a collection of pointers to nodes.
// Here I am using Irrlicht's 'array' collection class
irr::core::array<IAnimatedMeshSceneNode *> nodes;

...

// Create a new node, using whatever method you're currently using
IAnimatedMeshSceneNode * newNode = ...your node creation method...

// Add it to the end of collection of nodes
nodes.push_back(newNode);

...

// Now loop through all the nodes in the collection, 
// and do whatever you need to do to them.
for(u32 i = 0; i < nodes.size(); ++i)
{
    IAnimatedMeshSceneNode * node = nodes[i];

    // .... do something with each node
}


(This is untested, and personally I wouldn't become reliant on Irrlicht by using its collection classes, but it should give you the general idea)
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

WWW wrote:LOL :lol: :oops: , you are right Aki ,thanks ,but how can i access them individually?(for exemple if i want to check the third mesh)
ahh, now we come to the point !!! :lol:

as rogerborg said you could use an array for this... ;)

or you can give each node an individual ID and get the node later by its ID:

Code: Select all

// create 10 nodes with IDs from 1 to 10
for(int ID = 1; ID <= 10; ID++){
  smgr->addAnimatedMeshSceneNode(ptMesh, 0, ID);
}

// then later get the wanted node by its ID (here ID = 3)
ISceneNode* testNode = smgr->getSceneNodeFromId(3);
// now you can do what you want with this node...
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

Heh, I'd never even thought of using a scene nodes 'Id' as an actual Id rather than as a set of bitflags for collision. I wonder if we could take the hit in 1.5 of separating Id and flags?
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
WWW
Posts: 26
Joined: Thu Oct 04, 2007 1:41 pm

Post by WWW »

THANK YOU guys for all your help , it works (i tried Acki's method) :wink:.
It's there any way to place my meshes around in a random position? :roll:
shogun
Posts: 162
Joined: Wed Sep 05, 2007 11:02 am
Location: inside

Post by shogun »

Yes, there is.

Search hint: rand()
Post Reply