invsphere for egg syntax

This commit is contained in:
David Rose 2005-01-05 21:24:32 +00:00
parent 9d8f7fe834
commit a1d0fbc932
9 changed files with 53 additions and 4 deletions

View File

@ -303,7 +303,7 @@ fill_viz_geom() {
<< "Recomputing viz for " << *this << "\n";
}
static const int num_slices = 8;
static const int num_slices = 16;
static const int num_stacks = 8;
GeomTristrip *sphere = new GeomTristrip;

View File

@ -322,7 +322,7 @@ fill_viz_geom() {
<< "Recomputing viz for " << *this << "\n";
}
static const int num_slices = 8;
static const int num_slices = 16;
static const int num_stacks = 8;
GeomTristrip *sphere = new GeomTristrip;

View File

@ -74,6 +74,7 @@ egg-object-type-dcs <DCS> { 1 }
# collisions more optimally than regular visible polygons.
egg-object-type-barrier <Collide> { Polyset descend }
egg-object-type-sphere <Collide> { Sphere descend }
egg-object-type-invsphere <Collide> { InvSphere descend }
egg-object-type-tube <Collide> { Tube descend }
# As above, but these are flagged to be "intangible", so that they

View File

@ -1117,6 +1117,21 @@ GROUPING ENTRIES
The geometry represents a sphere. The vertices in the group are
averaged together to determine the sphere's center and radius.
InvSphere
The geometry represents an inverse sphere. This is the same as
Sphere, with the normal inverted, so that the solid part of an
inverse sphere is the entire world outside of it. Note that an
inverse sphere is in infinitely large solid with a finite hole
cut into it.
Tube
The geometry represents a tube. This is a cylinder-like shape
with hemispherical endcaps; it is sometimes called a capsule or
a lozenge in other packages. The smallest tube shape that will
fit around the vertices is used.
The flags may be any zero or more of:

View File

@ -813,6 +813,9 @@ string_cs_type(const string &string) {
return CST_polyset;
} else if (cmp_nocase_uh(string, "sphere") == 0) {
return CST_sphere;
} else if (cmp_nocase_uh(string, "inv-sphere") == 0 ||
cmp_nocase_uh(string, "invsphere") == 0) {
return CST_inv_sphere;
} else if (cmp_nocase_uh(string, "tube") == 0) {
return CST_tube;
} else {
@ -1185,6 +1188,8 @@ ostream &operator << (ostream &out, EggGroup::CollisionSolidType t) {
return out << "Polyset";
case EggGroup::CST_sphere:
return out << "Sphere";
case EggGroup::CST_inv_sphere:
return out << "InvSphere";
case EggGroup::CST_tube:
return out << "Tube";
}

View File

@ -79,11 +79,11 @@ PUBLISHED:
CST_polyset = 0x00030000,
CST_sphere = 0x00040000,
CST_tube = 0x00050000,
CST_inv_sphere = 0x00060000,
};
enum CollideFlags {
// The bits here must correspond to those in Flags, below.
CF_none = 0x00000000,
CF_intangible = 0x00080000,
CF_descend = 0x00100000,
CF_event = 0x00200000,
CF_keep = 0x00400000,
@ -91,6 +91,7 @@ PUBLISHED:
CF_center = 0x01000000,
CF_turnstile = 0x02000000,
CF_level = 0x04000000,
CF_intangible = 0x08000000,
};
EggGroup(const string &name = "");

View File

@ -68,6 +68,7 @@
#include "selectiveChildNode.h"
#include "collisionNode.h"
#include "collisionSphere.h"
#include "collisionInvSphere.h"
#include "collisionTube.h"
#include "collisionPlane.h"
#include "collisionPolygon.h"
@ -2196,6 +2197,10 @@ make_collision_solids(EggGroup *start_group, EggGroup *egg_group,
make_collision_sphere(egg_group, cnode, start_group->get_collide_flags());
break;
case EggGroup::CST_inv_sphere:
make_collision_inv_sphere(egg_group, cnode, start_group->get_collide_flags());
break;
case EggGroup::CST_tube:
make_collision_tube(egg_group, cnode, start_group->get_collide_flags());
break;
@ -2301,6 +2306,26 @@ make_collision_sphere(EggGroup *egg_group, CollisionNode *cnode,
}
}
////////////////////////////////////////////////////////////////////
// Function: EggLoader::make_collision_inv_sphere
// Access: Private
// Description: Creates a single CollisionInvSphere corresponding
// to the polygons associated with this group.
////////////////////////////////////////////////////////////////////
void EggLoader::
make_collision_inv_sphere(EggGroup *egg_group, CollisionNode *cnode,
EggGroup::CollideFlags flags) {
LPoint3f center;
float radius;
Colorf dummycolor;
if (make_sphere(egg_group, center, radius, dummycolor)) {
CollisionInvSphere *cssphere =
new CollisionInvSphere(center, radius);
apply_collision_flags(cssphere, flags);
cnode->add_solid(cssphere);
}
}
////////////////////////////////////////////////////////////////////
// Function: EggLoader::make_collision_tube
// Access: Private

View File

@ -138,6 +138,8 @@ private:
EggGroup::CollideFlags flags);
void make_collision_sphere(EggGroup *egg_group, CollisionNode *cnode,
EggGroup::CollideFlags flags);
void make_collision_inv_sphere(EggGroup *egg_group, CollisionNode *cnode,
EggGroup::CollideFlags flags);
void make_collision_tube(EggGroup *egg_group, CollisionNode *cnode,
EggGroup::CollideFlags flags);
void apply_collision_flags(CollisionSolid *solid,

View File

@ -2,7 +2,7 @@
#define OTHER_LIBS interrogatedb:c dconfig:c dtoolconfig:m \
dtoolutil:c dtoolbase:c dtool:m
#define USE_PACKAGES gl glx
#define USE_PACKAGES gl glx cg
#begin lib_target
#define TARGET glxdisplay