33 from_collision_solids(
NodePath &np,
bool clear) {
48 if (is_tangible(cnode)) {
52 body->add_shapes_from_collision_solids(cnode);
56 body->set_name(cnode->get_name());
64 ghost->add_shapes_from_collision_solids(cnode);
67 ghost->set_name(cnode->get_name());
90 for (
size_t j = 0; j < cnode->get_num_solids(); ++j) {
92 if (solid->is_tangible()) {
115 array->add_column(name, 1, Geom::NT_uint16, Geom::C_index);
118 unregistered_format->add_array(array);
120 registered_format = GeomVertexFormat::register_format(unregistered_format);
122 return registered_format;
140 array->add_column(name, 1, Geom::NT_uint8, Geom::C_other);
143 unregistered_format->add_array(array);
145 registered_format = GeomVertexFormat::register_format(unregistered_format);
147 return registered_format;
156 return make_geom(node, format, two_sided,
true);
165 return make_geom(node, format,
false,
false);
174 btTransform trans = btTransform::getIdentity();
175 get_node_transform(trans, node);
177 btSoftBody *body = (btSoftBody *)node->get_object();
184 fmt = BulletHelper::add_sb_flip_column(fmt);
186 nassertr(fmt->has_column(InternalName::get_vertex()),
nullptr);
187 nassertr(fmt->has_column(InternalName::get_normal()),
nullptr);
189 btSoftBody::tNodeArray &nodes(body->m_nodes);
198 for (
int j=0; j<nodes.size(); ++j) {
199 btVector3 v = nodes[j].m_x;
200 btVector3 &n = nodes[j].m_n;
202 v = trans.invXform(v);
204 vwriter.add_data3((PN_stdfloat)v.getX(), (PN_stdfloat)v.getY(), (PN_stdfloat)v.getZ());
205 nwriter.add_data3((PN_stdfloat)n.getX(), (PN_stdfloat)n.getY(), (PN_stdfloat)n.getZ());
206 fwriter.add_data1i(0);
210 for (
int j=0; j<nodes.size(); ++j) {
211 btVector3 v = nodes[j].m_x;
212 btVector3 &n = nodes[j].m_n;
214 v = trans.invXform(v);
216 vwriter.add_data3((PN_stdfloat)v.getX(), (PN_stdfloat)v.getY(), (PN_stdfloat)v.getZ());
217 nwriter.add_data3((PN_stdfloat)n.getX(), (PN_stdfloat)n.getY(), (PN_stdfloat)n.getZ());
218 fwriter.add_data1i(1);
223 btSoftBody::Node *node0 = &nodes[0];
228 btSoftBody::tFaceArray &faces(body->m_faces);
231 prim->set_shade_model(Geom::SM_uniform);
233 for (
int j=0; j<faces.size(); ++j) {
234 i0 = int(faces[j].m_n[0] - node0);
235 i1 = int(faces[j].m_n[1] - node0);
236 i2 = int(faces[j].m_n[2] - node0);
238 prim->add_vertices(i0, i1, i2);
239 prim->close_primitive();
242 i0 = nodes.size() + int(faces[j].m_n[0] - node0);
243 i1 = nodes.size() + int(faces[j].m_n[2] - node0);
244 i2 = nodes.size() + int(faces[j].m_n[1] - node0);
246 prim->add_vertices(i0, i1, i2);
247 prim->close_primitive();
252 btSoftBody::tLinkArray &links(body->m_links);
255 prim->set_shade_model(Geom::SM_uniform);
257 for (
int j=0; j<links.size(); ++j) {
258 i0 = int(links[j].m_n[0] - node0);
259 i1 = int(links[j].m_n[1] - node0);
261 prim->add_vertices(i0, i1);
262 prim->close_primitive();
267 geom =
new Geom(vdata);
268 geom->add_primitive(prim);
277 make_texcoords_for_patch(
Geom *geom,
int resx,
int resy) {
281 nassertv(vdata->has_column(InternalName::get_texcoord()));
292 while (!texcoords.is_at_end()) {
298 u = (float)ix/(
float)(resx - 1);
299 v = (float)iy/(
float)(resy - 1);
301 texcoords.set_data2f(u, v);
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
CPT(GeomVertexFormat) BulletHelper
Given a source GeomVertexFormat, converts it if necessary to the appropriate format for rendering.
PT(Geom) BulletHelper
Returns a bounding-box visualization of the indicated node's "tight" bounding volume.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A node in the scene graph that can hold any number of CollisionSolids.
get_into_collide_mask
Returns the current "into" CollideMask.
The abstract base class for all things that can collide with other things in the world,...
Defines a series of disconnected line segments.
This is an abstract base class for a family of classes that represent the fundamental geometry primit...
Defines a series of disconnected triangles.
This defines the actual numeric vertex data stored in a Geom, in the structure defined by a particula...
This object provides the functionality of both a GeomVertexReader and a GeomVertexWriter,...
This object provides a high-level interface for quickly writing a sequence of numeric values from a v...
A container for geometry primitives.
Encodes a string name in a hash table, mapping it to a pointer.
This is a set of zero or more NodePaths.
void add_path(const NodePath &node_path)
Adds a new NodePath to the collection.
get_num_paths
Returns the number of NodePaths in the collection.
get_path
Returns the nth NodePath in the collection.
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
static NodePath any_path(PandaNode *node, Thread *current_thread=Thread::get_current_thread())
Returns a new NodePath that represents any arbitrary path from the root to the indicated node.
void remove_node(Thread *current_thread=Thread::get_current_thread())
Disconnects the referenced node from the scene graph.
NodePathCollection find_all_matches(const std::string &path) const
Returns the complete set of all NodePaths that begin with this NodePath and can be extended by path.
PandaNode * node() const
Returns the referenced node of the path.
const TransformState * get_transform(Thread *current_thread=Thread::get_current_thread()) const
Returns the complete transform object set on this node.
A basic node of the scene graph or data graph.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.