94static bool Sphere_Array_Valid =
false;
297 if (!Sphere_Array_Valid) {
316 Sphere_Array_Valid =
true;
329 float benefit_factor = 1 - (0.5f / (polycount * polycount));
330 values[lod] = (benefit_factor * screen_area *
LODBias) / polycount;
486 for (
int i=0; i<mesh.Vertex_ct; i++)
488 vb->
x = mesh.vtx[i].
X;
489 vb->
y = mesh.vtx[i].
Y;
490 vb->
z = mesh.vtx[i].
Z;
492 vb->
nx = mesh.vtx_normal[i].
X;
493 vb->
ny = mesh.vtx_normal[i].
Y;
494 vb->
nz = mesh.vtx_normal[i].
Z;
503 vb->
u1 = mesh.vtx_uv[i].
X;
504 vb->
v1 = mesh.vtx_uv[i].
Y;
514 for (
int i=0; i<mesh.face_ct; i++)
516 mem[3*i]=mesh.tri_poly[i].
I;
517 mem[3*i+1]=mesh.tri_poly[i].
J;
518 mem[3*i+2]=mesh.tri_poly[i].
K;
636 temp.
Scale(real_scale);
652 bool use_inverse =
false;
671 0.0f, 0.0f, 1.0f, cpos.
Y,
672 1.0f, 0.0f, 0.0f, cpos.
Z);
674 tm.
Scale(real_scale);
882 if (
scale == 1.0f)
return;
890 for (i = 0; i < count; i++) {
919 for (i = 0; i < count; i++) {
1153 prototype->
Load (cload);
1162 ::memset (&Definition, 0,
sizeof (Definition));
1168 ::memset (&Definition, 0,
sizeof (Definition));
1169 ::strcpy (Definition.Name, sphere->
Get_Name ());
1173 Definition.Attributes = sphere->
Get_Flags ();
1190 const char *filename = ::strrchr (name,
'\\');
1191 if (filename !=
NULL) {
1197 ::strcpy (Definition.TextureName, filename);
1227 ColorChannel.Reset ();
1228 AlphaChannel.Reset ();
1229 ScaleChannel.Reset ();
1230 VectorChannel.Reset ();
1236 cload.
Read (&Definition,
sizeof (Definition));
1240 ColorChannel.Load (cload);
1244 AlphaChannel.Load (cload);
1248 ScaleChannel.Load (cload);
1252 VectorChannel.Load (cload);
1267 csave.
Write (&Definition,
sizeof (Definition));
1270 if (ColorChannel.Get_Key_Count () > 0) {
1272 ColorChannel.Save (csave);
1276 if (AlphaChannel.Get_Key_Count () > 0) {
1278 AlphaChannel.Save (csave);
1283 if (ScaleChannel.Get_Key_Count () > 0) {
1285 ScaleChannel.Save (csave);
1289 if (VectorChannel.Get_Key_Count () > 0) {
1291 VectorChannel.Save (csave);
1301 return Definition.Name;
1328 sphere->
Set_Flags (Definition.Attributes);
1440 if ( alpha_vector == v &&
1441 inverse == inverse_alpha &&
1442 is_additive == IsAdditive &&
1448 inverse_alpha = inverse;
1452 assert(Intensity >= 0.0f);
1454 Vector3 vec = alpha_vector.angle.Rotate_Vector (
Vector3 (1, 0, 0));
1456 if (inverse_alpha) {
1457 for (
int idx=0; idx < Vertex_ct; idx++) {
1465 if (temp > 1.0f) temp = 1.0f;
1467 Set_DCG (is_additive, idx, temp);
1472 for (
int idx=0; idx < Vertex_ct; idx++) {
1480 if (temp > 1.0f) temp = 1.0f;
1482 Set_DCG (is_additive, idx, 1.0F - temp);
1513 face_ct = (Slices * Stacks * 2);
1515 Vertex_ct = ((Slices+1) * Stacks) + 2;
1523 Vector3 vec(0.0f, 0.0f, radius);
1539 uv->
U = 0.5f; uv->
V = 0.0f;
1542 for (stacks = 0; stacks < Stacks; stacks++) {
1544 float stackstep = ((float)stacks + 1) / ((
float) Stacks+1);
1545 float XAxisAngle =
WWMATH_PI * stackstep;
1547 for (slices = 0; slices <= Slices; slices++) {
1549 float slicestep = ((float)slices) / ((
float)Slices);
1550 float YAxisAngle = (
WWMATH_PI * 2.0f) * slicestep;
1556 *veclist = mat * vec;
1570 *veclist = -1.0f * vec;
1571 uv->
U = 0.5f; uv->
V = 1.0f;
1578 for(
int idx = 0; idx < Vertex_ct; idx++) {
1590 fan_size = Slices+2;
1594 for (
int ct = 0; ct < fan_size; ct++) {
1600 int vtx_idx = Vertex_ct - 1;
1601 for (ct = fan_size; ct < (fan_size * 2); ct++) {
1609 strip_size = ((Slices+1) * 2);
1610 strip_ct = Stacks - 1;
1613 for (stacks = 0; stacks < strip_ct; stacks++) {
1615 int store_idx = stacks * strip_size;
1616 int base_vtx = 1 + (stacks * (Slices+1));
1617 int cur_vtx = base_vtx;
1619 for(ct = 0; ct <= Slices; ct++) {
1621 strips[store_idx] = cur_vtx + (Slices+1);
1622 strips[store_idx+1] = cur_vtx;
1642 for (stacks = 0; stacks < strip_ct; stacks++) {
1644 in = &strips[strip_size * stacks];
1648 for(
int fidx=0; fidx < (strip_size - 2); fidx++) {
1658 if (fidx >= (strip_size-2))
break;
1674 for(slices = 0; slices < fan_ct; slices++) {
1676 in = &fans[fan_size * slices];
1679 for (
int fidx=0; fidx < (fan_size - 2); fidx++) {
1681 out->
I = base_idx[0];
1692 WWASSERT(((
int)out) == ((
int)(tri_poly + face_ct)));
1732void SphereMeshClass::Free(
void)
1734 if (vtx)
delete [] vtx;
1735 if (vtx_normal)
delete [] vtx_normal;
1736 if (vtx_uv)
delete [] vtx_uv;
1737 if (dcg)
delete [] dcg;
1738 if (strips)
delete [] strips;
1739 if (fans)
delete [] fans;
1740 if (tri_poly)
delete [] tri_poly;
Color scale(const Color &a, const Color &b)
T Bound(T original, T minval, T maxval)
WWINLINE void Init(const Vector3 ¢er, const Vector3 &extent)
uint32 Read(void *buf, uint32 nbytes)
uint32 Write(const void *buf, uint32 nbytes)
bool Begin_Chunk(uint32 id)
static void Set_Vertex_Buffer(const VertexBufferClass *vb, unsigned stream=0)
static void Set_Texture(unsigned stage, TextureBaseClass *texture)
static void Set_Index_Buffer(const IndexBufferClass *ib, unsigned short index_base_offset)
static Vector4 Convert_Color(unsigned color)
static void Draw_Triangles(unsigned buffer_type, unsigned short start_index, unsigned short polygon_count, unsigned short min_vertex_index, unsigned short vertex_count)
static void Set_Material(const VertexMaterialClass *material)
static void Set_Shader(const ShaderClass &shader)
static void Get_Transform(D3DTRANSFORMSTATETYPE transform, Matrix4x4 &m)
static void Set_Transform(D3DTRANSFORMSTATETYPE transform, const Matrix4x4 &m)
unsigned short * Get_Index_Array()
VertexFormatXYZNDUV2 * Get_Formatted_Vertex_Array()
void Translate(float x, float y, float z)
WWINLINE void Scale(float scale)
WWINLINE void Rotate_X(float theta)
WWINLINE void Make_Identity(void)
WWINLINE void Rotate_Z(float theta)
static WWINLINE void Transform_Vector(const Matrix4x4 &tm, const Vector3 &in, Vector3 *out)
static void Add_Object(RenderObjClass *robj)
const T & Get_Value(void) const
virtual float Get_Screen_Size(CameraClass &camera)
Vector3 Get_Position(void) const
virtual void Set_Transform(const Matrix3D &m)
void Validate_Cached_Bounding_Volumes(void) const
virtual int Is_Not_Hidden_At_All(void)
virtual void Set_Position(const Vector3 &v)
virtual const SphereClass & Get_Bounding_Sphere(void) const
AABoxClass CachedBoundingBox
RenderObjClass & operator=(const RenderObjClass &)
static const float AT_MAX_LOD
SphereClass CachedBoundingSphere
static const float AT_MIN_LOD
static ShaderClass _PresetAlphaShader
void Enable_Fog(const char *source)
static void Insert_Triangles(const SphereClass &bounding_sphere, unsigned short start_index, unsigned short polygon_count, unsigned short min_vertex_index, unsigned short vertex_count)
VisRasterizerClass * VisRasterizer
void Init(const Vector3 &pos, float radius)
virtual PrototypeClass * Load_W3D(ChunkLoadClass &cload)
void Generate(float radius, int slices, int stacks)
void Set_Alpha_Vector(const AlphaVectorStruct &v, bool inverse, bool is_additive, bool force=false)
~SpherePrototypeClass(void)
virtual RenderObjClass * Create(void)
SpherePrototypeClass(void)
virtual int Get_Class_ID(void) const
bool Load(ChunkLoadClass &cload)
bool Save(ChunkSaveClass &csave)
virtual const char * Get_Name(void) const
SphereRenderObjClass & operator=(const SphereRenderObjClass &)
void Set_Animation_Duration(float time)
virtual void Scale(float scale)
virtual void Get_Obj_Space_Bounding_Sphere(SphereClass &sphere) const
TextureClass * SphereTexture
virtual int Get_Num_Polys(void) const
virtual int Get_LOD_Level(void) const
virtual int Class_ID(void) const
AlphaVectorStruct Get_Default_Vector(void) const
Vector3 Get_Default_Color(void) const
virtual float Get_Post_Increment_Value(void) const
const SphereVectorChannelClass & Peek_Vector_Channel(void)
AlphaVectorStruct CurrentVector
float Value[SPHERE_NUM_LOD+2]
void Set_Alpha_Channel(const SphereAlphaChannelClass &data)
void Set_Scale_Channel(const SphereScaleChannelClass &data)
float Get_Default_Alpha(void) const
virtual void Set_LOD_Level(int lod)
SphereAlphaChannelClass AlphaChannel
SphereScaleChannelClass ScaleChannel
void Start_Animating(void)
virtual const char * Get_Name(void) const
SphereColorChannelClass ColorChannel
void Set_Vector_Channel(const SphereVectorChannelClass &data)
static void Generate_Shared_Mesh_Arrays(const AlphaVectorStruct &alphavector)
void Set_Flags(unsigned int flags)
virtual void Special_Render(SpecialRenderInfoClass &rinfo)
virtual void Render(RenderInfoClass &rinfo)
virtual void Update_Cached_Bounding_Volumes(void) const
virtual void Decrement_LOD(void)
virtual int Get_LOD_Count(void) const
const SphereColorChannelClass & Peek_Color_Channel(void)
virtual void Get_Obj_Space_Bounding_Box(AABoxClass &aabox) const
void Update_On_Visibilty(void)
virtual void Set_Position(const Vector3 &v)
virtual void update_cached_box(void)
SphereVectorChannelClass VectorChannel
void Set_Local_Center_Extent(const Vector3 ¢er, const Vector3 &extent)
virtual void Set_Transform(const Matrix3D &m)
~SphereRenderObjClass(void)
char Name[2 *W3D_NAME_LEN]
const SphereScaleChannelClass & Peek_Scale_Channel(void)
void calculate_value_array(float screen_area, float *values) const
const SphereAlphaChannelClass & Peek_Alpha_Channel(void)
VertexMaterialClass * SphereMaterial
void Set_Texture(TextureClass *tf)
virtual int Calculate_Cost_Value_Arrays(float screen_area, float *values, float *costs) const
virtual float Get_Cost(void) const
void vis_render_sphere(SpecialRenderInfoClass &rinfo, const Vector3 ¢er, const Vector3 &extent)
unsigned int Get_Flags(void)
virtual float Get_Value(void) const
void Set_Color_Channel(const SphereColorChannelClass &data)
virtual void Increment_LOD(void)
const AABoxClass & Get_Box(void)
SphereRenderObjClass(void)
void Stop_Animating(void)
virtual void Prepare_LOD(CameraClass &camera)
virtual RenderObjClass * Clone(void) const
Vector3 Get_Default_Scale(void) const
virtual void Set_Name(const char *name)
const StringClass & Get_Full_Path(void) const
static WWINLINE float Dot_Product(const Vector3 &a, const Vector3 &b)
void Set_Model_Transform(const Matrix3D &model)
static void Convert_Vector(const W3dVectorStruct &v, Vector3 *set)
static void Convert_Shader(const W3dShaderStruct &shader, ShaderClass *set)
virtual TextureClass * Get_Texture(const char *filename, MipCountType mip_level_count=MIP_LEVELS_ALL, WW3DFormat texture_format=WW3D_FORMAT_UNKNOWN, bool allow_compression=true, TextureBaseClass::TexAssetType type=TextureBaseClass::TEX_REGULAR, bool allow_reduction=true)
static WW3DAssetManager * Get_Instance(void)
static unsigned int Get_Frame_Time(void)
static void Add_To_Static_Sort_List(RenderObjClass *robj, unsigned int sort_level)
static bool Are_Static_Sort_Lists_Enabled(void)
static bool Is_Sorting_Enabled(void)
const unsigned dynamic_fvf_type
@ BUFFER_TYPE_DYNAMIC_DX8
@ BUFFER_TYPE_DYNAMIC_SORTING
#define REF_PTR_RELEASE(x)
#define REF_PTR_SET(dst, src)
SphereLoaderClass _SphereLoader
SphereMeshClass SphereMeshArray[SPHERE_NUM_LOD]
float SphereLODCosts[SPHERE_NUM_LOD+1]
#define SPHERE_HIGHEST_LOD
#define SPHERE_LOWEST_LOD
char Name[2 *W3D_NAME_LEN]
char TextureName[2 *W3D_NAME_LEN]