Ejemplo n.º 1
0
// This is called just after the constructor when your object has been created.  Construct has set
// up your object here so it is safe to make runtime calls.
void ExtObject::OnCreate()
{
	// Load the edittime data that was serialized.
	bin ar;
	ar.attach(info.editObject->eData, info.editObject->eSize);

	// Read the data.  Same format as you exported in EditExt::Serialize.
	// Your runtime loader must be able to load all versions!
	int Version = 0;
	ar >> Version;

	// Finished reading data
	ar.detach();

	// Height is line width
	float angle = cr::to_radians(info.editObject->eAngle);
	float length = info.editObject->eWidth;
	line_width = info.editObject->eHeight;

	start.x = info.editObject->eX;
	start.y = info.editObject->eY;
	start.z = 0;

	end.x = start.x + cos(angle) * length;
	end.y = start.y + sin(angle) * length;
	end.z = 0;

	UpdateInfoBox();

	// Box collisions
	info.collMode = COLLISIONMODE_ANGLED_BOX;

	info.angle = info.editObject->eAngle;
	info.pInfo->filter = info.editObject->eColor;

	SetupPrivateVariableVector(pRuntime, this, privateVars);

	// Update bounding box
	pRuntime->UpdateBoundingBox(this);
}
Ejemplo n.º 2
0
// This is called just after the constructor when your object has been created.  Construct has set
// up your object here so it is safe to make runtime calls.
void ExtObject::OnCreate()
{
	bin ar;
	ar.attach(info.editObject->eData, info.editObject->eSize);

	int Version = 0;
	ar >> Version;


	ImageHandleInfo* imgTexture = pRuntime->LoadSerializedImageHandle(ar);
	iTexture = renderer->CreateTextureFromHandle(imgTexture);

	COLORREF vertex[4];
	float vertex_opacity[4];

	ar >> vertex[0] >> vertex[1] >> vertex[2] >> vertex[3];
	ar >> vertex_opacity[0] >> vertex_opacity[1] >> vertex_opacity[2] >> vertex_opacity[3];

	for(int i = 0; i < 4; i++)
	{
		vertex_filter[i].r = GetRValue(vertex[i]) / 255.0f;
		vertex_filter[i].g = GetGValue(vertex[i]) / 255.0f;
		vertex_filter[i].b = GetBValue(vertex[i]) / 255.0f;
		vertex_filter[i].a = vertex_opacity[i];
	}

	ar >> image_left_margin	>> image_right_margin >> image_top_margin >> image_bottom_margin;

	int hs;
	ar >> hs;
	hotspot_pos = (hotspot_position)hs;

	ar.detach();

	info.collMode = COLLISIONMODE_BOX;

	info.w = info.editObject->eWidth;
	info.h = info.editObject->eHeight;

	switch (hotspot_pos) {
	case hs_topleft:
		hs_xf = 0.0f;
		hs_yf = 0.0f;
		break;
	case hs_top:
		hs_xf = 0.5f;
		hs_yf = 0.0f;
		break;
	case hs_topright:
		hs_xf = 1.0f;
		hs_yf = 0.0f;
		break;
	case hs_left:
		hs_xf = 0.0f;
		hs_yf = 0.5f;
		break;
	case hs_center:
		hs_xf = 0.5f;
		hs_yf = 0.5f;
		break;
	case hs_right:
		hs_xf = 1.0f;
		hs_yf = 0.5f;
		break;
	case hs_bottomleft:
		hs_xf = 0.0f;
		hs_yf = 1.0f;
		break;
	case hs_bottom:
		hs_xf = 0.5f;
		hs_yf = 1.0f;
		break;
	case hs_bottomright:
		hs_xf = 1.0f;
		hs_yf = 1.0f;
		break;
	}

	info.HotSpotX = info.w * hs_xf;
	info.HotSpotY = info.h * hs_yf;
	oldw = info.w;
	oldh = info.h;

	info.HotSpotAngle = atan(float(info.HotSpotY) / float(info.HotSpotX));
	info.HotSpotDist = sqrt((double)info.HotSpotX * info.HotSpotX + info.HotSpotY * info.HotSpotY);

	info.x = info.editObject->eX;
	info.y = info.editObject->eY;

	info.pInfo->filter = info.editObject->eColor;
	info.angle = info.editObject->eAngle;

	info.visible = true;
	padding = 0;

	// Setup private vars
	SetupPrivateVariableVector(pRuntime, this, privateVars);

	objAttach = NULL;

	// Update bounding box
	pRuntime->UpdateBoundingBox(this);
}