Example #1
0
	void loadInto(ci::geom::Target* target, const ci::geom::AttribSet& requestedAttribs) const {
    for (auto &attrib : requestedAttribs) {
      size_t dims = getAttribDims(attrib);
      if (dims) {
        const void* pointer = getAttribPointer(attrib);
        if(pointer) target->copyAttrib(attrib, dims, 0, static_cast<const float*>(pointer), getNumVertices());
      }
    }

    if (getNumIndices()) {
      target->copyIndices(getPrimitive(), &indices[0], getNumIndices(), sizeof(element_t));
    }
  }
Example #2
0
bool ATOM_AABBTreeBuilder::buildFromPrimitives (ATOM_AABBTree *tree, ATOM_AABBTree::PrimitiveType prim, const ATOM_Vector3f *verts, unsigned numVerts, const unsigned short *indices, unsigned numPrimitives, unsigned maxLeafPrimitiveCount, int maxDepth)
{
	if (!numPrimitives)
	{
		return false;
	}

	reset ();

	_vertices.resize (numVerts);
	memcpy (&_vertices[0], verts, sizeof(ATOM_Vector3f) * numVerts);

	unsigned numIndices = calcIndexCount (prim, numPrimitives);
	_indices.resize (numIndices);
	memcpy (&_indices[0], indices, sizeof(unsigned short) * numIndices);

	_extractedIndices.resize (numPrimitives * 3);

	WorkingItem *item = new WorkingItem;
	item->primitives.resize (numPrimitives);
	item->depth = 0;
	_items.push_back (item);

	for (unsigned i = 0; i < numPrimitives; ++i)
	{
		item->primitives[i] = i;
		getPrimitive (i, indices, prim, &_extractedIndices[i*3]);
	}

	item->left = -1;
	item->right = -1;

	int off = 0;
	for (;;)
	{
		workOnItem (prim, *_items[off++], maxLeafPrimitiveCount, maxDepth - 1);
		if (off == _items.size())
		{
			break;
		}
	}

	return buildFinalTree (tree, prim);
}
Example #3
0
void ATOM_AABBTree::rayIntersectR (unsigned node, const ATOM_Ray &ray, float &d, int &t, bool testOnly, bool boxTestOnly, int *indexOut) const
{
	const AABBTreeNode &theNode = _nodes[node];
	float dist = 0.f;

	bool boxTest = testOnly ? ray.intersectionTest (theNode.bbox) : ray.intersectionTestEx (theNode.bbox, dist);
	if (!boxTest)
	{
		return;
	}

	if (theNode.left == -1 && theNode.right == -1)
	{
		if (boxTestOnly)
		{
			if (testOnly)
			{
				t = 0;
				return;
			}
			else if (dist > 0.f && dist < d)
			{
				d = dist;
			}
		}
		else
		{
			for (unsigned i = 0; i < theNode.numPrimitives; ++i)
			{
				unsigned primitive = _leafPrimitiveLists[theNode.primitive + i];
				unsigned short indices[3];
				getPrimitive (primitive, &_indices[0], _primitiveType, indices);
				const ATOM_Vector3f &v0 = _vertices[indices[0]];
				const ATOM_Vector3f &v1 = _vertices[indices[1]];
				const ATOM_Vector3f &v2 = _vertices[indices[2]];
				float u, v;
				if (ray.intersectionTest (v0, v1, v2, false, u, v, dist) && dist > 0.f && dist < d)
				{
					t = primitive;

					if (testOnly)
					{
						return;
					}

					if (indexOut)
					{
						indexOut[0] = indices[0];
						indexOut[1] = indices[1];
						indexOut[2] = indices[2];
					}
					d = dist;
				}
			}
		}
	}
	else
	{
		if (theNode.left != -1)
		{
			rayIntersectR (theNode.left, ray, d, t, testOnly, boxTestOnly, indexOut);

			if (testOnly && t != -1)
			{
				return;
			}
		}

		if (theNode.right != -1)
		{
			rayIntersectR (theNode.right, ray, d, t, testOnly, boxTestOnly, indexOut);

			if (testOnly && t != -1)
			{
				return;
			}
		}
	}
}
int16_t rice::p2p::util::XMLObjectOutputStream_PutField::getShort(::java::lang::String* name)
{
    return npc((java_cast< ::java::lang::Short* >(getPrimitive(name))))->shortValue();
}
int64_t rice::p2p::util::XMLObjectOutputStream_PutField::getLong(::java::lang::String* name)
{
    return npc((java_cast< ::java::lang::Long* >(getPrimitive(name))))->longValue();
}
int32_t rice::p2p::util::XMLObjectOutputStream_PutField::getInt(::java::lang::String* name)
{
    return npc((java_cast< ::java::lang::Integer* >(getPrimitive(name))))->intValue();
}
float rice::p2p::util::XMLObjectOutputStream_PutField::getFloat(::java::lang::String* name)
{
    return npc((java_cast< ::java::lang::Float* >(getPrimitive(name))))->floatValue();
}
double rice::p2p::util::XMLObjectOutputStream_PutField::getDouble(::java::lang::String* name)
{
    return npc((java_cast< ::java::lang::Double* >(getPrimitive(name))))->doubleValue();
}
char16_t rice::p2p::util::XMLObjectOutputStream_PutField::getChar(::java::lang::String* name)
{
    return npc((java_cast< ::java::lang::Character* >(getPrimitive(name))))->charValue();
}
int8_t rice::p2p::util::XMLObjectOutputStream_PutField::getByte(::java::lang::String* name)
{
    return npc((java_cast< ::java::lang::Byte* >(getPrimitive(name))))->byteValue();
}
bool rice::p2p::util::XMLObjectOutputStream_PutField::getBoolean(::java::lang::String* name)
{
    return npc((java_cast< ::java::lang::Boolean* >(getPrimitive(name))))->booleanValue();
}