2011-02-23 10:52:22 +00:00
|
|
|
/*
|
2008-12-19 12:14:58 +00:00
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2008-12-19 12:14:58 +00:00
|
|
|
*
|
|
|
|
|
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
|
|
|
|
* All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* Contributor(s): Blender Foundation, full update, glsl support
|
|
|
|
|
*
|
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
|
*/
|
|
|
|
|
|
2011-02-27 20:29:51 +00:00
|
|
|
/** \file blender/editors/space_view3d/drawmesh.c
|
|
|
|
|
* \ingroup spview3d
|
|
|
|
|
*/
|
|
|
|
|
|
2008-12-19 12:14:58 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
#include <math.h>
|
|
|
|
|
|
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
2011-05-09 04:06:48 +00:00
|
|
|
#include "BLI_utildefines.h"
|
2008-12-19 12:14:58 +00:00
|
|
|
#include "BLI_blenlib.h"
|
2009-11-10 20:43:45 +00:00
|
|
|
#include "BLI_math.h"
|
2008-12-19 12:14:58 +00:00
|
|
|
#include "BLI_edgehash.h"
|
2011-01-07 18:36:47 +00:00
|
|
|
#include "BLI_utildefines.h"
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
#include "DNA_material_types.h"
|
2012-02-19 22:17:30 +00:00
|
|
|
#include "DNA_mesh_types.h"
|
2008-12-19 12:14:58 +00:00
|
|
|
#include "DNA_meshdata_types.h"
|
2011-11-08 13:07:16 +00:00
|
|
|
#include "DNA_node_types.h"
|
|
|
|
|
#include "DNA_object_types.h"
|
2008-12-19 12:14:58 +00:00
|
|
|
#include "DNA_property_types.h"
|
|
|
|
|
#include "DNA_scene_types.h"
|
|
|
|
|
#include "DNA_screen_types.h"
|
|
|
|
|
#include "DNA_view3d_types.h"
|
2010-03-11 18:27:45 +00:00
|
|
|
#include "DNA_windowmanager_types.h"
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
#include "BKE_DerivedMesh.h"
|
|
|
|
|
#include "BKE_effect.h"
|
|
|
|
|
#include "BKE_image.h"
|
|
|
|
|
#include "BKE_material.h"
|
2009-08-15 19:48:50 +00:00
|
|
|
#include "BKE_paint.h"
|
2008-12-19 12:14:58 +00:00
|
|
|
#include "BKE_property.h"
|
2009-07-24 10:43:58 +00:00
|
|
|
#include "BKE_tessmesh.h"
|
2011-11-08 13:07:16 +00:00
|
|
|
#include "BKE_scene.h"
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
#include "BIF_gl.h"
|
|
|
|
|
#include "BIF_glutil.h"
|
|
|
|
|
|
|
|
|
|
#include "UI_resources.h"
|
|
|
|
|
|
2010-07-14 10:46:12 +00:00
|
|
|
#include "GPU_buffers.h"
|
2008-12-19 12:14:58 +00:00
|
|
|
#include "GPU_extensions.h"
|
|
|
|
|
#include "GPU_draw.h"
|
TexFace to Material Settings big patch
Summary:
========
The idea here is to move the texface options into the material panel.
For images with the change please visit:
http://code.blender.org/index.php/2011/09/bge-material-texface-changes
1 - Some of the legacy problems 2.49 and 2.5x has with the texface system:
==========================================================================
1.1) Shadow, Bilboard and Halo are mutual exclusive (in the code), yet you can
select a face to be more than one mode.
1.2) Sort only works for blend Alpha yet it's an option regardless of the
Transparency Blend you pick.
1.3) Shared doesn't affect anything in BGE.
1.4) ObColor only works for Text objects (old bitmap texts) when using Texture
Face Materials. (not address yet, I so far ignored obcolor)
2 - Notes:
============
2.1) Now "Use Face Textures" in material Option panel will work in Multitexture
even if there is no texture channel.
2.2) In FaceTexture mode it will use TexFace all the time, even if you don't
check the "Use Texture Face" option in the UI. It's a matter of decision, since
the code for either way is there. I decided by the solution that makes the
creation of a material fast - in this mode the user doesn't need to mess with
textures or this "Use Texture Face" option at all. I'm not strong in my opinion
here. But I think if we don't have this then what is the point of the Texture
Face mode?
2.3) I kept references for tface only when we need the image, UV or the tiling
setting. It should help later when/if we split the Image and UV layers from the
tface struct (Campbell and Brecht proposal).
3 - Changes in a Nutshell:
==========================
3.1) "Texture Face" panel (in the Mesh/Object Data panel) no longer exists. Those settings are all part of the material properties, visible when Game Render is set.
3.2) "Texture Face" Shading mode (in the Render panel) is now called “Single Texture”, it needs a material for special settings (e.g. Billboard, Alpha Sort, …).
3.3) New options in the Material Panel
* Shadeless option in the Material panel is now supported for all three Shading modes.
* Physics is now toggleable, this is the old Collision option.
* Two Side (on) is now called Back Culling (off).
* Alpha Sort is one of the Alpha options, together (and mutually exclusive) to Alpha Blend, Alpha Clip, Add and Opaque (i.e. solid).
* Shadow, Billboard and Halo are grouped in the “Face Orientation” property.
* "Face Textures" and "Face Textures Alpha" (under Options) can be used for all but GLSL shading mode (to be supported in GLSL eventually).
* The backend in the game engine is still the same as before. The only changes are in the interface and in the way you need to think your materials. The bottomline is: It’s no longer possible to share materials between faces that do not share the same game properties.
4 - Acknowledgment:
==================
Mike Pan for the design discussions, and testing along the whole development process.
Vitor Balbio for the first hands-on code with the interface changes. That helped me a lot to push me into work on that.
Benoit Bolsee and Brecht van Lommel for patch review (* no one reviewed the whole patch, or the latest iteractions, so I still hold liability for any problems).
Blender artists that gave feedback and helped testing the patch.
Patch review and original documentation can be found here:
http://wiki.blender.org/index.php/User:Dfelinto/TexFace
http://codereview.appspot.com/4289041/
2011-09-19 19:55:59 +00:00
|
|
|
#include "GPU_material.h"
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2008-12-30 13:16:14 +00:00
|
|
|
#include "ED_mesh.h"
|
2011-11-08 13:07:16 +00:00
|
|
|
#include "ED_uvedit.h"
|
2008-12-30 13:16:14 +00:00
|
|
|
|
2008-12-19 12:14:58 +00:00
|
|
|
#include "view3d_intern.h" // own include
|
|
|
|
|
|
2011-12-20 08:47:36 +00:00
|
|
|
/* user data structures for derived mesh callbacks */
|
|
|
|
|
typedef struct drawMeshFaceSelect_userData {
|
|
|
|
|
Mesh *me;
|
|
|
|
|
EdgeHash *eh;
|
|
|
|
|
} drawMeshFaceSelect_userData;
|
|
|
|
|
|
|
|
|
|
typedef struct drawEMTFMapped_userData {
|
2011-12-20 10:59:56 +00:00
|
|
|
BMEditMesh *em;
|
2011-12-20 08:47:36 +00:00
|
|
|
short has_mcol;
|
|
|
|
|
short has_mtface;
|
|
|
|
|
MFace *mf;
|
|
|
|
|
MTFace *tf;
|
|
|
|
|
} drawEMTFMapped_userData;
|
|
|
|
|
|
|
|
|
|
typedef struct drawTFace_userData {
|
|
|
|
|
MFace *mf;
|
|
|
|
|
MTFace *tf;
|
|
|
|
|
} drawTFace_userData;
|
|
|
|
|
|
2011-08-12 18:13:55 +00:00
|
|
|
/**************************** Face Select Mode *******************************/
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2011-08-12 18:13:55 +00:00
|
|
|
/* Flags for marked edges */
|
2008-12-19 12:14:58 +00:00
|
|
|
enum {
|
|
|
|
|
eEdge_Visible = (1<<0),
|
|
|
|
|
eEdge_Select = (1<<1),
|
|
|
|
|
};
|
|
|
|
|
|
2011-08-12 18:13:55 +00:00
|
|
|
/* Creates a hash of edges to flags indicating selected/visible */
|
2008-12-19 12:14:58 +00:00
|
|
|
static void get_marked_edge_info__orFlags(EdgeHash *eh, int v0, int v1, int flags)
|
|
|
|
|
{
|
|
|
|
|
int *flags_p;
|
|
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (!BLI_edgehash_haskey(eh, v0, v1))
|
2011-03-03 17:59:04 +00:00
|
|
|
BLI_edgehash_insert(eh, v0, v1, NULL);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
flags_p = (int*) BLI_edgehash_lookup_p(eh, v0, v1);
|
|
|
|
|
*flags_p |= flags;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static EdgeHash *get_tface_mesh_marked_edge_info(Mesh *me)
|
|
|
|
|
{
|
|
|
|
|
EdgeHash *eh = BLI_edgehash_new();
|
2012-02-05 03:25:13 +00:00
|
|
|
MPoly *mp;
|
|
|
|
|
MLoop *ml;
|
|
|
|
|
MLoop *ml_next;
|
|
|
|
|
int i, j;
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
for (i=0; i<me->totpoly; i++) {
|
2012-02-05 03:25:13 +00:00
|
|
|
mp = &me->mpoly[i];
|
2011-01-12 03:41:12 +00:00
|
|
|
|
2012-02-05 03:25:13 +00:00
|
|
|
if (!(mp->flag & ME_HIDE)) {
|
2011-08-12 18:13:55 +00:00
|
|
|
unsigned int flags = eEdge_Visible;
|
2012-02-05 03:25:13 +00:00
|
|
|
if (mp->flag & ME_FACE_SEL) flags |= eEdge_Select;
|
2011-08-12 18:13:55 +00:00
|
|
|
|
2012-02-05 03:25:13 +00:00
|
|
|
ml = me->mloop + mp->loopstart;
|
|
|
|
|
for (j=0; j<mp->totloop; j++, ml++) {
|
|
|
|
|
ml_next = ME_POLY_LOOP_NEXT(me->mloop, mp, j);
|
|
|
|
|
get_marked_edge_info__orFlags(eh, ml->v, ml_next->v, flags);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return eh;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-08-12 18:13:55 +00:00
|
|
|
static int draw_mesh_face_select__setHiddenOpts(void *userData, int index)
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
2011-12-20 08:47:36 +00:00
|
|
|
drawMeshFaceSelect_userData *data = userData;
|
2009-01-31 13:30:56 +00:00
|
|
|
Mesh *me= data->me;
|
|
|
|
|
MEdge *med = &me->medge[index];
|
2008-12-19 12:14:58 +00:00
|
|
|
uintptr_t flags = (intptr_t) BLI_edgehash_lookup(data->eh, med->v1, med->v2);
|
|
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (me->drawflag & ME_DRAWEDGES) {
|
|
|
|
|
if (me->drawflag & ME_HIDDENEDGES)
|
2008-12-19 12:14:58 +00:00
|
|
|
return 1;
|
2011-08-12 18:13:55 +00:00
|
|
|
else
|
2008-12-19 12:14:58 +00:00
|
|
|
return (flags & eEdge_Visible);
|
|
|
|
|
}
|
2011-08-12 18:13:55 +00:00
|
|
|
else
|
|
|
|
|
return (flags & eEdge_Select);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
2.5
View3D has been split now in a local part (RegionView3D) and a
per-area part (old View3D). Currently local is:
- view transform
- camera zoom/offset
- gpencil (todo)
- custom clipping planes
Rest is in Area still, like active camera, draw type, layers,
localview, custom centers, around-settings, transform widget,
gridlines, and so on (mostly stuff as available in header).
To see it work; also added new feature for region split,
press SHIFT+ALT+CTRL+S for four-split.
The idea is to make a preset 4-split, configured to stick
to top/right/front views for three views.
Another cool idea to explore is to then box-clip all drawing
based on these 3 views.
Note about the code:
- currently view3d still stores some depricated settings, to
convert from older files. Not all settings are copied over
though, like custom clip planes or the 'lock view to object'.
- since some view3d ops are now on area level, the operators
for it should keep track of that.
Bugfix in transform: quat initialize in operator-invoke missed
one zero.
Als brought back GE to compile for missing Ipos and channels.
2009-01-19 16:54:41 +00:00
|
|
|
|
2011-08-12 18:13:55 +00:00
|
|
|
static int draw_mesh_face_select__setSelectOpts(void *userData, int index)
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
2011-12-20 08:47:36 +00:00
|
|
|
drawMeshFaceSelect_userData *data = userData;
|
2008-12-19 12:14:58 +00:00
|
|
|
MEdge *med = &data->me->medge[index];
|
|
|
|
|
uintptr_t flags = (intptr_t) BLI_edgehash_lookup(data->eh, med->v1, med->v2);
|
|
|
|
|
|
|
|
|
|
return flags & eEdge_Select;
|
|
|
|
|
}
|
2.5
View3D has been split now in a local part (RegionView3D) and a
per-area part (old View3D). Currently local is:
- view transform
- camera zoom/offset
- gpencil (todo)
- custom clipping planes
Rest is in Area still, like active camera, draw type, layers,
localview, custom centers, around-settings, transform widget,
gridlines, and so on (mostly stuff as available in header).
To see it work; also added new feature for region split,
press SHIFT+ALT+CTRL+S for four-split.
The idea is to make a preset 4-split, configured to stick
to top/right/front views for three views.
Another cool idea to explore is to then box-clip all drawing
based on these 3 views.
Note about the code:
- currently view3d still stores some depricated settings, to
convert from older files. Not all settings are copied over
though, like custom clip planes or the 'lock view to object'.
- since some view3d ops are now on area level, the operators
for it should keep track of that.
Bugfix in transform: quat initialize in operator-invoke missed
one zero.
Als brought back GE to compile for missing Ipos and channels.
2009-01-19 16:54:41 +00:00
|
|
|
|
2010-10-19 15:35:46 +00:00
|
|
|
/* draws unselected */
|
2011-08-12 18:13:55 +00:00
|
|
|
static int draw_mesh_face_select__drawFaceOptsInv(void *userData, int index)
|
2010-10-19 15:35:46 +00:00
|
|
|
{
|
|
|
|
|
Mesh *me = (Mesh*)userData;
|
|
|
|
|
|
2011-11-23 18:53:49 +00:00
|
|
|
MPoly *mface = &me->mpoly[index];
|
2012-02-22 16:52:06 +00:00
|
|
|
if (!(mface->flag&ME_HIDE) && !(mface->flag&ME_FACE_SEL))
|
2010-10-19 15:35:46 +00:00
|
|
|
return 2; /* Don't set color */
|
|
|
|
|
else
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2.5
View3D has been split now in a local part (RegionView3D) and a
per-area part (old View3D). Currently local is:
- view transform
- camera zoom/offset
- gpencil (todo)
- custom clipping planes
Rest is in Area still, like active camera, draw type, layers,
localview, custom centers, around-settings, transform widget,
gridlines, and so on (mostly stuff as available in header).
To see it work; also added new feature for region split,
press SHIFT+ALT+CTRL+S for four-split.
The idea is to make a preset 4-split, configured to stick
to top/right/front views for three views.
Another cool idea to explore is to then box-clip all drawing
based on these 3 views.
Note about the code:
- currently view3d still stores some depricated settings, to
convert from older files. Not all settings are copied over
though, like custom clip planes or the 'lock view to object'.
- since some view3d ops are now on area level, the operators
for it should keep track of that.
Bugfix in transform: quat initialize in operator-invoke missed
one zero.
Als brought back GE to compile for missing Ipos and channels.
2009-01-19 16:54:41 +00:00
|
|
|
|
2011-08-12 18:13:55 +00:00
|
|
|
static void draw_mesh_face_select(RegionView3D *rv3d, Mesh *me, DerivedMesh *dm)
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
2011-12-20 08:47:36 +00:00
|
|
|
drawMeshFaceSelect_userData data;
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
data.me = me;
|
|
|
|
|
data.eh = get_tface_mesh_marked_edge_info(me);
|
|
|
|
|
|
|
|
|
|
glEnable(GL_DEPTH_TEST);
|
|
|
|
|
glDisable(GL_LIGHTING);
|
2.5
View3D has been split now in a local part (RegionView3D) and a
per-area part (old View3D). Currently local is:
- view transform
- camera zoom/offset
- gpencil (todo)
- custom clipping planes
Rest is in Area still, like active camera, draw type, layers,
localview, custom centers, around-settings, transform widget,
gridlines, and so on (mostly stuff as available in header).
To see it work; also added new feature for region split,
press SHIFT+ALT+CTRL+S for four-split.
The idea is to make a preset 4-split, configured to stick
to top/right/front views for three views.
Another cool idea to explore is to then box-clip all drawing
based on these 3 views.
Note about the code:
- currently view3d still stores some depricated settings, to
convert from older files. Not all settings are copied over
though, like custom clip planes or the 'lock view to object'.
- since some view3d ops are now on area level, the operators
for it should keep track of that.
Bugfix in transform: quat initialize in operator-invoke missed
one zero.
Als brought back GE to compile for missing Ipos and channels.
2009-01-19 16:54:41 +00:00
|
|
|
bglPolygonOffset(rv3d->dist, 1.0);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2010-10-19 15:35:46 +00:00
|
|
|
/* Draw (Hidden) Edges */
|
|
|
|
|
setlinestyle(1);
|
2008-12-19 12:14:58 +00:00
|
|
|
UI_ThemeColor(TH_EDGE_FACESEL);
|
2011-08-12 18:13:55 +00:00
|
|
|
dm->drawMappedEdges(dm, draw_mesh_face_select__setHiddenOpts, &data);
|
2010-10-19 15:35:46 +00:00
|
|
|
setlinestyle(0);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
/* Draw Selected Faces */
|
2012-02-22 16:52:06 +00:00
|
|
|
if (me->drawflag & ME_DRAWFACES) {
|
2008-12-19 12:14:58 +00:00
|
|
|
glEnable(GL_BLEND);
|
|
|
|
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
2010-10-19 15:35:46 +00:00
|
|
|
/* dull unselected faces so as not to get in the way of seeing color */
|
|
|
|
|
glColor4ub(96, 96, 96, 64);
|
2011-12-01 12:12:39 +00:00
|
|
|
dm->drawMappedFacesTex(dm, draw_mesh_face_select__drawFaceOptsInv, NULL, (void*)me);
|
2010-10-19 15:35:46 +00:00
|
|
|
|
2008-12-19 12:14:58 +00:00
|
|
|
glDisable(GL_BLEND);
|
|
|
|
|
}
|
|
|
|
|
|
2.5
View3D has been split now in a local part (RegionView3D) and a
per-area part (old View3D). Currently local is:
- view transform
- camera zoom/offset
- gpencil (todo)
- custom clipping planes
Rest is in Area still, like active camera, draw type, layers,
localview, custom centers, around-settings, transform widget,
gridlines, and so on (mostly stuff as available in header).
To see it work; also added new feature for region split,
press SHIFT+ALT+CTRL+S for four-split.
The idea is to make a preset 4-split, configured to stick
to top/right/front views for three views.
Another cool idea to explore is to then box-clip all drawing
based on these 3 views.
Note about the code:
- currently view3d still stores some depricated settings, to
convert from older files. Not all settings are copied over
though, like custom clip planes or the 'lock view to object'.
- since some view3d ops are now on area level, the operators
for it should keep track of that.
Bugfix in transform: quat initialize in operator-invoke missed
one zero.
Als brought back GE to compile for missing Ipos and channels.
2009-01-19 16:54:41 +00:00
|
|
|
bglPolygonOffset(rv3d->dist, 1.0);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
/* Draw Stippled Outline for selected faces */
|
|
|
|
|
glColor3ub(255, 255, 255);
|
|
|
|
|
setlinestyle(1);
|
2011-08-12 18:13:55 +00:00
|
|
|
dm->drawMappedEdges(dm, draw_mesh_face_select__setSelectOpts, &data);
|
2008-12-19 12:14:58 +00:00
|
|
|
setlinestyle(0);
|
|
|
|
|
|
2.5
View3D has been split now in a local part (RegionView3D) and a
per-area part (old View3D). Currently local is:
- view transform
- camera zoom/offset
- gpencil (todo)
- custom clipping planes
Rest is in Area still, like active camera, draw type, layers,
localview, custom centers, around-settings, transform widget,
gridlines, and so on (mostly stuff as available in header).
To see it work; also added new feature for region split,
press SHIFT+ALT+CTRL+S for four-split.
The idea is to make a preset 4-split, configured to stick
to top/right/front views for three views.
Another cool idea to explore is to then box-clip all drawing
based on these 3 views.
Note about the code:
- currently view3d still stores some depricated settings, to
convert from older files. Not all settings are copied over
though, like custom clip planes or the 'lock view to object'.
- since some view3d ops are now on area level, the operators
for it should keep track of that.
Bugfix in transform: quat initialize in operator-invoke missed
one zero.
Als brought back GE to compile for missing Ipos and channels.
2009-01-19 16:54:41 +00:00
|
|
|
bglPolygonOffset(rv3d->dist, 0.0); // resets correctly now, even after calling accumulated offsets
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
BLI_edgehash_free(data.eh, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
2011-08-12 18:13:55 +00:00
|
|
|
/***************************** Texture Drawing ******************************/
|
|
|
|
|
|
2008-12-19 12:14:58 +00:00
|
|
|
static Material *give_current_material_or_def(Object *ob, int matnr)
|
|
|
|
|
{
|
|
|
|
|
extern Material defmaterial; // render module abuse...
|
|
|
|
|
Material *ma= give_current_material(ob, matnr);
|
|
|
|
|
|
|
|
|
|
return ma?ma:&defmaterial;
|
|
|
|
|
}
|
|
|
|
|
|
TexFace to Material Settings big patch
Summary:
========
The idea here is to move the texface options into the material panel.
For images with the change please visit:
http://code.blender.org/index.php/2011/09/bge-material-texface-changes
1 - Some of the legacy problems 2.49 and 2.5x has with the texface system:
==========================================================================
1.1) Shadow, Bilboard and Halo are mutual exclusive (in the code), yet you can
select a face to be more than one mode.
1.2) Sort only works for blend Alpha yet it's an option regardless of the
Transparency Blend you pick.
1.3) Shared doesn't affect anything in BGE.
1.4) ObColor only works for Text objects (old bitmap texts) when using Texture
Face Materials. (not address yet, I so far ignored obcolor)
2 - Notes:
============
2.1) Now "Use Face Textures" in material Option panel will work in Multitexture
even if there is no texture channel.
2.2) In FaceTexture mode it will use TexFace all the time, even if you don't
check the "Use Texture Face" option in the UI. It's a matter of decision, since
the code for either way is there. I decided by the solution that makes the
creation of a material fast - in this mode the user doesn't need to mess with
textures or this "Use Texture Face" option at all. I'm not strong in my opinion
here. But I think if we don't have this then what is the point of the Texture
Face mode?
2.3) I kept references for tface only when we need the image, UV or the tiling
setting. It should help later when/if we split the Image and UV layers from the
tface struct (Campbell and Brecht proposal).
3 - Changes in a Nutshell:
==========================
3.1) "Texture Face" panel (in the Mesh/Object Data panel) no longer exists. Those settings are all part of the material properties, visible when Game Render is set.
3.2) "Texture Face" Shading mode (in the Render panel) is now called “Single Texture”, it needs a material for special settings (e.g. Billboard, Alpha Sort, …).
3.3) New options in the Material Panel
* Shadeless option in the Material panel is now supported for all three Shading modes.
* Physics is now toggleable, this is the old Collision option.
* Two Side (on) is now called Back Culling (off).
* Alpha Sort is one of the Alpha options, together (and mutually exclusive) to Alpha Blend, Alpha Clip, Add and Opaque (i.e. solid).
* Shadow, Billboard and Halo are grouped in the “Face Orientation” property.
* "Face Textures" and "Face Textures Alpha" (under Options) can be used for all but GLSL shading mode (to be supported in GLSL eventually).
* The backend in the game engine is still the same as before. The only changes are in the interface and in the way you need to think your materials. The bottomline is: It’s no longer possible to share materials between faces that do not share the same game properties.
4 - Acknowledgment:
==================
Mike Pan for the design discussions, and testing along the whole development process.
Vitor Balbio for the first hands-on code with the interface changes. That helped me a lot to push me into work on that.
Benoit Bolsee and Brecht van Lommel for patch review (* no one reviewed the whole patch, or the latest iteractions, so I still hold liability for any problems).
Blender artists that gave feedback and helped testing the patch.
Patch review and original documentation can be found here:
http://wiki.blender.org/index.php/User:Dfelinto/TexFace
http://codereview.appspot.com/4289041/
2011-09-19 19:55:59 +00:00
|
|
|
/* Icky globals, fix with userdata parameter */
|
|
|
|
|
|
|
|
|
|
static struct TextureDrawState {
|
|
|
|
|
Object *ob;
|
|
|
|
|
int islit, istex;
|
|
|
|
|
int color_profile;
|
|
|
|
|
unsigned char obcol[4];
|
|
|
|
|
} Gtexdraw = {NULL, 0, 0, 0, {0, 0, 0, 0}};
|
|
|
|
|
|
|
|
|
|
static int set_draw_settings_cached(int clearcache, MTFace *texface, Material *ma, struct TextureDrawState gtexdraw)
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
TexFace to Material Settings big patch
Summary:
========
The idea here is to move the texface options into the material panel.
For images with the change please visit:
http://code.blender.org/index.php/2011/09/bge-material-texface-changes
1 - Some of the legacy problems 2.49 and 2.5x has with the texface system:
==========================================================================
1.1) Shadow, Bilboard and Halo are mutual exclusive (in the code), yet you can
select a face to be more than one mode.
1.2) Sort only works for blend Alpha yet it's an option regardless of the
Transparency Blend you pick.
1.3) Shared doesn't affect anything in BGE.
1.4) ObColor only works for Text objects (old bitmap texts) when using Texture
Face Materials. (not address yet, I so far ignored obcolor)
2 - Notes:
============
2.1) Now "Use Face Textures" in material Option panel will work in Multitexture
even if there is no texture channel.
2.2) In FaceTexture mode it will use TexFace all the time, even if you don't
check the "Use Texture Face" option in the UI. It's a matter of decision, since
the code for either way is there. I decided by the solution that makes the
creation of a material fast - in this mode the user doesn't need to mess with
textures or this "Use Texture Face" option at all. I'm not strong in my opinion
here. But I think if we don't have this then what is the point of the Texture
Face mode?
2.3) I kept references for tface only when we need the image, UV or the tiling
setting. It should help later when/if we split the Image and UV layers from the
tface struct (Campbell and Brecht proposal).
3 - Changes in a Nutshell:
==========================
3.1) "Texture Face" panel (in the Mesh/Object Data panel) no longer exists. Those settings are all part of the material properties, visible when Game Render is set.
3.2) "Texture Face" Shading mode (in the Render panel) is now called “Single Texture”, it needs a material for special settings (e.g. Billboard, Alpha Sort, …).
3.3) New options in the Material Panel
* Shadeless option in the Material panel is now supported for all three Shading modes.
* Physics is now toggleable, this is the old Collision option.
* Two Side (on) is now called Back Culling (off).
* Alpha Sort is one of the Alpha options, together (and mutually exclusive) to Alpha Blend, Alpha Clip, Add and Opaque (i.e. solid).
* Shadow, Billboard and Halo are grouped in the “Face Orientation” property.
* "Face Textures" and "Face Textures Alpha" (under Options) can be used for all but GLSL shading mode (to be supported in GLSL eventually).
* The backend in the game engine is still the same as before. The only changes are in the interface and in the way you need to think your materials. The bottomline is: It’s no longer possible to share materials between faces that do not share the same game properties.
4 - Acknowledgment:
==================
Mike Pan for the design discussions, and testing along the whole development process.
Vitor Balbio for the first hands-on code with the interface changes. That helped me a lot to push me into work on that.
Benoit Bolsee and Brecht van Lommel for patch review (* no one reviewed the whole patch, or the latest iteractions, so I still hold liability for any problems).
Blender artists that gave feedback and helped testing the patch.
Patch review and original documentation can be found here:
http://wiki.blender.org/index.php/User:Dfelinto/TexFace
http://codereview.appspot.com/4289041/
2011-09-19 19:55:59 +00:00
|
|
|
static Material *c_ma;
|
2008-12-19 12:14:58 +00:00
|
|
|
static int c_textured;
|
|
|
|
|
static MTFace *c_texface;
|
TexFace to Material Settings big patch
Summary:
========
The idea here is to move the texface options into the material panel.
For images with the change please visit:
http://code.blender.org/index.php/2011/09/bge-material-texface-changes
1 - Some of the legacy problems 2.49 and 2.5x has with the texface system:
==========================================================================
1.1) Shadow, Bilboard and Halo are mutual exclusive (in the code), yet you can
select a face to be more than one mode.
1.2) Sort only works for blend Alpha yet it's an option regardless of the
Transparency Blend you pick.
1.3) Shared doesn't affect anything in BGE.
1.4) ObColor only works for Text objects (old bitmap texts) when using Texture
Face Materials. (not address yet, I so far ignored obcolor)
2 - Notes:
============
2.1) Now "Use Face Textures" in material Option panel will work in Multitexture
even if there is no texture channel.
2.2) In FaceTexture mode it will use TexFace all the time, even if you don't
check the "Use Texture Face" option in the UI. It's a matter of decision, since
the code for either way is there. I decided by the solution that makes the
creation of a material fast - in this mode the user doesn't need to mess with
textures or this "Use Texture Face" option at all. I'm not strong in my opinion
here. But I think if we don't have this then what is the point of the Texture
Face mode?
2.3) I kept references for tface only when we need the image, UV or the tiling
setting. It should help later when/if we split the Image and UV layers from the
tface struct (Campbell and Brecht proposal).
3 - Changes in a Nutshell:
==========================
3.1) "Texture Face" panel (in the Mesh/Object Data panel) no longer exists. Those settings are all part of the material properties, visible when Game Render is set.
3.2) "Texture Face" Shading mode (in the Render panel) is now called “Single Texture”, it needs a material for special settings (e.g. Billboard, Alpha Sort, …).
3.3) New options in the Material Panel
* Shadeless option in the Material panel is now supported for all three Shading modes.
* Physics is now toggleable, this is the old Collision option.
* Two Side (on) is now called Back Culling (off).
* Alpha Sort is one of the Alpha options, together (and mutually exclusive) to Alpha Blend, Alpha Clip, Add and Opaque (i.e. solid).
* Shadow, Billboard and Halo are grouped in the “Face Orientation” property.
* "Face Textures" and "Face Textures Alpha" (under Options) can be used for all but GLSL shading mode (to be supported in GLSL eventually).
* The backend in the game engine is still the same as before. The only changes are in the interface and in the way you need to think your materials. The bottomline is: It’s no longer possible to share materials between faces that do not share the same game properties.
4 - Acknowledgment:
==================
Mike Pan for the design discussions, and testing along the whole development process.
Vitor Balbio for the first hands-on code with the interface changes. That helped me a lot to push me into work on that.
Benoit Bolsee and Brecht van Lommel for patch review (* no one reviewed the whole patch, or the latest iteractions, so I still hold liability for any problems).
Blender artists that gave feedback and helped testing the patch.
Patch review and original documentation can be found here:
http://wiki.blender.org/index.php/User:Dfelinto/TexFace
http://codereview.appspot.com/4289041/
2011-09-19 19:55:59 +00:00
|
|
|
static int c_backculled;
|
2008-12-19 12:14:58 +00:00
|
|
|
static int c_badtex;
|
TexFace to Material Settings big patch
Summary:
========
The idea here is to move the texface options into the material panel.
For images with the change please visit:
http://code.blender.org/index.php/2011/09/bge-material-texface-changes
1 - Some of the legacy problems 2.49 and 2.5x has with the texface system:
==========================================================================
1.1) Shadow, Bilboard and Halo are mutual exclusive (in the code), yet you can
select a face to be more than one mode.
1.2) Sort only works for blend Alpha yet it's an option regardless of the
Transparency Blend you pick.
1.3) Shared doesn't affect anything in BGE.
1.4) ObColor only works for Text objects (old bitmap texts) when using Texture
Face Materials. (not address yet, I so far ignored obcolor)
2 - Notes:
============
2.1) Now "Use Face Textures" in material Option panel will work in Multitexture
even if there is no texture channel.
2.2) In FaceTexture mode it will use TexFace all the time, even if you don't
check the "Use Texture Face" option in the UI. It's a matter of decision, since
the code for either way is there. I decided by the solution that makes the
creation of a material fast - in this mode the user doesn't need to mess with
textures or this "Use Texture Face" option at all. I'm not strong in my opinion
here. But I think if we don't have this then what is the point of the Texture
Face mode?
2.3) I kept references for tface only when we need the image, UV or the tiling
setting. It should help later when/if we split the Image and UV layers from the
tface struct (Campbell and Brecht proposal).
3 - Changes in a Nutshell:
==========================
3.1) "Texture Face" panel (in the Mesh/Object Data panel) no longer exists. Those settings are all part of the material properties, visible when Game Render is set.
3.2) "Texture Face" Shading mode (in the Render panel) is now called “Single Texture”, it needs a material for special settings (e.g. Billboard, Alpha Sort, …).
3.3) New options in the Material Panel
* Shadeless option in the Material panel is now supported for all three Shading modes.
* Physics is now toggleable, this is the old Collision option.
* Two Side (on) is now called Back Culling (off).
* Alpha Sort is one of the Alpha options, together (and mutually exclusive) to Alpha Blend, Alpha Clip, Add and Opaque (i.e. solid).
* Shadow, Billboard and Halo are grouped in the “Face Orientation” property.
* "Face Textures" and "Face Textures Alpha" (under Options) can be used for all but GLSL shading mode (to be supported in GLSL eventually).
* The backend in the game engine is still the same as before. The only changes are in the interface and in the way you need to think your materials. The bottomline is: It’s no longer possible to share materials between faces that do not share the same game properties.
4 - Acknowledgment:
==================
Mike Pan for the design discussions, and testing along the whole development process.
Vitor Balbio for the first hands-on code with the interface changes. That helped me a lot to push me into work on that.
Benoit Bolsee and Brecht van Lommel for patch review (* no one reviewed the whole patch, or the latest iteractions, so I still hold liability for any problems).
Blender artists that gave feedback and helped testing the patch.
Patch review and original documentation can be found here:
http://wiki.blender.org/index.php/User:Dfelinto/TexFace
http://codereview.appspot.com/4289041/
2011-09-19 19:55:59 +00:00
|
|
|
static int c_lit;
|
2008-12-19 12:14:58 +00:00
|
|
|
|
TexFace to Material Settings big patch
Summary:
========
The idea here is to move the texface options into the material panel.
For images with the change please visit:
http://code.blender.org/index.php/2011/09/bge-material-texface-changes
1 - Some of the legacy problems 2.49 and 2.5x has with the texface system:
==========================================================================
1.1) Shadow, Bilboard and Halo are mutual exclusive (in the code), yet you can
select a face to be more than one mode.
1.2) Sort only works for blend Alpha yet it's an option regardless of the
Transparency Blend you pick.
1.3) Shared doesn't affect anything in BGE.
1.4) ObColor only works for Text objects (old bitmap texts) when using Texture
Face Materials. (not address yet, I so far ignored obcolor)
2 - Notes:
============
2.1) Now "Use Face Textures" in material Option panel will work in Multitexture
even if there is no texture channel.
2.2) In FaceTexture mode it will use TexFace all the time, even if you don't
check the "Use Texture Face" option in the UI. It's a matter of decision, since
the code for either way is there. I decided by the solution that makes the
creation of a material fast - in this mode the user doesn't need to mess with
textures or this "Use Texture Face" option at all. I'm not strong in my opinion
here. But I think if we don't have this then what is the point of the Texture
Face mode?
2.3) I kept references for tface only when we need the image, UV or the tiling
setting. It should help later when/if we split the Image and UV layers from the
tface struct (Campbell and Brecht proposal).
3 - Changes in a Nutshell:
==========================
3.1) "Texture Face" panel (in the Mesh/Object Data panel) no longer exists. Those settings are all part of the material properties, visible when Game Render is set.
3.2) "Texture Face" Shading mode (in the Render panel) is now called “Single Texture”, it needs a material for special settings (e.g. Billboard, Alpha Sort, …).
3.3) New options in the Material Panel
* Shadeless option in the Material panel is now supported for all three Shading modes.
* Physics is now toggleable, this is the old Collision option.
* Two Side (on) is now called Back Culling (off).
* Alpha Sort is one of the Alpha options, together (and mutually exclusive) to Alpha Blend, Alpha Clip, Add and Opaque (i.e. solid).
* Shadow, Billboard and Halo are grouped in the “Face Orientation” property.
* "Face Textures" and "Face Textures Alpha" (under Options) can be used for all but GLSL shading mode (to be supported in GLSL eventually).
* The backend in the game engine is still the same as before. The only changes are in the interface and in the way you need to think your materials. The bottomline is: It’s no longer possible to share materials between faces that do not share the same game properties.
4 - Acknowledgment:
==================
Mike Pan for the design discussions, and testing along the whole development process.
Vitor Balbio for the first hands-on code with the interface changes. That helped me a lot to push me into work on that.
Benoit Bolsee and Brecht van Lommel for patch review (* no one reviewed the whole patch, or the latest iteractions, so I still hold liability for any problems).
Blender artists that gave feedback and helped testing the patch.
Patch review and original documentation can be found here:
http://wiki.blender.org/index.php/User:Dfelinto/TexFace
http://codereview.appspot.com/4289041/
2011-09-19 19:55:59 +00:00
|
|
|
Object *litob = NULL; //to get mode to turn off mipmap in painting mode
|
2011-10-23 17:52:20 +00:00
|
|
|
int backculled = GEMAT_BACKCULL;
|
TexFace to Material Settings big patch
Summary:
========
The idea here is to move the texface options into the material panel.
For images with the change please visit:
http://code.blender.org/index.php/2011/09/bge-material-texface-changes
1 - Some of the legacy problems 2.49 and 2.5x has with the texface system:
==========================================================================
1.1) Shadow, Bilboard and Halo are mutual exclusive (in the code), yet you can
select a face to be more than one mode.
1.2) Sort only works for blend Alpha yet it's an option regardless of the
Transparency Blend you pick.
1.3) Shared doesn't affect anything in BGE.
1.4) ObColor only works for Text objects (old bitmap texts) when using Texture
Face Materials. (not address yet, I so far ignored obcolor)
2 - Notes:
============
2.1) Now "Use Face Textures" in material Option panel will work in Multitexture
even if there is no texture channel.
2.2) In FaceTexture mode it will use TexFace all the time, even if you don't
check the "Use Texture Face" option in the UI. It's a matter of decision, since
the code for either way is there. I decided by the solution that makes the
creation of a material fast - in this mode the user doesn't need to mess with
textures or this "Use Texture Face" option at all. I'm not strong in my opinion
here. But I think if we don't have this then what is the point of the Texture
Face mode?
2.3) I kept references for tface only when we need the image, UV or the tiling
setting. It should help later when/if we split the Image and UV layers from the
tface struct (Campbell and Brecht proposal).
3 - Changes in a Nutshell:
==========================
3.1) "Texture Face" panel (in the Mesh/Object Data panel) no longer exists. Those settings are all part of the material properties, visible when Game Render is set.
3.2) "Texture Face" Shading mode (in the Render panel) is now called “Single Texture”, it needs a material for special settings (e.g. Billboard, Alpha Sort, …).
3.3) New options in the Material Panel
* Shadeless option in the Material panel is now supported for all three Shading modes.
* Physics is now toggleable, this is the old Collision option.
* Two Side (on) is now called Back Culling (off).
* Alpha Sort is one of the Alpha options, together (and mutually exclusive) to Alpha Blend, Alpha Clip, Add and Opaque (i.e. solid).
* Shadow, Billboard and Halo are grouped in the “Face Orientation” property.
* "Face Textures" and "Face Textures Alpha" (under Options) can be used for all but GLSL shading mode (to be supported in GLSL eventually).
* The backend in the game engine is still the same as before. The only changes are in the interface and in the way you need to think your materials. The bottomline is: It’s no longer possible to share materials between faces that do not share the same game properties.
4 - Acknowledgment:
==================
Mike Pan for the design discussions, and testing along the whole development process.
Vitor Balbio for the first hands-on code with the interface changes. That helped me a lot to push me into work on that.
Benoit Bolsee and Brecht van Lommel for patch review (* no one reviewed the whole patch, or the latest iteractions, so I still hold liability for any problems).
Blender artists that gave feedback and helped testing the patch.
Patch review and original documentation can be found here:
http://wiki.blender.org/index.php/User:Dfelinto/TexFace
http://codereview.appspot.com/4289041/
2011-09-19 19:55:59 +00:00
|
|
|
int alphablend = 0;
|
|
|
|
|
int textured = 0;
|
|
|
|
|
int lit = 0;
|
|
|
|
|
|
2008-12-19 12:14:58 +00:00
|
|
|
if (clearcache) {
|
TexFace to Material Settings big patch
Summary:
========
The idea here is to move the texface options into the material panel.
For images with the change please visit:
http://code.blender.org/index.php/2011/09/bge-material-texface-changes
1 - Some of the legacy problems 2.49 and 2.5x has with the texface system:
==========================================================================
1.1) Shadow, Bilboard and Halo are mutual exclusive (in the code), yet you can
select a face to be more than one mode.
1.2) Sort only works for blend Alpha yet it's an option regardless of the
Transparency Blend you pick.
1.3) Shared doesn't affect anything in BGE.
1.4) ObColor only works for Text objects (old bitmap texts) when using Texture
Face Materials. (not address yet, I so far ignored obcolor)
2 - Notes:
============
2.1) Now "Use Face Textures" in material Option panel will work in Multitexture
even if there is no texture channel.
2.2) In FaceTexture mode it will use TexFace all the time, even if you don't
check the "Use Texture Face" option in the UI. It's a matter of decision, since
the code for either way is there. I decided by the solution that makes the
creation of a material fast - in this mode the user doesn't need to mess with
textures or this "Use Texture Face" option at all. I'm not strong in my opinion
here. But I think if we don't have this then what is the point of the Texture
Face mode?
2.3) I kept references for tface only when we need the image, UV or the tiling
setting. It should help later when/if we split the Image and UV layers from the
tface struct (Campbell and Brecht proposal).
3 - Changes in a Nutshell:
==========================
3.1) "Texture Face" panel (in the Mesh/Object Data panel) no longer exists. Those settings are all part of the material properties, visible when Game Render is set.
3.2) "Texture Face" Shading mode (in the Render panel) is now called “Single Texture”, it needs a material for special settings (e.g. Billboard, Alpha Sort, …).
3.3) New options in the Material Panel
* Shadeless option in the Material panel is now supported for all three Shading modes.
* Physics is now toggleable, this is the old Collision option.
* Two Side (on) is now called Back Culling (off).
* Alpha Sort is one of the Alpha options, together (and mutually exclusive) to Alpha Blend, Alpha Clip, Add and Opaque (i.e. solid).
* Shadow, Billboard and Halo are grouped in the “Face Orientation” property.
* "Face Textures" and "Face Textures Alpha" (under Options) can be used for all but GLSL shading mode (to be supported in GLSL eventually).
* The backend in the game engine is still the same as before. The only changes are in the interface and in the way you need to think your materials. The bottomline is: It’s no longer possible to share materials between faces that do not share the same game properties.
4 - Acknowledgment:
==================
Mike Pan for the design discussions, and testing along the whole development process.
Vitor Balbio for the first hands-on code with the interface changes. That helped me a lot to push me into work on that.
Benoit Bolsee and Brecht van Lommel for patch review (* no one reviewed the whole patch, or the latest iteractions, so I still hold liability for any problems).
Blender artists that gave feedback and helped testing the patch.
Patch review and original documentation can be found here:
http://wiki.blender.org/index.php/User:Dfelinto/TexFace
http://codereview.appspot.com/4289041/
2011-09-19 19:55:59 +00:00
|
|
|
c_textured= c_lit= c_backculled= -1;
|
2008-12-19 12:14:58 +00:00
|
|
|
c_texface= (MTFace*) -1;
|
|
|
|
|
c_badtex= 0;
|
2012-02-22 16:52:06 +00:00
|
|
|
}
|
|
|
|
|
else {
|
TexFace to Material Settings big patch
Summary:
========
The idea here is to move the texface options into the material panel.
For images with the change please visit:
http://code.blender.org/index.php/2011/09/bge-material-texface-changes
1 - Some of the legacy problems 2.49 and 2.5x has with the texface system:
==========================================================================
1.1) Shadow, Bilboard and Halo are mutual exclusive (in the code), yet you can
select a face to be more than one mode.
1.2) Sort only works for blend Alpha yet it's an option regardless of the
Transparency Blend you pick.
1.3) Shared doesn't affect anything in BGE.
1.4) ObColor only works for Text objects (old bitmap texts) when using Texture
Face Materials. (not address yet, I so far ignored obcolor)
2 - Notes:
============
2.1) Now "Use Face Textures" in material Option panel will work in Multitexture
even if there is no texture channel.
2.2) In FaceTexture mode it will use TexFace all the time, even if you don't
check the "Use Texture Face" option in the UI. It's a matter of decision, since
the code for either way is there. I decided by the solution that makes the
creation of a material fast - in this mode the user doesn't need to mess with
textures or this "Use Texture Face" option at all. I'm not strong in my opinion
here. But I think if we don't have this then what is the point of the Texture
Face mode?
2.3) I kept references for tface only when we need the image, UV or the tiling
setting. It should help later when/if we split the Image and UV layers from the
tface struct (Campbell and Brecht proposal).
3 - Changes in a Nutshell:
==========================
3.1) "Texture Face" panel (in the Mesh/Object Data panel) no longer exists. Those settings are all part of the material properties, visible when Game Render is set.
3.2) "Texture Face" Shading mode (in the Render panel) is now called “Single Texture”, it needs a material for special settings (e.g. Billboard, Alpha Sort, …).
3.3) New options in the Material Panel
* Shadeless option in the Material panel is now supported for all three Shading modes.
* Physics is now toggleable, this is the old Collision option.
* Two Side (on) is now called Back Culling (off).
* Alpha Sort is one of the Alpha options, together (and mutually exclusive) to Alpha Blend, Alpha Clip, Add and Opaque (i.e. solid).
* Shadow, Billboard and Halo are grouped in the “Face Orientation” property.
* "Face Textures" and "Face Textures Alpha" (under Options) can be used for all but GLSL shading mode (to be supported in GLSL eventually).
* The backend in the game engine is still the same as before. The only changes are in the interface and in the way you need to think your materials. The bottomline is: It’s no longer possible to share materials between faces that do not share the same game properties.
4 - Acknowledgment:
==================
Mike Pan for the design discussions, and testing along the whole development process.
Vitor Balbio for the first hands-on code with the interface changes. That helped me a lot to push me into work on that.
Benoit Bolsee and Brecht van Lommel for patch review (* no one reviewed the whole patch, or the latest iteractions, so I still hold liability for any problems).
Blender artists that gave feedback and helped testing the patch.
Patch review and original documentation can be found here:
http://wiki.blender.org/index.php/User:Dfelinto/TexFace
http://codereview.appspot.com/4289041/
2011-09-19 19:55:59 +00:00
|
|
|
textured = gtexdraw.istex;
|
|
|
|
|
litob = gtexdraw.ob;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* convert number of lights into boolean */
|
|
|
|
|
if (gtexdraw.islit) lit = 1;
|
|
|
|
|
|
|
|
|
|
if (ma) {
|
|
|
|
|
alphablend = ma->game.alpha_blend;
|
|
|
|
|
if (ma->mode & MA_SHLESS) lit = 0;
|
|
|
|
|
backculled = ma->game.flag & GEMAT_BACKCULL;
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (texface) {
|
TexFace to Material Settings big patch
Summary:
========
The idea here is to move the texface options into the material panel.
For images with the change please visit:
http://code.blender.org/index.php/2011/09/bge-material-texface-changes
1 - Some of the legacy problems 2.49 and 2.5x has with the texface system:
==========================================================================
1.1) Shadow, Bilboard and Halo are mutual exclusive (in the code), yet you can
select a face to be more than one mode.
1.2) Sort only works for blend Alpha yet it's an option regardless of the
Transparency Blend you pick.
1.3) Shared doesn't affect anything in BGE.
1.4) ObColor only works for Text objects (old bitmap texts) when using Texture
Face Materials. (not address yet, I so far ignored obcolor)
2 - Notes:
============
2.1) Now "Use Face Textures" in material Option panel will work in Multitexture
even if there is no texture channel.
2.2) In FaceTexture mode it will use TexFace all the time, even if you don't
check the "Use Texture Face" option in the UI. It's a matter of decision, since
the code for either way is there. I decided by the solution that makes the
creation of a material fast - in this mode the user doesn't need to mess with
textures or this "Use Texture Face" option at all. I'm not strong in my opinion
here. But I think if we don't have this then what is the point of the Texture
Face mode?
2.3) I kept references for tface only when we need the image, UV or the tiling
setting. It should help later when/if we split the Image and UV layers from the
tface struct (Campbell and Brecht proposal).
3 - Changes in a Nutshell:
==========================
3.1) "Texture Face" panel (in the Mesh/Object Data panel) no longer exists. Those settings are all part of the material properties, visible when Game Render is set.
3.2) "Texture Face" Shading mode (in the Render panel) is now called “Single Texture”, it needs a material for special settings (e.g. Billboard, Alpha Sort, …).
3.3) New options in the Material Panel
* Shadeless option in the Material panel is now supported for all three Shading modes.
* Physics is now toggleable, this is the old Collision option.
* Two Side (on) is now called Back Culling (off).
* Alpha Sort is one of the Alpha options, together (and mutually exclusive) to Alpha Blend, Alpha Clip, Add and Opaque (i.e. solid).
* Shadow, Billboard and Halo are grouped in the “Face Orientation” property.
* "Face Textures" and "Face Textures Alpha" (under Options) can be used for all but GLSL shading mode (to be supported in GLSL eventually).
* The backend in the game engine is still the same as before. The only changes are in the interface and in the way you need to think your materials. The bottomline is: It’s no longer possible to share materials between faces that do not share the same game properties.
4 - Acknowledgment:
==================
Mike Pan for the design discussions, and testing along the whole development process.
Vitor Balbio for the first hands-on code with the interface changes. That helped me a lot to push me into work on that.
Benoit Bolsee and Brecht van Lommel for patch review (* no one reviewed the whole patch, or the latest iteractions, so I still hold liability for any problems).
Blender artists that gave feedback and helped testing the patch.
Patch review and original documentation can be found here:
http://wiki.blender.org/index.php/User:Dfelinto/TexFace
http://codereview.appspot.com/4289041/
2011-09-19 19:55:59 +00:00
|
|
|
textured = textured && (texface->tpage);
|
|
|
|
|
|
|
|
|
|
/* no material, render alpha if texture has depth=32 */
|
|
|
|
|
if (!ma && BKE_image_has_alpha(texface->tpage))
|
|
|
|
|
alphablend = GPU_BLEND_ALPHA;
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
TexFace to Material Settings big patch
Summary:
========
The idea here is to move the texface options into the material panel.
For images with the change please visit:
http://code.blender.org/index.php/2011/09/bge-material-texface-changes
1 - Some of the legacy problems 2.49 and 2.5x has with the texface system:
==========================================================================
1.1) Shadow, Bilboard and Halo are mutual exclusive (in the code), yet you can
select a face to be more than one mode.
1.2) Sort only works for blend Alpha yet it's an option regardless of the
Transparency Blend you pick.
1.3) Shared doesn't affect anything in BGE.
1.4) ObColor only works for Text objects (old bitmap texts) when using Texture
Face Materials. (not address yet, I so far ignored obcolor)
2 - Notes:
============
2.1) Now "Use Face Textures" in material Option panel will work in Multitexture
even if there is no texture channel.
2.2) In FaceTexture mode it will use TexFace all the time, even if you don't
check the "Use Texture Face" option in the UI. It's a matter of decision, since
the code for either way is there. I decided by the solution that makes the
creation of a material fast - in this mode the user doesn't need to mess with
textures or this "Use Texture Face" option at all. I'm not strong in my opinion
here. But I think if we don't have this then what is the point of the Texture
Face mode?
2.3) I kept references for tface only when we need the image, UV or the tiling
setting. It should help later when/if we split the Image and UV layers from the
tface struct (Campbell and Brecht proposal).
3 - Changes in a Nutshell:
==========================
3.1) "Texture Face" panel (in the Mesh/Object Data panel) no longer exists. Those settings are all part of the material properties, visible when Game Render is set.
3.2) "Texture Face" Shading mode (in the Render panel) is now called “Single Texture”, it needs a material for special settings (e.g. Billboard, Alpha Sort, …).
3.3) New options in the Material Panel
* Shadeless option in the Material panel is now supported for all three Shading modes.
* Physics is now toggleable, this is the old Collision option.
* Two Side (on) is now called Back Culling (off).
* Alpha Sort is one of the Alpha options, together (and mutually exclusive) to Alpha Blend, Alpha Clip, Add and Opaque (i.e. solid).
* Shadow, Billboard and Halo are grouped in the “Face Orientation” property.
* "Face Textures" and "Face Textures Alpha" (under Options) can be used for all but GLSL shading mode (to be supported in GLSL eventually).
* The backend in the game engine is still the same as before. The only changes are in the interface and in the way you need to think your materials. The bottomline is: It’s no longer possible to share materials between faces that do not share the same game properties.
4 - Acknowledgment:
==================
Mike Pan for the design discussions, and testing along the whole development process.
Vitor Balbio for the first hands-on code with the interface changes. That helped me a lot to push me into work on that.
Benoit Bolsee and Brecht van Lommel for patch review (* no one reviewed the whole patch, or the latest iteractions, so I still hold liability for any problems).
Blender artists that gave feedback and helped testing the patch.
Patch review and original documentation can be found here:
http://wiki.blender.org/index.php/User:Dfelinto/TexFace
http://codereview.appspot.com/4289041/
2011-09-19 19:55:59 +00:00
|
|
|
else
|
|
|
|
|
textured = 0;
|
|
|
|
|
|
|
|
|
|
if (backculled!=c_backculled) {
|
|
|
|
|
if (backculled) glEnable(GL_CULL_FACE);
|
|
|
|
|
else glDisable(GL_CULL_FACE);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
TexFace to Material Settings big patch
Summary:
========
The idea here is to move the texface options into the material panel.
For images with the change please visit:
http://code.blender.org/index.php/2011/09/bge-material-texface-changes
1 - Some of the legacy problems 2.49 and 2.5x has with the texface system:
==========================================================================
1.1) Shadow, Bilboard and Halo are mutual exclusive (in the code), yet you can
select a face to be more than one mode.
1.2) Sort only works for blend Alpha yet it's an option regardless of the
Transparency Blend you pick.
1.3) Shared doesn't affect anything in BGE.
1.4) ObColor only works for Text objects (old bitmap texts) when using Texture
Face Materials. (not address yet, I so far ignored obcolor)
2 - Notes:
============
2.1) Now "Use Face Textures" in material Option panel will work in Multitexture
even if there is no texture channel.
2.2) In FaceTexture mode it will use TexFace all the time, even if you don't
check the "Use Texture Face" option in the UI. It's a matter of decision, since
the code for either way is there. I decided by the solution that makes the
creation of a material fast - in this mode the user doesn't need to mess with
textures or this "Use Texture Face" option at all. I'm not strong in my opinion
here. But I think if we don't have this then what is the point of the Texture
Face mode?
2.3) I kept references for tface only when we need the image, UV or the tiling
setting. It should help later when/if we split the Image and UV layers from the
tface struct (Campbell and Brecht proposal).
3 - Changes in a Nutshell:
==========================
3.1) "Texture Face" panel (in the Mesh/Object Data panel) no longer exists. Those settings are all part of the material properties, visible when Game Render is set.
3.2) "Texture Face" Shading mode (in the Render panel) is now called “Single Texture”, it needs a material for special settings (e.g. Billboard, Alpha Sort, …).
3.3) New options in the Material Panel
* Shadeless option in the Material panel is now supported for all three Shading modes.
* Physics is now toggleable, this is the old Collision option.
* Two Side (on) is now called Back Culling (off).
* Alpha Sort is one of the Alpha options, together (and mutually exclusive) to Alpha Blend, Alpha Clip, Add and Opaque (i.e. solid).
* Shadow, Billboard and Halo are grouped in the “Face Orientation” property.
* "Face Textures" and "Face Textures Alpha" (under Options) can be used for all but GLSL shading mode (to be supported in GLSL eventually).
* The backend in the game engine is still the same as before. The only changes are in the interface and in the way you need to think your materials. The bottomline is: It’s no longer possible to share materials between faces that do not share the same game properties.
4 - Acknowledgment:
==================
Mike Pan for the design discussions, and testing along the whole development process.
Vitor Balbio for the first hands-on code with the interface changes. That helped me a lot to push me into work on that.
Benoit Bolsee and Brecht van Lommel for patch review (* no one reviewed the whole patch, or the latest iteractions, so I still hold liability for any problems).
Blender artists that gave feedback and helped testing the patch.
Patch review and original documentation can be found here:
http://wiki.blender.org/index.php/User:Dfelinto/TexFace
http://codereview.appspot.com/4289041/
2011-09-19 19:55:59 +00:00
|
|
|
c_backculled= backculled;
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (textured!=c_textured || texface!=c_texface) {
|
|
|
|
|
if (textured ) {
|
TexFace to Material Settings big patch
Summary:
========
The idea here is to move the texface options into the material panel.
For images with the change please visit:
http://code.blender.org/index.php/2011/09/bge-material-texface-changes
1 - Some of the legacy problems 2.49 and 2.5x has with the texface system:
==========================================================================
1.1) Shadow, Bilboard and Halo are mutual exclusive (in the code), yet you can
select a face to be more than one mode.
1.2) Sort only works for blend Alpha yet it's an option regardless of the
Transparency Blend you pick.
1.3) Shared doesn't affect anything in BGE.
1.4) ObColor only works for Text objects (old bitmap texts) when using Texture
Face Materials. (not address yet, I so far ignored obcolor)
2 - Notes:
============
2.1) Now "Use Face Textures" in material Option panel will work in Multitexture
even if there is no texture channel.
2.2) In FaceTexture mode it will use TexFace all the time, even if you don't
check the "Use Texture Face" option in the UI. It's a matter of decision, since
the code for either way is there. I decided by the solution that makes the
creation of a material fast - in this mode the user doesn't need to mess with
textures or this "Use Texture Face" option at all. I'm not strong in my opinion
here. But I think if we don't have this then what is the point of the Texture
Face mode?
2.3) I kept references for tface only when we need the image, UV or the tiling
setting. It should help later when/if we split the Image and UV layers from the
tface struct (Campbell and Brecht proposal).
3 - Changes in a Nutshell:
==========================
3.1) "Texture Face" panel (in the Mesh/Object Data panel) no longer exists. Those settings are all part of the material properties, visible when Game Render is set.
3.2) "Texture Face" Shading mode (in the Render panel) is now called “Single Texture”, it needs a material for special settings (e.g. Billboard, Alpha Sort, …).
3.3) New options in the Material Panel
* Shadeless option in the Material panel is now supported for all three Shading modes.
* Physics is now toggleable, this is the old Collision option.
* Two Side (on) is now called Back Culling (off).
* Alpha Sort is one of the Alpha options, together (and mutually exclusive) to Alpha Blend, Alpha Clip, Add and Opaque (i.e. solid).
* Shadow, Billboard and Halo are grouped in the “Face Orientation” property.
* "Face Textures" and "Face Textures Alpha" (under Options) can be used for all but GLSL shading mode (to be supported in GLSL eventually).
* The backend in the game engine is still the same as before. The only changes are in the interface and in the way you need to think your materials. The bottomline is: It’s no longer possible to share materials between faces that do not share the same game properties.
4 - Acknowledgment:
==================
Mike Pan for the design discussions, and testing along the whole development process.
Vitor Balbio for the first hands-on code with the interface changes. That helped me a lot to push me into work on that.
Benoit Bolsee and Brecht van Lommel for patch review (* no one reviewed the whole patch, or the latest iteractions, so I still hold liability for any problems).
Blender artists that gave feedback and helped testing the patch.
Patch review and original documentation can be found here:
http://wiki.blender.org/index.php/User:Dfelinto/TexFace
http://codereview.appspot.com/4289041/
2011-09-19 19:55:59 +00:00
|
|
|
c_badtex= !GPU_set_tpage(texface, !(litob->mode & OB_MODE_TEXTURE_PAINT), alphablend);
|
2012-02-22 16:52:06 +00:00
|
|
|
}else {
|
TexFace to Material Settings big patch
Summary:
========
The idea here is to move the texface options into the material panel.
For images with the change please visit:
http://code.blender.org/index.php/2011/09/bge-material-texface-changes
1 - Some of the legacy problems 2.49 and 2.5x has with the texface system:
==========================================================================
1.1) Shadow, Bilboard and Halo are mutual exclusive (in the code), yet you can
select a face to be more than one mode.
1.2) Sort only works for blend Alpha yet it's an option regardless of the
Transparency Blend you pick.
1.3) Shared doesn't affect anything in BGE.
1.4) ObColor only works for Text objects (old bitmap texts) when using Texture
Face Materials. (not address yet, I so far ignored obcolor)
2 - Notes:
============
2.1) Now "Use Face Textures" in material Option panel will work in Multitexture
even if there is no texture channel.
2.2) In FaceTexture mode it will use TexFace all the time, even if you don't
check the "Use Texture Face" option in the UI. It's a matter of decision, since
the code for either way is there. I decided by the solution that makes the
creation of a material fast - in this mode the user doesn't need to mess with
textures or this "Use Texture Face" option at all. I'm not strong in my opinion
here. But I think if we don't have this then what is the point of the Texture
Face mode?
2.3) I kept references for tface only when we need the image, UV or the tiling
setting. It should help later when/if we split the Image and UV layers from the
tface struct (Campbell and Brecht proposal).
3 - Changes in a Nutshell:
==========================
3.1) "Texture Face" panel (in the Mesh/Object Data panel) no longer exists. Those settings are all part of the material properties, visible when Game Render is set.
3.2) "Texture Face" Shading mode (in the Render panel) is now called “Single Texture”, it needs a material for special settings (e.g. Billboard, Alpha Sort, …).
3.3) New options in the Material Panel
* Shadeless option in the Material panel is now supported for all three Shading modes.
* Physics is now toggleable, this is the old Collision option.
* Two Side (on) is now called Back Culling (off).
* Alpha Sort is one of the Alpha options, together (and mutually exclusive) to Alpha Blend, Alpha Clip, Add and Opaque (i.e. solid).
* Shadow, Billboard and Halo are grouped in the “Face Orientation” property.
* "Face Textures" and "Face Textures Alpha" (under Options) can be used for all but GLSL shading mode (to be supported in GLSL eventually).
* The backend in the game engine is still the same as before. The only changes are in the interface and in the way you need to think your materials. The bottomline is: It’s no longer possible to share materials between faces that do not share the same game properties.
4 - Acknowledgment:
==================
Mike Pan for the design discussions, and testing along the whole development process.
Vitor Balbio for the first hands-on code with the interface changes. That helped me a lot to push me into work on that.
Benoit Bolsee and Brecht van Lommel for patch review (* no one reviewed the whole patch, or the latest iteractions, so I still hold liability for any problems).
Blender artists that gave feedback and helped testing the patch.
Patch review and original documentation can be found here:
http://wiki.blender.org/index.php/User:Dfelinto/TexFace
http://codereview.appspot.com/4289041/
2011-09-19 19:55:59 +00:00
|
|
|
GPU_set_tpage(NULL, 0, 0);
|
2008-12-19 12:14:58 +00:00
|
|
|
c_badtex= 0;
|
|
|
|
|
}
|
|
|
|
|
c_textured= textured;
|
|
|
|
|
c_texface= texface;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (c_badtex) lit= 0;
|
TexFace to Material Settings big patch
Summary:
========
The idea here is to move the texface options into the material panel.
For images with the change please visit:
http://code.blender.org/index.php/2011/09/bge-material-texface-changes
1 - Some of the legacy problems 2.49 and 2.5x has with the texface system:
==========================================================================
1.1) Shadow, Bilboard and Halo are mutual exclusive (in the code), yet you can
select a face to be more than one mode.
1.2) Sort only works for blend Alpha yet it's an option regardless of the
Transparency Blend you pick.
1.3) Shared doesn't affect anything in BGE.
1.4) ObColor only works for Text objects (old bitmap texts) when using Texture
Face Materials. (not address yet, I so far ignored obcolor)
2 - Notes:
============
2.1) Now "Use Face Textures" in material Option panel will work in Multitexture
even if there is no texture channel.
2.2) In FaceTexture mode it will use TexFace all the time, even if you don't
check the "Use Texture Face" option in the UI. It's a matter of decision, since
the code for either way is there. I decided by the solution that makes the
creation of a material fast - in this mode the user doesn't need to mess with
textures or this "Use Texture Face" option at all. I'm not strong in my opinion
here. But I think if we don't have this then what is the point of the Texture
Face mode?
2.3) I kept references for tface only when we need the image, UV or the tiling
setting. It should help later when/if we split the Image and UV layers from the
tface struct (Campbell and Brecht proposal).
3 - Changes in a Nutshell:
==========================
3.1) "Texture Face" panel (in the Mesh/Object Data panel) no longer exists. Those settings are all part of the material properties, visible when Game Render is set.
3.2) "Texture Face" Shading mode (in the Render panel) is now called “Single Texture”, it needs a material for special settings (e.g. Billboard, Alpha Sort, …).
3.3) New options in the Material Panel
* Shadeless option in the Material panel is now supported for all three Shading modes.
* Physics is now toggleable, this is the old Collision option.
* Two Side (on) is now called Back Culling (off).
* Alpha Sort is one of the Alpha options, together (and mutually exclusive) to Alpha Blend, Alpha Clip, Add and Opaque (i.e. solid).
* Shadow, Billboard and Halo are grouped in the “Face Orientation” property.
* "Face Textures" and "Face Textures Alpha" (under Options) can be used for all but GLSL shading mode (to be supported in GLSL eventually).
* The backend in the game engine is still the same as before. The only changes are in the interface and in the way you need to think your materials. The bottomline is: It’s no longer possible to share materials between faces that do not share the same game properties.
4 - Acknowledgment:
==================
Mike Pan for the design discussions, and testing along the whole development process.
Vitor Balbio for the first hands-on code with the interface changes. That helped me a lot to push me into work on that.
Benoit Bolsee and Brecht van Lommel for patch review (* no one reviewed the whole patch, or the latest iteractions, so I still hold liability for any problems).
Blender artists that gave feedback and helped testing the patch.
Patch review and original documentation can be found here:
http://wiki.blender.org/index.php/User:Dfelinto/TexFace
http://codereview.appspot.com/4289041/
2011-09-19 19:55:59 +00:00
|
|
|
if (lit!=c_lit || ma!=c_ma) {
|
2008-12-19 12:14:58 +00:00
|
|
|
if (lit) {
|
|
|
|
|
float spec[4];
|
TexFace to Material Settings big patch
Summary:
========
The idea here is to move the texface options into the material panel.
For images with the change please visit:
http://code.blender.org/index.php/2011/09/bge-material-texface-changes
1 - Some of the legacy problems 2.49 and 2.5x has with the texface system:
==========================================================================
1.1) Shadow, Bilboard and Halo are mutual exclusive (in the code), yet you can
select a face to be more than one mode.
1.2) Sort only works for blend Alpha yet it's an option regardless of the
Transparency Blend you pick.
1.3) Shared doesn't affect anything in BGE.
1.4) ObColor only works for Text objects (old bitmap texts) when using Texture
Face Materials. (not address yet, I so far ignored obcolor)
2 - Notes:
============
2.1) Now "Use Face Textures" in material Option panel will work in Multitexture
even if there is no texture channel.
2.2) In FaceTexture mode it will use TexFace all the time, even if you don't
check the "Use Texture Face" option in the UI. It's a matter of decision, since
the code for either way is there. I decided by the solution that makes the
creation of a material fast - in this mode the user doesn't need to mess with
textures or this "Use Texture Face" option at all. I'm not strong in my opinion
here. But I think if we don't have this then what is the point of the Texture
Face mode?
2.3) I kept references for tface only when we need the image, UV or the tiling
setting. It should help later when/if we split the Image and UV layers from the
tface struct (Campbell and Brecht proposal).
3 - Changes in a Nutshell:
==========================
3.1) "Texture Face" panel (in the Mesh/Object Data panel) no longer exists. Those settings are all part of the material properties, visible when Game Render is set.
3.2) "Texture Face" Shading mode (in the Render panel) is now called “Single Texture”, it needs a material for special settings (e.g. Billboard, Alpha Sort, …).
3.3) New options in the Material Panel
* Shadeless option in the Material panel is now supported for all three Shading modes.
* Physics is now toggleable, this is the old Collision option.
* Two Side (on) is now called Back Culling (off).
* Alpha Sort is one of the Alpha options, together (and mutually exclusive) to Alpha Blend, Alpha Clip, Add and Opaque (i.e. solid).
* Shadow, Billboard and Halo are grouped in the “Face Orientation” property.
* "Face Textures" and "Face Textures Alpha" (under Options) can be used for all but GLSL shading mode (to be supported in GLSL eventually).
* The backend in the game engine is still the same as before. The only changes are in the interface and in the way you need to think your materials. The bottomline is: It’s no longer possible to share materials between faces that do not share the same game properties.
4 - Acknowledgment:
==================
Mike Pan for the design discussions, and testing along the whole development process.
Vitor Balbio for the first hands-on code with the interface changes. That helped me a lot to push me into work on that.
Benoit Bolsee and Brecht van Lommel for patch review (* no one reviewed the whole patch, or the latest iteractions, so I still hold liability for any problems).
Blender artists that gave feedback and helped testing the patch.
Patch review and original documentation can be found here:
http://wiki.blender.org/index.php/User:Dfelinto/TexFace
http://codereview.appspot.com/4289041/
2011-09-19 19:55:59 +00:00
|
|
|
if (!ma)ma= give_current_material_or_def(NULL, 0); //default material
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
spec[0]= ma->spec*ma->specr;
|
|
|
|
|
spec[1]= ma->spec*ma->specg;
|
|
|
|
|
spec[2]= ma->spec*ma->specb;
|
|
|
|
|
spec[3]= 1.0;
|
|
|
|
|
|
|
|
|
|
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, spec);
|
|
|
|
|
glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
|
2011-03-25 13:37:50 +00:00
|
|
|
glMateriali(GL_FRONT_AND_BACK, GL_SHININESS, CLAMPIS(ma->har, 0, 128));
|
2008-12-19 12:14:58 +00:00
|
|
|
glEnable(GL_LIGHTING);
|
|
|
|
|
glEnable(GL_COLOR_MATERIAL);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
glDisable(GL_LIGHTING);
|
|
|
|
|
glDisable(GL_COLOR_MATERIAL);
|
|
|
|
|
}
|
|
|
|
|
c_lit= lit;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return c_badtex;
|
|
|
|
|
}
|
|
|
|
|
|
2.5
View3D has been split now in a local part (RegionView3D) and a
per-area part (old View3D). Currently local is:
- view transform
- camera zoom/offset
- gpencil (todo)
- custom clipping planes
Rest is in Area still, like active camera, draw type, layers,
localview, custom centers, around-settings, transform widget,
gridlines, and so on (mostly stuff as available in header).
To see it work; also added new feature for region split,
press SHIFT+ALT+CTRL+S for four-split.
The idea is to make a preset 4-split, configured to stick
to top/right/front views for three views.
Another cool idea to explore is to then box-clip all drawing
based on these 3 views.
Note about the code:
- currently view3d still stores some depricated settings, to
convert from older files. Not all settings are copied over
though, like custom clip planes or the 'lock view to object'.
- since some view3d ops are now on area level, the operators
for it should keep track of that.
Bugfix in transform: quat initialize in operator-invoke missed
one zero.
Als brought back GE to compile for missing Ipos and channels.
2009-01-19 16:54:41 +00:00
|
|
|
static void draw_textured_begin(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *ob)
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
|
|
|
|
unsigned char obcol[4];
|
2011-10-06 05:01:24 +00:00
|
|
|
int istex, solidtex;
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2009-01-02 19:10:35 +00:00
|
|
|
// XXX scene->obedit warning
|
2011-10-06 05:01:24 +00:00
|
|
|
|
|
|
|
|
/* texture draw is abused for mask selection mode, do this so wire draw
|
|
|
|
|
* with face selection in weight paint is not lit. */
|
2012-02-22 16:52:06 +00:00
|
|
|
if ((v3d->drawtype <= OB_WIRE) && (ob->mode & OB_MODE_WEIGHT_PAINT)) {
|
2011-10-06 05:01:24 +00:00
|
|
|
solidtex= FALSE;
|
|
|
|
|
Gtexdraw.islit= 0;
|
|
|
|
|
}
|
2012-02-22 16:52:06 +00:00
|
|
|
else if (v3d->drawtype==OB_SOLID || ((ob->mode & OB_MODE_EDIT) && v3d->drawtype!=OB_TEXTURE)) {
|
2008-12-19 12:14:58 +00:00
|
|
|
/* draw with default lights in solid draw mode and edit mode */
|
2011-10-06 05:01:24 +00:00
|
|
|
solidtex= TRUE;
|
2008-12-19 12:14:58 +00:00
|
|
|
Gtexdraw.islit= -1;
|
|
|
|
|
}
|
2009-02-06 19:21:24 +00:00
|
|
|
else {
|
2008-12-19 12:14:58 +00:00
|
|
|
/* draw with lights in the scene otherwise */
|
2011-10-06 05:01:24 +00:00
|
|
|
solidtex= FALSE;
|
2011-05-18 17:52:26 +00:00
|
|
|
Gtexdraw.islit= GPU_scene_object_lights(scene, ob, v3d->lay, rv3d->viewmat, !rv3d->is_persp);
|
2009-02-06 19:21:24 +00:00
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-01-19 10:04:51 +00:00
|
|
|
rgba_float_to_uchar(obcol, ob->col);
|
|
|
|
|
|
2008-12-19 12:14:58 +00:00
|
|
|
glCullFace(GL_BACK); glEnable(GL_CULL_FACE);
|
2012-02-22 16:52:06 +00:00
|
|
|
if (solidtex || v3d->drawtype==OB_TEXTURE) istex= 1;
|
2008-12-19 12:14:58 +00:00
|
|
|
else istex= 0;
|
|
|
|
|
|
|
|
|
|
Gtexdraw.ob = ob;
|
|
|
|
|
Gtexdraw.istex = istex;
|
Changes to Color Management
After testing and feedback, I've decided to slightly modify the way color
management works internally. While the previous method worked well for
rendering, was a smaller transition and had some advantages over this
new method, it was a bit more ambiguous, and was making things difficult
for other areas such as compositing.
This implementation now considers all color data (with only a couple of
exceptions such as brush colors) to be stored in linear RGB color space,
rather than sRGB as previously. This brings it in line with Nuke, which also
operates this way, quite successfully. Color swatches, pickers, color ramp
display are now gamma corrected to display gamma so you can see what
you're doing, but the numbers themselves are considered linear. This
makes understanding blending modes more clear (a 0.5 value on overlay
will not change the result now) as well as making color swatches act more
predictably in the compositor, however bringing over color values from
applications like photoshop or gimp, that operate in a gamma space,
will give identical results.
This commit will convert over existing files saved by earlier 2.5 versions to
work generally the same, though there may be some slight differences with
things like textures. Now that we're set on changing other areas of shading,
this won't be too disruptive overall.
I've made a diagram explaining the pipeline here:
http://mke3.net/blender/devel/2.5/25_linear_workflow_pipeline.png
and some docs here:
http://www.blender.org/development/release-logs/blender-250/color-management/
2009-12-02 07:56:34 +00:00
|
|
|
Gtexdraw.color_profile = scene->r.color_mgt_flag & R_COLOR_MANAGEMENT;
|
2008-12-19 12:14:58 +00:00
|
|
|
memcpy(Gtexdraw.obcol, obcol, sizeof(obcol));
|
TexFace to Material Settings big patch
Summary:
========
The idea here is to move the texface options into the material panel.
For images with the change please visit:
http://code.blender.org/index.php/2011/09/bge-material-texface-changes
1 - Some of the legacy problems 2.49 and 2.5x has with the texface system:
==========================================================================
1.1) Shadow, Bilboard and Halo are mutual exclusive (in the code), yet you can
select a face to be more than one mode.
1.2) Sort only works for blend Alpha yet it's an option regardless of the
Transparency Blend you pick.
1.3) Shared doesn't affect anything in BGE.
1.4) ObColor only works for Text objects (old bitmap texts) when using Texture
Face Materials. (not address yet, I so far ignored obcolor)
2 - Notes:
============
2.1) Now "Use Face Textures" in material Option panel will work in Multitexture
even if there is no texture channel.
2.2) In FaceTexture mode it will use TexFace all the time, even if you don't
check the "Use Texture Face" option in the UI. It's a matter of decision, since
the code for either way is there. I decided by the solution that makes the
creation of a material fast - in this mode the user doesn't need to mess with
textures or this "Use Texture Face" option at all. I'm not strong in my opinion
here. But I think if we don't have this then what is the point of the Texture
Face mode?
2.3) I kept references for tface only when we need the image, UV or the tiling
setting. It should help later when/if we split the Image and UV layers from the
tface struct (Campbell and Brecht proposal).
3 - Changes in a Nutshell:
==========================
3.1) "Texture Face" panel (in the Mesh/Object Data panel) no longer exists. Those settings are all part of the material properties, visible when Game Render is set.
3.2) "Texture Face" Shading mode (in the Render panel) is now called “Single Texture”, it needs a material for special settings (e.g. Billboard, Alpha Sort, …).
3.3) New options in the Material Panel
* Shadeless option in the Material panel is now supported for all three Shading modes.
* Physics is now toggleable, this is the old Collision option.
* Two Side (on) is now called Back Culling (off).
* Alpha Sort is one of the Alpha options, together (and mutually exclusive) to Alpha Blend, Alpha Clip, Add and Opaque (i.e. solid).
* Shadow, Billboard and Halo are grouped in the “Face Orientation” property.
* "Face Textures" and "Face Textures Alpha" (under Options) can be used for all but GLSL shading mode (to be supported in GLSL eventually).
* The backend in the game engine is still the same as before. The only changes are in the interface and in the way you need to think your materials. The bottomline is: It’s no longer possible to share materials between faces that do not share the same game properties.
4 - Acknowledgment:
==================
Mike Pan for the design discussions, and testing along the whole development process.
Vitor Balbio for the first hands-on code with the interface changes. That helped me a lot to push me into work on that.
Benoit Bolsee and Brecht van Lommel for patch review (* no one reviewed the whole patch, or the latest iteractions, so I still hold liability for any problems).
Blender artists that gave feedback and helped testing the patch.
Patch review and original documentation can be found here:
http://wiki.blender.org/index.php/User:Dfelinto/TexFace
http://codereview.appspot.com/4289041/
2011-09-19 19:55:59 +00:00
|
|
|
set_draw_settings_cached(1, NULL, NULL, Gtexdraw);
|
2008-12-19 12:14:58 +00:00
|
|
|
glShadeModel(GL_SMOOTH);
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-03 12:30:59 +00:00
|
|
|
static void draw_textured_end(void)
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
|
|
|
|
/* switch off textures */
|
TexFace to Material Settings big patch
Summary:
========
The idea here is to move the texface options into the material panel.
For images with the change please visit:
http://code.blender.org/index.php/2011/09/bge-material-texface-changes
1 - Some of the legacy problems 2.49 and 2.5x has with the texface system:
==========================================================================
1.1) Shadow, Bilboard and Halo are mutual exclusive (in the code), yet you can
select a face to be more than one mode.
1.2) Sort only works for blend Alpha yet it's an option regardless of the
Transparency Blend you pick.
1.3) Shared doesn't affect anything in BGE.
1.4) ObColor only works for Text objects (old bitmap texts) when using Texture
Face Materials. (not address yet, I so far ignored obcolor)
2 - Notes:
============
2.1) Now "Use Face Textures" in material Option panel will work in Multitexture
even if there is no texture channel.
2.2) In FaceTexture mode it will use TexFace all the time, even if you don't
check the "Use Texture Face" option in the UI. It's a matter of decision, since
the code for either way is there. I decided by the solution that makes the
creation of a material fast - in this mode the user doesn't need to mess with
textures or this "Use Texture Face" option at all. I'm not strong in my opinion
here. But I think if we don't have this then what is the point of the Texture
Face mode?
2.3) I kept references for tface only when we need the image, UV or the tiling
setting. It should help later when/if we split the Image and UV layers from the
tface struct (Campbell and Brecht proposal).
3 - Changes in a Nutshell:
==========================
3.1) "Texture Face" panel (in the Mesh/Object Data panel) no longer exists. Those settings are all part of the material properties, visible when Game Render is set.
3.2) "Texture Face" Shading mode (in the Render panel) is now called “Single Texture”, it needs a material for special settings (e.g. Billboard, Alpha Sort, …).
3.3) New options in the Material Panel
* Shadeless option in the Material panel is now supported for all three Shading modes.
* Physics is now toggleable, this is the old Collision option.
* Two Side (on) is now called Back Culling (off).
* Alpha Sort is one of the Alpha options, together (and mutually exclusive) to Alpha Blend, Alpha Clip, Add and Opaque (i.e. solid).
* Shadow, Billboard and Halo are grouped in the “Face Orientation” property.
* "Face Textures" and "Face Textures Alpha" (under Options) can be used for all but GLSL shading mode (to be supported in GLSL eventually).
* The backend in the game engine is still the same as before. The only changes are in the interface and in the way you need to think your materials. The bottomline is: It’s no longer possible to share materials between faces that do not share the same game properties.
4 - Acknowledgment:
==================
Mike Pan for the design discussions, and testing along the whole development process.
Vitor Balbio for the first hands-on code with the interface changes. That helped me a lot to push me into work on that.
Benoit Bolsee and Brecht van Lommel for patch review (* no one reviewed the whole patch, or the latest iteractions, so I still hold liability for any problems).
Blender artists that gave feedback and helped testing the patch.
Patch review and original documentation can be found here:
http://wiki.blender.org/index.php/User:Dfelinto/TexFace
http://codereview.appspot.com/4289041/
2011-09-19 19:55:59 +00:00
|
|
|
GPU_set_tpage(NULL, 0, 0);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
glShadeModel(GL_FLAT);
|
|
|
|
|
glDisable(GL_CULL_FACE);
|
|
|
|
|
|
|
|
|
|
/* XXX, bad patch - GPU_default_lights() calls
|
|
|
|
|
* glLightfv(GL_LIGHT_POSITION, ...) which
|
|
|
|
|
* is transformed by the current matrix... we
|
|
|
|
|
* need to make sure that matrix is identity.
|
|
|
|
|
*
|
|
|
|
|
* It would be better if drawmesh.c kept track
|
|
|
|
|
* of and restored the light settings it changed.
|
|
|
|
|
* - zr
|
|
|
|
|
*/
|
|
|
|
|
glPushMatrix();
|
|
|
|
|
glLoadIdentity();
|
|
|
|
|
GPU_default_lights();
|
|
|
|
|
glPopMatrix();
|
|
|
|
|
}
|
|
|
|
|
|
2011-09-23 18:29:45 +00:00
|
|
|
static int draw_tface__set_draw_legacy(MTFace *tface, int has_mcol, int matnr)
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
TexFace to Material Settings big patch
Summary:
========
The idea here is to move the texface options into the material panel.
For images with the change please visit:
http://code.blender.org/index.php/2011/09/bge-material-texface-changes
1 - Some of the legacy problems 2.49 and 2.5x has with the texface system:
==========================================================================
1.1) Shadow, Bilboard and Halo are mutual exclusive (in the code), yet you can
select a face to be more than one mode.
1.2) Sort only works for blend Alpha yet it's an option regardless of the
Transparency Blend you pick.
1.3) Shared doesn't affect anything in BGE.
1.4) ObColor only works for Text objects (old bitmap texts) when using Texture
Face Materials. (not address yet, I so far ignored obcolor)
2 - Notes:
============
2.1) Now "Use Face Textures" in material Option panel will work in Multitexture
even if there is no texture channel.
2.2) In FaceTexture mode it will use TexFace all the time, even if you don't
check the "Use Texture Face" option in the UI. It's a matter of decision, since
the code for either way is there. I decided by the solution that makes the
creation of a material fast - in this mode the user doesn't need to mess with
textures or this "Use Texture Face" option at all. I'm not strong in my opinion
here. But I think if we don't have this then what is the point of the Texture
Face mode?
2.3) I kept references for tface only when we need the image, UV or the tiling
setting. It should help later when/if we split the Image and UV layers from the
tface struct (Campbell and Brecht proposal).
3 - Changes in a Nutshell:
==========================
3.1) "Texture Face" panel (in the Mesh/Object Data panel) no longer exists. Those settings are all part of the material properties, visible when Game Render is set.
3.2) "Texture Face" Shading mode (in the Render panel) is now called “Single Texture”, it needs a material for special settings (e.g. Billboard, Alpha Sort, …).
3.3) New options in the Material Panel
* Shadeless option in the Material panel is now supported for all three Shading modes.
* Physics is now toggleable, this is the old Collision option.
* Two Side (on) is now called Back Culling (off).
* Alpha Sort is one of the Alpha options, together (and mutually exclusive) to Alpha Blend, Alpha Clip, Add and Opaque (i.e. solid).
* Shadow, Billboard and Halo are grouped in the “Face Orientation” property.
* "Face Textures" and "Face Textures Alpha" (under Options) can be used for all but GLSL shading mode (to be supported in GLSL eventually).
* The backend in the game engine is still the same as before. The only changes are in the interface and in the way you need to think your materials. The bottomline is: It’s no longer possible to share materials between faces that do not share the same game properties.
4 - Acknowledgment:
==================
Mike Pan for the design discussions, and testing along the whole development process.
Vitor Balbio for the first hands-on code with the interface changes. That helped me a lot to push me into work on that.
Benoit Bolsee and Brecht van Lommel for patch review (* no one reviewed the whole patch, or the latest iteractions, so I still hold liability for any problems).
Blender artists that gave feedback and helped testing the patch.
Patch review and original documentation can be found here:
http://wiki.blender.org/index.php/User:Dfelinto/TexFace
http://codereview.appspot.com/4289041/
2011-09-19 19:55:59 +00:00
|
|
|
Material *ma= give_current_material(Gtexdraw.ob, matnr+1);
|
|
|
|
|
int validtexture=0;
|
|
|
|
|
|
|
|
|
|
if (ma && (ma->game.flag & GEMAT_INVISIBLE)) return 0;
|
2008-12-19 12:14:58 +00:00
|
|
|
|
TexFace to Material Settings big patch
Summary:
========
The idea here is to move the texface options into the material panel.
For images with the change please visit:
http://code.blender.org/index.php/2011/09/bge-material-texface-changes
1 - Some of the legacy problems 2.49 and 2.5x has with the texface system:
==========================================================================
1.1) Shadow, Bilboard and Halo are mutual exclusive (in the code), yet you can
select a face to be more than one mode.
1.2) Sort only works for blend Alpha yet it's an option regardless of the
Transparency Blend you pick.
1.3) Shared doesn't affect anything in BGE.
1.4) ObColor only works for Text objects (old bitmap texts) when using Texture
Face Materials. (not address yet, I so far ignored obcolor)
2 - Notes:
============
2.1) Now "Use Face Textures" in material Option panel will work in Multitexture
even if there is no texture channel.
2.2) In FaceTexture mode it will use TexFace all the time, even if you don't
check the "Use Texture Face" option in the UI. It's a matter of decision, since
the code for either way is there. I decided by the solution that makes the
creation of a material fast - in this mode the user doesn't need to mess with
textures or this "Use Texture Face" option at all. I'm not strong in my opinion
here. But I think if we don't have this then what is the point of the Texture
Face mode?
2.3) I kept references for tface only when we need the image, UV or the tiling
setting. It should help later when/if we split the Image and UV layers from the
tface struct (Campbell and Brecht proposal).
3 - Changes in a Nutshell:
==========================
3.1) "Texture Face" panel (in the Mesh/Object Data panel) no longer exists. Those settings are all part of the material properties, visible when Game Render is set.
3.2) "Texture Face" Shading mode (in the Render panel) is now called “Single Texture”, it needs a material for special settings (e.g. Billboard, Alpha Sort, …).
3.3) New options in the Material Panel
* Shadeless option in the Material panel is now supported for all three Shading modes.
* Physics is now toggleable, this is the old Collision option.
* Two Side (on) is now called Back Culling (off).
* Alpha Sort is one of the Alpha options, together (and mutually exclusive) to Alpha Blend, Alpha Clip, Add and Opaque (i.e. solid).
* Shadow, Billboard and Halo are grouped in the “Face Orientation” property.
* "Face Textures" and "Face Textures Alpha" (under Options) can be used for all but GLSL shading mode (to be supported in GLSL eventually).
* The backend in the game engine is still the same as before. The only changes are in the interface and in the way you need to think your materials. The bottomline is: It’s no longer possible to share materials between faces that do not share the same game properties.
4 - Acknowledgment:
==================
Mike Pan for the design discussions, and testing along the whole development process.
Vitor Balbio for the first hands-on code with the interface changes. That helped me a lot to push me into work on that.
Benoit Bolsee and Brecht van Lommel for patch review (* no one reviewed the whole patch, or the latest iteractions, so I still hold liability for any problems).
Blender artists that gave feedback and helped testing the patch.
Patch review and original documentation can be found here:
http://wiki.blender.org/index.php/User:Dfelinto/TexFace
http://codereview.appspot.com/4289041/
2011-09-19 19:55:59 +00:00
|
|
|
validtexture = set_draw_settings_cached(0, tface, ma, Gtexdraw);
|
|
|
|
|
|
|
|
|
|
if (tface && validtexture) {
|
2008-12-19 12:14:58 +00:00
|
|
|
glColor3ub(0xFF, 0x00, 0xFF);
|
|
|
|
|
return 2; /* Don't set color */
|
2012-02-22 16:52:06 +00:00
|
|
|
}
|
|
|
|
|
else if (ma && ma->shade_flag&MA_OBCOLOR) {
|
2008-12-19 12:14:58 +00:00
|
|
|
glColor3ubv(Gtexdraw.obcol);
|
|
|
|
|
return 2; /* Don't set color */
|
2012-02-22 16:52:06 +00:00
|
|
|
}
|
|
|
|
|
else if (!has_mcol) {
|
2008-12-19 12:14:58 +00:00
|
|
|
if (tface) glColor3f(1.0, 1.0, 1.0);
|
|
|
|
|
else {
|
2012-02-22 16:52:06 +00:00
|
|
|
if (ma) {
|
Changes to Color Management
After testing and feedback, I've decided to slightly modify the way color
management works internally. While the previous method worked well for
rendering, was a smaller transition and had some advantages over this
new method, it was a bit more ambiguous, and was making things difficult
for other areas such as compositing.
This implementation now considers all color data (with only a couple of
exceptions such as brush colors) to be stored in linear RGB color space,
rather than sRGB as previously. This brings it in line with Nuke, which also
operates this way, quite successfully. Color swatches, pickers, color ramp
display are now gamma corrected to display gamma so you can see what
you're doing, but the numbers themselves are considered linear. This
makes understanding blending modes more clear (a 0.5 value on overlay
will not change the result now) as well as making color swatches act more
predictably in the compositor, however bringing over color values from
applications like photoshop or gimp, that operate in a gamma space,
will give identical results.
This commit will convert over existing files saved by earlier 2.5 versions to
work generally the same, though there may be some slight differences with
things like textures. Now that we're set on changing other areas of shading,
this won't be too disruptive overall.
I've made a diagram explaining the pipeline here:
http://mke3.net/blender/devel/2.5/25_linear_workflow_pipeline.png
and some docs here:
http://www.blender.org/development/release-logs/blender-250/color-management/
2009-12-02 07:56:34 +00:00
|
|
|
float col[3];
|
2012-02-22 16:52:06 +00:00
|
|
|
if (Gtexdraw.color_profile) linearrgb_to_srgb_v3_v3(col, &ma->r);
|
Changes to Color Management
After testing and feedback, I've decided to slightly modify the way color
management works internally. While the previous method worked well for
rendering, was a smaller transition and had some advantages over this
new method, it was a bit more ambiguous, and was making things difficult
for other areas such as compositing.
This implementation now considers all color data (with only a couple of
exceptions such as brush colors) to be stored in linear RGB color space,
rather than sRGB as previously. This brings it in line with Nuke, which also
operates this way, quite successfully. Color swatches, pickers, color ramp
display are now gamma corrected to display gamma so you can see what
you're doing, but the numbers themselves are considered linear. This
makes understanding blending modes more clear (a 0.5 value on overlay
will not change the result now) as well as making color swatches act more
predictably in the compositor, however bringing over color values from
applications like photoshop or gimp, that operate in a gamma space,
will give identical results.
This commit will convert over existing files saved by earlier 2.5 versions to
work generally the same, though there may be some slight differences with
things like textures. Now that we're set on changing other areas of shading,
this won't be too disruptive overall.
I've made a diagram explaining the pipeline here:
http://mke3.net/blender/devel/2.5/25_linear_workflow_pipeline.png
and some docs here:
http://www.blender.org/development/release-logs/blender-250/color-management/
2009-12-02 07:56:34 +00:00
|
|
|
else copy_v3_v3(col, &ma->r);
|
|
|
|
|
|
|
|
|
|
glColor3fv(col);
|
|
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
else glColor3f(1.0, 1.0, 1.0);
|
|
|
|
|
}
|
|
|
|
|
return 2; /* Don't set color */
|
2012-02-22 16:52:06 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2008-12-19 12:14:58 +00:00
|
|
|
return 1; /* Set color from mcol */
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-10-04 11:42:44 +00:00
|
|
|
|
2011-11-10 12:28:26 +00:00
|
|
|
static int draw_mcol__set_draw_legacy(MTFace *UNUSED(tface), int has_mcol, int UNUSED(matnr))
|
2011-06-17 18:04:56 +00:00
|
|
|
{
|
2011-10-04 12:27:48 +00:00
|
|
|
if (has_mcol) return 1;
|
2011-06-17 18:04:56 +00:00
|
|
|
else return 2;
|
|
|
|
|
}
|
2011-10-04 11:42:44 +00:00
|
|
|
|
2011-09-23 18:29:45 +00:00
|
|
|
static int draw_tface__set_draw(MTFace *tface, int has_mcol, int matnr)
|
2009-10-22 23:22:05 +00:00
|
|
|
{
|
TexFace to Material Settings big patch
Summary:
========
The idea here is to move the texface options into the material panel.
For images with the change please visit:
http://code.blender.org/index.php/2011/09/bge-material-texface-changes
1 - Some of the legacy problems 2.49 and 2.5x has with the texface system:
==========================================================================
1.1) Shadow, Bilboard and Halo are mutual exclusive (in the code), yet you can
select a face to be more than one mode.
1.2) Sort only works for blend Alpha yet it's an option regardless of the
Transparency Blend you pick.
1.3) Shared doesn't affect anything in BGE.
1.4) ObColor only works for Text objects (old bitmap texts) when using Texture
Face Materials. (not address yet, I so far ignored obcolor)
2 - Notes:
============
2.1) Now "Use Face Textures" in material Option panel will work in Multitexture
even if there is no texture channel.
2.2) In FaceTexture mode it will use TexFace all the time, even if you don't
check the "Use Texture Face" option in the UI. It's a matter of decision, since
the code for either way is there. I decided by the solution that makes the
creation of a material fast - in this mode the user doesn't need to mess with
textures or this "Use Texture Face" option at all. I'm not strong in my opinion
here. But I think if we don't have this then what is the point of the Texture
Face mode?
2.3) I kept references for tface only when we need the image, UV or the tiling
setting. It should help later when/if we split the Image and UV layers from the
tface struct (Campbell and Brecht proposal).
3 - Changes in a Nutshell:
==========================
3.1) "Texture Face" panel (in the Mesh/Object Data panel) no longer exists. Those settings are all part of the material properties, visible when Game Render is set.
3.2) "Texture Face" Shading mode (in the Render panel) is now called “Single Texture”, it needs a material for special settings (e.g. Billboard, Alpha Sort, …).
3.3) New options in the Material Panel
* Shadeless option in the Material panel is now supported for all three Shading modes.
* Physics is now toggleable, this is the old Collision option.
* Two Side (on) is now called Back Culling (off).
* Alpha Sort is one of the Alpha options, together (and mutually exclusive) to Alpha Blend, Alpha Clip, Add and Opaque (i.e. solid).
* Shadow, Billboard and Halo are grouped in the “Face Orientation” property.
* "Face Textures" and "Face Textures Alpha" (under Options) can be used for all but GLSL shading mode (to be supported in GLSL eventually).
* The backend in the game engine is still the same as before. The only changes are in the interface and in the way you need to think your materials. The bottomline is: It’s no longer possible to share materials between faces that do not share the same game properties.
4 - Acknowledgment:
==================
Mike Pan for the design discussions, and testing along the whole development process.
Vitor Balbio for the first hands-on code with the interface changes. That helped me a lot to push me into work on that.
Benoit Bolsee and Brecht van Lommel for patch review (* no one reviewed the whole patch, or the latest iteractions, so I still hold liability for any problems).
Blender artists that gave feedback and helped testing the patch.
Patch review and original documentation can be found here:
http://wiki.blender.org/index.php/User:Dfelinto/TexFace
http://codereview.appspot.com/4289041/
2011-09-19 19:55:59 +00:00
|
|
|
Material *ma= give_current_material(Gtexdraw.ob, matnr+1);
|
2009-10-22 23:22:05 +00:00
|
|
|
|
TexFace to Material Settings big patch
Summary:
========
The idea here is to move the texface options into the material panel.
For images with the change please visit:
http://code.blender.org/index.php/2011/09/bge-material-texface-changes
1 - Some of the legacy problems 2.49 and 2.5x has with the texface system:
==========================================================================
1.1) Shadow, Bilboard and Halo are mutual exclusive (in the code), yet you can
select a face to be more than one mode.
1.2) Sort only works for blend Alpha yet it's an option regardless of the
Transparency Blend you pick.
1.3) Shared doesn't affect anything in BGE.
1.4) ObColor only works for Text objects (old bitmap texts) when using Texture
Face Materials. (not address yet, I so far ignored obcolor)
2 - Notes:
============
2.1) Now "Use Face Textures" in material Option panel will work in Multitexture
even if there is no texture channel.
2.2) In FaceTexture mode it will use TexFace all the time, even if you don't
check the "Use Texture Face" option in the UI. It's a matter of decision, since
the code for either way is there. I decided by the solution that makes the
creation of a material fast - in this mode the user doesn't need to mess with
textures or this "Use Texture Face" option at all. I'm not strong in my opinion
here. But I think if we don't have this then what is the point of the Texture
Face mode?
2.3) I kept references for tface only when we need the image, UV or the tiling
setting. It should help later when/if we split the Image and UV layers from the
tface struct (Campbell and Brecht proposal).
3 - Changes in a Nutshell:
==========================
3.1) "Texture Face" panel (in the Mesh/Object Data panel) no longer exists. Those settings are all part of the material properties, visible when Game Render is set.
3.2) "Texture Face" Shading mode (in the Render panel) is now called “Single Texture”, it needs a material for special settings (e.g. Billboard, Alpha Sort, …).
3.3) New options in the Material Panel
* Shadeless option in the Material panel is now supported for all three Shading modes.
* Physics is now toggleable, this is the old Collision option.
* Two Side (on) is now called Back Culling (off).
* Alpha Sort is one of the Alpha options, together (and mutually exclusive) to Alpha Blend, Alpha Clip, Add and Opaque (i.e. solid).
* Shadow, Billboard and Halo are grouped in the “Face Orientation” property.
* "Face Textures" and "Face Textures Alpha" (under Options) can be used for all but GLSL shading mode (to be supported in GLSL eventually).
* The backend in the game engine is still the same as before. The only changes are in the interface and in the way you need to think your materials. The bottomline is: It’s no longer possible to share materials between faces that do not share the same game properties.
4 - Acknowledgment:
==================
Mike Pan for the design discussions, and testing along the whole development process.
Vitor Balbio for the first hands-on code with the interface changes. That helped me a lot to push me into work on that.
Benoit Bolsee and Brecht van Lommel for patch review (* no one reviewed the whole patch, or the latest iteractions, so I still hold liability for any problems).
Blender artists that gave feedback and helped testing the patch.
Patch review and original documentation can be found here:
http://wiki.blender.org/index.php/User:Dfelinto/TexFace
http://codereview.appspot.com/4289041/
2011-09-19 19:55:59 +00:00
|
|
|
if (ma && (ma->game.flag & GEMAT_INVISIBLE)) return 0;
|
|
|
|
|
|
|
|
|
|
if (tface && set_draw_settings_cached(0, tface, ma, Gtexdraw)) {
|
2009-10-22 23:22:05 +00:00
|
|
|
return 2; /* Don't set color */
|
2012-02-22 16:52:06 +00:00
|
|
|
}
|
|
|
|
|
else if (tface && tface->mode&TF_OBCOL) {
|
2009-10-22 23:22:05 +00:00
|
|
|
return 2; /* Don't set color */
|
2012-02-22 16:52:06 +00:00
|
|
|
}
|
|
|
|
|
else if (!has_mcol) {
|
2010-06-23 16:35:42 +00:00
|
|
|
return 1; /* Don't set color */
|
2012-02-22 16:52:06 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2009-10-22 23:22:05 +00:00
|
|
|
return 1; /* Set color from mcol */
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
static void add_tface_color_layer(DerivedMesh *dm)
|
|
|
|
|
{
|
2011-11-29 05:09:54 +00:00
|
|
|
MTFace *tface = DM_get_poly_data_layer(dm, CD_MTFACE);
|
2009-10-22 23:22:05 +00:00
|
|
|
MFace *mface = dm->getTessFaceArray(dm);
|
|
|
|
|
MCol *finalCol;
|
|
|
|
|
int i,j;
|
|
|
|
|
MCol *mcol = dm->getTessFaceDataArray(dm, CD_WEIGHT_MCOL);
|
2012-02-22 16:52:06 +00:00
|
|
|
if (!mcol)
|
2009-10-22 23:22:05 +00:00
|
|
|
mcol = dm->getTessFaceDataArray(dm, CD_MCOL);
|
|
|
|
|
|
|
|
|
|
finalCol = MEM_mallocN(sizeof(MCol)*4*dm->getNumTessFaces(dm),"add_tface_color_layer");
|
2012-02-22 16:52:06 +00:00
|
|
|
for (i=0;i<dm->getNumTessFaces(dm);i++) {
|
TexFace to Material Settings big patch
Summary:
========
The idea here is to move the texface options into the material panel.
For images with the change please visit:
http://code.blender.org/index.php/2011/09/bge-material-texface-changes
1 - Some of the legacy problems 2.49 and 2.5x has with the texface system:
==========================================================================
1.1) Shadow, Bilboard and Halo are mutual exclusive (in the code), yet you can
select a face to be more than one mode.
1.2) Sort only works for blend Alpha yet it's an option regardless of the
Transparency Blend you pick.
1.3) Shared doesn't affect anything in BGE.
1.4) ObColor only works for Text objects (old bitmap texts) when using Texture
Face Materials. (not address yet, I so far ignored obcolor)
2 - Notes:
============
2.1) Now "Use Face Textures" in material Option panel will work in Multitexture
even if there is no texture channel.
2.2) In FaceTexture mode it will use TexFace all the time, even if you don't
check the "Use Texture Face" option in the UI. It's a matter of decision, since
the code for either way is there. I decided by the solution that makes the
creation of a material fast - in this mode the user doesn't need to mess with
textures or this "Use Texture Face" option at all. I'm not strong in my opinion
here. But I think if we don't have this then what is the point of the Texture
Face mode?
2.3) I kept references for tface only when we need the image, UV or the tiling
setting. It should help later when/if we split the Image and UV layers from the
tface struct (Campbell and Brecht proposal).
3 - Changes in a Nutshell:
==========================
3.1) "Texture Face" panel (in the Mesh/Object Data panel) no longer exists. Those settings are all part of the material properties, visible when Game Render is set.
3.2) "Texture Face" Shading mode (in the Render panel) is now called “Single Texture”, it needs a material for special settings (e.g. Billboard, Alpha Sort, …).
3.3) New options in the Material Panel
* Shadeless option in the Material panel is now supported for all three Shading modes.
* Physics is now toggleable, this is the old Collision option.
* Two Side (on) is now called Back Culling (off).
* Alpha Sort is one of the Alpha options, together (and mutually exclusive) to Alpha Blend, Alpha Clip, Add and Opaque (i.e. solid).
* Shadow, Billboard and Halo are grouped in the “Face Orientation” property.
* "Face Textures" and "Face Textures Alpha" (under Options) can be used for all but GLSL shading mode (to be supported in GLSL eventually).
* The backend in the game engine is still the same as before. The only changes are in the interface and in the way you need to think your materials. The bottomline is: It’s no longer possible to share materials between faces that do not share the same game properties.
4 - Acknowledgment:
==================
Mike Pan for the design discussions, and testing along the whole development process.
Vitor Balbio for the first hands-on code with the interface changes. That helped me a lot to push me into work on that.
Benoit Bolsee and Brecht van Lommel for patch review (* no one reviewed the whole patch, or the latest iteractions, so I still hold liability for any problems).
Blender artists that gave feedback and helped testing the patch.
Patch review and original documentation can be found here:
http://wiki.blender.org/index.php/User:Dfelinto/TexFace
http://codereview.appspot.com/4289041/
2011-09-19 19:55:59 +00:00
|
|
|
Material *ma= give_current_material(Gtexdraw.ob, mface[i].mat_nr+1);
|
|
|
|
|
|
|
|
|
|
if (ma && (ma->game.flag&GEMAT_INVISIBLE)) {
|
2012-02-22 16:52:06 +00:00
|
|
|
if ( mcol )
|
2009-10-22 23:22:05 +00:00
|
|
|
memcpy(&finalCol[i*4],&mcol[i*4],sizeof(MCol)*4);
|
|
|
|
|
else
|
2012-02-22 16:52:06 +00:00
|
|
|
for (j=0;j<4;j++) {
|
2009-10-22 23:22:05 +00:00
|
|
|
finalCol[i*4+j].b = 255;
|
|
|
|
|
finalCol[i*4+j].g = 255;
|
|
|
|
|
finalCol[i*4+j].r = 255;
|
|
|
|
|
}
|
|
|
|
|
}
|
TexFace to Material Settings big patch
Summary:
========
The idea here is to move the texface options into the material panel.
For images with the change please visit:
http://code.blender.org/index.php/2011/09/bge-material-texface-changes
1 - Some of the legacy problems 2.49 and 2.5x has with the texface system:
==========================================================================
1.1) Shadow, Bilboard and Halo are mutual exclusive (in the code), yet you can
select a face to be more than one mode.
1.2) Sort only works for blend Alpha yet it's an option regardless of the
Transparency Blend you pick.
1.3) Shared doesn't affect anything in BGE.
1.4) ObColor only works for Text objects (old bitmap texts) when using Texture
Face Materials. (not address yet, I so far ignored obcolor)
2 - Notes:
============
2.1) Now "Use Face Textures" in material Option panel will work in Multitexture
even if there is no texture channel.
2.2) In FaceTexture mode it will use TexFace all the time, even if you don't
check the "Use Texture Face" option in the UI. It's a matter of decision, since
the code for either way is there. I decided by the solution that makes the
creation of a material fast - in this mode the user doesn't need to mess with
textures or this "Use Texture Face" option at all. I'm not strong in my opinion
here. But I think if we don't have this then what is the point of the Texture
Face mode?
2.3) I kept references for tface only when we need the image, UV or the tiling
setting. It should help later when/if we split the Image and UV layers from the
tface struct (Campbell and Brecht proposal).
3 - Changes in a Nutshell:
==========================
3.1) "Texture Face" panel (in the Mesh/Object Data panel) no longer exists. Those settings are all part of the material properties, visible when Game Render is set.
3.2) "Texture Face" Shading mode (in the Render panel) is now called “Single Texture”, it needs a material for special settings (e.g. Billboard, Alpha Sort, …).
3.3) New options in the Material Panel
* Shadeless option in the Material panel is now supported for all three Shading modes.
* Physics is now toggleable, this is the old Collision option.
* Two Side (on) is now called Back Culling (off).
* Alpha Sort is one of the Alpha options, together (and mutually exclusive) to Alpha Blend, Alpha Clip, Add and Opaque (i.e. solid).
* Shadow, Billboard and Halo are grouped in the “Face Orientation” property.
* "Face Textures" and "Face Textures Alpha" (under Options) can be used for all but GLSL shading mode (to be supported in GLSL eventually).
* The backend in the game engine is still the same as before. The only changes are in the interface and in the way you need to think your materials. The bottomline is: It’s no longer possible to share materials between faces that do not share the same game properties.
4 - Acknowledgment:
==================
Mike Pan for the design discussions, and testing along the whole development process.
Vitor Balbio for the first hands-on code with the interface changes. That helped me a lot to push me into work on that.
Benoit Bolsee and Brecht van Lommel for patch review (* no one reviewed the whole patch, or the latest iteractions, so I still hold liability for any problems).
Blender artists that gave feedback and helped testing the patch.
Patch review and original documentation can be found here:
http://wiki.blender.org/index.php/User:Dfelinto/TexFace
http://codereview.appspot.com/4289041/
2011-09-19 19:55:59 +00:00
|
|
|
else if (tface && mface && set_draw_settings_cached(0, tface, ma, Gtexdraw)) {
|
2012-02-22 16:52:06 +00:00
|
|
|
for (j=0;j<4;j++) {
|
2009-10-22 23:22:05 +00:00
|
|
|
finalCol[i*4+j].b = 255;
|
|
|
|
|
finalCol[i*4+j].g = 0;
|
|
|
|
|
finalCol[i*4+j].r = 255;
|
|
|
|
|
}
|
2012-02-22 16:52:06 +00:00
|
|
|
}
|
|
|
|
|
else if (tface && tface->mode&TF_OBCOL) {
|
|
|
|
|
for (j=0;j<4;j++) {
|
2011-10-10 00:01:44 +00:00
|
|
|
finalCol[i*4+j].b = FTOCHAR(Gtexdraw.obcol[0]);
|
2010-06-23 16:35:42 +00:00
|
|
|
finalCol[i*4+j].g = FTOCHAR(Gtexdraw.obcol[1]);
|
2011-10-10 00:01:44 +00:00
|
|
|
finalCol[i*4+j].r = FTOCHAR(Gtexdraw.obcol[2]);
|
2009-10-22 23:22:05 +00:00
|
|
|
}
|
2012-02-22 16:52:06 +00:00
|
|
|
}
|
|
|
|
|
else if (!mcol) {
|
2009-10-22 23:22:05 +00:00
|
|
|
if (tface) {
|
2012-02-22 16:52:06 +00:00
|
|
|
for (j=0;j<4;j++) {
|
2009-10-22 23:22:05 +00:00
|
|
|
finalCol[i*4+j].b = 255;
|
|
|
|
|
finalCol[i*4+j].g = 255;
|
|
|
|
|
finalCol[i*4+j].r = 255;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
Changes to Color Management
After testing and feedback, I've decided to slightly modify the way color
management works internally. While the previous method worked well for
rendering, was a smaller transition and had some advantages over this
new method, it was a bit more ambiguous, and was making things difficult
for other areas such as compositing.
This implementation now considers all color data (with only a couple of
exceptions such as brush colors) to be stored in linear RGB color space,
rather than sRGB as previously. This brings it in line with Nuke, which also
operates this way, quite successfully. Color swatches, pickers, color ramp
display are now gamma corrected to display gamma so you can see what
you're doing, but the numbers themselves are considered linear. This
makes understanding blending modes more clear (a 0.5 value on overlay
will not change the result now) as well as making color swatches act more
predictably in the compositor, however bringing over color values from
applications like photoshop or gimp, that operate in a gamma space,
will give identical results.
This commit will convert over existing files saved by earlier 2.5 versions to
work generally the same, though there may be some slight differences with
things like textures. Now that we're set on changing other areas of shading,
this won't be too disruptive overall.
I've made a diagram explaining the pipeline here:
http://mke3.net/blender/devel/2.5/25_linear_workflow_pipeline.png
and some docs here:
http://www.blender.org/development/release-logs/blender-250/color-management/
2009-12-02 07:56:34 +00:00
|
|
|
float col[3];
|
2009-10-22 23:22:05 +00:00
|
|
|
Material *ma= give_current_material(Gtexdraw.ob, mface[i].mat_nr+1);
|
Changes to Color Management
After testing and feedback, I've decided to slightly modify the way color
management works internally. While the previous method worked well for
rendering, was a smaller transition and had some advantages over this
new method, it was a bit more ambiguous, and was making things difficult
for other areas such as compositing.
This implementation now considers all color data (with only a couple of
exceptions such as brush colors) to be stored in linear RGB color space,
rather than sRGB as previously. This brings it in line with Nuke, which also
operates this way, quite successfully. Color swatches, pickers, color ramp
display are now gamma corrected to display gamma so you can see what
you're doing, but the numbers themselves are considered linear. This
makes understanding blending modes more clear (a 0.5 value on overlay
will not change the result now) as well as making color swatches act more
predictably in the compositor, however bringing over color values from
applications like photoshop or gimp, that operate in a gamma space,
will give identical results.
This commit will convert over existing files saved by earlier 2.5 versions to
work generally the same, though there may be some slight differences with
things like textures. Now that we're set on changing other areas of shading,
this won't be too disruptive overall.
I've made a diagram explaining the pipeline here:
http://mke3.net/blender/devel/2.5/25_linear_workflow_pipeline.png
and some docs here:
http://www.blender.org/development/release-logs/blender-250/color-management/
2009-12-02 07:56:34 +00:00
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (ma) {
|
|
|
|
|
if (Gtexdraw.color_profile) linearrgb_to_srgb_v3_v3(col, &ma->r);
|
Changes to Color Management
After testing and feedback, I've decided to slightly modify the way color
management works internally. While the previous method worked well for
rendering, was a smaller transition and had some advantages over this
new method, it was a bit more ambiguous, and was making things difficult
for other areas such as compositing.
This implementation now considers all color data (with only a couple of
exceptions such as brush colors) to be stored in linear RGB color space,
rather than sRGB as previously. This brings it in line with Nuke, which also
operates this way, quite successfully. Color swatches, pickers, color ramp
display are now gamma corrected to display gamma so you can see what
you're doing, but the numbers themselves are considered linear. This
makes understanding blending modes more clear (a 0.5 value on overlay
will not change the result now) as well as making color swatches act more
predictably in the compositor, however bringing over color values from
applications like photoshop or gimp, that operate in a gamma space,
will give identical results.
This commit will convert over existing files saved by earlier 2.5 versions to
work generally the same, though there may be some slight differences with
things like textures. Now that we're set on changing other areas of shading,
this won't be too disruptive overall.
I've made a diagram explaining the pipeline here:
http://mke3.net/blender/devel/2.5/25_linear_workflow_pipeline.png
and some docs here:
http://www.blender.org/development/release-logs/blender-250/color-management/
2009-12-02 07:56:34 +00:00
|
|
|
else copy_v3_v3(col, &ma->r);
|
|
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
for (j=0;j<4;j++) {
|
2011-10-10 00:01:44 +00:00
|
|
|
finalCol[i*4+j].b = FTOCHAR(col[0]);
|
2010-06-23 16:35:42 +00:00
|
|
|
finalCol[i*4+j].g = FTOCHAR(col[1]);
|
2011-10-10 00:01:44 +00:00
|
|
|
finalCol[i*4+j].r = FTOCHAR(col[2]);
|
2009-10-22 23:22:05 +00:00
|
|
|
}
|
Changes to Color Management
After testing and feedback, I've decided to slightly modify the way color
management works internally. While the previous method worked well for
rendering, was a smaller transition and had some advantages over this
new method, it was a bit more ambiguous, and was making things difficult
for other areas such as compositing.
This implementation now considers all color data (with only a couple of
exceptions such as brush colors) to be stored in linear RGB color space,
rather than sRGB as previously. This brings it in line with Nuke, which also
operates this way, quite successfully. Color swatches, pickers, color ramp
display are now gamma corrected to display gamma so you can see what
you're doing, but the numbers themselves are considered linear. This
makes understanding blending modes more clear (a 0.5 value on overlay
will not change the result now) as well as making color swatches act more
predictably in the compositor, however bringing over color values from
applications like photoshop or gimp, that operate in a gamma space,
will give identical results.
This commit will convert over existing files saved by earlier 2.5 versions to
work generally the same, though there may be some slight differences with
things like textures. Now that we're set on changing other areas of shading,
this won't be too disruptive overall.
I've made a diagram explaining the pipeline here:
http://mke3.net/blender/devel/2.5/25_linear_workflow_pipeline.png
and some docs here:
http://www.blender.org/development/release-logs/blender-250/color-management/
2009-12-02 07:56:34 +00:00
|
|
|
}
|
2009-10-22 23:22:05 +00:00
|
|
|
else
|
2012-02-22 16:52:06 +00:00
|
|
|
for (j=0;j<4;j++) {
|
2009-10-22 23:22:05 +00:00
|
|
|
finalCol[i*4+j].b = 255;
|
|
|
|
|
finalCol[i*4+j].g = 255;
|
|
|
|
|
finalCol[i*4+j].r = 255;
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-02-22 16:52:06 +00:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
for (j=0;j<4;j++) {
|
2011-10-10 00:01:44 +00:00
|
|
|
finalCol[i*4+j].r = mcol[i*4+j].r;
|
2009-10-22 23:22:05 +00:00
|
|
|
finalCol[i*4+j].g = mcol[i*4+j].g;
|
2011-10-10 00:01:44 +00:00
|
|
|
finalCol[i*4+j].b = mcol[i*4+j].b;
|
2009-10-22 23:22:05 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-11-30 18:03:56 +00:00
|
|
|
CustomData_add_layer( &dm->faceData, CD_TEXTURE_MCOL, CD_ASSIGN, finalCol, dm->numTessFaceData );
|
2009-10-22 23:22:05 +00:00
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
static int draw_tface_mapped__set_draw(void *userData, int index)
|
|
|
|
|
{
|
2012-02-08 09:07:24 +00:00
|
|
|
Mesh *me = (Mesh *)userData;
|
2009-07-24 10:43:58 +00:00
|
|
|
|
2012-02-08 09:07:24 +00:00
|
|
|
/* array checked for NULL before calling */
|
|
|
|
|
MPoly *mpoly = &me->mpoly[index];
|
2011-11-13 15:13:59 +00:00
|
|
|
|
2012-02-08 09:07:24 +00:00
|
|
|
BLI_assert(index >= 0 && index < me->totpoly);
|
2009-07-24 10:43:58 +00:00
|
|
|
|
2012-02-08 09:07:24 +00:00
|
|
|
if (mpoly->flag & ME_HIDE) {
|
|
|
|
|
return 0;
|
2009-07-24 10:43:58 +00:00
|
|
|
}
|
2012-02-08 09:07:24 +00:00
|
|
|
else {
|
|
|
|
|
MTexPoly *tpoly = (me->mtpoly) ? &me->mtpoly[index] : NULL;
|
|
|
|
|
MTFace mtf= {{{0}}};
|
|
|
|
|
int matnr = mpoly->mat_nr;
|
2009-07-24 10:43:58 +00:00
|
|
|
|
2012-02-08 09:07:24 +00:00
|
|
|
if (tpoly) {
|
|
|
|
|
ME_MTEXFACE_CPY(&mtf, tpoly);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return draw_tface__set_draw(&mtf, (me->mloopcol != NULL), matnr);
|
|
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int draw_em_tf_mapped__set_draw(void *userData, int index)
|
|
|
|
|
{
|
2011-12-20 08:47:36 +00:00
|
|
|
drawEMTFMapped_userData *data = userData;
|
2011-09-24 11:03:52 +00:00
|
|
|
BMEditMesh *em = data->em;
|
2009-07-24 10:43:58 +00:00
|
|
|
BMFace *efa= EDBM_get_face_for_index(em, index);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-02-12 10:51:45 +00:00
|
|
|
if (efa==NULL || BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) {
|
2008-12-19 12:14:58 +00:00
|
|
|
return 0;
|
2011-09-24 11:03:52 +00:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
MTFace mtf= {{{0}}};
|
|
|
|
|
int matnr = efa->mat_nr;
|
|
|
|
|
|
|
|
|
|
if (data->has_mtface) {
|
|
|
|
|
MTexPoly *tpoly = CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY);
|
2012-02-08 09:02:10 +00:00
|
|
|
ME_MTEXFACE_CPY(&mtf, tpoly);
|
2011-09-24 11:03:52 +00:00
|
|
|
}
|
2009-07-25 14:13:26 +00:00
|
|
|
|
2011-09-24 11:03:52 +00:00
|
|
|
return draw_tface__set_draw_legacy(&mtf, data->has_mcol, matnr);
|
2009-07-24 10:43:58 +00:00
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
2012-01-11 07:03:47 +00:00
|
|
|
static int wpaint__setSolidDrawOptions_material(void *userData, int index, int *drawSmooth_r)
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
|
|
|
|
Mesh *me = (Mesh*)userData;
|
TexFace to Material Settings big patch
Summary:
========
The idea here is to move the texface options into the material panel.
For images with the change please visit:
http://code.blender.org/index.php/2011/09/bge-material-texface-changes
1 - Some of the legacy problems 2.49 and 2.5x has with the texface system:
==========================================================================
1.1) Shadow, Bilboard and Halo are mutual exclusive (in the code), yet you can
select a face to be more than one mode.
1.2) Sort only works for blend Alpha yet it's an option regardless of the
Transparency Blend you pick.
1.3) Shared doesn't affect anything in BGE.
1.4) ObColor only works for Text objects (old bitmap texts) when using Texture
Face Materials. (not address yet, I so far ignored obcolor)
2 - Notes:
============
2.1) Now "Use Face Textures" in material Option panel will work in Multitexture
even if there is no texture channel.
2.2) In FaceTexture mode it will use TexFace all the time, even if you don't
check the "Use Texture Face" option in the UI. It's a matter of decision, since
the code for either way is there. I decided by the solution that makes the
creation of a material fast - in this mode the user doesn't need to mess with
textures or this "Use Texture Face" option at all. I'm not strong in my opinion
here. But I think if we don't have this then what is the point of the Texture
Face mode?
2.3) I kept references for tface only when we need the image, UV or the tiling
setting. It should help later when/if we split the Image and UV layers from the
tface struct (Campbell and Brecht proposal).
3 - Changes in a Nutshell:
==========================
3.1) "Texture Face" panel (in the Mesh/Object Data panel) no longer exists. Those settings are all part of the material properties, visible when Game Render is set.
3.2) "Texture Face" Shading mode (in the Render panel) is now called “Single Texture”, it needs a material for special settings (e.g. Billboard, Alpha Sort, …).
3.3) New options in the Material Panel
* Shadeless option in the Material panel is now supported for all three Shading modes.
* Physics is now toggleable, this is the old Collision option.
* Two Side (on) is now called Back Culling (off).
* Alpha Sort is one of the Alpha options, together (and mutually exclusive) to Alpha Blend, Alpha Clip, Add and Opaque (i.e. solid).
* Shadow, Billboard and Halo are grouped in the “Face Orientation” property.
* "Face Textures" and "Face Textures Alpha" (under Options) can be used for all but GLSL shading mode (to be supported in GLSL eventually).
* The backend in the game engine is still the same as before. The only changes are in the interface and in the way you need to think your materials. The bottomline is: It’s no longer possible to share materials between faces that do not share the same game properties.
4 - Acknowledgment:
==================
Mike Pan for the design discussions, and testing along the whole development process.
Vitor Balbio for the first hands-on code with the interface changes. That helped me a lot to push me into work on that.
Benoit Bolsee and Brecht van Lommel for patch review (* no one reviewed the whole patch, or the latest iteractions, so I still hold liability for any problems).
Blender artists that gave feedback and helped testing the patch.
Patch review and original documentation can be found here:
http://wiki.blender.org/index.php/User:Dfelinto/TexFace
http://codereview.appspot.com/4289041/
2011-09-19 19:55:59 +00:00
|
|
|
|
2011-11-23 18:53:49 +00:00
|
|
|
if (me->mat && me->mpoly) {
|
|
|
|
|
Material *ma= me->mat[me->mpoly[index].mat_nr];
|
2011-09-20 04:45:01 +00:00
|
|
|
if (ma && (ma->game.flag & GEMAT_INVISIBLE)) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2010-10-07 10:04:07 +00:00
|
|
|
}
|
|
|
|
|
|
2008-12-19 12:14:58 +00:00
|
|
|
*drawSmooth_r = 1;
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2012-01-11 07:03:47 +00:00
|
|
|
/* when face select is on, use face hidden flag */
|
|
|
|
|
static int wpaint__setSolidDrawOptions_facemask(void *userData, int index, int *drawSmooth_r)
|
|
|
|
|
{
|
|
|
|
|
Mesh *me = (Mesh*)userData;
|
2012-02-05 03:25:13 +00:00
|
|
|
MPoly *mp = &me->mpoly[index];
|
|
|
|
|
if (mp->flag & ME_HIDE) return 0;
|
2012-01-11 07:03:47 +00:00
|
|
|
*drawSmooth_r = 1;
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-14 17:55:27 +00:00
|
|
|
static void draw_mesh_text(Scene *scene, Object *ob, int glsl)
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
|
|
|
|
Mesh *me = ob->data;
|
|
|
|
|
DerivedMesh *ddm;
|
2012-02-08 09:07:24 +00:00
|
|
|
MPoly *mp, *mface = me->mpoly;
|
|
|
|
|
MTexPoly *mtpoly = me->mtpoly;
|
|
|
|
|
MLoopUV *mloopuv = me->mloopuv;
|
|
|
|
|
MLoopUV *luv;
|
|
|
|
|
MLoopCol *mloopcol = me->mloopcol; /* why does mcol exist? */
|
|
|
|
|
MLoopCol *lcol;
|
|
|
|
|
|
2008-12-19 12:14:58 +00:00
|
|
|
bProperty *prop = get_ob_property(ob, "Text");
|
|
|
|
|
GPUVertexAttribs gattribs;
|
2012-02-08 09:07:24 +00:00
|
|
|
int a, totpoly = me->totpoly;
|
|
|
|
|
|
|
|
|
|
/* fake values to pass to GPU_render_text() */
|
|
|
|
|
MCol tmp_mcol[4] = {{0}};
|
|
|
|
|
MCol *tmp_mcol_pt = mloopcol ? tmp_mcol : NULL;
|
|
|
|
|
MTFace tmp_tf = {{{0}}};
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
/* don't draw without tfaces */
|
2012-02-22 16:52:06 +00:00
|
|
|
if (!mtpoly || !mloopuv)
|
2008-12-19 12:14:58 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
/* don't draw when editing */
|
2012-02-22 16:52:06 +00:00
|
|
|
if (ob->mode & OB_MODE_EDIT)
|
2008-12-19 12:14:58 +00:00
|
|
|
return;
|
2012-02-22 16:52:06 +00:00
|
|
|
else if (ob==OBACT)
|
|
|
|
|
if (paint_facesel_test(ob) || paint_vertsel_test(ob))
|
2008-12-19 12:14:58 +00:00
|
|
|
return;
|
|
|
|
|
|
2009-01-04 14:14:06 +00:00
|
|
|
ddm = mesh_get_derived_deform(scene, ob, CD_MASK_BAREMESH);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
for (a=0, mp=mface; a<totpoly ; a++, mtpoly++, mp++) {
|
2012-02-08 09:07:24 +00:00
|
|
|
short matnr= mp->mat_nr;
|
|
|
|
|
int mf_smooth= mp->flag & ME_SMOOTH;
|
TexFace to Material Settings big patch
Summary:
========
The idea here is to move the texface options into the material panel.
For images with the change please visit:
http://code.blender.org/index.php/2011/09/bge-material-texface-changes
1 - Some of the legacy problems 2.49 and 2.5x has with the texface system:
==========================================================================
1.1) Shadow, Bilboard and Halo are mutual exclusive (in the code), yet you can
select a face to be more than one mode.
1.2) Sort only works for blend Alpha yet it's an option regardless of the
Transparency Blend you pick.
1.3) Shared doesn't affect anything in BGE.
1.4) ObColor only works for Text objects (old bitmap texts) when using Texture
Face Materials. (not address yet, I so far ignored obcolor)
2 - Notes:
============
2.1) Now "Use Face Textures" in material Option panel will work in Multitexture
even if there is no texture channel.
2.2) In FaceTexture mode it will use TexFace all the time, even if you don't
check the "Use Texture Face" option in the UI. It's a matter of decision, since
the code for either way is there. I decided by the solution that makes the
creation of a material fast - in this mode the user doesn't need to mess with
textures or this "Use Texture Face" option at all. I'm not strong in my opinion
here. But I think if we don't have this then what is the point of the Texture
Face mode?
2.3) I kept references for tface only when we need the image, UV or the tiling
setting. It should help later when/if we split the Image and UV layers from the
tface struct (Campbell and Brecht proposal).
3 - Changes in a Nutshell:
==========================
3.1) "Texture Face" panel (in the Mesh/Object Data panel) no longer exists. Those settings are all part of the material properties, visible when Game Render is set.
3.2) "Texture Face" Shading mode (in the Render panel) is now called “Single Texture”, it needs a material for special settings (e.g. Billboard, Alpha Sort, …).
3.3) New options in the Material Panel
* Shadeless option in the Material panel is now supported for all three Shading modes.
* Physics is now toggleable, this is the old Collision option.
* Two Side (on) is now called Back Culling (off).
* Alpha Sort is one of the Alpha options, together (and mutually exclusive) to Alpha Blend, Alpha Clip, Add and Opaque (i.e. solid).
* Shadow, Billboard and Halo are grouped in the “Face Orientation” property.
* "Face Textures" and "Face Textures Alpha" (under Options) can be used for all but GLSL shading mode (to be supported in GLSL eventually).
* The backend in the game engine is still the same as before. The only changes are in the interface and in the way you need to think your materials. The bottomline is: It’s no longer possible to share materials between faces that do not share the same game properties.
4 - Acknowledgment:
==================
Mike Pan for the design discussions, and testing along the whole development process.
Vitor Balbio for the first hands-on code with the interface changes. That helped me a lot to push me into work on that.
Benoit Bolsee and Brecht van Lommel for patch review (* no one reviewed the whole patch, or the latest iteractions, so I still hold liability for any problems).
Blender artists that gave feedback and helped testing the patch.
Patch review and original documentation can be found here:
http://wiki.blender.org/index.php/User:Dfelinto/TexFace
http://codereview.appspot.com/4289041/
2011-09-19 19:55:59 +00:00
|
|
|
Material *mat = me->mat[matnr];
|
|
|
|
|
int mode= mat->game.flag;
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-02-08 09:07:24 +00:00
|
|
|
if (!(mode&GEMAT_INVISIBLE) && (mode&GEMAT_TEXT) && mp->totloop >= 3) {
|
|
|
|
|
/* get the polygon as a tri/quad */
|
|
|
|
|
int mp_vi[4];
|
2008-12-19 12:14:58 +00:00
|
|
|
float v1[3], v2[3], v3[3], v4[3];
|
|
|
|
|
char string[MAX_PROPSTRING];
|
|
|
|
|
int characters, i, glattrib= -1, badtex= 0;
|
|
|
|
|
|
2012-02-08 09:07:24 +00:00
|
|
|
|
|
|
|
|
/* TEXFACE */
|
|
|
|
|
ME_MTEXFACE_CPY(&tmp_tf, mtpoly);
|
|
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (glsl) {
|
2008-12-19 12:14:58 +00:00
|
|
|
GPU_enable_material(matnr+1, &gattribs);
|
|
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
for (i=0; i<gattribs.totlayer; i++) {
|
|
|
|
|
if (gattribs.layer[i].type == CD_MTFACE) {
|
2008-12-19 12:14:58 +00:00
|
|
|
glattrib = gattribs.layer[i].glindex;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
2012-02-08 09:07:24 +00:00
|
|
|
badtex = set_draw_settings_cached(0, &tmp_tf, mat, Gtexdraw);
|
2008-12-19 12:14:58 +00:00
|
|
|
if (badtex) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-08 09:07:24 +00:00
|
|
|
mp_vi[0] = me->mloop[mp->loopstart + 0].v;
|
|
|
|
|
mp_vi[1] = me->mloop[mp->loopstart + 1].v;
|
|
|
|
|
mp_vi[2] = me->mloop[mp->loopstart + 2].v;
|
|
|
|
|
mp_vi[3] = (mp->totloop >= 4) ? me->mloop[mp->loopstart + 3].v : 0;
|
|
|
|
|
|
|
|
|
|
/* UV */
|
|
|
|
|
luv = &mloopuv[mp->loopstart];
|
|
|
|
|
copy_v2_v2(tmp_tf.uv[0], luv->uv); luv++;
|
|
|
|
|
copy_v2_v2(tmp_tf.uv[1], luv->uv); luv++;
|
|
|
|
|
copy_v2_v2(tmp_tf.uv[2], luv->uv); luv++;
|
|
|
|
|
if (mp->totloop >= 4) {
|
|
|
|
|
copy_v2_v2(tmp_tf.uv[3], luv->uv);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* COLOR */
|
|
|
|
|
if (mloopcol) {
|
|
|
|
|
unsigned int totloop_clamp = MIN2(4, mp->totloop);
|
|
|
|
|
unsigned int j;
|
|
|
|
|
lcol = &mloopcol[mp->loopstart];
|
|
|
|
|
|
|
|
|
|
for (j = 0; j <= totloop_clamp; j++, lcol++) {
|
|
|
|
|
tmp_mcol[j].a = lcol->a;
|
|
|
|
|
tmp_mcol[j].r = lcol->r;
|
|
|
|
|
tmp_mcol[j].g = lcol->g;
|
|
|
|
|
tmp_mcol[j].b = lcol->b;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* LOCATION */
|
|
|
|
|
ddm->getVertCo(ddm, mp_vi[0], v1);
|
|
|
|
|
ddm->getVertCo(ddm, mp_vi[1], v2);
|
2012-02-25 16:04:03 +00:00
|
|
|
ddm->getVertCo(ddm, mp_vi[2], v3);
|
2012-02-08 09:07:24 +00:00
|
|
|
if (mp->totloop >= 4) {
|
|
|
|
|
ddm->getVertCo(ddm, mp_vi[3], v4);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
// The BM_FONT handling is in the gpu module, shared with the
|
|
|
|
|
// game engine, was duplicated previously
|
|
|
|
|
|
|
|
|
|
set_property_valstr(prop, string);
|
|
|
|
|
characters = strlen(string);
|
|
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (!BKE_image_get_ibuf(mtpoly->tpage, NULL))
|
2008-12-19 12:14:58 +00:00
|
|
|
characters = 0;
|
|
|
|
|
|
|
|
|
|
if (!mf_smooth) {
|
|
|
|
|
float nor[3];
|
|
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
normal_tri_v3( nor,v1, v2, v3);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
glNormal3fv(nor);
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-08 09:07:24 +00:00
|
|
|
GPU_render_text(&tmp_tf, mode, string, characters,
|
|
|
|
|
(unsigned int*)tmp_mcol_pt, v1, v2, v3, (mp->totloop >= 4 ? v4: NULL), glattrib);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ddm->release(ddm);
|
|
|
|
|
}
|
|
|
|
|
|
2011-12-01 12:12:39 +00:00
|
|
|
static int compareDrawOptions(void *userData, int cur_index, int next_index)
|
|
|
|
|
{
|
2011-12-20 08:47:36 +00:00
|
|
|
drawTFace_userData *data = userData;
|
2011-12-01 12:12:39 +00:00
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (data->mf && data->mf[cur_index].mat_nr != data->mf[next_index].mat_nr)
|
2011-12-01 12:12:39 +00:00
|
|
|
return 0;
|
|
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (data->tf && data->tf[cur_index].tpage != data->tf[next_index].tpage)
|
2011-12-01 12:12:39 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2011-12-01 18:26:57 +00:00
|
|
|
static int compareDrawOptionsEm(void *userData, int cur_index, int next_index)
|
|
|
|
|
{
|
2011-12-20 08:47:36 +00:00
|
|
|
drawEMTFMapped_userData *data= userData;
|
2011-12-01 18:26:57 +00:00
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (data->mf && data->mf[cur_index].mat_nr != data->mf[next_index].mat_nr)
|
2011-12-01 18:26:57 +00:00
|
|
|
return 0;
|
|
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (data->tf && data->tf[cur_index].tpage != data->tf[next_index].tpage)
|
2011-12-01 18:26:57 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-09 15:46:53 +00:00
|
|
|
void draw_mesh_textured_old(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *ob, DerivedMesh *dm, int draw_flags)
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
|
|
|
|
Mesh *me= ob->data;
|
|
|
|
|
|
|
|
|
|
/* correct for negative scale */
|
2012-02-22 16:52:06 +00:00
|
|
|
if (ob->transflag & OB_NEG_SCALE) glFrontFace(GL_CW);
|
2008-12-19 12:14:58 +00:00
|
|
|
else glFrontFace(GL_CCW);
|
|
|
|
|
|
|
|
|
|
/* draw the textured mesh */
|
2.5
View3D has been split now in a local part (RegionView3D) and a
per-area part (old View3D). Currently local is:
- view transform
- camera zoom/offset
- gpencil (todo)
- custom clipping planes
Rest is in Area still, like active camera, draw type, layers,
localview, custom centers, around-settings, transform widget,
gridlines, and so on (mostly stuff as available in header).
To see it work; also added new feature for region split,
press SHIFT+ALT+CTRL+S for four-split.
The idea is to make a preset 4-split, configured to stick
to top/right/front views for three views.
Another cool idea to explore is to then box-clip all drawing
based on these 3 views.
Note about the code:
- currently view3d still stores some depricated settings, to
convert from older files. Not all settings are copied over
though, like custom clip planes or the 'lock view to object'.
- since some view3d ops are now on area level, the operators
for it should keep track of that.
Bugfix in transform: quat initialize in operator-invoke missed
one zero.
Als brought back GE to compile for missing Ipos and channels.
2009-01-19 16:54:41 +00:00
|
|
|
draw_textured_begin(scene, v3d, rv3d, ob);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2010-11-25 21:59:12 +00:00
|
|
|
glColor4f(1.0f,1.0f,1.0f,1.0f);
|
|
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (ob->mode & OB_MODE_EDIT) {
|
2011-12-20 08:47:36 +00:00
|
|
|
drawEMTFMapped_userData data;
|
2011-09-23 18:29:45 +00:00
|
|
|
|
2011-09-24 11:03:52 +00:00
|
|
|
data.em= me->edit_btmesh;
|
|
|
|
|
data.has_mcol= CustomData_has_layer(&me->edit_btmesh->bm->ldata, CD_MLOOPCOL);
|
|
|
|
|
data.has_mtface= CustomData_has_layer(&me->edit_btmesh->bm->pdata, CD_MTEXPOLY);
|
2011-12-10 05:38:00 +00:00
|
|
|
data.mf= DM_get_tessface_data_layer(dm, CD_MFACE);
|
|
|
|
|
data.tf= DM_get_tessface_data_layer(dm, CD_MTFACE);
|
2011-09-23 18:29:45 +00:00
|
|
|
|
2011-12-01 18:26:57 +00:00
|
|
|
dm->drawMappedFacesTex(dm, draw_em_tf_mapped__set_draw, compareDrawOptionsEm, &data);
|
2011-08-12 18:13:55 +00:00
|
|
|
}
|
2012-02-22 16:52:06 +00:00
|
|
|
else if (draw_flags & DRAW_FACE_SELECT) {
|
|
|
|
|
if (ob->mode & OB_MODE_WEIGHT_PAINT)
|
2012-01-11 07:03:47 +00:00
|
|
|
dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions_facemask, GPU_enable_material, NULL, me, 1);
|
2008-12-19 12:14:58 +00:00
|
|
|
else
|
2011-12-02 01:01:07 +00:00
|
|
|
dm->drawMappedFacesTex(dm, me->mpoly ? draw_tface_mapped__set_draw : NULL, NULL, me);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
2009-02-19 23:53:40 +00:00
|
|
|
else {
|
2012-02-22 16:52:06 +00:00
|
|
|
if (GPU_buffer_legacy(dm)) {
|
Add weight preview to WeightVG modifiers, and first, simple/basic refactor of how modifiers can generate preview.
User side:
* Preview for DynamicPaint should keep the same behavior (for now). Weight preview should be somawhat quicker, though.
* Preview for WeightVG modifiers is only active in WeightPaint mode, and if the affected vgroup is the active one.
* Last active preview modifier in stack wins!
Note: that modifier preview topic is yet to be further refined, quite raw/incomplete for now.
Dev side:
* In draw code, renamed DRAW_DYNAMIC_PAINT_PREVIEW flag to DRAW_MODIFIERS_PREVIEW
* Removed use of MOD_DPAINT_PREVIEW_READY in DynamicPaint code (seems unecessary, and if it was, should be of more general scope).
* Added eModifierTypeFlag_UsesPreview to ModifierTypeFlag, for modifiers that can generate some preview data.
* Added three new modifier funcs, to handle preview modifiers in draw code / mod stack.
* For weights preview: added the generic DM_update_weight_mcol func, which can update WEIGHT_MCOL layer with either a given array of weights (currently used by DynamicPaint only), or from current active vgroup(s).
So now, draw code is fully generic (i.e. no more modifier-type checking in it). Mod stack code is generic to some extent, but will need more work.
2012-01-22 17:54:23 +00:00
|
|
|
if (draw_flags & DRAW_MODIFIERS_PREVIEW)
|
2011-12-01 12:12:39 +00:00
|
|
|
dm->drawFacesTex(dm, draw_mcol__set_draw_legacy, NULL, NULL);
|
2011-06-17 18:04:56 +00:00
|
|
|
else
|
2011-12-01 12:12:39 +00:00
|
|
|
dm->drawFacesTex(dm, draw_tface__set_draw_legacy, NULL, NULL);
|
2011-08-12 18:13:55 +00:00
|
|
|
}
|
2009-10-22 23:22:05 +00:00
|
|
|
else {
|
2011-12-20 08:47:36 +00:00
|
|
|
drawTFace_userData userData;
|
2011-12-09 11:46:48 +00:00
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (!CustomData_has_layer(&dm->faceData,CD_TEXTURE_MCOL))
|
2009-10-22 23:22:05 +00:00
|
|
|
add_tface_color_layer(dm);
|
2011-08-12 18:13:55 +00:00
|
|
|
|
2011-12-10 05:38:00 +00:00
|
|
|
userData.mf = DM_get_tessface_data_layer(dm, CD_MFACE);
|
|
|
|
|
userData.tf = DM_get_tessface_data_layer(dm, CD_MTFACE);
|
2011-12-09 11:46:48 +00:00
|
|
|
|
|
|
|
|
dm->drawFacesTex(dm, draw_tface__set_draw, compareDrawOptions, &userData);
|
2009-10-22 23:22:05 +00:00
|
|
|
}
|
2009-02-19 23:53:40 +00:00
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
/* draw game engine text hack */
|
2012-02-22 16:52:06 +00:00
|
|
|
if (get_ob_property(ob, "Text"))
|
2008-12-22 09:43:29 +00:00
|
|
|
draw_mesh_text(scene, ob, 0);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
draw_textured_end();
|
|
|
|
|
|
|
|
|
|
/* draw edges and selected faces over textured mesh */
|
2012-02-22 16:52:06 +00:00
|
|
|
if (!(ob == scene->obedit) && (draw_flags & DRAW_FACE_SELECT))
|
2011-08-12 18:13:55 +00:00
|
|
|
draw_mesh_face_select(rv3d, me, dm);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
/* reset from negative scale correction */
|
|
|
|
|
glFrontFace(GL_CCW);
|
|
|
|
|
|
|
|
|
|
/* in editmode, the blend mode needs to be set incase it was ADD */
|
|
|
|
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-08 13:07:16 +00:00
|
|
|
/************************** NEW SHADING NODES ********************************/
|
|
|
|
|
|
|
|
|
|
typedef struct TexMatCallback {
|
|
|
|
|
Scene *scene;
|
|
|
|
|
Object *ob;
|
|
|
|
|
Mesh *me;
|
|
|
|
|
DerivedMesh *dm;
|
|
|
|
|
} TexMatCallback;
|
|
|
|
|
|
|
|
|
|
static void tex_mat_set_material_cb(void *UNUSED(userData), int mat_nr, void *attribs)
|
|
|
|
|
{
|
|
|
|
|
/* all we have to do here is simply enable the GLSL material, but note
|
|
|
|
|
that the GLSL code will give different result depending on the drawtype,
|
|
|
|
|
in texture draw mode it will output the active texture node, in material
|
|
|
|
|
draw mode it will show the full material. */
|
|
|
|
|
GPU_enable_material(mat_nr, attribs);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void tex_mat_set_texture_cb(void *userData, int mat_nr, void *attribs)
|
|
|
|
|
{
|
|
|
|
|
/* texture draw mode without GLSL */
|
|
|
|
|
TexMatCallback *data= (TexMatCallback*)userData;
|
|
|
|
|
GPUVertexAttribs *gattribs = attribs;
|
|
|
|
|
Image *ima;
|
|
|
|
|
ImageUser *iuser;
|
|
|
|
|
bNode *node;
|
|
|
|
|
int texture_set= 0;
|
|
|
|
|
|
|
|
|
|
/* draw image texture if we find one */
|
2012-02-22 16:52:06 +00:00
|
|
|
if (ED_object_get_active_image(data->ob, mat_nr, &ima, &iuser, &node)) {
|
2011-11-08 13:07:16 +00:00
|
|
|
/* get openl texture */
|
|
|
|
|
int mipmap= 1;
|
|
|
|
|
int bindcode= (ima)? GPU_verify_image(ima, iuser, 0, 0, mipmap): 0;
|
|
|
|
|
float zero[4] = {0.0f, 0.0f, 0.0f, 0.0f};
|
|
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (bindcode) {
|
2011-11-08 13:07:16 +00:00
|
|
|
NodeTexBase *texbase= node->storage;
|
|
|
|
|
|
|
|
|
|
/* disable existing material */
|
|
|
|
|
GPU_disable_material();
|
|
|
|
|
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, zero);
|
|
|
|
|
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, zero);
|
|
|
|
|
glMateriali(GL_FRONT_AND_BACK, GL_SHININESS, 0);
|
|
|
|
|
|
|
|
|
|
/* bind texture */
|
|
|
|
|
glEnable(GL_COLOR_MATERIAL);
|
|
|
|
|
glEnable(GL_TEXTURE_2D);
|
|
|
|
|
|
|
|
|
|
glBindTexture(GL_TEXTURE_2D, ima->bindcode);
|
|
|
|
|
glColor3f(1.0f, 1.0f, 1.0f);
|
|
|
|
|
|
|
|
|
|
glMatrixMode(GL_TEXTURE);
|
|
|
|
|
glLoadMatrixf(texbase->tex_mapping.mat);
|
|
|
|
|
glMatrixMode(GL_MODELVIEW);
|
|
|
|
|
|
|
|
|
|
/* use active UV texture layer */
|
|
|
|
|
memset(gattribs, 0, sizeof(*gattribs));
|
|
|
|
|
|
|
|
|
|
gattribs->layer[0].type= CD_MTFACE;
|
|
|
|
|
gattribs->layer[0].name[0]= '\0';
|
|
|
|
|
gattribs->layer[0].gltexco= 1;
|
|
|
|
|
gattribs->totlayer= 1;
|
|
|
|
|
|
|
|
|
|
texture_set= 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (!texture_set) {
|
2011-11-08 13:07:16 +00:00
|
|
|
glMatrixMode(GL_TEXTURE);
|
|
|
|
|
glLoadIdentity();
|
|
|
|
|
glMatrixMode(GL_MODELVIEW);
|
|
|
|
|
|
|
|
|
|
/* disable texture */
|
|
|
|
|
glDisable(GL_TEXTURE_2D);
|
|
|
|
|
glDisable(GL_COLOR_MATERIAL);
|
|
|
|
|
|
|
|
|
|
/* draw single color */
|
|
|
|
|
GPU_enable_material(mat_nr, attribs);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int tex_mat_set_face_mesh_cb(void *userData, int index)
|
|
|
|
|
{
|
|
|
|
|
/* faceselect mode face hiding */
|
|
|
|
|
TexMatCallback *data= (TexMatCallback*)userData;
|
|
|
|
|
Mesh *me = (Mesh*)data->me;
|
2012-02-05 03:25:13 +00:00
|
|
|
MPoly *mp = &me->mpoly[index];
|
2011-11-08 13:07:16 +00:00
|
|
|
|
2012-02-05 03:25:13 +00:00
|
|
|
return !(mp->flag & ME_HIDE);
|
2011-11-08 13:07:16 +00:00
|
|
|
}
|
|
|
|
|
|
2011-11-10 03:40:02 +00:00
|
|
|
static int tex_mat_set_face_editmesh_cb(void *userData, int index)
|
2011-11-08 13:07:16 +00:00
|
|
|
{
|
|
|
|
|
/* editmode face hiding */
|
2011-11-10 03:40:02 +00:00
|
|
|
TexMatCallback *data= (TexMatCallback*)userData;
|
|
|
|
|
Mesh *me = (Mesh*)data->me;
|
|
|
|
|
BMFace *efa= EDBM_get_face_for_index(me->edit_btmesh, index);
|
2011-11-08 13:07:16 +00:00
|
|
|
|
2012-02-12 10:51:45 +00:00
|
|
|
return !BM_elem_flag_test(efa, BM_ELEM_HIDDEN);
|
2011-11-08 13:07:16 +00:00
|
|
|
}
|
|
|
|
|
|
2011-11-09 15:46:53 +00:00
|
|
|
void draw_mesh_textured(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *ob, DerivedMesh *dm, int draw_flags)
|
2011-11-08 13:07:16 +00:00
|
|
|
{
|
2012-02-22 16:52:06 +00:00
|
|
|
if ((!scene_use_new_shading_nodes(scene)) || (draw_flags & DRAW_MODIFIERS_PREVIEW)) {
|
2011-11-09 15:46:53 +00:00
|
|
|
draw_mesh_textured_old(scene, v3d, rv3d, ob, dm, draw_flags);
|
2011-11-08 13:07:16 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* set opengl state for negative scale & color */
|
2012-02-22 16:52:06 +00:00
|
|
|
if (ob->transflag & OB_NEG_SCALE) glFrontFace(GL_CW);
|
2011-11-08 13:07:16 +00:00
|
|
|
else glFrontFace(GL_CCW);
|
|
|
|
|
|
|
|
|
|
glEnable(GL_LIGHTING);
|
|
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (ob->mode & OB_MODE_WEIGHT_PAINT) {
|
2011-11-08 13:07:16 +00:00
|
|
|
/* weight paint mode exception */
|
|
|
|
|
int useColors= 1;
|
|
|
|
|
|
2012-01-11 07:03:47 +00:00
|
|
|
dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions_material,
|
2011-12-01 12:12:39 +00:00
|
|
|
GPU_enable_material, NULL, ob->data, useColors);
|
2011-11-08 13:07:16 +00:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
Mesh *me= ob->data;
|
|
|
|
|
TexMatCallback data = {scene, ob, me, dm};
|
|
|
|
|
int (*set_face_cb)(void*, int);
|
|
|
|
|
int glsl;
|
|
|
|
|
|
|
|
|
|
/* face hiding callback depending on mode */
|
2012-02-22 16:52:06 +00:00
|
|
|
if (ob == scene->obedit)
|
2011-11-08 13:07:16 +00:00
|
|
|
set_face_cb= tex_mat_set_face_editmesh_cb;
|
2012-02-22 16:52:06 +00:00
|
|
|
else if (draw_flags & DRAW_FACE_SELECT)
|
2011-11-08 13:07:16 +00:00
|
|
|
set_face_cb= tex_mat_set_face_mesh_cb;
|
|
|
|
|
else
|
|
|
|
|
set_face_cb= NULL;
|
|
|
|
|
|
|
|
|
|
/* test if we can use glsl */
|
|
|
|
|
glsl= (v3d->drawtype == OB_MATERIAL) && GPU_glsl_support();
|
|
|
|
|
|
|
|
|
|
GPU_begin_object_materials(v3d, rv3d, scene, ob, glsl, NULL);
|
|
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (glsl) {
|
2011-11-08 13:07:16 +00:00
|
|
|
/* draw glsl */
|
|
|
|
|
dm->drawMappedFacesMat(dm,
|
|
|
|
|
tex_mat_set_material_cb,
|
|
|
|
|
set_face_cb, &data);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
float zero[4] = {0.0f, 0.0f, 0.0f, 0.0f};
|
|
|
|
|
|
|
|
|
|
/* draw textured */
|
|
|
|
|
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, zero);
|
|
|
|
|
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, zero);
|
|
|
|
|
glMateriali(GL_FRONT_AND_BACK, GL_SHININESS, 0);
|
|
|
|
|
|
|
|
|
|
dm->drawMappedFacesMat(dm,
|
|
|
|
|
tex_mat_set_texture_cb,
|
|
|
|
|
set_face_cb, &data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GPU_end_object_materials();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* reset opengl state */
|
|
|
|
|
glDisable(GL_COLOR_MATERIAL);
|
|
|
|
|
glDisable(GL_TEXTURE_2D);
|
|
|
|
|
glDisable(GL_LIGHTING);
|
|
|
|
|
glBindTexture(GL_TEXTURE_2D, 0);
|
|
|
|
|
glFrontFace(GL_CCW);
|
|
|
|
|
|
|
|
|
|
glMatrixMode(GL_TEXTURE);
|
|
|
|
|
glLoadIdentity();
|
|
|
|
|
glMatrixMode(GL_MODELVIEW);
|
|
|
|
|
|
|
|
|
|
/* faceselect mode drawing over textured mesh */
|
2012-02-22 16:52:06 +00:00
|
|
|
if (!(ob == scene->obedit) && (draw_flags & DRAW_FACE_SELECT))
|
2011-11-08 13:07:16 +00:00
|
|
|
draw_mesh_face_select(rv3d, ob->data, dm);
|
|
|
|
|
}
|
|
|
|
|
|