Skip to content
Browse files

Added support for phong effect type. I left line 43 from previous ver…

…sion but I am unsure that "effect.getChild("profile_COMMON/technique/constant/transparent")" is correct. I have added correct support at line 46 "diffuse = effect.getChild("profile_COMMON/technique/lambert/transparent");" Also added print out to command line to let the user when they try to use an effect type that isn't supported. This should be printed as an error message in a future update.
  • Loading branch information...
1 parent 39fed82 commit 9fbafa3264daace1a9de67be46bed72b366a430d @Codeguyross committed Nov 15, 2011
Showing with 31 additions and 3 deletions.
  1. +31 −3 src/colladaLoader/xmlMapping/Effect.java
View
34 src/colladaLoader/xmlMapping/Effect.java
@@ -25,13 +25,41 @@
private float[] color;
private boolean hasTexture = false;
+ //add support for your chosen effect here
Effect(XMLElement effect, Library_Images images)
{
ID = effect.getString("id");
+ XMLElement diffuse = null;
- XMLElement diffuse = effect.getChild("profile_COMMON/technique/lambert/diffuse");
- if (diffuse == null)
- diffuse = effect.getChild("profile_COMMON/technique/constant/transparent");
+ //Get the effect type. Common examples are lambert and Phong
+ String effectType = effect.getChild("profile_COMMON/technique").getChild(0).getName().toString();
+
+ if(effectType.equals("lambert")) {
+ //get lambert -> diffuse if possible
+ diffuse = effect.getChild("profile_COMMON/technique/lambert/diffuse");
+ //if lambert -> diffuse does not exist then take the transparency value as the diffuse value
+
+ if (diffuse == null) //not sure about this constant/transparent...havent seen this in collada file before but leaving it in case
+ diffuse = effect.getChild("profile_COMMON/technique/constant/transparent");
+
+ if (diffuse == null) //in case the transparent above doesnt catch the transparent value when a diffuse is not present
+ diffuse = effect.getChild("profile_COMMON/technique/lambert/transparent");
+ }
+
+ if(effectType.equals("phong")) {
+ //get Phong -> diffuse if possible
+ diffuse = effect.getChild("profile_COMMON/technique/phong/diffuse");
+
+ //if Phong -> diffuse does not exist then take the transparency value as the diffuse value
+ if (diffuse == null)
+ diffuse = effect.getChild("profile_COMMON/technique/phong/transparent");
+ }
+
+ //give user error message to tell them where to look to add support for their shader listed in the collada file
+ if( diffuse == null)
+ System.out.print("Unable to find diffuse value. Try adding support for your chosen effect in the Effect.java");
+
+ //if diffuse is null an error will be thrown here
if (diffuse.getChildren()[0].getName().equals("texture"))
{
hasTexture = true;

0 comments on commit 9fbafa3

Please sign in to comment.
Something went wrong with that request. Please try again.