Jump to content

  • Log In with Google      Sign In   
  • Create Account

Calling all IT Pros from Canada and Australia.. we need your help! Support our site by taking a quick sponsored surveyand win a chance at a $50 Amazon gift card. Click here to get started!


Member Since 09 Jun 2005
Offline Last Active Nov 03 2012 03:02 PM

Posts I've Made

In Topic: Saving data, according to list

03 November 2012 - 02:48 PM

Seems that i solved this problem, thanks to "boost.any"


But sometimes, very rarely, you actually want to store a whole bunch of messy, unrelated types in a container without trying to ram them into some sort of class hierarchy. Parsers are a good example of this.

Exactly my case! Parser & compiler.

At parsing stage i just "push_back" my structs into custom vector:
using boost::any_cast;
typedef std::vector< boost::any > AnyVector;
AnyVector values;

Later when saving, i just cast them back, get my values and save.
  for ( std::vector< boost::any >::const_iterator p = parser->tab->values.begin();
	p != parser->tab->values.end();
	++p )
   if ( p->type() == typeid(int) )
	cout << "ID: " << any_cast<int>(*p) << endl;
   if ( p->type() == typeid(MY_STRUCT) )
						   // ....
						  fwrite(mystruct, ...);
etc etc...

Each struct is saved correctly with correct nr of them.
Just tested and it works.

In Topic: Saving data, according to list

03 November 2012 - 03:38 AM

I just loop through them, they are saved in specific order, same order as i use the "fwrite" in my CPP source.
But how i would know in advance in what order the commands will be in the script source?

For ex: script
print "test 1"
print "test 2"

I have to write "cls" struct once, and then "print" twice.
In same order. The order could be anything. Because its compiler. And user can write this in any order.

In Topic: Need help with rewriting loop

19 August 2012 - 06:10 AM

Thanks, that was it. Works fine now.
I don't know how i missed that little thing.

EDIT: i probably shouldn't code at 4 AM, without sleeping.

In Topic: Finding bounds of a square on the cube or something like that

02 August 2012 - 02:30 AM

OK as usually after posting topic, i got this to work but not fully.

Because for each cube the X,Y,Z coords change, i need to somehow calculate the bounds using also the X,Y,Z coords. Relative to to block coords or something, but i don't know the math behind it.

If for example: X=4, Y=3, Z=6, how i should calculate bounds for it?
Block size is 1x1x1 (100x100x100) pixels always.

For X0,Y0,Z0 i got really bounds like: 0-1 (float values from gluUnproject, without casting them to int's). But for coords like X1, Y1, Z1 it will no longer work.

Should i multiply X,Y,Z with 1 or something? Or subtract something? I just don't know.

In Topic: Ignore background color when using glReadPixels?

15 April 2012 - 05:27 PM

OK, another idea i was thinking about is as follows:
Z can only holds values from 0 to 7. So if i do simple logic like:

if(R<=255 & G<=255 & B >7) {
// Ignore All Three Color Values Read
//  Because They Are Background Color Values.

So basically do not allow user to choose color, which B (blue) is less than or equal to 7.

I think it will work and still it is possible to use a lot more colors than some very limited amount of colors for background.
But somebody's other thoughts on this will also help me.