Blender  V2.59
strand.h
Go to the documentation of this file.
00001 /*
00002  * $Id: strand.h 35233 2011-02-27 19:31:27Z jesterking $
00003  *
00004  * ***** BEGIN GPL LICENSE BLOCK *****
00005  *
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License
00008  * as published by the Free Software Foundation; either version 2
00009  * of the License, or (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software Foundation,
00018  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00019  *
00020  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
00021  * All rights reserved.
00022  *
00023  * The Original Code is: none of this file.
00024  *
00025  * Contributor(s): Brecht Van Lommel.
00026  *
00027  * ***** END GPL LICENSE BLOCK *****
00028  */
00029 
00035 #ifndef STRAND_H
00036 #define STRAND_H 
00037 
00038 struct StrandVert;
00039 struct StrandRen;
00040 struct StrandBuffer;
00041 struct ShadeSample;
00042 struct StrandPart;
00043 struct Render;
00044 struct RenderPart;
00045 struct RenderBuckets;
00046 struct RenderPrimitiveIterator;
00047 struct ZSpan;
00048 struct ObjectInstanceRen;
00049 struct StrandSurface;
00050 struct DerivedMesh;
00051 struct ObjectRen;
00052 
00053 typedef struct StrandPoint {
00054         /* position within segment */
00055         float t;
00056 
00057         /* camera space */
00058         float co[3];
00059         float nor[3];
00060         float tan[3];
00061         float strandco;
00062         float width;
00063 
00064         /* derivatives */
00065         float dtco[3], dsco[3];
00066         float dtstrandco;
00067 
00068         /* outer points */
00069         float co1[3], co2[3];
00070         float hoco1[4], hoco2[4];
00071         float zco1[3], zco2[3];
00072         int clip1, clip2;
00073 
00074         /* screen space */
00075         float hoco[4];
00076         float x, y;
00077 
00078         /* simplification */
00079         float alpha;
00080 } StrandPoint;
00081 
00082 typedef struct StrandSegment {
00083         struct StrandVert *v[4];
00084         struct StrandRen *strand;
00085         struct StrandBuffer *buffer;
00086         struct ObjectInstanceRen *obi;
00087         float sqadaptcos;
00088 
00089         StrandPoint point1, point2;
00090         int shaded;
00091 } StrandSegment;
00092 
00093 struct StrandShadeCache;
00094 typedef struct StrandShadeCache StrandShadeCache;
00095 
00096 void strand_eval_point(StrandSegment *sseg, StrandPoint *spoint);
00097 void render_strand_segment(struct Render *re, float winmat[][4], struct StrandPart *spart, struct ZSpan *zspan, int totzspan, StrandSegment *sseg);
00098 void strand_minmax(struct StrandRen *strand, float *min, float *max, float width);
00099 
00100 struct StrandSurface *cache_strand_surface(struct Render *re, struct ObjectRen *obr, struct DerivedMesh *dm, float mat[][4], int timeoffset);
00101 void free_strand_surface(struct Render *re);
00102 
00103 struct StrandShadeCache *strand_shade_cache_create(void);
00104 void strand_shade_cache_free(struct StrandShadeCache *cache);
00105 void strand_shade_segment(struct Render *re, struct StrandShadeCache *cache, struct StrandSegment *sseg, struct ShadeSample *ssamp, float t, float s, int addpassflag);
00106 void strand_shade_unref(struct StrandShadeCache *cache, struct StrandVert *svert);
00107 
00108 struct RenderBuckets *init_buckets(struct Render *re);
00109 void add_buckets_primitive(struct RenderBuckets *buckets, float *min, float *max, void *prim);
00110 void free_buckets(struct RenderBuckets *buckets);
00111 void project_hoco_to_bucket(struct RenderBuckets *buckets, float *hoco, float *bucketco);
00112 
00113 struct RenderPrimitiveIterator *init_primitive_iterator(struct Render *re, struct RenderBuckets *buckets, struct RenderPart *pa);
00114 void *next_primitive_iterator(struct RenderPrimitiveIterator *iter);
00115 void free_primitive_iterator(struct RenderPrimitiveIterator *iter);
00116 
00117 #endif
00118