3D in 2D Tic-Tac-Toe game->some thoughts

Discuss about anything related to the Irrlicht Engine, or read announcements about any significant features or usage changes.
Post Reply
MikeR
Posts: 767
Joined: Sun Dec 26, 2004 4:03 pm
Location: Northern California USA
Contact:

3D in 2D Tic-Tac-Toe game->some thoughts

Post by MikeR »

I'm looking at taking a popular 2d game and making it 3d in irrlicht.
I'm going to need 2 windows. 1 for the 3D render, and 1 for text.
I'm trying to figure out the best way to do this.

I need to ask the player if they want to go first or let the puter go first.
If player, get position for players peice, place peice in the 3d view.
else, place puters piece.

I haven't worked with the gui stuff much yet. Namely the different types of text boxes, so I don't have a clue which one would be best to use.
I'll need to have space for instructions, and getting input in this box.
How to add imput to the box is another story as well.

The 3d view I think will be easy.(I hope) I make up a class for each peice and call a "New" peice to place in the scene.

Which text box would be best?
Anyone have a tut on how to get user input and add it into the text box? and use that text to make things work in irrlicht?
Last edited by MikeR on Sat Jan 28, 2006 1:58 am, edited 1 time in total.
If it exists in the real world, it can be created in 3d

Sys specs:
AMD 3700+ 64 processor
1.0 gb ram
e-Geforce 6600 graphics 256 mb onboard ram
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

hmm maybe this is what you're looking for-
http://irrlicht.sourceforge.net/phpBB2/ ... hp?p=30735
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
MikeR
Posts: 767
Joined: Sun Dec 26, 2004 4:03 pm
Location: Northern California USA
Contact:

Post by MikeR »

Thanks. Forgot about that one.
If it exists in the real world, it can be created in 3d

Sys specs:
AMD 3700+ 64 processor
1.0 gb ram
e-Geforce 6600 graphics 256 mb onboard ram
MikeR
Posts: 767
Joined: Sun Dec 26, 2004 4:03 pm
Location: Northern California USA
Contact:

Post by MikeR »

Ok, I'm making up my object class.

I'm not doing bad. I've only got 24 errors. :) (usually, it's many, many more)
Object.h:19: error: ISO C++ forbids declaration of `Xmesh' with no type
Ok, what type would an animatedmeshscenenode be? I've tried string. Got a hilliarius message about how "string" isnt a type. :D

Here's the code:

Code: Select all

Object::Xmesh(core::vector3df position, scene::ISceneManager* smgr, video::IVideoDriver* driver) 
{
   VideoDriver   = driver; 
   SceneManager   = smgr; 
   Xmesh   = SceneManager->addAnimatedMeshSceneNode( 
   smgr->getMesh("media/XText.x"));
   Xmesh->setPosition(position); 
   Xmesh->setMaterialFlag(video::EMF_LIGHTING, false); // disable dynamic lighting 
   Xmesh->getMaterial(0).Shininess = 20.0f;) // set size of specular highlights 
}
What I don't know is what type to give this.
It's not an int, const, or short, and the compiler won't accept string.
If it exists in the real world, it can be created in 3d

Sys specs:
AMD 3700+ 64 processor
1.0 gb ram
e-Geforce 6600 graphics 256 mb onboard ram
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

tsk tsk, it clearly says in the ISceneManager reference that addAnimatedMeshSceneNode returns an IAnimatedMeshSceneNode pointer:
http://irrlicht.sourceforge.net/docu/cl ... nager.html
also, i don't see how Xmesh can be a variable and a function at the same time, unless its not used elsewhere in Object. and what happens if you call Object->Xmesh() twice?
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
MikeR
Posts: 767
Joined: Sun Dec 26, 2004 4:03 pm
Location: Northern California USA
Contact:

Post by MikeR »

The main problem I'm having is understanding how classes are put together when you are using a lib like Irrlicht.
I know how to do this in 2d, but am struggling with understanding how to make it work in 3d.
I've decided that for now, I just need to get the class to work so that someting can be displayed on the screen. Then, I can work on the "merging" part. I've taken everything eccept for my Xmesh out of this class and renamed the class.
Here is the class:

Code: Select all

//my tic-tac-toe X class
//Xmesh.h 
#ifndef XMESH_H 
#define XMESH_H 

#include "irrlicht.h" 

using namespace irr; 
using namespace core; 
using namespace video; 
using namespace scene; 


class Xmesh
{ 
public: 

   Xmesh(core::vector3df position, ISceneManager* smgr, video::IVideoDriver* driver);

private: 
   video::IVideoDriver*             VideoDriver; 
   scene::ISceneManager*            SceneManager; 
   scene::IAnimatedMeshSceneNode*   Xobject;
 
}; 

 Xmesh::Xmesh(core::vector3df position, scene::ISceneManager* smgr, video::IVideoDriver* driver) 
{
   VideoDriver   = driver; 
   SceneManager   = smgr; 
   Xobject = SceneManager->addAnimatedMeshSceneNode(true); 
   smgr->getMesh("media/XText.x");
   Xobject->setPosition(position); 
   Xobject->setMaterialFlag(video::EMF_LIGHTING, false); // disable dynamic lighting 
   Xobject->getMaterial(0).Shininess = 20.0f;) // set size of specular highlights 
}

#endif
I have declared the class name, it's variables, and such.
In the private section, I declare IAnimatedMeshSceneNode* = Xobject
Then, outside the class, I declare the constructor and what variables it holds.
Now, my first error is:
In file included from main.cpp:11:
Xmesh.h: In constructor `Xmesh::Xmesh(irr::core::vector3df, irr::scene::ISceneManager*, irr::video::IVideoDriver*)':
Xmesh.h:34: error: no matching function for call to `irr::scene::ISceneManager::addAnimatedMeshSceneNode(bool)'
I don't understand why the compiler isn't recognising that Xobject is an IAnimatedMeshSceneNode*. I have tried changing this to read:

Code: Select all

Xobject = smgr->addAnimatedMeshSceneNode(true); 
got more errors.

Code: Select all

Xmesh = Xobject->addAnimatedMeshSceneNode(true); 
Both ways seemed to work better, as in the compiler recognised the IAnimatedMeshSceneNode*, but I got a bunch more errors.
Can you help me understand why this isn't working?
(don't need my code written for me. Mabe psuedo code?)
My book at this point is not doing me much good.
If it exists in the real world, it can be created in 3d

Sys specs:
AMD 3700+ 64 processor
1.0 gb ram
e-Geforce 6600 graphics 256 mb onboard ram
MikeR
Posts: 767
Joined: Sun Dec 26, 2004 4:03 pm
Location: Northern California USA
Contact:

Post by MikeR »

Ok, scratch all that above. I figured out what was happening.
I changed to the following:

Code: Select all

 Xobject = smgr->addAnimatedMeshSceneNode( 
   smgr->getMesh("media/XText.x"));
and removed a stray ) at the end of the block and it compiled without errors. :)
Now to test.

Edit to add:

-->Success. (this is a screenshot)<--

The X is just hardcoded there, but it shows that my class is working. :)

Edit #2
-->Here is a pic showing multiple Xs and Os.<--
I changed the background color and the X and O colors to make things stand out better.
If it exists in the real world, it can be created in 3d

Sys specs:
AMD 3700+ 64 processor
1.0 gb ram
e-Geforce 6600 graphics 256 mb onboard ram
MikeR
Posts: 767
Joined: Sun Dec 26, 2004 4:03 pm
Location: Northern California USA
Contact:

Post by MikeR »

-->2d and 3d combined<--(link) :)

Now to get the 2d actually working where it takes keyboard input and puts it into the listbox. Then I can have the 2d instructions place 3d objects onto the scene.
I need to make a vec of 3d postiions tho. :)
If it exists in the real world, it can be created in 3d

Sys specs:
AMD 3700+ 64 processor
1.0 gb ram
e-Geforce 6600 graphics 256 mb onboard ram
Post Reply