Raised This Month: $ Target: $400
 0% 

Pole Block dimensions.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
deeS
Junior Member
Join Date: Dec 2008
Old 08-03-2009 , 23:09   Pole Block dimensions.
Reply With Quote #1

Hey, I have been trying to add pole blocks to my Blockmaker plugin, I can create the blocks, but the dimensions on them are wrong and I can only use the center of the entity rather than the whole thing, my math is wrong when it comes to the dimension.
So far this is the code i have for the pole sections. I'm sorry I cannot release the entire plugin code.
If you need more of the code please let me know.

Code:
const Float:SCALE_NORMAL = 1.0;
const Float:SCALE_LARGE = 2.0;
const Float:SCALE_SMALL = 0.25;
const Float:SCALE_POLE = 0.125;

enum { SIZE_SMALL, SIZE_NORMAL, SIZE_LARGE, SIZE_POLE };

/* pole block dimensions */
new Float:gfPoleBlockSizeMinForX[3] = {-32.0,-4.0,-4.0};
new Float:gfPoleBlockSizeMaxForX[3] = { 32.0, 4.0, 4.0};
new Float:gfPoleBlockSizeMinForZ[3] = {-4.0,-4.0,-32.0};
new Float:gfPoleBlockSizeMaxForZ[3] = { 4.0, 4.0, 32.0};
new Float:gfPoleBlockSizeMinForY[3] = {-4.0,-32.0,-4.0};
new Float:gfPoleBlockSizeMaxForY[3] = { 4.0, 32.0, 4.0};

switch (gBlockSize[id])
	{
		case SMALL: szSize = "Small";
		case NORMAL: szSize = "Normal";
		case LARGE: szSize = "Large";
		case POLE: szSize = "Pole";
	}

//get scale depending on size
		switch (gBlockSize[id])
		{
			case SMALL: fScale = SCALE_SMALL;
			case NORMAL: fScale = SCALE_NORMAL;
			case LARGE: fScale = SCALE_LARGE;
			case POLE: fScale = SCALE_POLE;
		}
//set mins, maxs and angles depending on axis
	switch (axis)
	{
		case X:
		{
			if (size == POLE) {
				vSizeMin = gfPoleBlockSizeMinForX;
				vSizeMax = gfPoleBlockSizeMaxForX;
			} else {
				vSizeMin = gfBlockSizeMinForX;
				vSizeMax = gfBlockSizeMaxForX;
			}
			
			vAngles[0] = 90.0;
		}
		
		case Y:
		{
			if (size == POLE) {
				vSizeMin = gfPoleBlockSizeMinForY;
				vSizeMax = gfPoleBlockSizeMaxForY;
			} else {
				vSizeMin = gfBlockSizeMinForY;
				vSizeMax = gfBlockSizeMaxForY;
			}
			
			vAngles[0] = 90.0;
			vAngles[2] = 90.0;
		}
		
		case Z:
		{
			if (size == POLE) {
				vSizeMin = gfPoleBlockSizeMinForZ;
				vSizeMax = gfPoleBlockSizeMaxForZ;
			} else {
				vSizeMin = gfBlockSizeMinForZ;
				vSizeMax = gfBlockSizeMaxForZ;
			}
			
			vAngles = gfDefaultBlockAngles;
		}
	}
	
	//set block model name and scale depending on size
	switch (size)
	{
		case SMALL:
		{
			fScale = SCALE_SMALL;
		}
		
		case NORMAL:
		{
			fScale = SCALE_NORMAL;
		}
		
		case LARGE:
		{
			fScale = SCALE_LARGE;
		}
		
		case POLE:
		{
			fScale = SCALE_POLE;
		}
	}
	
	return createBlock(id, blockType, vOrigin, vAngles, vSizeMin, vSizeMax, fScale, -1.0);
}
//if its a valid block type
		if (blockType >= 0 && blockType < gBlockMax)
		{
			if(fScale == SCALE_NORMAL) {
				entity_set_model(ent, gszBlockModels[blockType]);
			} else if(fScale == SCALE_LARGE) {
				entity_set_model(ent, gszBlockLargeModels[blockType]);
			} else if(fScale == SCALE_POLE) {
				entity_set_model(ent, gszBlockPoleModels[blockType]);
			} else {
				entity_set_model(ent, gszBlockSmallModels[blockType]);
			}
//get block information 
		entity_get_vector(ent, EV_VEC_angles, vAngles);
		new Float:fScale = entity_get_float(ent, EV_FL_fuser1);
				//get the sprite attached to the top of the block
		

		if(fScale == SCALE_NORMAL) {
			fScale = SCALE_LARGE;
			entity_set_model(ent, gszBlockLargeModels[blockType]);
		} else if(fScale == SCALE_SMALL) {
			fScale = SCALE_NORMAL;
			entity_set_model(ent, gszBlockModels[blockType]);
		} else if(fScale == SCALE_LARGE) {
			fScale = SCALE_POLE;
			entity_set_model(ent, gszBlockPoleModels[blockType]);
		} else {
			fScale = SCALE_SMALL;
			entity_set_model(ent, gszBlockSmallModels[blockType]);
		}
		
		
		entity_set_float(ent, EV_FL_fuser1, fScale);
			
		
		//create new block using current block information with new angles and sizes
		if (vAngles[0] == 0.0 && vAngles[2] == 0.0)
		if (size == POLE) {
			vSizeMin = gfPoleBlockSizeMinForZ;
			vSizeMax = gfPoleBlockSizeMaxForZ;
		} else {
			vSizeMin = gfBlockSizeMinForZ;
			vSizeMax = gfBlockSizeMaxForZ;
		}
		else if (vAngles[0] == 90.0 && vAngles[2] == 0.0)
		if (size == POLE) {
			vSizeMin = gfPoleBlockSizeMinForX;
			vSizeMax = gfPoleBlockSizeMaxForX;
		} else {
			vSizeMin = gfBlockSizeMinForX;
			vSizeMax = gfBlockSizeMaxForX;
		}
		else
		if (size == POLE) {
			vSizeMin = gfPoleBlockSizeMinForY;
			vSizeMax = gfPoleBlockSizeMaxForY;
		} else {
			vSizeMin = gfBlockSizeMinForY;
			vSizeMax = gfBlockSizeMaxForY;
		}
		for (new i = 0; i < 3; ++i) {
			if(vSizeMin[i] != 4.0 && vSizeMin[i] != -4.0) {
				vSizeMin[i] *= fScale;
			}
			if(vSizeMax[i] != 4.0 && vSizeMax[i] != -4.0) {
				vSizeMax[i] *= fScale;
			}
		}
			
		entity_set_size(ent, vSizeMin, vSizeMax);
	}
}

Thank you for any help.
deeS is offline
Old 08-03-2009, 23:48
BigMac
This message has been deleted by BigMac.
wzk
Junior Member
Join Date: Aug 2009
Old 08-10-2009 , 12:36   Re: Pole Block dimensions.
Reply With Quote #2

Used part of its code, and with what I used a little more and I even added, I usually create the blocks, but when I save the POLE becomes SMALL ...
I'm trying to resolve this, but the only thing I can say to you is that the value of SCALE_POLE is 1.0 and not 0.125.

PHP Code:
const Float:SCALE_POLE 0.125

// change to:

const Float:SCALE_POLE 1.0 
Sorry my bad english :/
wzk is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 18:17.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode