openframeworks / openframeworks/openFrameworks
of3dPrimitive as reference to external ofMesh
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 10.4k
- Forks
- 2.6k
- Avg merge
- 1d 21h
- Merged PRs (30d)
- 9
Description
i've been looking at three.js rencently and there's this neat idea where you can put a mesh in the equivalent of our of3dPrimitive to have several copies with different transformations, it would work something like:
ofMesh sphere = ofMesh::sphere(...);
of3dPrimitive spherePrimitive1(sphere);
spherePrimitive1.setPosition(...);
of3dPrimitive spherePrimitive2(sphere);
spherePrimitive2.setPosition(...);
of3dPrimitive spherePrimitive3(sphere);
spherePrimitive3.setPosition(...);
as it is right now in OF to have several spheres we need to make as much copies of all the geometry which doesn't make much sense.
internally of3dPrimitive contains an ofPtr to a mesh so we would just need to have need to have a setMesh method, i think what would make more sense is to pass an ofPtr since that way memory management would be way easier, the only problem is that the syntax would be slightly complicated:
ofPtr<ofMesh> sphere = ofMesh::sphere(...);
of3dPrimitive spherePrimitive1;
spherePrimitive1.setMesh(sphere);
spherePrimitive1.setPosition(...);
or we could have something like ofMesh::Ptr so you could do:
ofMesh::Ptr sphere = ofMesh::sphere(...);
of3dPrimitive spherePrimitive1;
spherePrimitive1.setMesh(sphere);
spherePrimitive1.setPosition(...);
and/or even a typedef:
ofMeshPtr sphere = ofMesh::sphere(...);
of3dPrimitive spherePrimitive1;
spherePrimitive1.setMesh(sphere);
spherePrimitive1.setPosition(...);
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the of3dPrimitive and ofMesh APIs, especially the existing internal ofPtr mesh ownership. Compare the proposed setMesh and pointer forms, then establish how multiple primitives can share one mesh while keeping independent transformations; done means the selected API supports this without duplicating geometry.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- computer-graphics
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100