//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- TEST(PrimitiveSetIndexedUInt, GetOpenGLPrimitive_FromTriangles) { ref<UIntArray> indices = new UIntArray; indices->reserve(6); indices->add(0); indices->add(1); indices->add(2); indices->add(3); indices->add(4); indices->add(5); ref<PrimitiveSetIndexedUInt> myPrim = new PrimitiveSetIndexedUInt(PT_TRIANGLES); myPrim->setIndices(indices.p()); ASSERT_EQ(2u, myPrim->faceCount()); UIntArray conn; myPrim->getFaceIndices(0, &conn); ASSERT_EQ(3u, conn.size()); EXPECT_EQ(0u, conn.get(0)); EXPECT_EQ(1u, conn.get(1)); EXPECT_EQ(2u, conn.get(2)); myPrim->getFaceIndices(1, &conn); ASSERT_EQ(3u, conn.size()); EXPECT_EQ(3u, conn.get(0)); EXPECT_EQ(4u, conn.get(1)); EXPECT_EQ(5u, conn.get(2)); }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- TEST(PrimitiveSetIndexedUInt, GetOpenGLPrimitive_FromLineStrip) { ref<UIntArray> indices = new UIntArray; indices->reserve(4); indices->add(0); indices->add(1); indices->add(2); indices->add(3); ref<PrimitiveSetIndexedUInt> myPrim = new PrimitiveSetIndexedUInt(PT_LINE_STRIP); myPrim->setIndices(indices.p()); ASSERT_EQ(3u, myPrim->faceCount()); UIntArray conn; myPrim->getFaceIndices(0, &conn); ASSERT_EQ(2u, conn.size()); EXPECT_EQ(0u, conn.get(0)); EXPECT_EQ(1u, conn.get(1)); myPrim->getFaceIndices(1, &conn); ASSERT_EQ(2u, conn.size()); EXPECT_EQ(1u, conn.get(0)); EXPECT_EQ(2u, conn.get(1)); myPrim->getFaceIndices(2, &conn); ASSERT_EQ(2u, conn.size()); EXPECT_EQ(2u, conn.get(0)); EXPECT_EQ(3u, conn.get(1)); }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- TEST(PrimitiveSetIndexedUInt, GetOpenGLPrimitive_FromTriStrip) { // See TEST(GeometryBuilderTest, AddTriangleStrip) ref<UIntArray> indices = new UIntArray; indices->reserve(6); indices->add(0); indices->add(1); indices->add(2); indices->add(3); indices->add(4); indices->add(5); ref<PrimitiveSetIndexedUInt> myPrim = new PrimitiveSetIndexedUInt(PT_TRIANGLE_STRIP); myPrim->setIndices(indices.p()); ASSERT_EQ(4u, myPrim->faceCount()); UIntArray conn; myPrim->getFaceIndices(0, &conn); ASSERT_EQ(3u, conn.size()); EXPECT_EQ(0u, conn.get(0)); EXPECT_EQ(1u, conn.get(1)); EXPECT_EQ(2u, conn.get(2)); myPrim->getFaceIndices(1, &conn); ASSERT_EQ(3u, conn.size()); EXPECT_EQ(2u, conn.get(0)); EXPECT_EQ(1u, conn.get(1)); EXPECT_EQ(3u, conn.get(2)); myPrim->getFaceIndices(2, &conn); ASSERT_EQ(3u, conn.size()); EXPECT_EQ(2u, conn.get(0)); EXPECT_EQ(3u, conn.get(1)); EXPECT_EQ(4u, conn.get(2)); myPrim->getFaceIndices(3, &conn); ASSERT_EQ(3u, conn.size()); EXPECT_EQ(4u, conn.get(0)); EXPECT_EQ(3u, conn.get(1)); EXPECT_EQ(5u, conn.get(2)); }