4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation; either version 2 of the License, or
7
* (at your option) any later version.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
/**********************************************
21
* Copyright (C) 2001-2002 Bertrand 'blam' LAMY
22
**********************************************/
31
extern P3_renderer* renderer;
38
P3_class P3_class_volume = {
40
(batch_func) P3_volume_batch,
42
(shadow_func) P3_volume_shadow,
43
(raypick_func) P3_volume_raypick,
44
(raypick_b_func) P3_volume_raypick_b,
48
P3_volume* P3_volume_new (P3_volume* c) {
50
c = (P3_volume*) malloc (sizeof (P3_volume));
52
P3_coordsys_initialize ((P3_coordsys*) c);
54
c->class = &P3_class_volume;
59
void P3_volume_batch (P3_volume* c, P3_instance* csys) {
61
if (c->option & P3_OBJECT_HIDDEN) { return; }
62
/* compute new renderer stuff: enter in this coordsys */
63
P3_multiply_matrix (c->render_matrix, renderer->c_camera->render_matrix, P3_coordsys_get_root_matrix ((P3_coordsys*) c));
66
if(o != NULL && o->class->batch != 0 && !(c->option & P3_OBJECT_HIDDEN)) {
67
o->class->batch (o, (P3_instance*) c);
71
int P3_volume_shadow (P3_volume* v, P3_instance* inst, P3_light* light) {
72
if (v->shape != NULL && v->shape->class->shadow != 0) {
73
return v->shape->class->shadow (v->shape, (P3_instance*) v, light);
78
void P3_volume_raypick (P3_volume* inst, P3_raypick_data* data, P3_raypickable* parent) {
79
if (inst->shape == NULL || inst->shape->class->raypick == 0 || inst->option & P3_OBJECT_NON_SOLID) return;
80
/* transform origin and direction into the volume coordsys */
81
inst->shape->class->raypick (inst->shape, data, (P3_raypickable*) inst);
84
int P3_volume_raypick_b (P3_volume* inst, P3_raypick_data* data, P3_raypickable* parent) {
85
if (inst->shape == NULL || inst->shape->class->raypick_b == 0 || inst->option & P3_OBJECT_NON_SOLID) return P3_FALSE;
86
/* transform origin and direction into the volume coordsys */
87
return inst->shape->class->raypick_b (inst->shape, data, (P3_raypickable*) inst);
90
void P3_volume_get_data (P3_volume* v, P3_chunk* chunk) {
91
P3_chunk_save (chunk, v->m, 19 * sizeof (GLfloat));
92
P3_chunk_save_int (chunk, v->option);
95
void P3_volume_set_data (P3_volume* v, P3_chunk* chunk) {
96
v->class = &P3_class_volume;
97
v->validity = P3_COORDSYS_INVALID;
99
P3_chunk_load (chunk, v->m, 19 * sizeof (GLfloat));
100
v->option = P3_chunk_load_int (chunk);