is there any 'on the fly' beveled cube mesh creator?
-
- Posts: 363
- Joined: Thu Dec 16, 2010 8:50 pm
- Location: Somewhere in the clouds.. drinking pink lemonade and sunshine..
is there any 'on the fly' beveled cube mesh creator?
i need one for my purpose. and i was planning to write one today. i already got started.
if there is not already something like that i would be happy to continue and then post it in 'code snippets' forum when done.
EDIT: i know there are things like blender but i was planning on adding some features (that i needed for my game) like pushing and pulling any of the six face and also i dont want to have to keep loading a pre-made model.
EDIT EDIT: almost done ...tricker than i thought... took whole night...
for now i just have the raw vertices and indices. i am having some trouble deriving my customer scene node and having it rendered... maybe some one can help me with that...
if there is not already something like that i would be happy to continue and then post it in 'code snippets' forum when done.
EDIT: i know there are things like blender but i was planning on adding some features (that i needed for my game) like pushing and pulling any of the six face and also i dont want to have to keep loading a pre-made model.
EDIT EDIT: almost done ...tricker than i thought... took whole night...
for now i just have the raw vertices and indices. i am having some trouble deriving my customer scene node and having it rendered... maybe some one can help me with that...
ent1ty wrote: success is a matter of concentration and desire
at a cost measure in computer resourcesButler Lampson wrote: all problems in Computer Science can be solved by another level of indirection
-
- Posts: 363
- Joined: Thu Dec 16, 2010 8:50 pm
- Location: Somewhere in the clouds.. drinking pink lemonade and sunshine..
-
- Posts: 1215
- Joined: Tue Jan 09, 2007 7:03 pm
- Location: Leuven, Belgium
-
- Posts: 363
- Joined: Thu Dec 16, 2010 8:50 pm
- Location: Somewhere in the clouds.. drinking pink lemonade and sunshine..
i cant get it to register with the scene manager for some reason...Radikalizm wrote:looks like you messed up some vertex positions and indices there
What exactly have you accomplished already? Can you already get a correct shape?
What kind of problems are you having with your custom scene node?
it renders when i explicitly call its render() method though...
i'll post the code fragments i am having trouble with next day. it is late (early) and i really need to get some sleep.
i messed up because i tthought i was getting the texture coordinates to scale with the x,y,z size but turns out they were the normals so then i dont know what i did and i ended up with what you saw on the picture.
well goodnight. or good mornign rather
ent1ty wrote: success is a matter of concentration and desire
at a cost measure in computer resourcesButler Lampson wrote: all problems in Computer Science can be solved by another level of indirection
-
- Posts: 1215
- Joined: Tue Jan 09, 2007 7:03 pm
- Location: Leuven, Belgium
-
- Posts: 363
- Joined: Thu Dec 16, 2010 8:50 pm
- Location: Somewhere in the clouds.. drinking pink lemonade and sunshine..
Radikalizm wrote:Sounds like the node's parent is not set as the root scene node or any other valid scene node, or there's something wrong with your registering function
Code: Select all
virtual void onRegisterSceneNode()
{
if(IsVisible)
{
SceneManager->registerNodeForRendering(this);
};
scene::ISceneNode::onRegisterSceneNode()
};
Code: Select all
new cbIrrBrickNode( ..., mngr->getRootSceneNode(), ... );
ent1ty wrote: success is a matter of concentration and desire
at a cost measure in computer resourcesButler Lampson wrote: all problems in Computer Science can be solved by another level of indirection
-
- Posts: 1215
- Joined: Tue Jan 09, 2007 7:03 pm
- Location: Leuven, Belgium
-
- Posts: 363
- Joined: Thu Dec 16, 2010 8:50 pm
- Location: Somewhere in the clouds.. drinking pink lemonade and sunshine..
Radikalizm wrote:Maybe you should post the implementation of your class when you have the time, otherwise I could keep on guessing all night
i just started learning how the irrlicht works internally. so....
Code: Select all
#ifndef CBIRRLICHTBOX_H
#define CBIRRLICHTBOX_H
#include "ISceneNode.h"
#include "cubeGeometryCreator.h"
#include <irrlicht.h>
using namespace irr;
/** cbBoxFace class
* Helps batch vertices together into a face
* for easier real-time 'push' && 'pull' manipulations.
*
**/
class cbBoxFace
{
public:
//! Default constructor
cbBoxFace(): vertices(0){};
//! Constructor
cbBoxFace( video::S3DVertex* vertices );
//! Destructor
~cbBoxFace(){};
bool isSelected;
core::array<video::S3DVertex*> vertices;
};
/** cbIrrlichtBox class
* Creates the irrlicht scene node for a beveled or unbeveled
* 'box' that can be easily handled and managed by cbBox class.
* Planned features include being able to extend out any one of
* the six faces, scaling in any combination of the three axis,
* and rotating in a cubular way like roblox. Also dynamically
* change bevel setting.
**/
class cbIrrlichtBox : public scene::ISceneNode
{
//if true then the cube mesh will be recreated as beveled
bool beveled;
// array of 'faces' (6) used in manipulation of 'push' && 'pull'
core::array<cbBoxFace> faces;
// size in the three axis
core::vector3df size;
// cube geometry creator
cubeGeometryCreator* geo_creator;
scene::SMesh* mesh;
core::aabbox3df box;
public:
//! Default constructor
cbIrrlichtBox();
//! Constructor
cbIrrlichtBox( const core::vector3df& size =core::vector3df(1,1,1), bool isBeveled =0, cubeGeometryCreator* geo_creator_new =0,
scene::ISceneNode* parent =0, scene::ISceneManager* mngr =0, irr::s32 id = -1);
//! Destructor
virtual ~cbIrrlichtBox();
//creates and/or recalculates the box mesh as needed.
void resetBoxMesh( const core::vector3df& new_size);
// sets mesh
void setMesh( scene::SMesh* mesh_new );
virtual void onRegisterSceneNode()
{
if(IsVisible)
{
SceneManager->registerNodeForRendering(this);
};
};
virtual void render()
{
if(IsVisible)
{
scene::IMeshBuffer* buffer =mesh->getMeshBuffer(0);
SceneManager->getVideoDriver()->drawMeshBuffer( buffer );
};
};
virtual video::SMaterial& getMaterial( u32 i )
{
return mesh->getMeshBuffer(0)->getMaterial();
};
virtual u32 getMaterialCount() const
{
return 1;
};
virtual const core::aabbox3d<f32>& getBoundingBox() const
{
return box;
};
};
#endif // CBIRRLICHTBOX_H
Code: Select all
#include "cbIrrlichtBox.h"
using namespace irr;
cbIrrlichtBox::cbIrrlichtBox():
scene::ISceneNode( 0, 0, -1 ),
beveled(0),
faces(0),
size( core::vector3df(1.f, 1.f, 1.f) ),
geo_creator(0),
mesh(0),
box(0.f,0.f,0.f,0.f,0.f,0.f)
{
resetBoxMesh(size);
};
cbIrrlichtBox::cbIrrlichtBox(const core::vector3df& new_size,
bool isBeveled, cubeGeometryCreator* geo_creator_new, scene::ISceneNode* parent,
scene::ISceneManager* mngr, irr::s32 id): scene::ISceneNode(parent, mngr, id),
beveled(isBeveled), faces(0), size(new_size)
{
resetBoxMesh(size);
};
cbIrrlichtBox::~cbIrrlichtBox()
{
};
void cbIrrlichtBox::resetBoxMesh( const core::vector3df& new_size )
{
if(!beveled)
{
setMesh( geo_creator->createCubeMesh( new_size ) );
}
else
{
setMesh( geo_creator->createBeveledCubeMesh( new_size ) );
};
};
void cbIrrlichtBox::setMesh( scene::SMesh* mesh_new )
{
mesh =mesh_new;
box.reset(0,0,0);
box =mesh->getBoundingBox();
};
EDIT: do NOT i say do NOT post correct vertex indices. i want to figure them out on my own.
i am doing it manually just this once to 'expeand my mind' and be able to think better in 3d dimnesions.
ent1ty wrote: success is a matter of concentration and desire
at a cost measure in computer resourcesButler Lampson wrote: all problems in Computer Science can be solved by another level of indirection
-
- Posts: 1215
- Joined: Tue Jan 09, 2007 7:03 pm
- Location: Leuven, Belgium
I'm just going to list some general things I've noticed in your code
The default constructor shouldn't be needed, nor should you use it in its current state since it's passing a null pointer as the scene manager to the ISceneNode constructor (which is not a good idea), nor is it creating any of the systems needed later on, I don't see any initialization for your geometry creator for example
I also don't see you passing the geo_creator_new parameter to your geo_creator object in your other constructor, unless I'm overlooking something (which could be possible since it's quite late over here)
I don't get how you are actually getting geometry on the screen
Also, you should set the default value for a formal parameter to a value which matches its type, in your case you're passing 0 to a boolean parameter (isBeveled) which is generally not a good practice
In your onRegisterNode() function you're forgetting to call ISceneNode::onRegisterNode() which is probably causing your node not getting drawn by the scene manager
You should also drop the objects you've created inside your destructor, right now you're creating memory leaks
In your render call you should also set the active material to the mesh material, and you should set the world transformation to your node's world transformation (otherwise it won't be drawn in the right place)
I think that about covers it, I'll have another look in the morning
Also, on a side note, why not just use the geometry creator to build a mesh, and draw it using a mesh scene node?
The default constructor shouldn't be needed, nor should you use it in its current state since it's passing a null pointer as the scene manager to the ISceneNode constructor (which is not a good idea), nor is it creating any of the systems needed later on, I don't see any initialization for your geometry creator for example
I also don't see you passing the geo_creator_new parameter to your geo_creator object in your other constructor, unless I'm overlooking something (which could be possible since it's quite late over here)
I don't get how you are actually getting geometry on the screen
Also, you should set the default value for a formal parameter to a value which matches its type, in your case you're passing 0 to a boolean parameter (isBeveled) which is generally not a good practice
In your onRegisterNode() function you're forgetting to call ISceneNode::onRegisterNode() which is probably causing your node not getting drawn by the scene manager
You should also drop the objects you've created inside your destructor, right now you're creating memory leaks
In your render call you should also set the active material to the mesh material, and you should set the world transformation to your node's world transformation (otherwise it won't be drawn in the right place)
I think that about covers it, I'll have another look in the morning
Also, on a side note, why not just use the geometry creator to build a mesh, and draw it using a mesh scene node?
-
- Posts: 363
- Joined: Thu Dec 16, 2010 8:50 pm
- Location: Somewhere in the clouds.. drinking pink lemonade and sunshine..
thank you for your input rad i really appreciate it.
ill be sure to fix those things and see if i can get a better result.
ill be sure to fix those things and see if i can get a better result.
ent1ty wrote: success is a matter of concentration and desire
at a cost measure in computer resourcesButler Lampson wrote: all problems in Computer Science can be solved by another level of indirection