Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login
    1. Maxon Developers Forum
    2. fraukman2
    F
    • Profile
    • Following 0
    • Followers 0
    • Topics 1
    • Posts 2
    • Best 0
    • Controversial 0
    • Groups 0

    fraukman2

    @fraukman2

    0
    Reputation
    1
    Profile views
    2
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    fraukman2 Unfollow Follow

    Latest posts made by fraukman2

    • RE: Wrong Polygon indices

      Hi @m_adam, I just tested your suggestion and worked flawless, thank you very much.

      Cheers and happy holidays

      posted in Cinema 4D SDK
      F
      fraukman2
    • Wrong Polygon indices

      Hi everyone, I'm writing a small ray tracer, and I'm having problems with the mesh indices, the order is wrong.

      for(int i = 0;i < meshes.size();i++)
      			{
      				for (int k = 0; k < meshes[i].PolyCount;k++)
      				{
      					Int32 indexPointA = meshes[i].indices[k].a;
      					Int32 indexPointB = meshes[i].indices[k].b;
      					Int32 indexPointC = meshes[i].indices[k].c;
      					
      					Tri triangle;
      					triangle.vertex0 = (meshes[i].vertices[indexPointA]) / 100.0f;
      					triangle.vertex1 = (meshes[i].vertices[indexPointB]) / 100.0f;
      					triangle.vertex2 = (meshes[i].vertices[indexPointC]) / 100.0f;
      					IntersectTri(ray, triangle);
      					if (ray.t < 1e30f)
      					{
      						_film->setImagePixel(x, y, 255, 255, 255);
      					}
      				}
      			}
      

      I'm using a plane (previously triangulated) to test and get this result:

      Capturar.PNG

      i debuged the indices and they are wrong.
      indices:
      {1,3,0} - triangle 1
      {1,2,3} - triangle 2

      this is how i get the polygons:

      void Scene::_recurseHierarchy(BaseObject* op)
      	{
      		while (op)
      		{
      			Bool isPolygon = op->IsInstanceOf(Opolygon) && !op->IsInstanceOf(Ojoint);
      			if (isPolygon)
      			{
      				Frog::Mesh mesh = {};
      				GePrint(op->GetName());
      
      				PolygonObject* poly = (PolygonObject*)op;
      				if (poly)
      				{
      					Int32 numOfVertices = poly->GetPointCount();
      					const CPolygon* cpoly = poly->GetPolygonR();
      					CPolygon* trianguled = nullptr;
      					const Vector* vetices = poly->GetPointR();
      					Int32 trianguledPolyCount;
      					Bool triRes = Triangulate(vetices, numOfVertices, &trianguled, &trianguledPolyCount);
      					if (triRes)
      					{
      						mesh.vertices = vetices;
      						mesh.indices = trianguled;
      						mesh.PolyCount = trianguledPolyCount;
      						objects.push_back(mesh);
      					}
      				}
      			}
      			_recurseHierarchy(op->GetDown());
      			op = op->GetNext();
      		}
      	}
      

      Can anyone point me what I'm doing wrong ?

      posted in Cinema 4D SDK c++
      F
      fraukman2