mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 02:15:43 -04:00
qpgeom sprites in dx8
This commit is contained in:
parent
43f4675d65
commit
ef53db4d3b
@ -540,23 +540,6 @@ get_coordinate_system() const {
|
|||||||
return _coordinate_system;
|
return _coordinate_system;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
// Function: GraphicsStateGuardian::get_internal_coordinate_system
|
|
||||||
// Access: Public
|
|
||||||
// Description: Returns the coordinate system used internally by the
|
|
||||||
// GSG, if any one particular coordinate system is used.
|
|
||||||
// The default, CS_default, indicates that the GSG can
|
|
||||||
// use any coordinate system.
|
|
||||||
//
|
|
||||||
// If this returns other than CS_default, the
|
|
||||||
// GraphicsEngine will automatically convert all
|
|
||||||
// transforms into the indicated coordinate system.
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
INLINE CoordinateSystem GraphicsStateGuardian::
|
|
||||||
get_internal_coordinate_system() const {
|
|
||||||
return _coordinate_system;
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: GraphicsStateGuardian::get_cs_transform
|
// Function: GraphicsStateGuardian::get_cs_transform
|
||||||
// Access: Public
|
// Access: Public
|
||||||
|
@ -842,6 +842,24 @@ set_coordinate_system(CoordinateSystem cs) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: GraphicsStateGuardian::get_internal_coordinate_system
|
||||||
|
// Access: Public, Virtual
|
||||||
|
// Description: Returns the coordinate system used internally by the
|
||||||
|
// GSG. This may be the same as the external coordinate
|
||||||
|
// system reported by get_coordinate_system(), or it may
|
||||||
|
// be something different.
|
||||||
|
//
|
||||||
|
// In any case, vertices that have been transformed
|
||||||
|
// before being handed to the GSG (that is, vertices
|
||||||
|
// with a contents value of C_clip_point) will be
|
||||||
|
// expected to be in this coordinate system.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
CoordinateSystem GraphicsStateGuardian::
|
||||||
|
get_internal_coordinate_system() const {
|
||||||
|
return _internal_coordinate_system;
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: GraphicsStateGuardian::issue_transform
|
// Function: GraphicsStateGuardian::issue_transform
|
||||||
// Access: Public, Virtual
|
// Access: Public, Virtual
|
||||||
|
@ -184,7 +184,7 @@ public:
|
|||||||
|
|
||||||
void set_coordinate_system(CoordinateSystem cs);
|
void set_coordinate_system(CoordinateSystem cs);
|
||||||
INLINE CoordinateSystem get_coordinate_system() const;
|
INLINE CoordinateSystem get_coordinate_system() const;
|
||||||
INLINE CoordinateSystem get_internal_coordinate_system() const;
|
virtual CoordinateSystem get_internal_coordinate_system() const;
|
||||||
|
|
||||||
INLINE const TransformState *get_cs_transform() const;
|
INLINE const TransformState *get_cs_transform() const;
|
||||||
|
|
||||||
|
@ -46,20 +46,18 @@ munge_format_impl(const qpGeomVertexFormat *orig,
|
|||||||
new_format->set_animation(animation);
|
new_format->set_animation(animation);
|
||||||
PT(qpGeomVertexArrayFormat) new_array_format = new qpGeomVertexArrayFormat;
|
PT(qpGeomVertexArrayFormat) new_array_format = new qpGeomVertexArrayFormat;
|
||||||
|
|
||||||
const qpGeomVertexColumn *vertex_type =
|
const qpGeomVertexColumn *vertex_type = orig->get_vertex_column();
|
||||||
orig->get_column(InternalName::get_vertex());
|
const qpGeomVertexColumn *normal_type = orig->get_normal_column();
|
||||||
const qpGeomVertexColumn *normal_type =
|
const qpGeomVertexColumn *color_type = orig->get_color_column();
|
||||||
orig->get_column(InternalName::get_normal());
|
|
||||||
const qpGeomVertexColumn *color_type =
|
|
||||||
orig->get_column(InternalName::get_color());
|
|
||||||
const qpGeomVertexColumn *texcoord_type =
|
const qpGeomVertexColumn *texcoord_type =
|
||||||
orig->get_column(InternalName::get_texcoord());
|
orig->get_column(InternalName::get_texcoord());
|
||||||
|
|
||||||
if (vertex_type != (const qpGeomVertexColumn *)NULL) {
|
if (vertex_type != (const qpGeomVertexColumn *)NULL) {
|
||||||
new_array_format->add_column
|
new_array_format->add_column
|
||||||
(InternalName::get_vertex(), 3, qpGeomVertexColumn::NT_float32,
|
(InternalName::get_vertex(), 3, qpGeomVertexColumn::NT_float32,
|
||||||
qpGeomVertexColumn::C_point);
|
vertex_type->get_contents());
|
||||||
new_format->remove_column(vertex_type->get_name());
|
new_format->remove_column(vertex_type->get_name());
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// If we don't have a vertex type, not much we can do.
|
// If we don't have a vertex type, not much we can do.
|
||||||
return orig;
|
return orig;
|
||||||
|
@ -54,6 +54,7 @@
|
|||||||
#include "qpgeomTriangles.h"
|
#include "qpgeomTriangles.h"
|
||||||
#include "qpgeomTristrips.h"
|
#include "qpgeomTristrips.h"
|
||||||
#include "qpgeomTrifans.h"
|
#include "qpgeomTrifans.h"
|
||||||
|
#include "qpgeomLines.h"
|
||||||
#include "dxGeomMunger8.h"
|
#include "dxGeomMunger8.h"
|
||||||
#include "config_gobj.h"
|
#include "config_gobj.h"
|
||||||
#include "dxVertexBufferContext8.h"
|
#include "dxVertexBufferContext8.h"
|
||||||
@ -2693,13 +2694,32 @@ begin_draw_primitives(const qpGeom *geom, const qpGeomMunger *munger,
|
|||||||
_vertex_blending_enabled = false;
|
_vertex_blending_enabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_transform_stale) {
|
if (_transform_stale && !_vertex_data->is_vertex_transformed()) {
|
||||||
const D3DMATRIX *d3d_mat = (const D3DMATRIX *)_transform->get_mat().get_data();
|
const D3DMATRIX *d3d_mat = (const D3DMATRIX *)_transform->get_mat().get_data();
|
||||||
_pD3DDevice->SetTransform(D3DTS_WORLD, d3d_mat);
|
_pD3DDevice->SetTransform(D3DTS_WORLD, d3d_mat);
|
||||||
_transform_stale = false;
|
_transform_stale = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_vertex_data->is_vertex_transformed()) {
|
||||||
|
// If the vertex data claims to be already transformed into clip
|
||||||
|
// coordinates, wipe out the current projection and modelview
|
||||||
|
// matrix (so we don't attempt to transform it again).
|
||||||
|
|
||||||
|
// It's tempting just to use the D3DFVF_XYZRHW specification on
|
||||||
|
// these vertices, but that turns out to be a bigger hammer than
|
||||||
|
// we want: that also prevents lighting calculations and user clip
|
||||||
|
// planes.
|
||||||
|
_pD3DDevice->SetTransform(D3DTS_WORLD, &matIdentity);
|
||||||
|
static const LMatrix4f rescale_mat
|
||||||
|
(1, 0, 0, 0,
|
||||||
|
0, 1, 0, 0,
|
||||||
|
0, 0, 0.5, 0,
|
||||||
|
0, 0, 0.5, 1);
|
||||||
|
_transform_stale = true;
|
||||||
|
|
||||||
|
_pD3DDevice->SetTransform(D3DTS_PROJECTION, (const D3DMATRIX *)rescale_mat.get_data());
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -2818,6 +2838,38 @@ draw_tristrips(const qpGeomTristrips *primitive) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: DXGraphicsStateGuardian8::draw_lines
|
||||||
|
// Access: Public, Virtual
|
||||||
|
// Description: Draws a series of disconnected line segments.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void DXGraphicsStateGuardian8::
|
||||||
|
draw_lines(const qpGeomLines *primitive) {
|
||||||
|
_vertices_other_pcollector.add_level(primitive->get_num_vertices());
|
||||||
|
if (_vbuffer_active) {
|
||||||
|
IndexBufferContext *ibc = ((qpGeomPrimitive *)primitive)->prepare_now(get_prepared_objects(), this);
|
||||||
|
nassertv(ibc != (IndexBufferContext *)NULL);
|
||||||
|
apply_index_buffer(ibc);
|
||||||
|
|
||||||
|
_pD3DDevice->DrawIndexedPrimitive
|
||||||
|
(D3DPT_LINELIST,
|
||||||
|
primitive->get_min_vertex(),
|
||||||
|
primitive->get_max_vertex() - primitive->get_min_vertex() + 1,
|
||||||
|
0, primitive->get_num_primitives());
|
||||||
|
|
||||||
|
} else {
|
||||||
|
_pD3DDevice->DrawIndexedPrimitiveUP
|
||||||
|
(D3DPT_LINELIST,
|
||||||
|
primitive->get_min_vertex(),
|
||||||
|
primitive->get_max_vertex() - primitive->get_min_vertex() + 1,
|
||||||
|
primitive->get_num_primitives(),
|
||||||
|
primitive->get_flat_first_vertices(),
|
||||||
|
D3DFMT_INDEX16,
|
||||||
|
_vertex_data->get_array(0)->get_data(),
|
||||||
|
_vertex_data->get_format()->get_array(0)->get_stride());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: DXGraphicsStateGuardian8::end_draw_primitives()
|
// Function: DXGraphicsStateGuardian8::end_draw_primitives()
|
||||||
// Access: Public, Virtual
|
// Access: Public, Virtual
|
||||||
@ -2827,8 +2879,6 @@ draw_tristrips(const qpGeomTristrips *primitive) {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
void DXGraphicsStateGuardian8::
|
void DXGraphicsStateGuardian8::
|
||||||
end_draw_primitives() {
|
end_draw_primitives() {
|
||||||
GraphicsStateGuardian::end_draw_primitives();
|
|
||||||
|
|
||||||
// Turn off vertex blending--it seems to cause problems if we leave
|
// Turn off vertex blending--it seems to cause problems if we leave
|
||||||
// it on.
|
// it on.
|
||||||
if (_vertex_blending_enabled) {
|
if (_vertex_blending_enabled) {
|
||||||
@ -2836,6 +2886,13 @@ end_draw_primitives() {
|
|||||||
_pD3DDevice->SetRenderState(D3DRS_VERTEXBLEND, D3DVBF_DISABLE);
|
_pD3DDevice->SetRenderState(D3DRS_VERTEXBLEND, D3DVBF_DISABLE);
|
||||||
_vertex_blending_enabled = false;
|
_vertex_blending_enabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_vertex_data->is_vertex_transformed()) {
|
||||||
|
// Restore the projection matrix that we wiped out above.
|
||||||
|
prepare_lens();
|
||||||
|
}
|
||||||
|
|
||||||
|
GraphicsStateGuardian::end_draw_primitives();
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
@ -3579,7 +3636,7 @@ issue_tex_gen(const TexGenAttrib *attrib) {
|
|||||||
//enable_texturing(false);
|
//enable_texturing(false);
|
||||||
// reset the texcoordindex lookup to 0
|
// reset the texcoordindex lookup to 0
|
||||||
//_pD3DDevice->SetTransform(D3DTS_TEXTURE0, (D3DMATRIX *)dm.get_data());
|
//_pD3DDevice->SetTransform(D3DTS_TEXTURE0, (D3DMATRIX *)dm.get_data());
|
||||||
_pD3DDevice->SetTextureStageState(0, D3DTSS_TEXTURETRANSFORMFLAGS, 0);
|
//_pD3DDevice->SetTextureStageState(0, D3DTSS_TEXTURETRANSFORMFLAGS, 0);
|
||||||
_pD3DDevice->SetTextureStageState( 0, D3DTSS_TEXCOORDINDEX, 0);
|
_pD3DDevice->SetTextureStageState( 0, D3DTSS_TEXCOORDINDEX, 0);
|
||||||
|
|
||||||
} else if (attrib->get_mode(TextureStage::get_default()) == TexGenAttrib::M_eye_sphere_map) {
|
} else if (attrib->get_mode(TextureStage::get_default()) == TexGenAttrib::M_eye_sphere_map) {
|
||||||
|
@ -95,6 +95,7 @@ public:
|
|||||||
const qpGeomVertexData *vertex_data);
|
const qpGeomVertexData *vertex_data);
|
||||||
virtual void draw_triangles(const qpGeomTriangles *primitive);
|
virtual void draw_triangles(const qpGeomTriangles *primitive);
|
||||||
virtual void draw_tristrips(const qpGeomTristrips *primitive);
|
virtual void draw_tristrips(const qpGeomTristrips *primitive);
|
||||||
|
virtual void draw_lines(const qpGeomLines *primitive);
|
||||||
virtual void end_draw_primitives();
|
virtual void end_draw_primitives();
|
||||||
|
|
||||||
virtual TextureContext *prepare_texture(Texture *tex);
|
virtual TextureContext *prepare_texture(Texture *tex);
|
||||||
|
@ -49,8 +49,7 @@ munge_format_impl(const qpGeomVertexFormat *orig,
|
|||||||
PT(qpGeomVertexFormat) new_format = new qpGeomVertexFormat(*orig);
|
PT(qpGeomVertexFormat) new_format = new qpGeomVertexFormat(*orig);
|
||||||
new_format->set_animation(animation);
|
new_format->set_animation(animation);
|
||||||
|
|
||||||
const qpGeomVertexColumn *color_type =
|
const qpGeomVertexColumn *color_type = orig->get_color_column();
|
||||||
orig->get_column(InternalName::get_color());
|
|
||||||
if (color_type != (qpGeomVertexColumn *)NULL &&
|
if (color_type != (qpGeomVertexColumn *)NULL &&
|
||||||
color_type->get_numeric_type() == qpGeomVertexColumn::NT_packed_dabc) {
|
color_type->get_numeric_type() == qpGeomVertexColumn::NT_packed_dabc) {
|
||||||
// We need to convert the color format; OpenGL doesn't support the
|
// We need to convert the color format; OpenGL doesn't support the
|
||||||
|
@ -417,7 +417,10 @@ write(ostream &out, int indent_level) const {
|
|||||||
for (dti = _columns.begin(); dti != _columns.end(); ++dti) {
|
for (dti = _columns.begin(); dti != _columns.end(); ++dti) {
|
||||||
const qpGeomVertexColumn *column = (*dti);
|
const qpGeomVertexColumn *column = (*dti);
|
||||||
indent(out, indent_level + 2)
|
indent(out, indent_level + 2)
|
||||||
<< *column << " start at " << column->get_start() << "\n";
|
<< *column
|
||||||
|
<< " " << column->get_numeric_type()
|
||||||
|
<< " " << column->get_contents()
|
||||||
|
<< " start at " << column->get_start() << "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,3 +68,56 @@ void qpGeomVertexColumn::
|
|||||||
output(ostream &out) const {
|
output(ostream &out) const {
|
||||||
out << *get_name() << "(" << get_num_components() << ")";
|
out << *get_name() << "(" << get_num_components() << ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ostream &
|
||||||
|
operator << (ostream &out, qpGeomVertexColumn::NumericType numeric_type) {
|
||||||
|
switch (numeric_type) {
|
||||||
|
case qpGeomVertexColumn::NT_uint8:
|
||||||
|
return out << "uint8";
|
||||||
|
|
||||||
|
case qpGeomVertexColumn::NT_uint16:
|
||||||
|
return out << "uint16";
|
||||||
|
|
||||||
|
case qpGeomVertexColumn::NT_packed_dcba:
|
||||||
|
return out << "packed_dcba";
|
||||||
|
|
||||||
|
case qpGeomVertexColumn::NT_packed_dabc:
|
||||||
|
return out << "packed_dabc";
|
||||||
|
|
||||||
|
case qpGeomVertexColumn::NT_float32:
|
||||||
|
return out << "float32";
|
||||||
|
}
|
||||||
|
|
||||||
|
return out << "**invalid numeric type (" << (int)numeric_type << ")**";
|
||||||
|
}
|
||||||
|
|
||||||
|
ostream &
|
||||||
|
operator << (ostream &out, qpGeomVertexColumn::Contents contents) {
|
||||||
|
switch (contents) {
|
||||||
|
case qpGeomVertexColumn::C_other:
|
||||||
|
return out << "other";
|
||||||
|
|
||||||
|
case qpGeomVertexColumn::C_point:
|
||||||
|
return out << "point";
|
||||||
|
|
||||||
|
case qpGeomVertexColumn::C_clip_point:
|
||||||
|
return out << "clip_point";
|
||||||
|
|
||||||
|
case qpGeomVertexColumn::C_vector:
|
||||||
|
return out << "vector";
|
||||||
|
|
||||||
|
case qpGeomVertexColumn::C_texcoord:
|
||||||
|
return out << "texcoord";
|
||||||
|
|
||||||
|
case qpGeomVertexColumn::C_color:
|
||||||
|
return out << "color";
|
||||||
|
|
||||||
|
case qpGeomVertexColumn::C_index:
|
||||||
|
return out << "index";
|
||||||
|
|
||||||
|
case qpGeomVertexColumn::C_morph_delta:
|
||||||
|
return out << "morph_delta";
|
||||||
|
}
|
||||||
|
|
||||||
|
return out << "**invalid contents (" << (int)contents << ")**";
|
||||||
|
}
|
||||||
|
@ -95,6 +95,8 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
INLINE ostream &operator << (ostream &out, const qpGeomVertexColumn &obj);
|
INLINE ostream &operator << (ostream &out, const qpGeomVertexColumn &obj);
|
||||||
|
ostream &operator << (ostream &out, qpGeomVertexColumn::NumericType numeric_type);
|
||||||
|
ostream &operator << (ostream &out, qpGeomVertexColumn::Contents contents);
|
||||||
|
|
||||||
#include "qpgeomVertexColumn.I"
|
#include "qpgeomVertexColumn.I"
|
||||||
|
|
||||||
|
@ -83,6 +83,7 @@ qpGeomVertexReader::Reader *qpGeomVertexReader::
|
|||||||
make_reader() const {
|
make_reader() const {
|
||||||
switch (_column->get_contents()) {
|
switch (_column->get_contents()) {
|
||||||
case qpGeomVertexColumn::C_point:
|
case qpGeomVertexColumn::C_point:
|
||||||
|
case qpGeomVertexColumn::C_clip_point:
|
||||||
case qpGeomVertexColumn::C_texcoord:
|
case qpGeomVertexColumn::C_texcoord:
|
||||||
// These types are read as a 4-d homogeneous point.
|
// These types are read as a 4-d homogeneous point.
|
||||||
switch (_column->get_numeric_type()) {
|
switch (_column->get_numeric_type()) {
|
||||||
|
@ -87,6 +87,7 @@ qpGeomVertexWriter::Writer *qpGeomVertexWriter::
|
|||||||
make_writer() const {
|
make_writer() const {
|
||||||
switch (_column->get_contents()) {
|
switch (_column->get_contents()) {
|
||||||
case qpGeomVertexColumn::C_point:
|
case qpGeomVertexColumn::C_point:
|
||||||
|
case qpGeomVertexColumn::C_clip_point:
|
||||||
case qpGeomVertexColumn::C_texcoord:
|
case qpGeomVertexColumn::C_texcoord:
|
||||||
// These types are written as a 4-d homogeneous point.
|
// These types are written as a 4-d homogeneous point.
|
||||||
switch (_column->get_numeric_type()) {
|
switch (_column->get_numeric_type()) {
|
||||||
|
@ -209,6 +209,8 @@ public:
|
|||||||
|
|
||||||
virtual void apply_material(const Material *material)=0;
|
virtual void apply_material(const Material *material)=0;
|
||||||
|
|
||||||
|
virtual CoordinateSystem get_internal_coordinate_system() const=0;
|
||||||
|
|
||||||
virtual void issue_transform(const TransformState *) { }
|
virtual void issue_transform(const TransformState *) { }
|
||||||
virtual void issue_alpha_test(const AlphaTestAttrib *) { }
|
virtual void issue_alpha_test(const AlphaTestAttrib *) { }
|
||||||
virtual void issue_color_scale(const ColorScaleAttrib *) { }
|
virtual void issue_color_scale(const ColorScaleAttrib *) { }
|
||||||
|
@ -215,7 +215,8 @@ munge_points_to_quads(const CullTraverser *traverser) {
|
|||||||
const Lens *lens = scene->get_lens();
|
const Lens *lens = scene->get_lens();
|
||||||
const LMatrix4f &lens_mat = lens->get_projection_mat();
|
const LMatrix4f &lens_mat = lens->get_projection_mat();
|
||||||
LMatrix4f projection =
|
LMatrix4f projection =
|
||||||
LMatrix4f::convert_mat(CS_yup_right, lens->get_coordinate_system()) *
|
LMatrix4f::convert_mat(gsg->get_internal_coordinate_system(),
|
||||||
|
lens->get_coordinate_system()) *
|
||||||
lens_mat;
|
lens_mat;
|
||||||
|
|
||||||
LMatrix4f render_transform;
|
LMatrix4f render_transform;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user