Editor style Grid SceneNode [Updated: Sept. 27, 2009]

Post those lines of code you feel like sharing or find what you require for your project here; or simply use them as tutorials.
MasterGod
Posts: 2061
Joined: Fri May 25, 2007 8:06 pm
Location: Israel
Contact:

Post by MasterGod »

I think you shouldn't switch, its good enough as it is now.

So is there any progress ? clone() method and the warning I posted above (u32 and s32 checks)
Image
Dev State: Abandoned (For now..)
Requirements Analysis Doc: ~87%
UML: ~0.5%
Dark_Kilauea
Posts: 368
Joined: Tue Aug 21, 2007 1:43 am
Location: The Middle of Nowhere

Post by Dark_Kilauea »

Yes, I've figured out how the clone() is supposed to work, so expect an update soon (ie. whenever I get a chance to update the code)

As for the s32 and u32 issues, I don't expect much of a problem either...
rogerborg wrote:Every time someone learns to use a debugger, an angel gets their wings.
Dark_Kilauea
Posts: 368
Joined: Tue Aug 21, 2007 1:43 am
Location: The Middle of Nowhere

Post by Dark_Kilauea »

Ok, new version is up.

I fixed issues with variables being cast as signed integers as well as adding a working clone() method.

As always, you can get the new version on the first post. (same link)
rogerborg wrote:Every time someone learns to use a debugger, an angel gets their wings.
MasterGod
Posts: 2061
Joined: Fri May 25, 2007 8:06 pm
Location: Israel
Contact:

Post by MasterGod »

Thanks! great timing btw..

P.S
Edit:
Subject wrote:Editor style Grid SceneNode [Updated: Jan. 04, 2008]
Image
Dev State: Abandoned (For now..)
Requirements Analysis Doc: ~87%
UML: ~0.5%
MasterGod
Posts: 2061
Joined: Fri May 25, 2007 8:06 pm
Location: Israel
Contact:

Post by MasterGod »

Now that I updated my code with your new version I see there's another warning regarding u32-f32 issues.

Code: Select all

	if(m_AxisLineState == true)
	{
		driver->draw3DLine(vector3df(m_size,0,0),vector3df(-m_size,0,0),m_XLineColor);
		driver->draw3DLine(vector3df(0,0,m_size),vector3df(0,0,-m_size),m_ZLineColor);
	}
1>------ Build started: Project: <My project's name>, Configuration: Debug Win32 ------
1>Compiling...
1>CGridSceneNode.cpp
3 times both of this warnings:
conversion from 'irr::u32' to 'irr::f32', possible loss of data
unary minus operator applied to unsigned type, result still unsigned
1><My project's name> - 0 error(s), 6 warning(s)
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
Should be something like this:

Code: Select all

	if(m_AxisLineState == true)
	{
		driver->draw3DLine(vector3df((f32)m_size,0,0),vector3df(-(f32)m_size,0,0),m_XLineColor);
		driver->draw3DLine(vector3df(0,0,(f32)m_size),vector3df(0,0,-(f32)m_size),m_ZLineColor);
	}
1. Why does the clone method returns a ISceneNode* and not CGridSceneNode* ?
2. What "AutomaticCullingState = EAC_BOX;" does?

EDIT:
3. You say "//Axis Lines are a default Red and Blue for the X and Z axis respectively." but they aren't.
Image
Dev State: Abandoned (For now..)
Requirements Analysis Doc: ~87%
UML: ~0.5%
Dark_Kilauea
Posts: 368
Joined: Tue Aug 21, 2007 1:43 am
Location: The Middle of Nowhere

Post by Dark_Kilauea »

Seems like I forgot a place where m_size was still being used; I'll fix that soon. I'll also see about changing the return type of the clone() method for ya :)

AutomaticCullingState = EAC_BOX; tells irrlicht to default to using the Box method for culling this node. Not the most efficient for actually getting rid of the node if it can't be seen, but it is a cheap calculation. This flag is normally changed via the setAutomaticCulling() function. Frustrum would be better, but I'm not sure how much more it would cost per frame. I could set it to none, but that would mean that the grid would never stop rendering itself.

The colors aren't red and blue? Hmm... I might have messed that up while testing. I'll be sure to fix that as well.
rogerborg wrote:Every time someone learns to use a debugger, an angel gets their wings.
MasterGod
Posts: 2061
Joined: Fri May 25, 2007 8:06 pm
Location: Israel
Contact:

Post by MasterGod »

I've fixed that x-red z-blue thing, warnings, clone thing and made it more doxygen friendly, check it out, maybe continue work on this version?

http://rapidshare.com/files/82286299/CGridSceneNode.zip
Image
Dev State: Abandoned (For now..)
Requirements Analysis Doc: ~87%
UML: ~0.5%
Dark_Kilauea
Posts: 368
Joined: Tue Aug 21, 2007 1:43 am
Location: The Middle of Nowhere

Post by Dark_Kilauea »

Thanks a lot man. I changed the code a little bit to add back the default values to the constructor, as well as setting the default culling mode to frustum box. I want people to be able to set this node up quickly and easily, without having to type 50 some characters into the constructor :)

Again thanks. I've uploaded the newest copy.

If anyone would like to see something else added to this node, please ask. I'm really surprised how much it's grown.

[edit] Typo attack!
rogerborg wrote:Every time someone learns to use a debugger, an angel gets their wings.
MasterGod
Posts: 2061
Joined: Fri May 25, 2007 8:06 pm
Location: Israel
Contact:

Post by MasterGod »

Dark_Kilauea wrote:I changed the code a little bit...
I looked it up and I don't see any changes from what I sent except the frustum thing.. Care to mention Where you changed?
Dark_Kilauea wrote:If anyone would like to see something else added to this node, please ask. I'm really surprised how much it's grown
Well, I use it in my project so I might think of more things later on..

1. Its a great scene node, thank You for making it out of Mohaps's code.
2. Thanks for adding my nick in the .h file.
3. Update again the subject :wink:
4. If you want I can generate a .chm file using the doxygen comments (yes, for evey release of it) and send it to you so it can be added to the zip file.
Image
Dev State: Abandoned (For now..)
Requirements Analysis Doc: ~87%
UML: ~0.5%
Dark_Kilauea
Posts: 368
Joined: Tue Aug 21, 2007 1:43 am
Location: The Middle of Nowhere

Post by Dark_Kilauea »

1. Look in the constructor parameters. You'll see I added the defaults back.

2. You're welcome, I pay my minions well :P

3. Subject should be fine, the last update was Jan. 08

4. I don't think a chm help file will be necessary. Anyone should be able to figure out the node from the comments, and besides, it works just fine without most of the parameters.
rogerborg wrote:Every time someone learns to use a debugger, an angel gets their wings.
MasterGod
Posts: 2061
Joined: Fri May 25, 2007 8:06 pm
Location: Israel
Contact:

Post by MasterGod »

K thanks.
I have no problems with this latest version now, :P
Oh and yup I checked again now and I see the changes, good ones if I might add.
lol, this time I only changed some whitespaces and added a credit comment :lol:
I'll be sure to note if I need something else :)

P.S
Oh and btw I sent you a pm :wink:
Image
Dev State: Abandoned (For now..)
Requirements Analysis Doc: ~87%
UML: ~0.5%
Dark_Kilauea
Posts: 368
Joined: Tue Aug 21, 2007 1:43 am
Location: The Middle of Nowhere

Post by Dark_Kilauea »

PM read :)

Thanks for hosting a copy of this scenenode for me. To others: Check out the primary mirror. Please try to use the primary first to save me bandwidth on my webhost. I've provided the second one in case rapidshare doesn't work for you.

Thanks.
rogerborg wrote:Every time someone learns to use a debugger, an angel gets their wings.
MasterGod
Posts: 2061
Joined: Fri May 25, 2007 8:06 pm
Location: Israel
Contact:

Post by MasterGod »

A little fix to the clone method:

Code: Select all

//! Creates a clone of this scene node and its children.
	virtual CGridSceneNode* clone(ISceneNode* newParent = 0, ISceneManager* newSceneManager = 0);

Code: Select all

CGridSceneNode* CGridSceneNode::clone(ISceneNode *newParent, ISceneManager *newSceneManager)
{
	if (!newParent) newParent = Parent;
	if (!newSceneManager) newSceneManager = SceneManager;

	CGridSceneNode* cloner = new CGridSceneNode(
		newParent, // this line
		newSceneManager, // and this line
		ID,
		m_spacing,
		m_size*2,
		m_gridcolor,
		m_accentlineoffset,
		m_accentgridcolor,
		m_AxisLineState);

	cloner->SetAxisLineXColor(m_XLineColor);
	cloner->SetAxisLineZColor(m_ZLineColor);
	cloner->SetMaterial(Material);

	cloner->drop();
	return cloner;
}
Oh and it should be clone not Clone but I was the one who changed it to be Clone so it's my bad..
Image
Dev State: Abandoned (For now..)
Requirements Analysis Doc: ~87%
UML: ~0.5%
christianclavet
Posts: 1638
Joined: Mon Apr 30, 2007 3:24 am
Location: Montreal, CANADA
Contact:

Post by christianclavet »

That's perfect! Thank Dark_Kilauea

I'll surely check that code to put for creating my grid in my viewer!
MasterGod
Posts: 2061
Joined: Fri May 25, 2007 8:06 pm
Location: Israel
Contact:

Post by MasterGod »

Another thing to add to the clone method:
After new CGrid...

Code: Select all

if(!cloner)
		return 0;
Image
Dev State: Abandoned (For now..)
Requirements Analysis Doc: ~87%
UML: ~0.5%
Post Reply