Loading awd file throws null reference error in BoundingVolumeBase.as line 149

Software: Away3D 4.x

hamferus, Newbie
Posted: 20 November 2013 02:27 PM   Total Posts: 3

Hi,

Im creating board game and i have problem with loading player model. Im loading scenery model and it loads fine. But when I load player model i get this error

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at away3d.bounds::BoundingVolumeBase/fromGeometry()[/Users/robbateman/Documents/Adobe Flash Builder 4.7/away3d-core-fp11/src/away3d/bounds/BoundingVolumeBase.as:149]
at away3d.entities::Mesh/updateBounds()[/Users/robbateman/Documents/Adobe Flash Builder 4.7/away3d-core-fp11/src/away3d/entities/Mesh.as:282]
at away3d.entities::Entity/get bounds()[/Users/robbateman/Documents/Adobe Flash Builder 4.7/away3d-core-fp11/src/away3d/entities/Entity.as:194]
at away3d.entities::Entity/updateWorldBounds()[/Users/robbateman/Documents/Adobe Flash Builder 4.7/away3d-core-fp11/src/away3d/entities/Entity.as:0]
at away3d.entities::Entity/get worldBounds()[/Users/robbateman/Documents/Adobe Flash Builder 4.7/away3d-core-fp11/src/away3d/entities/Entity.as:212]
at away3d.core.partition::EntityNode/isInFrustum()[/Users/robbateman/Documents/Adobe Flash Builder 4.7/away3d-core-fp11/src/away3d/core/partition/EntityNode.as:73]
at away3d.core.traverse::EntityCollector/enterNode()[/Users/robbateman/Documents/Adobe Flash Builder 4.7/away3d-core-fp11/src/away3d/core/traverse/EntityCollector.as:206]
at away3d.core.partition::MeshNode/acceptTraverser()[/Users/robbateman/Documents/Adobe Flash Builder 4.7/away3d-core-fp11/src/away3d/core/partition/MeshNode.as:37]
at away3d.core.partition::NodeBase/acceptTraverser()[/Users/robbateman/Documents/Adobe Flash Builder 4.7/away3d-core-fp11/src/away3d/core/partition/NodeBase.as:170]
at away3d.core.partition::Partition3D/traverse()[/Users/robbateman/Documents/Adobe Flash Builder 4.7/away3d-core-fp11/src/away3d/core/partition/Partition3D.as:52]
at away3d.containers::Scene3D/traversePartitions()[/Users/robbateman/Documents/Adobe Flash Builder 4.7/away3d-core-fp11/src/away3d/containers/Scene3D.as:54]
at away3d.containers::View3D/render()[/Users/robbateman/Documents/Adobe Flash Builder 4.7/away3d-core-fp11/src/away3d/containers/View3D.as:666]
at hr.kucabajki.multitouch.boardGame.screens.screen6igra::Screen6Igra/oEF()[R:projektiIvanina kuca bajke17- 18 Multitouch aplikacijaflashsrchrkucabajkimultitouchboardGamescreensscreen6igraScreen6Igra.as:247]

This is how i create player:

for (var i:int 01i++)
   
{
    
var tempPlayer:Player = new Player(i,lightPicker,igraci_arr[i].likicId);
    
tempPlayer.boardPositions[0].playerX;//-1671
    
tempPlayer.boardPositions[0].playerY;//92
    
tempPlayer.boardPositions[0].playerZ;//-1590          
    
trace("tp.x: "tempPlayer.x);
    
players_arr.push(tempPlayer);
    
boardPositions[0].players_arr.push(tempPlayer);
    
_scene.addChild(tempPlayer);
   

and Player class looks like this:

package 
{
 import away3d
.containers.ObjectContainer3D;
 
import away3d.core.base.Geometry;
 
import away3d.entities.Mesh;
 
import away3d.events.AssetEvent;
 
import away3d.library.AssetLibrary;
 
import away3d.library.assets.AssetType;
 
import away3d.loaders.parsers.AWDParser;
 
import away3d.materials.ColorMaterial;
 
import away3d.materials.lightpickers.StaticLightPicker;
 
import flash.net.URLRequest;
 
/**
  * ...
  * @author luka 2013.
  */
 
public class Player extends ObjectContainer3D
 {
  
private var _pId:int;
  private var 
_currentPosition:int 0;
  
  private var 
_playerState:String "forward";
  
  
  private var 
lightPicker:StaticLightPicker;
  
  public function 
Player(_idlp,likicId
  
{
   
//AssetLibrary.enableParser(AWDParser);
   
   
AssetLibrary.addEventListener(AssetEvent.ASSET_COMPLETEplayerAwdLoaded);
   
AssetLibrary.load(new URLRequest("modeli/likovi/lik_2/lik_2.awd"));
   
   
lightPicker lp;
   
   
_pId _id;
   
  
}
  
  
private function playerAwdLoaded(e:AssetEvent):void
  {
   trace
("assetType: "+e.asset.assetType);
 
   
   if (
e.asset.assetType == AssetType.MESH)
   
{
    
var tempCMat:ColorMaterial
    
var tempMesh e.asset as Mesh;
    
trace("e.asset.name: " e.asset.name);
    if (
e.asset.name == "lik2")
    
{
     tempCMat 
= new ColorMaterial(0xff0000);
     
    
}
    
else
    
{
     tempCMat 
= new ColorMaterial(0x000000);
     
tempCMat.bothSides true;
    
}
    tempCMat
.lightPicker lightPicker;
    
tempMesh.material tempCMat;
    
tempMesh.castsShadows false;
    
tempMesh.mouseEnabled false;
    
addChild(tempMesh);
   
}
   
  }
  
  
 
 }

Strangest thing is when i remove code from playerAwdLoaded function model shows in 0,0,0 world position and not container 0,0,0 position. Even if i remove addChild from player class and remove _scene.addChild(tempPlayer) from loop that creates player model shows on 0,0,0 world position.

Player awd was made like this : Cinema4d->3ds file->preFab2->awd2
Scenery awd was cereated like this: FBX->3dsMax->awd->preFab2->awd2

I think my problem is that scenery model was made in lightwave and player in cinema4d because when i import 3ds cinema4d file in 3dsMax and export it as awd i see only two meshes in preFeb hierarchy tree but when i load 3ds model directly in preFab there are 3 meshes in hierarcy tree.

 


I have attached awd file created in preFab2 after importing 3ds file from cinema4d and 3ds file created in cinema4d

Any help or explanation why is player model acting like this would be nice smile

Luka

 

File Attachments
lik_2.awd  (File Size: 8KB - Downloads: 175)
lik2.3ds  (File Size: 18KB - Downloads: 0)
   

hamferus, Newbie
Posted: 21 November 2013 10:11 AM   Total Posts: 3   [ # 1 ]

Hi,

Little update.

After whole evening banging my head to desk and after new player models and some test models I realised that I get this error for every model i try to load through Player.as class. I made some primitives meshes in Player.as and they show normal but every awd model that i try to load i get null reference error in BoundingBolumeBase.as.

Luka

   

hamferus, Newbie
Posted: 21 November 2013 12:37 PM   Total Posts: 3   [ # 2 ]

Hi,

I solved the problem and it was my fault :( If you look at Player.as class I commented enableParser and that was the problem. I set up enableParser in main class for scenery and I thought that i dont need it in Player.as class so I commented it out

What a waste of day smile

Luka

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X