Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
de.javagl.jgltf.impl.v2.MeshPrimitive Maven / Gradle / Ivy
/*
* glTF JSON model
*
* Do not modify this class. It is automatically generated
* with JsonModelGen (https://github.com/javagl/JsonModelGen)
* Copyright (c) 2016-2021 Marco Hutter - http://www.javagl.de
*/
package de.javagl.jgltf.impl.v2;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
/**
* Geometry to be rendered with the given material.
*
* Auto-generated for mesh.primitive.schema.json
*
*/
public class MeshPrimitive
extends GlTFProperty
{
/**
* A plain JSON object, where each key corresponds to a mesh attribute
* semantic and each value is the index of the accessor containing
* attribute's data. (required)
*
*/
private Map attributes;
/**
* The index of the accessor that contains the vertex indices. (optional)
*
*/
private Integer indices;
/**
* The index of the material to apply to this primitive when rendering.
* (optional)
*
*/
private Integer material;
/**
* The topology type of primitives to render. (optional)
* Default: 4
* Valid values: [0, 1, 2, 3, 4, 5, 6]
*
*/
private Integer mode;
/**
* An array of morph targets. (optional)
* Minimum number of items: 1
* Array elements:
* A plain JSON object specifying attributes displacements in
* a morph target, where each key corresponds to one of the three
* supported attribute semantic (`POSITION`, `NORMAL`, or `TANGENT`) and
* each value is the index of the accessor containing the attribute
* displacements' data. (optional)
*
*/
private List> targets;
/**
* A plain JSON object, where each key corresponds to a mesh attribute
* semantic and each value is the index of the accessor containing
* attribute's data. (required)
*
* @param attributes The attributes to set
* @throws NullPointerException If the given value is null
*
*/
public void setAttributes(Map attributes) {
if (attributes == null) {
throw new NullPointerException((("Invalid value for attributes: "+ attributes)+", may not be null"));
}
this.attributes = attributes;
}
/**
* A plain JSON object, where each key corresponds to a mesh attribute
* semantic and each value is the index of the accessor containing
* attribute's data. (required)
*
* @return The attributes
*
*/
public Map getAttributes() {
return this.attributes;
}
/**
* Add the given attributes. The attributes of this instance will be
* replaced with a map that contains all previous mappings, and
* additionally the new mapping.
*
* @param key The key
* @param value The value
* @throws NullPointerException If the given key or value is null
*
*/
public void addAttributes(String key, Integer value) {
if (key == null) {
throw new NullPointerException("The key may not be null");
}
if (value == null) {
throw new NullPointerException("The value may not be null");
}
Map oldMap = this.attributes;
Map newMap = new LinkedHashMap();
if (oldMap!= null) {
newMap.putAll(oldMap);
}
newMap.put(key, value);
this.attributes = newMap;
}
/**
* Remove the given attributes. The attributes of this instance will be
* replaced with a map that contains all previous mappings, except for
* the one with the given key.
*
* @param key The key
* @throws NullPointerException If the given key is null
*
*/
public void removeAttributes(String key) {
if (key == null) {
throw new NullPointerException("The key may not be null");
}
Map oldMap = this.attributes;
Map newMap = new LinkedHashMap();
if (oldMap!= null) {
newMap.putAll(oldMap);
}
newMap.remove(key);
this.attributes = newMap;
}
/**
* The index of the accessor that contains the vertex indices. (optional)
*
* @param indices The indices to set
*
*/
public void setIndices(Integer indices) {
if (indices == null) {
this.indices = indices;
return ;
}
this.indices = indices;
}
/**
* The index of the accessor that contains the vertex indices. (optional)
*
* @return The indices
*
*/
public Integer getIndices() {
return this.indices;
}
/**
* The index of the material to apply to this primitive when rendering.
* (optional)
*
* @param material The material to set
*
*/
public void setMaterial(Integer material) {
if (material == null) {
this.material = material;
return ;
}
this.material = material;
}
/**
* The index of the material to apply to this primitive when rendering.
* (optional)
*
* @return The material
*
*/
public Integer getMaterial() {
return this.material;
}
/**
* The topology type of primitives to render. (optional)
* Default: 4
* Valid values: [0, 1, 2, 3, 4, 5, 6]
*
* @param mode The mode to set
* @throws IllegalArgumentException If the given value does not meet
* the given constraints
*
*/
public void setMode(Integer mode) {
if (mode == null) {
this.mode = mode;
return ;
}
if (((((((mode!= 0)&&(mode!= 1))&&(mode!= 2))&&(mode!= 3))&&(mode!= 4))&&(mode!= 5))&&(mode!= 6)) {
throw new IllegalArgumentException((("Invalid value for mode: "+ mode)+", valid: [0, 1, 2, 3, 4, 5, 6]"));
}
this.mode = mode;
}
/**
* The topology type of primitives to render. (optional)
* Default: 4
* Valid values: [0, 1, 2, 3, 4, 5, 6]
*
* @return The mode
*
*/
public Integer getMode() {
return this.mode;
}
/**
* Returns the default value of the mode
* @see #getMode
*
* @return The default mode
*
*/
public Integer defaultMode() {
return 4;
}
/**
* An array of morph targets. (optional)
* Minimum number of items: 1
* Array elements:
* A plain JSON object specifying attributes displacements in
* a morph target, where each key corresponds to one of the three
* supported attribute semantic (`POSITION`, `NORMAL`, or `TANGENT`) and
* each value is the index of the accessor containing the attribute
* displacements' data. (optional)
*
* @param targets The targets to set
* @throws IllegalArgumentException If the given value does not meet
* the given constraints
*
*/
public void setTargets(List> targets) {
if (targets == null) {
this.targets = targets;
return ;
}
if (targets.size()< 1) {
throw new IllegalArgumentException("Number of targets elements is < 1");
}
this.targets = targets;
}
/**
* An array of morph targets. (optional)
* Minimum number of items: 1
* Array elements:
* A plain JSON object specifying attributes displacements in
* a morph target, where each key corresponds to one of the three
* supported attribute semantic (`POSITION`, `NORMAL`, or `TANGENT`) and
* each value is the index of the accessor containing the attribute
* displacements' data. (optional)
*
* @return The targets
*
*/
public List> getTargets() {
return this.targets;
}
/**
* Add the given targets. The targets of this instance will be replaced
* with a list that contains all previous elements, and additionally the
* new element.
*
* @param element The element
* @throws NullPointerException If the given element is null
*
*/
public void addTargets(Map element) {
if (element == null) {
throw new NullPointerException("The element may not be null");
}
List> oldList = this.targets;
List> newList = new ArrayList>();
if (oldList!= null) {
newList.addAll(oldList);
}
newList.add(element);
this.targets = newList;
}
/**
* Remove the given targets. The targets of this instance will be
* replaced with a list that contains all previous elements, except for
* the removed one.
* If this new list would be empty, then it will be set to
* null
.
*
* @param element The element
* @throws NullPointerException If the given element is null
*
*/
public void removeTargets(Map element) {
if (element == null) {
throw new NullPointerException("The element may not be null");
}
List> oldList = this.targets;
List> newList = new ArrayList>();
if (oldList!= null) {
newList.addAll(oldList);
}
newList.remove(element);
if (newList.isEmpty()) {
this.targets = null;
} else {
this.targets = newList;
}
}
}