Primitive.hx 926 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package h3d.prim;
  2. class Primitive {
  3. public var buffer : Buffer;
  4. public var indexes : Indexes;
  5. public function triCount() {
  6. return if( indexes != null ) Std.int(indexes.count / 3) else if( buffer == null ) 0 else Std.int(buffer.totalVertices() / 3);
  7. }
  8. public function getBounds() : h3d.col.Bounds {
  9. throw "not implemented";
  10. return null;
  11. }
  12. public function alloc( engine : h3d.Engine ) {
  13. throw "not implemented";
  14. }
  15. public function selectMaterial( material : Int ) {
  16. }
  17. public function render( engine : h3d.Engine ) {
  18. if( buffer == null || buffer.isDisposed() ) alloc(engine);
  19. if( indexes == null )
  20. engine.renderTriBuffer(buffer);
  21. else
  22. engine.renderIndexed(buffer,indexes);
  23. }
  24. public function dispose() {
  25. if( buffer != null ) {
  26. buffer.dispose();
  27. buffer = null;
  28. }
  29. if( indexes != null ) {
  30. indexes.dispose();
  31. indexes = null;
  32. }
  33. }
  34. }