openframeworks / openframeworks/openFrameworks

of3dPrimitive as reference to external ofMesh

Open
#1,977 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

core feature section-3D
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.