Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

initial import

git-svn-id: https://wings.svn.sourceforge.net/svnroot/wings/trunk@1 a0a82711-911a-0410-9f52-85ee3e23afd8
  • Loading branch information...
commit a552d9c4187a1fa6d90f577531d8dda3283d9101 0 parents
@giniu giniu authored
Showing with 132,253 additions and 0 deletions.
  1. +114 −0 AUTHORS
  2. +139 −0 BUILD.unix
  3. +188 −0 BUILD.win32
  4. +74 −0 Makefile
  5. +184 −0 NOTES
  6. +29 −0 README
  7. +57 −0 contrib/rspt/README
  8. +38 −0 contrib/rspt/license.terms
  9. +65 −0 contrib/rspt/wpc_rspt__combiner.erl
  10. +375 −0 contrib/rspt/wpc_rspt_celshader.erl
  11. +76 −0 contrib/rspt/wpc_rspt_combiner.erl
  12. +171 −0 contrib/rspt/wpc_rspt_depth.erl
  13. +103 −0 contrib/rspt/wpc_rspt_frag.erl
  14. +824 −0 contrib/rspt/wpc_rspt_ma.erl
  15. +411 −0 contrib/rspt/wpc_rspt_mirror.erl
  16. +325 −0 contrib/rspt/wpc_rspt_noise.erl
  17. +171 −0 contrib/rspt/wpc_rspt_normal.erl
  18. +282 −0 contrib/rspt/wpc_rspt_phong.erl
  19. +315 −0 contrib/rspt/wpc_rspt_ps.erl
  20. +1,590 −0 contrib/rspt/wpc_rspt_re.erl
  21. +509 −0 contrib/rspt/wpc_rspt_sc.erl
  22. +521 −0 contrib/rspt/wpc_rspt_sh.erl
  23. +426 −0 contrib/rspt/wpc_rspt_skin.erl
  24. +1,138 −0 contrib/rspt/wpc_rspt_twc.erl
  25. +917 −0 contrib/rspt/wpc_rspt_twm.erl
  26. +100 −0 contrib/rspt/wpc_rspt_ve.erl
  27. +200 −0 contrib/rspt/wpc_rspt_vert.erl
  28. +1,433 −0 contrib/rspt/wpc_rspt_wm.erl
  29. +67 −0 e3d/Makefile
  30. +47 −0 e3d/e3d.hrl
  31. +188 −0 e3d/e3d__bmp.erl
  32. +189 −0 e3d/e3d__meshclean.erl
  33. +913 −0 e3d/e3d__png.erl
  34. +232 −0 e3d/e3d__tga.erl
  35. +869 −0 e3d/e3d__tif.erl
  36. +941 −0 e3d/e3d__tri_quad.erl
  37. +193 −0 e3d/e3d_bv.erl
  38. +37 −0 e3d/e3d_file.erl
  39. +527 −0 e3d/e3d_image.erl
  40. +27 −0 e3d/e3d_image.hrl
  41. +438 −0 e3d/e3d_mat.erl
  42. +1,019 −0 e3d/e3d_mesh.erl
  43. +525 −0 e3d/e3d_obj.erl
  44. +172 −0 e3d/e3d_q.erl
  45. +903 −0 e3d/e3d_tds.erl
  46. +91 −0 e3d/e3d_util.erl
  47. +297 −0 e3d/e3d_vec.erl
  48. BIN  ebin/wings.icon
  49. +1 −0  fonts/README
  50. +1,338 −0 fonts_src/6x11_cyrillic.bdf
  51. +2,443 −0 fonts_src/6x11_latin1.bdf
  52. +1,460 −0 fonts_src/6x11_latin2.bdf
  53. +1,577 −0 fonts_src/7x14_cyrillic.bdf
  54. +2,972 −0 fonts_src/7x14_latin1.bdf
  55. +1,639 −0 fonts_src/7x14_latin2.bdf
  56. +78 −0 fonts_src/Makefile
  57. +275 −0 fonts_src/bdf2wingsfont.erl
  58. +33,624 −0 fonts_src/fixed6x12.bdf
  59. +2,737 −0 fonts_src/fixed6x12_latin1.bdf
  60. +54,044 −0 fonts_src/fixed7x14.bdf
  61. +303 −0 fonts_src/map-ISO8859-1
  62. +305 −0 fonts_src/map-ISO8859-2
  63. +303 −0 fonts_src/map-ISO8859-5
  64. +2,698 −0 fonts_src/terminal8x12_latin1.bdf
  65. +45 −0 icons/Makefile
  66. BIN  icons/bluecube/axes.bmp
  67. BIN  icons/bluecube/body.bmp
  68. BIN  icons/bluecube/edge.bmp
  69. BIN  icons/bluecube/face.bmp
  70. BIN  icons/bluecube/groundplane.bmp
  71. BIN  icons/bluecube/internal_resize.tga
  72. BIN  icons/bluecube/perspective.bmp
  73. BIN  icons/bluecube/resize.bmp
  74. BIN  icons/bluecube/small_closed_eye.bmp
  75. BIN  icons/bluecube/small_eye.bmp
  76. BIN  icons/bluecube/small_image.bmp
  77. BIN  icons/bluecube/small_image2.bmp
  78. BIN  icons/bluecube/small_light.bmp
  79. BIN  icons/bluecube/small_locked.bmp
  80. BIN  icons/bluecube/small_object.bmp
  81. BIN  icons/bluecube/small_sel.bmp
  82. BIN  icons/bluecube/small_sel_light.bmp
  83. BIN  icons/bluecube/small_unlocked.bmp
  84. BIN  icons/bluecube/small_wire.bmp
  85. BIN  icons/bluecube/smooth.bmp
  86. BIN  icons/bluecube/vertex.bmp
  87. BIN  icons/bluecube/wings.bmp
  88. BIN  icons/classic/axes.bmp
  89. BIN  icons/classic/body.bmp
  90. BIN  icons/classic/edge.bmp
  91. BIN  icons/classic/face.bmp
  92. BIN  icons/classic/groundplane.bmp
  93. BIN  icons/classic/internal_resize.tga
  94. BIN  icons/classic/perspective.bmp
  95. BIN  icons/classic/resize.bmp
  96. BIN  icons/classic/small_closed_eye.bmp
  97. BIN  icons/classic/small_eye.bmp
  98. BIN  icons/classic/small_image.bmp
  99. BIN  icons/classic/small_image2.bmp
  100. BIN  icons/classic/small_light.bmp
  101. BIN  icons/classic/small_locked.bmp
  102. BIN  icons/classic/small_object.bmp
  103. BIN  icons/classic/small_sel.bmp
  104. BIN  icons/classic/small_sel_light.bmp
  105. BIN  icons/classic/small_unlocked.bmp
  106. BIN  icons/classic/small_wire.bmp
  107. BIN  icons/classic/smooth.bmp
  108. BIN  icons/classic/vertex.bmp
  109. BIN  icons/classic/wings.bmp
  110. +128 −0 icons/collect_bmp.erl
  111. +53 −0 intl_tools/Makefile
  112. +248 −0 intl_tools/tools.erl
  113. +16 −0 intl_tools/wings_intl.hrl
  114. +38 −0 license.terms
  115. BIN  macosx/3ds.icns
  116. +7 −0 macosx/English.lproj/Erlang.nib/classes.nib
  117. +12 −0 macosx/English.lproj/Erlang.nib/info.nib
  118. BIN  macosx/English.lproj/Erlang.nib/objects.nib
  119. BIN  macosx/English.lproj/InfoPlist.strings
  120. +13 −0 macosx/MyController.h
  121. +96 −0 macosx/MyController.m
  122. +656 −0 macosx/Wings3d.pbproj/project.pbxproj
  123. +97 −0 macosx/Wings3d.plist
  124. +470 −0 macosx/Wings3d.xcodeproj/project.pbxproj
  125. +1 −0  macosx/driver_symbols
  126. +20 −0 macosx/main.m
  127. BIN  macosx/mdl.icns
  128. BIN  macosx/mtl.icns
  129. BIN  macosx/ndo.icns
  130. BIN  macosx/obj.icns
  131. +20 −0 macosx/strip_mac_driver
  132. BIN  macosx/wings.icns
  133. BIN  macosx/wings3d.icns
  134. BIN  macosx/wrl.icns
  135. +1 −0  plugins/autouv/README
  136. +1 −0  plugins/commands/README
  137. +3 −0  plugins/default/README
  138. +1 −0  plugins/fonts/README
  139. +1 −0  plugins/import_export/README
  140. +1 −0  plugins/primitives/README
  141. +94 −0 plugins_src/Makefile
  142. +64 −0 plugins_src/accel/Makefile
  143. +778 −0 plugins_src/accel/perlin_noise_drv.c
  144. +123 −0 plugins_src/accel/pnoise.erl
  145. +250 −0 plugins_src/accel/wings_ogla_drv.c
  146. +111 −0 plugins_src/accel/wpc_ogla.erl
  147. +22 −0 plugins_src/accel/wpc_pnoise.erl
  148. +83 −0 plugins_src/autouv/Makefile
  149. +358 −0 plugins_src/autouv/autouv_fr.lang
  150. +398 −0 plugins_src/autouv/autouv_pl.lang
  151. +42 −0 plugins_src/autouv/auv.hrl
  152. +1,318 −0 plugins_src/autouv/auv_mapping.erl
  153. +754 −0 plugins_src/autouv/auv_matrix.erl
  154. +271 −0 plugins_src/autouv/auv_placement.erl
  155. +409 −0 plugins_src/autouv/auv_seg_ui.erl
  156. +1,003 −0 plugins_src/autouv/auv_segment.erl
Sorry, we could not display the entire diff because too many files (390) changed.
114 AUTHORS
@@ -0,0 +1,114 @@
+$Id: AUTHORS,v 1.32 2005/06/01 14:27:11 dgud Exp $
+
+Bj�rn Gustavsson:
+ Has written the bulk of code.
+ Started writing Wings beginning of April 2001.
+ Most of the Nendo functionality (except Rotate Free/Plane Cut)
+ was in place in the middle of July 2001.
+
+Jakob Cederlund:
+ Implemented the Tube, Cone, Sphere, and Torus objects.
+ Brain-storming and discussion partner.
+ Implemented the Collapse commands. Original idea and
+ implementation of the Intrude and Select Similar.
+ Implemented the original plug-in architecture.
+ Wrote the Spiral plug-in.
+
+Dan Gudmundsson:
+ Wrote the ESDL package that made it possible.
+ Ideas and inspiration.
+ Wrote the e3d_image modules.
+ Wrote the original material editor.
+ Principal author of Auto-UV.
+
+Vlad Dumitrescu: Bugfix for middle-mouse button emulation.
+
+Patrik Nyblom: User interface plugins for file dialogs. Makefiles for Windows.
+
+Anthony D'Agostino: Provided me with info on the NDO format.
+ Wrote the Torus Knot, Torus, and Plane plug-ins
+
+Gregg Griffin: Designed icons and the new look of Wings.
+
+Chris Osgood (WingsOne):
+ Wrote the qt_file plugin.
+
+ Contributed working code for several new features, such as
+ axis letters and showing the grid whenever the view is
+ axis-aligned.
+
+ Implemented advanced menus, named vectors, secondary
+ selections, and other new features in a set of patches.
+ These ideas, and some of the code, is now included in
+ the core of Wings.
+
+Howard Trickey:
+ Wrote the new, much better triangulator (and a quadrilator)
+ in e3d_mesh.
+ Wrote the AI import, Triangulate & Quadrangulate, and Text
+ plug-ins.
+ Wrote the Hash A:M exporter.
+
+Anders Conradi: Wrote the Select|Edge Ring command (originally as a plug-in).
+
+Sean Hinde (Earlyriser):
+ Wrote the VRML exporter.
+ Got Wings working on Mac OS X.
+ Packaged Wings an a Mac application.
+
+Danni Coy (KayosIII):
+ Significantly enhanced the Renderman exporter. Added the Render
+ command.
+
+Patrick de Klein (TheChalker):
+ Designed the Wings icon that is used on the Windows version of Wings.
+
+Clarence Vidalies (clacos):
+ Implemented the File|Save Incrementally command.
+
+Mark Luffel:
+ Implemented named selections groups.
+
+Chris Wayles:
+ Made nicer eye and pyramid icons for the Object and Outliner window.
+
+Raimo Niskanen (ratmapper):
+ Wrote the Yafray plug-in.
+
+Keith Bauer:
+ Created Mac OS X document icons for all file types that Wings supports.
+
+Dmitry Efremov:
+ Implemented the Cartoon Edges export plugin.
+
+Riccardo Venier (verme@insiberia.net):
+ Translated all the strings in the Wings core to Italian, and implemented
+ a mechanism for changing langugages.
+
+Paul M (elrond79):
+ Wrote intersect (vertex/edge) commands and force ortho view option when
+ camera is on one of the major axis.
+ Improved 3DS import so that all triangles are converted to polygons
+ (unless doing so would create holes or create isolated vertices).
+
+Nicolas Bouillard (syndarion):
+ French translation.
+
+Libor Divis:
+ Czech translation.
+
+Luiz Fonte Boa:
+ Portuguese translation.
+
+A. Giniewicz, M. Napiontek, and K. Giniewicz:
+ Polish translation.
+
+Tapio Ryyn�nen / Mostlymop:
+ Finnish translation.
+
+Auto-UV credits
+===============
+
+Dan Gudmundsson (idea; principal author)
+Bjorn Gustavsson
+Raimo Niskanen (implemented the Least Square Conformal Map algorithm)
139 BUILD.unix
@@ -0,0 +1,139 @@
+BUILDING WINGS 3D ON UNIX-LIKE SYSTEMS (including MacOS X)
+==========================================================
+
+This guide describes how you can build Wings on unix-like
+systems, such as GNU Linux, FreeBSD, Solaris, and MacOS X.
+
+$Revision: 1.5 $
+$Date: 2005/04/08 06:02:54 $
+
+Required software
+=================
+
+The following software is needed:
+
+- Erlang/OTP R10B-4 or later. http://www.erlang.org
+
+- SDL development library. http://www.libsdl.org.
+ (There are pre-built libraries for most platforms.)
+
+- ESDL 0.94.1025 or later. http://esdl.sf.net
+
+- A GNU compatible "make" program. Included with most unix-like
+ systems; otherwise get it from http://www.gnu.org.
+
+- bunzip2 for unpacking the Wings source tar file.
+ Included with most unix-like systems; otherwise get it
+ from http://sources.redhat.com/bzip2.
+
+- And, of course, the Wings source files. http://www.wings3d.com
+
+Summary of build process
+========================
+
+The following is a quick summary of the build process.
+
+* Download and install Erlang/OTP.
+* Download and install SDL.
+* Download and install ESDL.
+* Download and upnpack the Wings source file.
+* Run "make".
+
+Installing Erlang/OTP
+=====================
+
+Building Erlang/OTP according to the instructions in the README file.
+
+A few hints:
+
+The Erlang/OTP source tar file must be unpacked using a
+GNU compatible "tar" utility. On a MacOS X, you'll need
+to use the "gnutar" command, NOT "tar" or the StuffIt extractor.
+
+On Linux, make sure to use the "--enable-thread" option to
+the "configure" script.
+
+When you have built Erlang/OTP, modify the PATH environment variable
+so that the "erl" and "erlc" programs can be started from a shell prompt.
+
+Installing SDL
+=============
+
+Install SDL. Make sure that the library is found in the standard
+library search path.
+
+Installing ESDL
+===============
+
+Download ESDL and unpack it. Compile by running "make" from
+the source directory.
+
+Set the environment variable ESDL_PATH to point to top of the
+compiled ESDL installation.
+
+Unpacking the Wings source code
+===============================
+
+If you have the GNU tar program, use the "tar" program with
+the "j" flag to tell it to decompress using the "bunzip2" program.
+
+Example:
+
+$ tar jxf wings-0.98.16b.tar.bz2
+
+Otherwise, feed the output of "bzcat" to tar:
+
+$ bzcat wings-0.98.16b-pre1.tar.bz2 | tar xf -
+
+The build steps that follow assume that you are in the wings source
+directory.
+
+Example:
+
+$ cd wings-0.98.16b.tar.bz2
+
+Building Wings
+==============
+
+Build a Wings from the directory where the sources where unpacked.
+
+Example:
+
+$ pwd
+/home/bjorng/wings-0.98.16b
+$ make
+.
+.
+.
+<A lot of output follows>
+.
+.
+.
+$
+
+To run the Wings you have just build, you'll need to write a command line
+similar to this:
+
+ erl -pa $ESDL_PATH/ebin -pa <MY_WINGS_PATH>/ebin -run wings_start start_halt
+
+where you should substitute <MY_WINGS_PATH> with the path to the Wings
+source directory.
+
+Example:
+
+$ werl -pa $ESDL_PATH/ebin -pa /home/bjorng/wings-0.98.16b/ebin -run wings_start start_halt
+$
+
+Instead of writing the command line every time you want to start Wings,
+you can package it in a script like this:
+
+#!/bin/sh
+exec erl -pa $ESDL_PATH/ebin -pa /home/bjorng/wings-0.98.16b/ebin -run wings_start start_halt ${1+"$@"}
+
+Notes:
+
+[1] "exec" kills the shell process running the script, saving a
+ tiny amount of system memory.
+
+[2] The "${1+"$@"}" thing passes along any arguments (or none) to Wings,
+ allowing Wings to open up a wings file when it starts.
188 BUILD.win32
@@ -0,0 +1,188 @@
+BUILDING WINGS 3D ON WINDOWS
+============================
+
+This guide describes how you can build Wings 3D from the
+sources on a Windows system.
+
+$Revision: 1.12 $
+$Date: 2005/04/08 06:02:27 $
+
+Required software
+=================
+
+From Wings 0.98.16b and higher, Wings can be built on Windows
+using only free/open-source software.
+
+The following software is needed:
+
+- The Wings source. http://www.wings3d.com
+
+- Cygwin, a unix-like environment for Windows. http://www.cygwin.com
+
+- Erlang/OTP R10B-4 or later. http://www.erlang.org
+ (Download the pre-built binaries for Windows.)
+
+- ESDL 0.94.1025 or later. http://esdl.sf.net
+ (I recommend downloading the pre-built binaries for Windows.)
+
+- MinGW, a C compiler and libraries for building native Windows applications.
+ http://www.mingw.org
+
+- NSIS 2.02 or higher, an installer/uinstaller maker.
+ (The beta releases of NSIS 2.0 will no longer work.)
+ http://nsis.sf.net.
+
+Installing the software
+=======================
+
+In general, you should follow the instructions for each package.
+
+Installing Cygwin
+-----------------
+
+Make sure that you install the GNU Make program. It will be needed
+later in the build process.
+
+Setting up the environment
+==========================
+
+A few environment variables need to be set. They can be set
+for Windows globally from "My Computer", or only in the Cygwin shell
+by adding them to ".profile".
+
+ESDL_PATH need to be set to path of the directory you installed ESDL in.
+
+Modify the PATH environment variable so that the following programs
+are runnable from a Cygwin (bash) shell.
+
+ make (Cygwin, if you installed Make)
+
+ erlc.exe (Erlang/OTP)
+
+ mingw32-gcc (MinGW)
+
+ makensis.exe (NSIS)
+
+An easy way to check that the programs are runnable is to use the
+"which" command in a cygwin shell like this:
+
+$ which make
+/usr/bin/make
+$
+
+Unpacking the Wings source code
+===============================
+
+Give the "-j" flag to the "tar" program to tell it to decompress using
+the "bunzip2" program.
+
+Example:
+
+$ tar jxf wings-0.98.16b.tar.bz2
+
+The build steps that follow assume that you are in the wings source
+directory.
+
+Example:
+
+$ cd wings-0.98.16b.tar.bz2
+
+Basic build
+===========
+
+To build a minimal Wings that can be used for development purposes,
+all you need is to run make from inside the directory where the
+sources where unpacked.
+
+Example:
+
+$ pwd
+/home/bjorng/wings-0.98.16b
+$ make
+.
+.
+.
+<A lot of output follows>
+.
+.
+.
+$
+
+Running Wings
+============
+
+To run the Wings you have just build, you'll need to write a command line
+similar to this:
+
+ werl -pa $ESDL_PATH/ebin -pa <MY_WINGS_PATH>/ebin -run wings_start start_halt
+
+where you should substitute <MY_WINGS_PATH> with the path to the Wings
+source directory.
+
+Example:
+
+$ werl -pa $ESDL_PATH/ebin -pa c:/cygwin/home/bjorng/wings-0.98.16b/ebin -run wings_start start_halt
+$
+
+An Erlang console should appear, followed by the Wings window.
+It should work OK except that there will be no file dialog boxes
+if you try File|Open or File|Save. (See the next section on how
+to remedy that.)
+
+Instead of writing the command line every time you want to start Wings,
+you can package it in a script like this:
+
+#!/bin/bash
+exec werl -pa $ESDL_PATH/ebin -pa c:/cygwin/home/bjorng/wings-0.98.16b/ebin -run wings_start start_halt ${1+"$@"}
+
+Notes:
+
+[1] "exec" kills the shell process running the script, saving a
+ tiny amount of system memory.
+
+[2] The "${1+"$@"}" thing passes along any arguments (or none) to Wings,
+ allowing Wings to open up a wings file when it starts.
+
+You could also package the command line into a standard windows shortcut.
+(That is what I do.)
+
+Building the file dialog plug-in
+================================
+
+To get native Windows file dialog boxes, you'll need to compile
+the file dialog plug-in the "plugins_src/win32_file" directory.
+
+$ cd plugins_src/win32_file
+$ make
+<Some output>
+$
+
+Building all
+============
+
+Make sure that you current directory is the directory in which the
+sources where unpacked.
+
+Example:
+
+$ pwd
+/home/bjorng/wings_releases/wings-0.98.16b
+$
+
+To build all (including the installer), run the following command:
+
+$ make win32
+.
+.
+.
+<A lot of output follows>
+.
+.
+.
+$
+
+When everything is done, there should be a file named like
+
+ wings-0.98.16b.exe
+
+in the current directory.
74 Makefile
@@ -0,0 +1,74 @@
+#
+# Makefile --
+#
+# Top-level Makefile for building Wings 3D.
+#
+# Copyright (c) 2001-2005 Bjorn Gustavsson
+#
+# See the file "license.terms" for information on usage and redistribution
+# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+#
+# $Id: Makefile,v 1.23 2006/01/20 14:47:02 giniu Exp $
+#
+include vsn.mk
+
+all:
+ (cd intl_tools; $(MAKE))
+ (cd src; $(MAKE))
+ (cd fonts_src; $(MAKE))
+ (cd e3d; $(MAKE))
+ (cd plugins_src; $(MAKE))
+ (cd icons; $(MAKE))
+
+debug:
+ (cd intl_tools; $(MAKE) debug)
+ (cd src; $(MAKE) debug)
+ (cd fonts_src; $(MAKE) debug)
+ (cd e3d; $(MAKE) debug)
+ (cd plugins_src; $(MAKE) debug)
+ (cd icons; $(MAKE) debug)
+
+clean:
+ (cd intl_tools; $(MAKE) clean)
+ (cd src; $(MAKE) clean)
+ (cd fonts_src; $(MAKE) clean)
+ (cd e3d; $(MAKE) clean)
+ (cd plugins_src; $(MAKE) clean)
+ (cd icons; $(MAKE) clean)
+
+lang:
+ (cd intl_tools; $(MAKE))
+ (cd src; $(MAKE) lang)
+ (cd plugins_src; $(MAKE) lang)
+
+#
+# Build installer for Windows.
+#
+win32: all lang
+ (cd plugins_src/win32_file; $(MAKE))
+ (cd plugins_src/win32_file; $(MAKE) lang)
+ (cd plugins_src/jpeg; $(MAKE))
+ (cd plugins_src/jpeg; $(MAKE) lang)
+ (cd plugins_src/fbx; $(MAKE))
+ (cd plugins_src/fbx; $(MAKE) lang)
+ (cd win32; $(MAKE))
+ win32/make_installer
+
+#
+# Build a package for MacOS X.
+#
+macosx: all lang
+ (cd plugins_src/mac_file; $(MAKE))
+ (cd plugins_src/mac_file; $(MAKE) lang)
+ (cd plugins_src/fbx; $(MAKE))
+ (cd plugins_src/fbx; $(MAKE) lang)
+ (cd macosx; xcodebuild)
+ sh tools/mac_make_dmg $(WINGS_VSN)
+
+#
+# Build package for Unix.
+#
+unix: all lang
+ (cd plugins_src/jpeg; $(MAKE))
+ (cd plugins_src/jpeg; $(MAKE) lang)
+ unix/make_installer
184 NOTES
@@ -0,0 +1,184 @@
+--- 0.98.XX -----------------------------------------------------------------
+
+- Absolute snap now can pick reference point, old snap that used center of
+ selection as reference point was moved to MMB option. [Giniu]
+
+- Added new preference: constrain axes to grid. [Scorpius]
+
+- Added "Blue Cube" interface icons. The original icons are in the "Classic"
+ bundle. Switching between icon sets is easily accomplished through the
+ User Interface preference tab. [Scorpius]
+
+- Revived the Plane Plugin, which was removed from a previous release
+ because it created invalid objects. This has been fixed by adding a
+ thickness parameter; thereby creating a properly closed mesh. [Scorpius]
+
+- Added two new primitives (look under the More menu):
+ Tube: generates a hollow tube or pipe with an actual wall-thickness.
+ Gear: generates a very simple gear. Allows the user to specify the number
+ of teeth and the tooth height. [Scorpius]
+
+- Added two more primitives:
+ Ncube: Generates a cube with an arbitrary level of subdivisions (simply
+ specify the number of cuts per edge) plus a spherize option.
+ Ngon: Generates a polygon with an arbitrary number of vertices. This may
+ look like a single-sided polygon but, in fact, has two faces. [Scorpius]
+
+- New GeoDome primitive. Generates a geodesic dome with an arbitrary level
+ of subdivisions. Has three base objects, spherize and half-dome options.
+ [Scorpius]
+
+- New *.stl import/export plugin. Stereolithography files can be sent to
+ a service bureau to create an actual plastic prototype of your model.
+ [Scorpius]
+
+- New command in tools menu: "Scene Info: Area & Volume." Calculates the
+ area and volume for each object in the scene and displays the info in
+ a pop-up window. [Scorpius]
+
+- Bug fix: Language support now works for all operating systems, regardless
+ if the file path has an underscore. [Scorpius]
+
+- Added X export plugin.
+ [contributed by Ed Kolis (Ekolis)]
+
+--- 0.98.35 -----------------------------------------------------------------
+
+- Move absolute now works for lights. [Giniu]
+
+- Added very basic version of absolute scale, it would be extended
+ after feedback. [Giniu]
+
+- Both absolute scale and move is now placed in one menu group,
+ in absolute commands. [Giniu]
+
+- New absolute tool was added - snap - it is similar to move but
+ works with secondary selection. There two snap modes, quick LMB and
+ full RMB. Simple weld was eaten by quick version of snap. [Giniu]
+
+- Fixed bug in View -> Align to Selection. [Giniu]
+
+- Turn Edge plugin now have option dialog to choose between clasic
+ turn method, clockwise rotate and counterclockwise rotate. [Giniu]
+
+- An improved modelling lighting for people with newer gfx cards,
+ select 'one light' [Dgud]
+
+- Improved rotate command again when using constraints [Dgud]
+
+- Change the automatic chart rotation again in autouv [Dgud]
+
+- Hopefully fixed the unfold issue from inside the autouv window [Dgud]
+
+- New selection method: by sharp edges.
+ [contributed by Anthony D'Agostino (Scorpius)]
+
+- Polish translation fixes.
+ [contributed by Maciej Milewski]
+
+- Minor corrections for Mac and Windows to work with R11B and newest
+ SDL and esdl. For Mac, Mac OS 10.4 or higher ("Tiger") is now required.
+ (Unless you build from source yourself.) Sorry for that. [bjorng]
+
+--- 0.98.34 -----------------------------------------------------------------
+
+- Minor autouv fixes.
+
+- Fixed stored selection bug reported by LoTekK.
+
+- Added a loop cut mode to (tools) connect tool.
+
+- Fixed very small bug in vertex weld (troubles with undo).
+
+- Added second vertex weld mode for those who prefers just moving vertices
+ to target position and then clean mesh (it's under RMB click on "Weld").
+
+- Totally rewrote absolute move so now is works for any selection mode,
+ and is able to align, move whole objects and create multiple duplicates of object.
+ [Giniu]
+
+- Should now hopefully work on Mac OS 10.3.9 ("Panther").
+ Erlang/OTP updated to R10B-10, which has a fix for a rare
+ start-up problem. [Bjorn]
+
+--- 0.98.33 -----------------------------------------------------------------
+
+- Dan fixed (hopefully finally) the Rotate commands speed so they work as before.
+
+- Dan fixed rotate in vertex mode so it centers around all selected vertices.
+
+- Giniu made all active (compilable) plug-ins translatable and translated them to Polish
+ (the toxic and yafray plugins still needs to be translated, but are translatable).
+
+- Giniu added 4 selection methods: select by vertices with 6 or more edges,
+ select by non quadrangle faces (all faces, faces with odd or even number of edges).
+
+- Giniu added two new tools - "move->absolute" for positioning in absolute
+ coordinates and "weld" for welding single vertex to other one.
+
+- DesiredUserName/MicrobeSoft implemented pick-up and drop images in outliner.
+
+- Syndarion updated the French translation.
+
+- AUTOUV changes (Dan):
+ - In face mode added a combined project from normal and unfolding command.
+ - In segmenting mode, when uv-mapping failes the good charts gets uv-mapped and
+ the failed charts stays in the segmenting window.
+ - MMB on uv-mapping, finds and marks the old chart cuts.
+ - Repeat implemented.
+ - Other minor stuff, uv-grid and changed material/image handling.
+ - Re-written the texture image creator, move images with your uv's or
+ use it to draw vertex color or materials it can also use opengl shaders.
+
+- Programmers:
+ Update to the latest erlang release. (png requires it)
+ Both the #we and #st have a new field pst (plugin state)
+ That requires a re-compilation of most (all?) of the external plugins.
+ Plugins that use the pst field should export two functions:
+ PLUGIN:merge_we([We1,We2..]) and PLUGIN:merge_st(NewData,OldSt) both should
+ return the new data of the plugin.
+
+--- 0.98.32b -----------------------------------------------------------------
+
+- Giniu made AutoUV and almost all other plug-ins translatable and
+ translated them to Polish.
+
+- Import, especially 3DS import, improved.
+
+- Dan G fixed crash in the Connect tool. (Problem reported by Fonte Boa.)
+
+- The Image creation command now correctly create images
+ with size which are not multiples of 8 or 16.
+
+- Dan G made sure wings files containing bad images created by previous
+ versions of Wings can now be loaded, but with the faulty images
+ missing. (Problem reported by Hanzaa.)
+
+- Dan G fixed file open problem reported by Bob19971.
+
+- The length and color of normals shown by View|Show Normals can now
+ be changed in the preferences. (By Giniu.)
+
+- Dmitry Efremov has updated the hlines plug-in.
+
+- Changed toxic to render png instead of tga. (By Dan G.)
+
+- Dan G fixed the Rotate commands speed so they work as before.
+
+- Raimo added an option for loading rendered image into
+ internal viewer independent from external viewer option.
+
+AutoUV (by Dan G):
+
+- New commands in edge mode: slide, distribute evenly.
+
+- New commands in object mode:Normalize Chart sizes.
+
+- The Scale and Rotate commands now have magnets.
+
+
+For developers:
+
+- New function e3d_mesh:make_polygons/1. e3d_mesh:make_quads/1 changed back
+ to only make quads.
+
29 README
@@ -0,0 +1,29 @@
+WINGS 3D
+========
+
+$Revision: 1.7 $
+$Date: 2003/09/29 05:28:57 $
+
+Wings on the net
+----------------
+
+http://www.wings3d.com
+
+System Requirements for Running Wings
+-------------------------------------
+
+A working OpenGL driver.
+
+How to build Wings 3D
+---------------------
+
+If you want to build Wings yourself, you'll need to the
+to download the source tar file from http://www.wings3d.com.
+
+Build instructions are found in one of the following text files
+included in the source tar file.
+
+BUILD.unix How to build for a unix-like system, such as
+ GNU Linux or MacOS X.
+
+BUILD.win32 How to build for Microsoft Windows.
57 contrib/rspt/README
@@ -0,0 +1,57 @@
+Comments about the source
+
+The source code is written testing against wings 0.98.09 and esdl
+0.93.03143.
+
+The Renderer
+Basic render with vertex and fragment capability that renders
+ each light in its own pass and sums the all lights using eithr Accumlation buffer
+ or a Texture buffer. Each spotlight has some additional passes used to create
+ a z-buffer view for depth shadow calculations. Shadow calculations are corrected
+ by rendering backsides of objects, hence no z-offset needed.
+
+
+The tree view
+Basic tree view, needed for more advanced material editing, rather basic.
+Adds the posibility to apply textures to materials and using a number of "shaders".
+These are realy various different types of vertex/fragment programs. Includes per pixel
+phong shader, normal shader, cel shader.
+
+The uv-mapper
+More or less a clone of some free software that was called uv-mapper. Uses a window
+with displaing all vertexes with their UV-coordinates. A sort of hands on editor.
+
+
+
+Known issues incomplete list
+
+
+-povray exporter does not work with the code
+-depth shadowing only available for spotlights (not realy an error)
+-depth shadowing for project lights pointing straight down does not work
+-z-offset option is still not implemented (does not affect shadow quality)
+-parallel mesh line may cause the uv-cube mapper to fail
+-reflection "shader" is currently broken because of mispelling of an atom
+-no support for transparency in the global light model
+-missing support for older GPU
+-combiner program is not implemented but visible
+-the tree material editor is not recursive (needed to implement the combiner)
+-names in the material editor are the internal atom names
+-no option to turn off depth shadowing for spotlights
+-incomplete help
+-tree material editor is missing a tree height calculation
+-vertex and fragment programs are untested on ATI hardware,
+ ATI hardware may have problems due to shorter maximum frag/vertex programs lengths
+
+There are probably more ..
+
+
+Most of the advanced features in the render require a decently new card
+like GeForceFX 5200 or equivalent.
+
+
+
+
+
+Rolf Stenholm
+rolfstenholm@yahoo.se
38 contrib/rspt/license.terms
@@ -0,0 +1,38 @@
+This software is copyrighted by Rolf Stenholm and other parties.
+The following terms apply to all files associated with the software unless
+explicitly disclaimed in individual files.
+
+The authors hereby grant permission to use, copy, modify, distribute,
+and license this software and its documentation for any purpose, provided
+that existing copyright notices are retained in all copies and that this
+notice is included verbatim in any distributions. No written agreement,
+license, or royalty fee is required for any of the authorized uses.
+Modifications to this software may be copyrighted by their authors
+and need not follow the licensing terms described here, provided that
+the new terms are clearly indicated on the first page of each file where
+they apply.
+
+IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY
+FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
+ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY
+DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+
+THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES,
+INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE
+IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE
+NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
+MODIFICATIONS.
+
+GOVERNMENT USE: If you are acquiring this software on behalf of the
+U.S. government, the Government shall have only "Restricted Rights"
+in the software and related documentation as defined in the Federal
+Acquisition Regulations (FARs) in Clause 52.227.19 (c) (2). If you
+are acquiring the software on behalf of the Department of Defense, the
+software shall be classified as "Commercial Computer Software" and the
+Government shall have only "Restricted Rights" as defined in Clause
+252.227-7013 (c) (1) of DFARs. Notwithstanding the foregoing, the
+authors grant the U.S. Government and others acting in its behalf
+permission to use and distribute the software in accordance with the
+terms specified in this license.
65 contrib/rspt/wpc_rspt__combiner.erl
@@ -0,0 +1,65 @@
+%%
+%% Copyright (c) 2004 Rolf Stenholm
+%%
+%% See the file "license.terms" for information on usage and redistribution
+%% of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+%%
+%% $Id: wpc_rspt__combiner.erl,v 1.1 2004/08/25 05:33:05 bjorng Exp $
+%%
+
+%%%
+%%% Module to combine results
+%%%
+%%% XXX Just an obsolete duplicate of wpc_rspt_combiner.erl??? /Bjorn
+
+-module(wpc_rspt_combiner).
+-define(NEED_ESDL,1).
+-define(NEED_OPENGL,1).
+-include_lib("wings.hrl").
+-include_lib("e3d.hrl").
+-include_lib("e3d_image.hrl").
+
+
+-export([init/0,menu/2,command/2,attrib/2]).
+-export([help/0,material_opts/1]).
+
+
+init()->
+ %%io:format("Loading ~p ... ~n",[?MODULE]),
+ true.
+
+
+%% start with all red for ambient and diff
+menu(rspt_material_menu_ambFragProg0,Menu)->
+ [{"Combiner",wpc_rspt_combiner}] ++ Menu;
+menu(rspt_material_menu_diffFragProg0,Menu)->
+ [{"Combiner",wpc_rspt_combiner}] ++ Menu;
+menu(rspt_help,Menu)->
+ [{"Combining textures",{wpc_rspt_combiner,help}}] ++ Menu;
+menu(X, Menu)->
+ %%io:format("Ignoring menu ~p ~n",[X]),
+ Menu.
+
+
+command(_,_)-> next.
+
+
+help()->
+ wpc_rspt_wm:help_window(wpc_rspt_skinshader_help_window,"Skin shader",
+ ["Combiner",
+ "Experimental texture combiner"],[]).
+
+material_opts([S,diffFragProg0|Tail])->
+ material_init([diffFragProg0|Tail]),
+ ok;
+material_opts([S,ambFragProg0|Tail])->
+ material_init([ambFragProg0|Tail]),
+ ok;
+
+
+material_init(Target)->
+ wpc_rspt_ma:path_set([],[object|Target]),
+ wpc_rspt_ma:path_set([add],[object,combiner|Target]),
+ wpc_rspt_ma:path_set([default],[object,componentA|Target]),
+ wpc_rspt_ma:path_set([default],[object,componentB|Target]),
+ ok.
375 contrib/rspt/wpc_rspt_celshader.erl
@@ -0,0 +1,375 @@
+%%
+%% Copyright (c) 2004 Rolf Stenholm
+%%
+%% See the file "license.terms" for information on usage and redistribution
+%% of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+%%
+%% $Id: wpc_rspt_celshader.erl,v 1.1 2004/08/25 05:33:05 bjorng Exp $
+%%
+
+%%%
+%%% Model to produce cel shading
+%%%
+%%%
+
+
+-module(wpc_rspt_celshader).
+-define(NEED_ESDL,1).
+-define(NEED_OPENGL,1).
+-include_lib("wings.hrl").
+-include_lib("e3d.hrl").
+-include_lib("e3d_image.hrl").
+
+
+-export([init/0,menu/2,command/2,attrib/2,help/0]).
+-export([material_opts/1]).
+
+init()->
+ %%io:format("Loading ~p ... ~n",[?MODULE]),
+ true.
+
+%% start with all red for ambient and diff
+menu(rspt_material_menu_ambFragProg0,Menu)->
+ [{"Cel shader",wpc_rspt_celshader}] ++ Menu;
+menu(rspt_material_menu_diffFragProg0,Menu)->
+ [{"Cel shader",wpc_rspt_celshader}] ++ Menu;
+menu(rspt_help,Menu)->
+ [{"Using the cel shader",{wpc_rspt_celshader,help}}] ++ Menu;
+menu(X, Menu)->
+ %%io:format("Ignoring menu ~p ~n",[X]),
+ Menu.
+
+command(_,_)-> next.
+
+
+help()->
+ wpc_rspt_wm:help_window(wpc_rspt_celshader_help_window,"Cel shader",
+ ["Per pixel cel shader",
+ "This shader simulates a limited number of shades in rendering that is common in most painted art or drawn art."
+ "The 3D object is rendered as if there are a limited number of light and shade directions resulting in sharp "
+ "shadows on the 3D object. The number of shadows can be adjusted for each direction in the final image."
+ "It is possible to have separate shader for ambient light and diffuse light",
+ "Options",
+ "x_dirs",
+ "Determines the number of possible light directions of incoming light in horizontal directions. "
+ "The value for this option determines the width of each direction, 0 is smooth and 1 means no direction",
+ "y_dirs",
+ "Determines the number of possible light directions of incoming light in vertical directions. "
+ "The value for this option determines the width of each direction, 0 is smooth and 1 means no direction",
+ "z_dirs",
+ "Determines the number of possible light directions of incoming light in depth directions. "
+ "The value for this option determines the width of each direction, 0 is smooth and 1 means no direction",
+ "offset",
+ "Due to numerical errors it is sometimes nescessary to introduce a small offset in the computations."
+ "This value tweaks how rounding errors should be handled."
+ ],[]).
+
+
+%%%
+%%%
+%%%
+
+%%%
+%%%
+%%%
+sane(Text)->
+ sane(gl:getIntegerv(?GL_PROGRAM_ERROR_POSITION_ARB),Text).
+
+sane([-1|_],_)->
+ ok;
+sane([X|_],Text)->
+ saneNumber(X,Text,1).
+
+saneNumber(-1,_,1)->
+ ok;
+saneNumber(0,_,L)->
+ io:format("On line ~p ~n",[L]),
+ ok;
+saneNumber(X,[10|T],L)->
+ saneNumber(X-1,T,L+1);
+saneNumber(X,[_|T],L)->
+ saneNumber(X-1,T,L);
+saneNumber(_,_,_)->
+ io:format("Unknown instruction state ?~n",[]).
+
+
+vertexMach()->
+ gl:enable(?GL_VERTEX_PROGRAM_ARB),
+ %% should probably replace transforms with OPTION invariance
+ Text = "!!ARBvp1.0
+
+ PARAM biasM = {0.5,0.5,0.5,0};
+ PARAM biasO = {0.5,0.5,0.5,1};
+ PARAM mvp[4] = { state.matrix.mvp };
+ PARAM mv[4] = { state.matrix.modelview };
+ ATTRIB iPos = vertex.position;
+ ATTRIB iNormal = vertex.normal;
+ OUTPUT oPos = result.position;
+ OUTPUT oColor = result.color;
+ TEMP tPos,xfNormal,scalar;
+
+ #
+ # as specified to be correct matrix multiplication (duh) row major it seems
+ #
+ DP4 tPos.x, iPos,mvp[0];
+ DP4 tPos.y, iPos,mvp[1];
+ DP4 tPos.z, iPos,mvp[2];
+ DP4 tPos.w, iPos,mvp[3];
+ MOV oPos, tPos;
+
+ # as specified correct transformation (DP3 transform)
+ DP3 xfNormal.x, iNormal, mv[0];
+ DP3 xfNormal.y, iNormal, mv[1];
+ DP3 xfNormal.z, iNormal, mv[2];
+
+ # normalize normal
+ DP3 scalar, xfNormal,xfNormal;
+ RSQ scalar,scalar.x;
+ MUL xfNormal,scalar,xfNormal;
+
+ #
+ # set the out color to be the normals transformed to eye coordinates
+ # position will have to be divided to yield previous position !!!??
+ # if we can do this ...
+ MAD oColor,xfNormal,biasM,biasO;
+
+ # I should perpahs force alpha to one ...
+
+ END",
+ Bin = list_to_binary(Text),
+ gl:programStringARB(?GL_VERTEX_PROGRAM_ARB,?GL_PROGRAM_FORMAT_ASCII_ARB,length(Text),Bin),
+ io:format("Vertex Program String state ~p~n",[glu:errorString(gl:getError())]),
+ io:format("Program errors ~p ~n",[gl:getString(?GL_PROGRAM_ERROR_STRING_ARB)]),
+ sane(Text),
+ ok.
+
+
+getInvX()->
+ [_,_,Tile,_] = gl:getIntegerv(?GL_VIEWPORT),
+ "{" ++ float_to_list(2.0/Tile) ++ ",0,0,-1};".
+ %%"{0.0039,0,0,-1};".
+
+getInvY()->
+ [_,_,_,Tile] = gl:getIntegerv(?GL_VIEWPORT),
+ "{0," ++ float_to_list(2.0/Tile) ++ ",0,-1};".
+ %%"{0,0.0039,0,-1};".
+
+getInvZ()->
+ % fix this one ? hmm
+ %%io:format("The viewport distance is -- ~p ---~n",[gl:getFloatv(?GL_DEPTH_RANGE)]),
+ [Near,Far] = gl:getFloatv(?GL_DEPTH_RANGE),
+ "{0,0," ++ float_to_list(2.0/(Far-Near)) ++ ",-1};".
+
+attrib(V,ProgID)->
+ %%io:format("Using red only in program!! ~p as replacement for phong ~n",[ProgID]),
+ gl:getError(),
+ vertexMach(),
+
+ gl:enable(?GL_FRAGMENT_PROGRAM_ARB),
+ %%[X] = gl:genProgramsARB(1),
+
+
+
+
+
+
+
+
+ Text = "!!ARBfp1.0
+
+
+ PARAM invX = " ++ getInvX() ++ " #{0.0039,0,0,-1};
+ PARAM invY = " ++ getInvY() ++ " #{0,0.0039,0,-1};
+ PARAM invZ = " ++ getInvZ() ++ " #{0,0,2,-1};
+
+ PARAM skyL = {0,1,0,0};
+ PARAM eyeDir = {0,0,1,0};
+ PARAM col = {0,1,0,1};
+ PARAM bias = {0.5,0.5,0.5,0};
+ PARAM biasO = {0.5,0.5,0.5,1};
+ PARAM white = {1,1,1,1};
+ PARAM num2 = {2,2,2,0};
+ # cel shader bias funs " ++
+ celbias(V,ProgID) ++ %%PARAM num4 = {4,4,4,0};
+ %%PARAM div3 = {0.333333,0.333333,0.333333,0};
+ " PARAM prinv[4] = { state.matrix.projection.inverse };
+ #PARAM dPos = fragment.position;
+ PARAM lPos = state.light[0].position;
+ OUTPUT oColor = result.color;
+ TEMP cPos,ePos,wPos,dPos,VP,s,VPu,halfDir,halfDirU,dots,temp,xfNormal,celt,celf,celr;
+
+
+ #MOV oColor, fragment.color;
+
+ # unpack and frac the normal data as celshading
+ MUL celt, fragment.color, num4;
+ FLR celf,celt;
+ MUL_SAT celr,celf,div3;
+
+ #
+ # treat the computed value as real normal
+ #
+ SUB xfNormal, celr, bias;
+ #MUL xfNormal, xfNormal, num2;
+ # normalize to correct numerical errors
+ DP3 s,xfNormal,xfNormal;
+ RSQ s,s.x;
+ MUL xfNormal,s,xfNormal;
+
+ # device -> eye coordinate normal transform ..
+ MOV wPos, fragment.position;
+
+ # go from viewport transform -> device coords
+ DPH dPos.x,wPos, invX;
+ DPH dPos.y,wPos, invY;
+ # use state.depth.range instead
+ #DPH dPos.z,wPos, invZ;
+ MUL dPos.z, dPos.z,state.depth.range.z;
+ ADD dPos.z, dPos.z,state.depth.range.x;
+ MOV dPos.w,wPos.w;
+
+ # do divison and transform to clip coords
+ #RCP s,fragment.position.w;
+ #MUL cPos,dPos,s.x;
+ MOV cPos,dPos;
+ #MUL cPos,dPos,fragment.position.w;
+
+ # force last to be one
+ SWZ cPos.w, cPos, x,y,z,1;
+
+ # clip -> eye coords
+ DP4 ePos.x,cPos, prinv[0];
+ DP4 ePos.y,cPos, prinv[1];
+ DP4 ePos.z,cPos, prinv[2];
+ DP4 ePos.w,cPos, prinv[3];
+
+ # in theory we now only need to apply the default light model
+
+ # get VP
+ SUB VP,lPos,ePos;
+ #MOV VP, skyL; # correct since light always up
+ # could be bound incorrectness from previous stage
+ #MOV VP,lPos; # move lPos to test ...
+
+ # normalize VP
+ DP3 s,VP,VP;
+ RSQ s,s.x;
+ MUL VPu,s,VP;
+
+ ############# cel shader norm #############
+
+ # pack and celshade VPu instead
+ MAD VPu,bias,VPu,bias;
+
+ # unpack and frac the normal data as celshading
+ MUL celt, VPu, num4;
+ FLR celf,celt;
+ MUL_SAT celr,celf,div3;
+
+ # unpack to VPu
+ SUB VPu, celr, bias;
+ # normalize to correct numerical errors
+ DP3 s,VPu,VPu;
+ RSQ s,s.x;
+ MUL VPu,s,VPu;
+
+ ############## end of cel shader #############
+
+ # calc half dir normalized
+ #
+ ADD halfDir, VPu, eyeDir;
+ DP3 s, halfDir,halfDir;
+ RSQ s,s.x;
+ MUL halfDirU,halfDir,s;
+
+ # calculate diffuse and specular dot
+ DP3 dots.x, xfNormal,VPu;
+ DP3 dots.y, xfNormal,halfDirU;
+ MOV dots.w, state.material.shininess.x;
+ LIT dots,dots;
+
+ # acc color contribs
+ MAD temp, dots.y, state.lightprod[0].diffuse, state.lightprod[0].ambient;
+ MAD oColor.xyz, dots.z, state.lightprod[0].specular, temp;
+ MOV oColor.w, state.lightprod[0].diffuse.w;
+
+ # debug stuff
+
+ #MAD oColor,VPu,bias,biasO;
+ #MOV oColor.xyz,ePos;
+ #MOV oColor, fragment.color;
+ #MOV oColor.xyz,wPos.z;
+
+ END",
+ Bin = list_to_binary(Text),
+
+ %%gl:bindProgramARB(?GL_FRAGMENT_PROGRAM_ARB,X), %% later
+ gl:programStringARB(?GL_FRAGMENT_PROGRAM_ARB,?GL_PROGRAM_FORMAT_ASCII_ARB,length(Text),Bin),
+
+
+ io:format("Fragment Program String state ~p~n",[glu:errorString(gl:getError())]),
+ io:format("Program errors ~p ~n",[gl:getString(?GL_PROGRAM_ERROR_STRING_ARB)]),
+ %io:format("Position is ~p ~n",[gl:getIntegerv(?GL_PROGRAM_ERROR_POSITION_ARB)]),
+ %io:format("Are we using program ? ~p (number ~p) ~n",[gl:isProgramARB(?GL_FRAGMENT_PROGRAM_ARB),-1]),
+ sane(Text),
+ gl:disable(?GL_TEXTURE_2D),
+ gl:disable(?GL_LIGHTING),
+ %%gl:color3f(1,0,0),
+ ok.
+
+
+celbias(V,ProgID)->
+ %%io:format("V is ~p ~n",[V]),
+ Src = case ProgID of
+ diffFragProg0 ->
+ [diffFragProg0Opts,wpc_rspt];
+ ambFragProg0 ->
+ [ambFragProg0Opts,wpc_rspt]
+ end,
+
+ %%io:format("Src has been set target ~p ~n",[[read,x_dirs|Src]]),
+ %%io:format("Catched get is ~p ~n",[catch(wpc_rspt_ma:path_get_maybe(V,[read,x_dirs|Src],0.333))]),
+ X = wpc_rspt_wm:clamp(wpc_rspt_ma:path_get_maybe(V,[read,x_dirs|Src],0.333),0.01,1),
+ Y = wpc_rspt_wm:clamp(wpc_rspt_ma:path_get_maybe(V,[read,y_dirs|Src],0.333),0.01,1),
+ Z = wpc_rspt_wm:clamp(wpc_rspt_ma:path_get_maybe(V,[read,z_dirs|Src],0.333),0.01,1),
+ Offset = wpc_rspt_wm:clamp(wpc_rspt_ma:path_get_maybe(V,[read,offset|Src],0.0),0,1),
+
+ %%io:format("Finished XYZ calc~n",[]),
+
+ %%Offset = 0,
+
+ Txt2 = "
+ PARAM num4 = {" ++ float_to_list(Offset+1/X) ++","++float_to_list(Offset+1/Y)++","++float_to_list(Offset+1/Z)++",0};
+ PARAM div3 = {" ++ float_to_list(X) ++ ","++float_to_list(Y)++","++float_to_list(Z)++",0};
+ ",
+
+ %%io:format("Finished with celbias !! txt2=~p ~n",[Txt2]),
+
+ Txt = "
+ PARAM num4 = {4,4,4,0};
+ PARAM div3 = {0.333333,0.333333,0.333333,0};
+ ",
+ Txt2.
+
+
+%%
+%% Define material structure of elem
+%%
+material_opts([S,diffFragProg0|Tail])->
+ %%io:format("Mat opts celshader diff! (~p)~n",[[object,x_dirs,diffFragProg0Opts|Tail]]),
+ [Mat|_] = lists:reverse(Tail),
+ wpc_rspt_ma:path_set([],[object,diffFragProg0Opts|Tail]),
+ wpc_rspt_ma:path_set(0.05,[object,x_dirs,diffFragProg0Opts|Tail]),
+ wpc_rspt_ma:path_set(0.05,[object,y_dirs,diffFragProg0Opts|Tail]),
+ wpc_rspt_ma:path_set(0.05,[object,z_dirs,diffFragProg0Opts|Tail]),
+ wpc_rspt_ma:path_set(0.0,[object,offset,diffFragProg0Opts|Tail]),
+ ok;
+material_opts([S,ambFragProg0|Tail])->
+ %%io:format("Mat opts celshader amb (~p)~n",[[object,x_dirs,diffFragProg0Opts|Tail]]),
+ [Mat|_] = lists:reverse(Tail),
+ wpc_rspt_ma:path_set([],[object,ambFragProg0Opts|Tail]),
+ wpc_rspt_ma:path_set(0.05,[object,x_dirs,ambFragProg0Opts|Tail]),
+ wpc_rspt_ma:path_set(0.05,[object,y_dirs,ambFragProg0Opts|Tail]),
+ wpc_rspt_ma:path_set(0.05,[object,z_dirs,ambFragProg0Opts|Tail]),
+ wpc_rspt_ma:path_set(0.0,[object,offset,ambFragProg0Opts|Tail]),
+ ok.
76 contrib/rspt/wpc_rspt_combiner.erl
@@ -0,0 +1,76 @@
+%%
+%% Copyright (c) 2004 Rolf Stenholm
+%%
+%% See the file "license.terms" for information on usage and redistribution
+%% of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+%%
+%% $Id: wpc_rspt_combiner.erl,v 1.1 2004/08/25 05:33:05 bjorng Exp $
+%%
+
+%%%
+%%% Module to combine results
+%%%
+%%%
+
+-module(wpc_rspt_combiner).
+-define(NEED_ESDL,1).
+-define(NEED_OPENGL,1).
+-include_lib("wings.hrl").
+-include_lib("e3d.hrl").
+-include_lib("e3d_image.hrl").
+
+
+-export([init/0,menu/2,command/2,attrib/2]).
+-export([help/0,material_opts/1]).
+
+
+init()->
+ %%io:format("Loading ~p ... ~n",[?MODULE]),
+ true.
+
+
+%% start with all red for ambient and diff
+menu(rspt_material_menu_ambFragProg0,Menu)->
+ [{"Combiner",wpc_rspt_combiner}] ++ Menu;
+menu(rspt_material_menu_diffFragProg0,Menu)->
+ [{"Combiner",wpc_rspt_combiner}] ++ Menu;
+menu(rspt_help,Menu)->
+ [{"Combining textures",{wpc_rspt_combiner,help}}] ++ Menu;
+menu(X, Menu)->
+ %%io:format("Ignoring menu ~p ~n",[X]),
+ Menu.
+
+
+command(_,_)-> next.
+
+
+help()->
+ wpc_rspt_wm:help_window(wpc_rspt_skinshader_help_window,"Skin shader",
+ ["Combiner",
+ "Experimental texture combiner"],[]).
+
+material_opts([S,diffFragProg0|Tail])->
+ material_init(diffFragProg0,diffFragProg0Opts,[diffFragProg0Opts|Tail]),
+ ok;
+material_opts([S,ambFragProg0|Tail])->
+ material_init(ambFragProg0,ambFrag0Opts,[ambFragProg0Opts|Tail]),
+ ok.
+
+
+material_init(NSel,NOpts,Target)->
+ io:format("Setting the path ~p ~n",[Target]),
+ wpc_rspt_ma:path_set([],[object|Target]),
+ wpc_rspt_ma:path_set(add,[object,combiner|Target]),
+ wpc_rspt_ma:path_set(nothing,[object,combinerOpts|Target]),
+ wpc_rspt_ma:path_set(standard,[object,NSel,componentA|Target]),
+ wpc_rspt_ma:path_set(nothing,[object,NOpts,componentA|Target]),
+ wpc_rspt_ma:path_set(standard,[object,NSel,componentB|Target]),
+ wpc_rspt_ma:path_set(nothing,[object,NOpts,componentB|Target]),
+ ok.
+
+
+
+
+
+attrib(V,ProgID)->
+ ok.
171 contrib/rspt/wpc_rspt_depth.erl
@@ -0,0 +1,171 @@
+%%
+%% Copyright (c) 2004 Rolf Stenholm
+%%
+%% See the file "license.terms" for information on usage and redistribution
+%% of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+%%
+%% $Id: wpc_rspt_depth.erl,v 1.1 2004/08/25 05:33:05 bjorng Exp $
+%%
+
+%%%
+%%% Model to produce phong shading
+%%%
+%%%
+
+
+-module(wpc_rspt_depth).
+-define(NEED_ESDL,1).
+-define(NEED_OPENGL,1).
+-include_lib("wings.hrl").
+-include_lib("e3d.hrl").
+-include_lib("e3d_image.hrl").
+
+
+-export([init/0,menu/2,command/2,attrib/2]).
+
+
+init()->
+ %%io:format("Loading ~p ... ~n",[?MODULE]),
+ true.
+
+%% start with all red for ambient and diff
+menu(rspt_material_menu_ambFragProg0,Menu)->
+ [{"Depth color",wpc_rspt_depth}] ++ Menu;
+menu(rspt_material_menu_diffFragProg0,Menu)->
+ [{"Depth color",wpc_rspt_depth}] ++ Menu;
+menu(X, Menu)->
+ %%io:format("Ignoring menu ~p ~n",[X]),
+ Menu.
+
+command(_,_)-> next.
+
+
+%%%
+%%%
+%%%
+
+%%%
+%%%
+%%%
+sane(Text)->
+ sane(gl:getIntegerv(?GL_PROGRAM_ERROR_POSITION_ARB),Text).
+
+sane([-1|_],_)->
+ ok;
+sane([X|_],Text)->
+ saneNumber(X,Text,1).
+
+saneNumber(-1,_,1)->
+ ok;
+saneNumber(0,_,L)->
+ io:format("On line ~p ~n",[L]),
+ ok;
+saneNumber(X,[10|T],L)->
+ saneNumber(X-1,T,L+1);
+saneNumber(X,[_|T],L)->
+ saneNumber(X-1,T,L);
+saneNumber(_,_,_)->
+ io:format("Unknown instruction state ?~n",[]).
+
+
+vertexMach()->
+ gl:enable(?GL_VERTEX_PROGRAM_ARB),
+ %% should probably replace transforms with OPTION invariance
+ Text = "!!ARBvp1.0
+
+ PARAM biasM = {0.5,0.5,0.5,0};
+ PARAM biasO = {0.5,0.5,0.5,1};
+ PARAM mvp[4] = { state.matrix.mvp };
+ PARAM mv[4] = { state.matrix.modelview };
+ ATTRIB iPos = vertex.position;
+ ATTRIB iNormal = vertex.normal;
+ OUTPUT oPos = result.position;
+ OUTPUT oColor = result.color;
+ TEMP tPos,xfNormal,scalar;
+
+ #
+ # as specified to be correct matrix multiplication (duh) row major it seems
+ #
+ DP4 tPos.x, iPos,mvp[0];
+ DP4 tPos.y, iPos,mvp[1];
+ DP4 tPos.z, iPos,mvp[2];
+ DP4 tPos.w, iPos,mvp[3];
+ MOV oPos, tPos;
+
+ # as specified correct transformation (DP3 transform)
+ DP3 xfNormal.x, iNormal, mv[0];
+ DP3 xfNormal.y, iNormal, mv[1];
+ DP3 xfNormal.z, iNormal, mv[2];
+
+ # normalize normal
+ DP3 scalar, xfNormal,xfNormal;
+ RSQ scalar,scalar.x;
+ MUL xfNormal,scalar,xfNormal;
+
+ #
+ # set the out color to be the normals transformed to eye coordinates
+ # position will have to be divided to yield previous position !!!??
+ # if we can do this ...
+ MAD oColor,xfNormal,biasM,biasO;
+
+ # I should perpahs force alpha to one ...
+
+ END",
+ Bin = list_to_binary(Text),
+ gl:programStringARB(?GL_VERTEX_PROGRAM_ARB,?GL_PROGRAM_FORMAT_ASCII_ARB,length(Text),Bin),
+ io:format("Vertex Program String state ~p~n",[glu:errorString(gl:getError())]),
+ io:format("Program errors ~p ~n",[gl:getString(?GL_PROGRAM_ERROR_STRING_ARB)]),
+ sane(Text),
+ ok.
+
+
+getInvX()->
+ [_,_,Tile,_] = gl:getIntegerv(?GL_VIEWPORT),
+ "{" ++ float_to_list(2.0/Tile) ++ ",0,0,-1};".
+ %%"{0.0039,0,0,-1};".
+
+getInvY()->
+ [_,_,_,Tile] = gl:getIntegerv(?GL_VIEWPORT),
+ "{0," ++ float_to_list(2.0/Tile) ++ ",0,-1};".
+ %%"{0,0.0039,0,-1};".
+
+getInvZ()->
+ % fix this one ? hmm
+ %%io:format("The viewport distance is -- ~p ---~n",[gl:getFloatv(?GL_DEPTH_RANGE)]),
+ [Near,Far] = gl:getFloatv(?GL_DEPTH_RANGE),
+ "{0,0," ++ float_to_list(2.0/(Far-Near)) ++ ",-1};".
+
+attrib(V,ProgID)->
+ io:format("Using red only in program!! ~p as replacement for phong ~n",[ProgID]),
+ gl:getError(),
+ vertexMach(),
+
+ gl:enable(?GL_FRAGMENT_PROGRAM_ARB),
+ %%[X] = gl:genProgramsARB(1),
+
+
+
+
+
+ Text = "!!ARBfp1.0
+
+ PARAM white = {1,1,1,1};
+ OUTPUT oColor = result.color;
+ MOV oColor.xyz, fragment.position.z;
+ MOV oColor.w, white.w;
+ END",
+ Bin = list_to_binary(Text),
+
+ %%gl:bindProgramARB(?GL_FRAGMENT_PROGRAM_ARB,X), %% later
+ gl:programStringARB(?GL_FRAGMENT_PROGRAM_ARB,?GL_PROGRAM_FORMAT_ASCII_ARB,length(Text),Bin),
+
+
+ io:format("Fragment Program String state ~p~n",[glu:errorString(gl:getError())]),
+ io:format("Program errors ~p ~n",[gl:getString(?GL_PROGRAM_ERROR_STRING_ARB)]),
+ %io:format("Position is ~p ~n",[gl:getIntegerv(?GL_PROGRAM_ERROR_POSITION_ARB)]),
+ %io:format("Are we using program ? ~p (number ~p) ~n",[gl:isProgramARB(?GL_FRAGMENT_PROGRAM_ARB),-1]),
+ sane(Text),
+ gl:disable(?GL_TEXTURE_2D),
+ gl:disable(?GL_LIGHTING),
+ %%gl:color3f(1,0,0),
+ ok.
103 contrib/rspt/wpc_rspt_frag.erl
@@ -0,0 +1,103 @@
+%%
+%% Copyright (c) 2004 Rolf Stenholm
+%%
+%% See the file "license.terms" for information on usage and redistribution
+%% of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+%%
+%% $Id: wpc_rspt_frag.erl,v 1.1 2004/08/25 05:33:05 bjorng Exp $
+%%
+
+%%%
+%%% Fragment program test module
+%%%
+%%%
+
+
+-module(wpc_rspt_frag).
+-define(NEED_ESDL,1).
+-define(NEED_OPENGL,1).
+-include_lib("wings.hrl").
+-include_lib("e3d.hrl").
+-include_lib("e3d_image.hrl").
+
+
+-export([init/0,menu/2,command/2,attrib/2]).
+
+
+init()->
+ %%io:format("Loading ~p ... ~n",[?MODULE]),
+ true.
+
+%% start with all red for ambient and diff
+menu(rspt_material_menu_ambFragProg0,Menu)->
+ [{"Fragment program red",?MODULE}] ++ Menu;
+menu(rspt_material_menu_diffFragProg0,Menu)->
+ [{"Fragment program red",?MODULE}] ++ Menu;
+menu(X, Menu)->
+ %%io:format("Ignoring menu ~p ~n",[X]),
+ Menu.
+
+command(_,_)-> next.
+
+
+%%%
+%%%
+%%%
+
+
+attrib(V,ProgID)->
+ io:format("Using red only in program!! ~p as replacement for phong ~n",[ProgID]),
+ gl:getError(),
+ gl:enable(?GL_FRAGMENT_PROGRAM_ARB),
+ %%[X] = gl:genProgramsARB(1),
+ TextOld = "!!ARBfp1.0
+ # Simple program to show how to code up the default texture environment
+
+ PARAM col = {1,0,0,1};
+
+ OUTPUT outColor = result.color;
+
+ MOV outColor, col; #perform the modulation
+
+ END",
+
+ Text = "!!ARBfp1.0
+PARAM col = {1,0,0,1};
+PARAM zix = {0.002,0.002,0.002,1};
+PARAM neg = {0,0,-1,1};
+TEMP x,y,z,tx,ty,tz,tx2,ty2,tz2,tf,tf2;
+OUTPUT outc = result.color;
+DP3 x, state.matrix.mvp.inverse.row[0], fragment.position;
+DP3 y, state.matrix.mvp.inverse.row[1], fragment.position;
+DP3 z, state.matrix.mvp.inverse.row[2], fragment.position;
+SIN ty,y .y;
+SIN tx,x .x;
+SIN tz,z .z;
+SWZ tx2, tx, x,0,0,0;
+SWZ ty2, ty, 0,y,0,1;
+SWZ tz2, tz, 0,0,z,0;
+ADD tf, tx2,ty2;
+ADD tf2, tz2,tf;
+# should bias obj for numerical errors ...
+#KIL neg; no effect for anything why ?? check
+#COS obj,
+#MUL obj, zix, fragment.position;
+MOV outc, tf2;
+END
+",
+
+
+ Bin = list_to_binary(Text),
+
+ %%gl:bindProgramARB(?GL_FRAGMENT_PROGRAM_ARB,X), %% later
+ gl:programStringARB(?GL_FRAGMENT_PROGRAM_ARB,?GL_PROGRAM_FORMAT_ASCII_ARB,length(Text),Bin),
+
+
+ io:format("Program String state ~p~n",[glu:errorString(gl:getError())]),
+ io:format("Program errors ~p ~n",[gl:getString(?GL_PROGRAM_ERROR_STRING_ARB)]),
+ io:format("Position is ~p ~n",[gl:getIntegerv(?GL_PROGRAM_ERROR_POSITION_ARB)]),
+ io:format("Are we using program ? ~p (number ~p) ~n",[gl:isProgramARB(?GL_FRAGMENT_PROGRAM_ARB),-1]),
+ gl:disable(?GL_TEXTURE_2D),
+ gl:disable(?GL_LIGHTING),
+ %%gl:color3f(1,0,0),
+ ok.
824 contrib/rspt/wpc_rspt_ma.erl
@@ -0,0 +1,824 @@
+%%
+%% Copyright (c) 2004 Rolf Stenholm
+%%
+%% See the file "license.terms" for information on usage and redistribution
+%% of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+%%
+%% $Id: wpc_rspt_ma.erl,v 1.1 2004/08/25 05:33:05 bjorng Exp $
+%%
+
+%
+%Material module
+%
+%
+%
+%
+-module(wpc_rspt_ma).
+-define(NEED_ESDL,1).
+-define(NEED_OPENGL,1).
+-include_lib("wings.hrl").
+-include_lib("e3d.hrl").
+-include_lib("e3d_image.hrl").
+
+
+-export([init/0,menu/2,command/2]).
+-export([dialog/2]).
+-export([texture_compile/1,face/4,uvc/1,quantity/1,compile/3,resolve/3,gval/3,attrib/3]).
+%% the get and set material value funs (should skip bad values ??, no since these need policies )
+-export([path_get/2,path_get/1,path_set/3,path_set/2,path_get_maybe/3,path_get_maybe/2,texture/1]).
+
+
+%% link into app
+init()->
+ %%io:format("Loading wpc_rspt_ma ... ~n",[]),
+ true.
+
+
+menu(X, Menu)->
+ %%io:format("Material menu ~p ~n",[X]),
+ Menu.
+
+command({material,{new,Name}},St)->
+
+ case wpc_rspt_ps:is_enabled() of
+ true ->
+ %% bypass regular new
+ io:format("RSPT creating new material~n",[]),
+ %% do more here
+ {Name1,St1} = new_material(Name,false,St),
+ wpc_rspt_wm:set_current_state(St1),
+ St2 = material_window(Name1,St1),
+
+ %% correct ?? no
+ St2;
+ false ->
+ next
+ end;
+command({material,{edit,Name}},St)->
+
+ %% check if enabled
+ case wpc_rspt_ps:is_enabled() of
+ true ->
+ %% send what here ??
+ io:format("RSPT enabled bypassing!~n",[]),
+ St1 = material_window(Name,St),
+ St1;
+ false ->
+ io:format("RSPT disabled!~n",[]),
+ next
+ end;
+
+command(X,_)->
+ io:format("Mat Command ~p ~n",[X]),
+ next.
+
+%% material dialog for wings
+%% should not show up if disabled
+dialog({material_editor_setup,Name,Mat},Dialog)->
+ Dialog; %% ++ build_dialog(Mat);
+
+%%
+%% as formatted below
+%%
+dialog({material_editor_result,Name,Mat},Dialog)->
+ %%io:format("Dialog {material_editor_result,~p,~p} dialog data ~p ~n",[Name,Mat,Dialog]),
+ io:format("Dialog {material_editor_result,~p,~p},~p ~n",[Name,Mat,Dialog]),
+ %%invalid;
+ %% the dialog data is the a proplist of features
+ %%{[{wpc_rspt,Dialog}]++Mat,[]};
+ {insert(Dialog,Mat),[]};
+
+%%
+%% another dialog instruction
+dialog(X,Dialog)->
+ io:format("Dialog entry ~p ~n~n",[X]),
+ Dialog.
+
+
+%%%%%%%%%
+%%%%%%%%% dialog construction of plugin modules
+%%%%%%%%%
+
+build_dialog(Mat)->
+ [{vframe,[
+ {label,"Ambient material pipeline"},
+ build_pipe("ambPipe",Mat),
+ {label,"Ambient material stages"},
+ {hframe,build_dia("amb",0,5,Mat)},
+ {label,"Diffuse & Specular material pipeline"},
+ build_pipe("diffPipe",Mat),
+ {label,"Diffuse & Specular material stages"},
+ {hframe,build_dia("diff",0,5,Mat)}]
+
+ ,[{title,"RSPT material options"}]}].
+
+build_pipe(Arg,Mat)->
+ {menu,[{"Default",standard},
+ {"Foobar",foobar}]
+ ++ wpc_rspt_ps:get_mat(Arg),
+ gval(list_to_atom(Arg),Mat,standard),
+ [{key,list_to_atom(Arg)}]}.
+
+
+build_dia(L,X,X,Mat)->
+ [];
+build_dia(L,X,Y,Mat)->
+
+ [{vframe,[{menu,[{"None",standard},
+ {"Pure red",red_only},
+ %% fetch all material plugins ..
+ {"Blend",blend}] ++ wpc_rspt_ps:get_mat(L,X),
+ gval(list_to_atom(L ++ "FragProg" ++ [$0+X]),Mat,standard),
+ [{key,list_to_atom(L ++ "FragProg" ++ [$0+X])}]
+ }
+ ]}| build_dia(L,X+1,Y,Mat)].
+
+
+
+
+%%%%%%%%%%%
+%%%%%%%%%%% Create the material by default opengl ...
+%%%%%%%%%%%
+
+%%%
+%%%Should not directly be compiled into the scene data, additional call list should be used to
+%%%be able to adapt scene behaviour ...
+
+%% likely to be obsolete, but keep in case this becomes useful
+% should return gb_trees with textures, may need further adjustments
+texture_compile(#st{mat=Mat}=St)->
+ %% could use this to build mipmaps of every texture and pass on those values
+ %% (saved for later)
+ % write out all material data
+ %%io:format("=======================~n~p~n=======================~n ~n",[Mat]),
+ ok.
+%
+%color or uv
+%
+uvc({X,Y})->
+ %%io:format("Coord ~p ~p ~n",[X,Y]),
+ %%gl:texCoord2f(X,Y),
+ %% unit 0
+ gl:multiTexCoord2f(?GL_TEXTURE0,X,Y),
+ gl:multiTexCoord2f(?GL_TEXTURE1,X,Y),
+ gl:multiTexCoord2f(?GL_TEXTURE2,X,Y),
+ gl:multiTexCoord2f(?GL_TEXTURE3,X,Y),
+ gl:multiTexCoord2f(?GL_TEXTURE4,X,Y),
+ gl:multiTexCoord2f(?GL_TEXTURE5,X,Y),
+ gl:multiTexCoord2f(?GL_TEXTURE6,X,Y),
+ gl:multiTexCoord2f(?GL_TEXTURE7,X,Y),
+ ok;
+uvc({X,Y,Z})->
+ %% ignore the color data
+ %%gl:color3f(X,Y,Z),
+ ok;
+uvc(X)->
+ % never happens
+ %%io:format("=====================~n Other material ~p~n===================~n",[X]),
+ ok.
+
+%
+%Find the material
+%
+face(Face,#we{mat=Mat}=WE,St,Scene) when is_atom(Mat) ->
+ %attrib(Mat,St);
+ resolve(Mat,St,Scene);
+face(Face,#we{mat=Mat}=WE,St,Scene) ->
+ Name = proplists:get_value(Face,Mat),
+ %attrib(Name,St).
+ resolve(Name,St,Scene).
+
+
+
+%
+%Setup attributes for material (ignore vertex light)
+%
+attrib(Name,#st{mat=Mat}=St,ProgID)->
+ case gb_trees:lookup(Name,Mat) of
+ {value,V} ->
+ % proplist of stuff (safe mode???)
+ OpenGL = proplists:get_value(opengl,V),
+ Diffuse = proplists:get_value(diffuse,OpenGL),
+ Specular = proplists:get_value(specular,OpenGL),
+ Ambient = proplists:get_value(ambient,OpenGL),
+ Emission = proplists:get_value(emission,OpenGL),
+ Shininess = proplists:get_value(shininess,OpenGL),
+ % wings seems to multiply this with 128 why ? check later ...
+ % appears to be to cap values to 0-1
+ gl:materialf(?GL_FRONT_AND_BACK,?GL_SHININESS,Shininess*128),
+ gl:materialfv(?GL_FRONT_AND_BACK,?GL_AMBIENT,Ambient),
+ gl:materialfv(?GL_FRONT_AND_BACK,?GL_DIFFUSE,Diffuse),
+ gl:materialfv(?GL_FRONT_AND_BACK,?GL_SPECULAR,Specular),
+ gl:materialfv(?GL_FRONT_AND_BACK,?GL_EMISSION,Emission),
+ gl:disable(?GL_TEXTURE_2D),
+ gl:disable(?GL_ALPHA_TEST),
+ gl:enable(?GL_LIGHTING),
+ gl:disable(?GL_FRAGMENT_PROGRAM_ARB),
+ gl:disable(?GL_VERTEX_PROGRAM_ARB),
+ gl:disable(?GL_COLOR_LOGIC_OP),
+ %%
+ %%Handle maps part and potential texture id
+ %%
+ TexMat = proplists:get_value(maps,V),
+ texture(TexMat),
+ maProg(V,ProgID),
+ ok;
+ none ->
+ io:format("Warning material ~p is ignored ~n",[Name]),
+ %% do what ?? (ignore for the moment)
+ ok
+ end,
+ ok.
+
+%
+%Use textures as appropriate if we find some
+% does it crash some later needed use of stencil ?? hmm
+%
+texture(Mat)->
+ case proplists:get_value(diffuse,Mat,none) of
+ none ->
+ gl:bindTexture(?GL_TEXTURE_2D,0),
+ % no texture
+ ok;
+ Tex ->
+ case wings_image:txid(Tex) of
+ none ->
+ io:format("No texture for object with texture~n",[]),
+ ok;
+ ID ->
+ gl:bindTexture(?GL_TEXTURE_2D,ID),
+ %%io:format("Using texture ~p ~n",[ID]),
+ % render texture
+ gl:enable(?GL_TEXTURE_2D),
+ %% was GL_MODULATE only for debug ?? not true
+ gl:texEnvi(?GL_TEXTURE_ENV,?GL_TEXTURE_ENV_MODE,?GL_MODULATE),
+ %%
+ %% Wings does not have mipmaps this is bad ... or maybe unimportant in close ups ??
+ %% rebuild textures in wings ??? or copy them ??
+ %% mipmap by hand ??
+ %%
+ gl:texParameteri(?GL_TEXTURE_2D,?GL_TEXTURE_MAG_FILTER,?GL_LINEAR),
+ gl:texParameteri(?GL_TEXTURE_2D,?GL_TEXTURE_MIN_FILTER,?GL_LINEAR),
+ gl:texParameteri(?GL_TEXTURE_2D,?GL_TEXTURE_WRAP_S,?GL_REPEAT),
+ gl:texParameteri(?GL_TEXTURE_2D,?GL_TEXTURE_WRAP_T,?GL_REPEAT),
+ case wings_image:info(Tex) of
+ #e3d_image{bytes_pp=4}->
+ io:format("pp4 image!! ~n",[]),
+ gl:enable(?GL_ALPHA_TEST),
+ gl:alphaFunc(?GL_GREATER,0.5);
+ #e3d_image{type=a8} ->
+ io:format("a8 image!! ~n",[]),
+ gl:enable(?GL_ALPHA_TEST),
+ gl:alphaFunc(?GL_GREATER,0.5);
+ _ ->
+ gl:disable(?GL_ALPHA_TEST)
+ end,
+ ok
+ end
+ end.
+
+
+
+
+%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%% Compile all materials as requested
+%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%
+
+%%
+%%Will require more material defs
+%%likely to change to different material requests for ambiant & specular pass versus ambient
+%%
+%% Numbering of material to scene data
+%%
+%% Scene | Scene +1 | Scene +2 | ... | Scene + N
+%% the scene
+%% mat 1
+%% mat 2
+%% ...
+%% mat N (last material)
+%%
+compile(Scene,#st{mat=Mat}=St,Request)->
+ case Request of
+
+ %% bind material to scene objects
+ full ->
+ %%io:format("<<<<< material on >>>>>>>~n",[]),
+ lists:foldl(fun({Cmat,_},Acc) ->
+ gl:getError(),
+ gl:newList(Acc,?GL_COMPILE),
+ attrib(Cmat,St,0),
+ gl:endList(),
+ %%io:format("material GL state ~p compile number ~p ~n",[glu:errorString(gl:getError()),Acc]),
+ Acc+1
+ end,Scene+1,gb_trees:to_list(Mat)),
+ %% compiled on the gpu
+ ok;
+ %% run program with ID either ambient or
+ {full,ProgID} ->
+ %%io:format("<<<<< material on >>>>>>>~n",[]),
+ lists:foldl(fun({Cmat,_},Acc) ->
+ gl:getError(),
+ gl:newList(Acc,?GL_COMPILE),
+ attrib(Cmat,St,ProgID),
+ gl:endList(),
+ %%io:format("material GL state ~p compile number ~p ~n",[glu:errorString(gl:getError()),Acc]),
+ Acc+1
+ end,Scene+1,gb_trees:to_list(Mat)),
+ %% compiled on the gpu
+ ok;
+ %% bind empty material definitons to scene
+ none ->
+ %% zero all material settings
+ lists:foldl(fun({Cmat,_},Acc) ->
+ gl:getError(),
+ gl:newList(Acc,?GL_COMPILE),
+ gl:endList(),
+ %%io:format("material zero mat GL state ~p compile number ~p~n",[glu:errorString(gl:getError()),Acc]),
+ Acc+1
+ end,Scene+1,gb_trees:to_list(Mat)),
+ %% compiled on the gpu
+ ok
+ end.
+
+
+%%
+%%Number of material compile targets needed
+%%tightly connected to re modules scene entity
+%%
+quantity(#st{mat=Mat}=St)->
+ %%io:format("quantity of material is ~p ~n",[gb_trees:size(Mat)]),
+ gb_trees:size(Mat).
+
+
+%%
+%%get the material number for the current face and call it
+%%
+resolve(Matv,#st{mat=Mat}=St,Scene)->
+ %% resolve material number
+ Keys = gb_trees:keys(Mat),
+ %%io:format("Resolved number are ~p scene is ~p ~n",[resolve_number(Keys,Matv,Scene+1),Scene]),
+ gl:callList(resolve_number(Keys,Matv,Scene+1)),
+ ok.
+
+
+%%
+%% get number
+%%
+resolve_number([Matv|_],Matv,Num)->
+ Num;
+resolve_number([_|T],Matv,Num)->
+ resolve_number(T,Matv,Num+1).
+
+
+
+%%%%
+%%%%should fetch data values ...
+%%%%
+
+gval(Key,Mat,Def)->
+ case proplists:lookup(wpc_rspt,Mat) of
+
+ none ->
+ Def;
+ {_,T} ->
+ case proplists:lookup(Key,T) of
+
+ none ->
+ Def;
+ {_,V} ->
+ V
+ end
+ end.
+
+insert(Key,Val,Mat)->
+ %%io:format("<<< INSERT >>> {~p,~p} ~p ~n",[Key,Val,Mat]),
+ case proplists:lookup(wpc_rspt,Mat) of
+
+ none ->
+ %%io:format("<< insert into empty >> ~n",[]),
+ [{wpc_rspt,[{Key,Val}]}]++Mat;
+
+ {_,List} ->
+ %%io:format("<< insert into proplist >>~n",[]),
+ [{wpc_rspt, [{Key,Val}] ++ proplists:delete(Key,List)}]
+ ++ proplists:delete(wpc_rspt,Mat)
+ end.
+
+insert([{Key,Val}|T],Mat)->
+ insert(T,insert(Key,Val,Mat));
+insert([],Mat)->
+ %% ignore other ??
+ Mat;
+insert(_,Mat)->
+ Mat.
+
+
+
+
+%%%%%%%%%%%
+%%%%%%%%%%%
+%%%%%%%%%%% Ma program, anything that can be defined by OpenGL
+%%%%%%%%%%%
+%%%%%%%%%%%
+
+maProg(V,ProgID)->
+ case proplists:lookup(wpc_rspt,V) of
+
+ none ->
+ %%io:format("Material has no rspt ext ~n ~p ~n============~n",[V]),
+ progZero(ProgID);
+
+ {_,Ents} ->
+
+ case proplists:lookup(ProgID,Ents) of
+
+ none ->
+ %% skip
+ progZero(ProgID);
+ {_,standard} ->
+ %% skip this entry
+ progZero(ProgID);
+
+ {_,red_only} ->
+ %%io:format("Using red only in program!! ~p ~n",[ProgID]),
+ gl:disable(?GL_TEXTURE_2D),
+ gl:disable(?GL_LIGHTING),
+ gl:color3f(1,0,0);
+ {_,blend} ->
+ gl:logicOp(?GL_INVERT),
+ gl:enable(?GL_COLOR_LOGIC_OP),
+ ok;
+ {_,Mod} ->
+ %%io:format("Calling module ~p ~n",[Mod]),
+ %%io:format("Result: ~p ~n",[catch Mod:attrib(V,ProgID)]),
+ catch Mod:attrib(V,ProgID),
+ ok
+ %% plugin system here now ..
+ end
+ end.
+
+
+
+
+%%
+%%Program is zero or none, skip data for anything not Prog0
+%%
+progZero(ProgID)->
+ %% no prog, change scene only if appropriate
+ case ProgID of
+
+ ambFragProg0 ->
+ ok;
+ diffFragProg0 ->
+ ok;
+
+
+ _ ->
+ %%io:format("Using all white in ~p ~n",[ProgID]),
+ %% perhaps disable buffer writing here ??
+ %% not done since interfering with other stuff
+ %%gl:disable(?GL_TEXTURE_2D),
+ gl:color3f(1,1,1),
+ gl:blendEquation(?GL_FUNC_ADD),
+ gl:blendFunc(?GL_ZERO,?GL_ONE),
+ gl:enable(?GL_BLEND),
+ ok
+
+ end,
+ ok.
+
+
+%%
+%% Create material window ...
+%%
+material_window(Name,#st{mat=Mat}=St)->
+
+ AName = list_to_atom(Name),
+
+ %% fix any material without rspt funs
+ fix_rspt_mat(AName),
+
+ %%io:format("Materials ~p ~n",[wings_wm:get_current_state()]),
+ %% bombs if renaming materials ??!! check
+ Req = fun()->
+ #st{mat=OMat} = wpc_rspt_wm:get_current_state(),
+ [{AName,gb_trees:get(AName,OMat)}]
+ end,
+ wpc_rspt_wm:window(list_to_atom(Name++"_material_"++"window"),"Material properties " ++ Name,
+ [Name,""],[],Req,fun()-> wpc_rspt_wm:legend_material(Name) end,160,fun(Data)-> material_chain_defs(Data) end),
+
+ %%%%%%% [{AName,gb_trees:get(AName,Mat)}]),
+ wpc_rspt_wm:get_current_state().
+
+%%
+%% Include material attribute settings
+%%
+material_chain_defs(Data0)->
+ Data = material_def_chains(Data0),
+ Elem = wpc_rspt_ps:getPrefixed("material_event_chain"),
+ lists:foldl(fun(A,Acc)->
+ case catch(A(Acc)) of
+ {'EXIT',W} ->
+ %% should not be removed
+ io:format("Warning plugin error reported as ~p keeping material_chain~n",[W]),
+ Acc;
+ Acc1 ->
+ Acc1
+ end
+ end,Data,Elem).
+
+
+material_def_chains(Data0)->
+ F1 = fun(X)->
+ %%io:format("Mat diffFragProg0 handler called!!~n",[]),
+ case X of
+ height ->
+ 1;
+ {render,Zatom,IX,Y}->
+ Text = atom_to_list(Zatom),
+ gl:color3f(0,0,1),
+ wings_io:text_at(IX,Y+?LINE_HEIGHT,Text),
+ gl:color3f(0,0,0),
+ Y + ?LINE_HEIGHT;
+ {push,HW,[S|Obj],PX,PY} ->
+ %% should rotate Obj
+ %%io:format("Target ~p called~n",[Obj]),
+ %% value is
+ OVal = path_get([object|Obj]),
+ NVal = grab_next_menu_option([standard] ++ filter_a(wpc_rspt_ps:get_mat("diff",0)),OVal),
+ path_set(NVal,[object|Obj]), %% finished
+ catch(NVal:material_opts([S|Obj])),
+ HW;
+ _->
+ io:format("Diff handler ignoring ~p~n",[X])
+ end
+ end,
+ D1 = wpc_rspt_wm:chain_register({[atom,diffFragProg0,wpc_rspt],F1},Data0),
+ F2 = fun(X)->
+ %%io:format("Mat diffFragProg0 handler called!!~n",[]),
+ case X of
+ height ->
+ 1;
+ {render,Zatom,IX,Y}->
+ Text = atom_to_list(Zatom),
+ gl:color3f(0,0,1),
+ wings_io:text_at(IX,Y+?LINE_HEIGHT,Text),
+ gl:color3f(0,0,0),
+ Y + ?LINE_HEIGHT;
+ {push,HW,[S|Obj],PX,PY} ->
+ OVal = path_get([object|Obj]),
+ NVal = grab_next_menu_option([standard] ++ filter_a(wpc_rspt_ps:get_mat("amb",0)),OVal),
+ path_set(NVal,[object|Obj]), %% finished
+ catch(NVal:material_opts([S|Obj])),
+ HW;
+ _->
+ io:format("Amb handler ignoring ~p~n",[X])
+ end
+ end,
+ D2 = wpc_rspt_wm:chain_register({[atom,ambFragProg0,wpc_rspt],F2},D1),
+ F3 = fun(X)->
+ case X of
+ height ->
+ 1;
+ {render,Zatom,IX,Y}->
+ Text = atom_to_list(Zatom),
+ gl:color3f(0,0,1),
+ wings_io:text_at(IX,Y+?LINE_HEIGHT,Text),
+ gl:color3f(0,0,0),
+ Y + ?LINE_HEIGHT;
+ {push,HW,[S|Obj],PX,PY} ->
+ OVal = path_get([object|Obj]),
+ NVal = grab_next_menu_option([standard] ++ filter_a(wpc_rspt_ps:get_mat("ambPipe")),OVal),
+ path_set(NVal,[object|Obj]), %% finished
+ catch(NVal:material_opts([S|Obj])),
+ HW;
+ _->
+ io:format("DiffPrg handler ignoring ~p~n",[X])
+ end
+ end,
+ D3 = wpc_rspt_wm:chain_register({[atom,ambPipePrg,wpc_rspt],F3},D2),
+ F4 = fun(X)->
+ case X of
+ height ->
+ 1;
+ {render,Zatom,IX,Y}->
+ Text = atom_to_list(Zatom),
+ gl:color3f(0,0,1),
+ wings_io:text_at(IX,Y+?LINE_HEIGHT,Text),
+ gl:color3f(0,0,0),
+ Y + ?LINE_HEIGHT;
+ {push,HW,[S|Obj],PX,PY} ->
+ OVal = path_get([object|Obj]),
+ NVal = grab_next_menu_option([standard] ++ filter_a(wpc_rspt_ps:get_mat("diffPipe")),OVal),
+ path_set(NVal,[object|Obj]), %% finished
+ catch(NVal:material_opts([S|Obj])),
+ HW;
+ _->
+ io:format("AmbPrg handler ignoring ~p~n",[X])
+ end
+ end,
+ D4 = wpc_rspt_wm:chain_register({[atom,diffPipePrg,wpc_rspt],F4},D3).
+
+
+
+filter_a([{_,V}|T])->
+ [V|filter_a(T)];
+filter_a([])->
+ [].
+
+fix_rspt_mat(AName)->
+ %%io:format("Fixing material ~p~n",[AName]),
+
+ %%io:format("Fixing material ~p~n",[AName]),